Widget: DataExporter: Difference between revisions
From LINKS Community Center
Eschmidt (talk | contribs) No edit summary |
Eschmidt (talk | contribs) No edit summary |
||
Line 17: | Line 17: | ||
const permittedUsers = ['Eschmidt']; | const permittedUsers = ['Eschmidt']; | ||
async function exportData() { | async function exportData() { | ||
Line 32: | Line 30: | ||
const formData = new FormData(document.getElementById('export_form')); | const formData = new FormData(document.getElementById('export_form')); | ||
const lib = formData.get('library'); | const lib = formData.get('library'); | ||
let schemaUrl; | |||
if (lib === 'TL') schemaUrl = '/index.php?title=Category:Disaster_Community_Technology&action=raw'; | |||
else if (lib === 'UCL') schemaUrl = '/index.php?title=Category:Use_Cases&action=raw'; | |||
else if (lib === 'GL') schemaUrl = '/index.php?title=Category:Guideline&action=raw'; | |||
const | const schemaXml = await fetch(schemaUrl).then(rsp => rsp.text()); | ||
const | const schema = (new DOMParser).parseFromString(schemaXml, 'text/xml'); | ||
for (const field of | for (const field of schema.querySelectorAll('Field')) { | ||
const prop = field.querySelector('semanticmediawiki_Property')?.getAttribute('name') | const prop = field.querySelector('semanticmediawiki_Property')?.getAttribute('name') | ||
|| field.getAttribute('name'); | || field.getAttribute('name'); |