Postload JSZip

Close #18
This commit is contained in:
Joshua Ramon Enslin 2022-11-07 01:09:41 +01:00
parent fe791c2000
commit 453a726a9a
Signed by: jrenslin
GPG Key ID: 46016F84501B70AE
2 changed files with 37 additions and 19 deletions

View File

@ -450,6 +450,9 @@ class CsvxmlPage {
zipUploadToXml(validator) { zipUploadToXml(validator) {
// Wrap zipping in function to postload it
function runZipping() {
let zip = new JSZip(); let zip = new JSZip();
let xmlFiles = validator.generateXml(); let xmlFiles = validator.generateXml();
@ -475,6 +478,23 @@ class CsvxmlPage {
} }
if (typeof JSZip === "undefined") {
const loadScript = document.createElement("script");
loadScript.setAttribute("src", "assets/js/jszip/dist/jszip.min.js");
loadScript.addEventListener('load', function() {
// console.log("Post-loaded OpenLayers");
runZipping();
}, {passive: true, once: true});
document.body.appendChild(loadScript);
}
else {
runZipping();
}
}
listValidationErrors(validator) { listValidationErrors(validator) {
const dialogueContent = document.createElement("div"); const dialogueContent = document.createElement("div");

View File

@ -40,8 +40,6 @@ echo '
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/> <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<meta name="description" content="Validate import CSV files for museum-digital" /> <meta name="description" content="Validate import CSV files for museum-digital" />
<script src="assets/js/jszip/dist/jszip.min.js" type="text/javascript" async defer></script>
<link rel="stylesheet" type="text/css" href="assets/css/csvxml.css" /> <link rel="stylesheet" type="text/css" href="assets/css/csvxml.css" />
<meta name="theme-color" content="#aa4400" /> <meta name="theme-color" content="#aa4400" />
<link rel="shortcut icon" sizes="128x128" href="assets/img/mdlogo-csvxml.svg" /> <link rel="shortcut icon" sizes="128x128" href="assets/img/mdlogo-csvxml.svg" />