Difference between revisions of "Widget:DataExporter"
From LINKS Community Center
Line 29: | Line 29: | ||
const formData = new FormData(document.getElementById('export_form')); | const formData = new FormData(document.getElementById('export_form')); | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | const schemaXml = await fetch( | + | const schemaParams = new URLSearchParams(); |
+ | schemaParams.set('action', 'raw'); | ||
+ | schemaParams.set('title', encodeURIComponent('Category:' + formData.get('library'))); | ||
+ | |||
+ | const exportParams = new URLSearchParams(); | ||
+ | exportParams.set('action', 'ask'); | ||
+ | exportParams.set('format', 'spreadsheet'); | ||
+ | exportParams.set('fileformat', formData.get('fileformat')); | ||
+ | |||
+ | // exportUrl = '/api.php?action=ask&format=spreadsheet&query=[[Category:Disaster Community Technology]]'; | ||
+ | // exportUrl = '/api.php?action=ask&format=spreadsheet&query=[[Category:Use Cases]]'; | ||
+ | // exportUrl = '/api.php?action=ask&format=spreadsheet&query=[[Category:Guideline]]'; | ||
+ | |||
+ | const schemaXml = await fetch('/index.php?' + schemaParams.toString()).then(rsp => rsp.text()); | ||
const schema = (new DOMParser).parseFromString(schemaXml, 'text/xml'); | const schema = (new DOMParser).parseFromString(schemaXml, 'text/xml'); | ||
Line 44: | Line 52: | ||
output.innerHTML += prop + ' | ' + label + '<br>'; | output.innerHTML += prop + ' | ' + label + '<br>'; | ||
} | } | ||
+ | |||
+ | exportUrl += ''; // &fileformat=csv &fileformat=ods &fileformat=xlsx | ||
+ | exportUrl += ''; // &filename=MyFilename <- LIB+DATE | ||
} | } | ||
</script> | </script> | ||
− | |||
</head> | </head> | ||
Line 56: | Line 66: | ||
<legend>Library</legend> | <legend>Library</legend> | ||
− | <input type="radio" id="lib_TL" name="library" value=" | + | <input type="radio" id="lib_TL" name="library" value="Disaster_Community_Technology" checked> |
<label for="lib_TL">Technologies</label><br> | <label for="lib_TL">Technologies</label><br> | ||
− | <input type="radio" id="lib_UCL" name="library" value=" | + | <input type="radio" id="lib_UCL" name="library" value="Use_Cases"> |
<label for="lib_UCL">Use Cases</label><br> | <label for="lib_UCL">Use Cases</label><br> | ||
− | <input type="radio" id="lib_GL" name="library" value=" | + | <input type="radio" id="lib_GL" name="library" value="Guideline"> |
<label for="lib_GL">Guidelines</label> | <label for="lib_GL">Guidelines</label> | ||
</fieldset> | </fieldset> | ||
Line 68: | Line 78: | ||
<legend>Format</legend> | <legend>Format</legend> | ||
− | <input type="radio" id=" | + | <input type="radio" id="file_XLSX" name="fileformat" value="xlsx" checked> |
− | <label for=" | + | <label for="file_XLSX">Excel (.xlsx)</label><br> |
<input type="radio" id="file_ODS" name="fileformat" value="ods"> | <input type="radio" id="file_ODS" name="fileformat" value="ods"> |