Difference between revisions of "Widget:DataExporter"

From LINKS Community Center
Jump to: navigation, search
Line 7: Line 7:
 
             'use strict';
 
             'use strict';
  
             const base = 'https://links.communitycenter.eu';
+
             const usr = '/api.php?action=query&meta=userinfo&format=json';
 
             const url = '/index.php?title=Category:Disaster_Community_Technology&action=raw';
 
             const url = '/index.php?title=Category:Disaster_Community_Technology&action=raw';
  
             const usr = '/api.php?action=query&meta=userinfo&format=json';
+
             const permittedUsers = ['Eschmidt'];
 +
 
 +
            const output = document.getElementById('output');
  
 
             async function exportData() {
 
             async function exportData() {
Line 16: Line 18:
 
                 const usrName = usrData?.query?.userinfo?.name;
 
                 const usrName = usrData?.query?.userinfo?.name;
  
                 console.log(usrData)
+
                 if (!permittedUsers.includes(usrName)) {
                document.getElementById('output').innerText = usrName;
+
                    output.innerHTML = '<span style="color:red; font-size:large">Access Denied</span>';
 +
                    return;
 +
                }
 +
 
 +
                output.innerText = usrName;
 
             }
 
             }
 
         </script>
 
         </script>
Line 24: Line 30:
 
     <body>
 
     <body>
 
         <button type="button" onclick="exportData()">Export Data</button>
 
         <button type="button" onclick="exportData()">Export Data</button>
         <pre id="output">
+
         <div id="output"></div>
 
 
        </pre>
 
 
     </body>
 
     </body>
  
 
     </html>
 
     </html>
 
</includeonly>
 
</includeonly>

Revision as of 13:03, 15 August 2023