Widget: DataExporter: Difference between revisions
From LINKS Community Center
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 | 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()); | ||
if (!permittedUsers.includes(usrData?.query?.userinfo?.name)) { | |||
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 = | const schema = await fetch(dat).then(rsp => rsp.text()); | ||
output.innerText = schema; | |||
} | } | ||
</script> | </script> |