Widget: DataExporter: Difference between revisions

From LINKS Community Center
Jump to: navigation, search
Eschmidt (talk | contribs)
No edit summary
Eschmidt (talk | contribs)
No edit summary
Line 8: Line 8:


             const usr = '/api.php?action=query&meta=userinfo&format=json';
             const usr = '/api.php?action=query&meta=userinfo&format=json';
             const url = '/index.php?title=Category:Disaster_Community_Technology&action=raw';
             const dat = '/index.php?title=Category:Disaster_Community_Technology&action=raw';


             const permittedUsers = ['Eschmidt'];
             const permittedUsers = ['Eschmidt'];


           
             async function exportData() {
             async function exportData() {
                const output = document.getElementById('output');
                 const usrData = await fetch(usr).then(rsp => rsp.json());
                 const usrData = await fetch(usr).then(rsp => rsp.json());
                 const usrName = usrData?.query?.userinfo?.name;
                 if (!permittedUsers.includes(usrData?.query?.userinfo?.name)) {
               
                const output = document.getElementById('output');
               
                if (!permittedUsers.includes(usrName)) {
                     output.innerHTML = '<span style="color:red; font-size:large">Access Denied</span>';
                     output.innerHTML = '<span style="color:red; font-size:large">Access Denied</span>';
                     return;
                     return;
                 }
                 }


                 output.innerText = usrName;
                const schema = await fetch(dat).then(rsp => rsp.text());
 
                 output.innerText = schema;
             }
             }
         </script>
         </script>

Revision as of 12:19, 15 August 2023