Widget: DataExporter: Difference between revisions
From LINKS Community Center
Eschmidt (talk | contribs) No edit summary |
Eschmidt (talk | contribs) No edit summary |
||
Line 7: | Line 7: | ||
'use strict'; | 'use strict'; | ||
const | 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 | 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; | ||
if (!permittedUsers.includes(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> | ||
< | <div id="output"></div> | ||
</body> | </body> | ||
</html> | </html> | ||
</includeonly> | </includeonly> |