Bump GET parameter for force-refreshing CSS and JS
This commit is contained in:
		| @@ -1,7 +1,8 @@ | |||||||
| /* | /* | ||||||
|  * @import 'editMenu.css'; |  * @import 'editMenu.css'; | ||||||
| @import 'dialogue.css'; | @import 'dialogue.css'; | ||||||
|  */ |  */@import 'editMenu.css'; | ||||||
|  | @import 'dialogue.css'; | ||||||
| :root { | :root { | ||||||
|     --color-bg-normal: #FFF; |     --color-bg-normal: #FFF; | ||||||
|     --color-bg-raised: #EEE; |     --color-bg-raised: #EEE; | ||||||
| @@ -55,7 +56,7 @@ body { margin: 0; background: var(--color-bg-normal); color: var(--color-fg-norm | |||||||
|  |  | ||||||
| a { text-decoration: none; color: inherit; } | a { text-decoration: none; color: inherit; } | ||||||
|  |  | ||||||
| h1     { display: block; width: 100%; text-align: center; margin: 0 auto 1.5em auto; | h1     { display: block; width: 100%; text-align: center; margin: 0 auto .8em auto; | ||||||
|     padding: 1em 0; |     padding: 1em 0; | ||||||
|     font-size: 2.5em; line-height: 1.2em; } |     font-size: 2.5em; line-height: 1.2em; } | ||||||
| h1 > * { display: inline-block; vertical-align: middle; color: var(--color-fg-less); } | h1 > * { display: inline-block; vertical-align: middle; color: var(--color-fg-less); } | ||||||
| @@ -119,7 +120,23 @@ th { padding: .3em .5em; text-align: left; border-bottom: 2px solid var(--color- | |||||||
| tbody > tr:nth-child(2n + 1) { background: var(--color-bg-raised2); } | tbody > tr:nth-child(2n + 1) { background: var(--color-bg-raised2); } | ||||||
| td { padding: .3em .5em; border-bottom: 1px solid var(--color-borders); } | td { padding: .3em .5em; border-bottom: 1px solid var(--color-borders); } | ||||||
|  |  | ||||||
| body > div.uploader { background: var(--color-bg-raised2); border: 2px solid var(--color-bg-raised); padding: 1em 1em; } | #helpSection { margin-bottom: 0; font-size: .9em; | ||||||
|  |     padding-bottom: 0; border-bottom: 1px solid var(--color-borders); } | ||||||
|  | #helpSection h3:before { content: " ? "; display: inline-block; | ||||||
|  |     padding: .2em .5em; margin-right: .5em; | ||||||
|  |     background: var(--color-borders); border-radius: .2em; | ||||||
|  |     color: var(--color-borders-dark); } | ||||||
|  |  | ||||||
|  | @media screen and (min-width: 75em) { | ||||||
|  |     #helpSection > div { display: grid; grid-template-columns: 1fr 1fr; } | ||||||
|  |     #helpSection > div > div { display: inline-block; grid-column: auto; } | ||||||
|  | } | ||||||
|  | @media screen and (min-width: 95em) { | ||||||
|  |     #helpSection > div { grid-template-columns: 1fr 1fr 1fr; } | ||||||
|  | } | ||||||
|  |  | ||||||
|  | body > div.uploader { margin-bottom: 0; } | ||||||
|  | body > div.uploader > form { background: var(--color-bg-raised2); border: 2px solid var(--color-bg-raised); padding: 1em 1em; margin-bottom: 0; } | ||||||
|  |  | ||||||
| ul.fieldList { display: block; margin: .5em 0; padding: 0 0; list-style: none; } | ul.fieldList { display: block; margin: .5em 0; padding: 0 0; list-style: none; } | ||||||
| ul.fieldList > li { display: inline-block; margin: .1em; padding: .3em; | ul.fieldList > li { display: inline-block; margin: .1em; padding: .3em; | ||||||
|   | |||||||
							
								
								
									
										2
									
								
								public/assets/css/csvxml.min.css
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								public/assets/css/csvxml.min.css
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							| @@ -332,6 +332,7 @@ class CsvxmlPage { | |||||||
|     fieldList; |     fieldList; | ||||||
|     fieldListFlat; |     fieldListFlat; | ||||||
|     tls; |     tls; | ||||||
|  |     domHelpWrapper; | ||||||
|     domUploaderWrapper; |     domUploaderWrapper; | ||||||
|     domMainWrapper; |     domMainWrapper; | ||||||
|     selectedFields; |     selectedFields; | ||||||
| @@ -350,6 +351,10 @@ class CsvxmlPage { | |||||||
|  |  | ||||||
|         this.tls = Object.freeze(tls); |         this.tls = Object.freeze(tls); | ||||||
|  |  | ||||||
|  |         let domHelpWrapper = document.createElement("div"); | ||||||
|  |         domHelpWrapper.id = "helpSection"; | ||||||
|  |         this.domHelpWrapper = domHelpWrapper; | ||||||
|  |  | ||||||
|         let domUploaderWrapper = document.createElement("div"); |         let domUploaderWrapper = document.createElement("div"); | ||||||
|         domUploaderWrapper.id = "uploader"; |         domUploaderWrapper.id = "uploader"; | ||||||
|         domUploaderWrapper.classList.add("uploader"); |         domUploaderWrapper.classList.add("uploader"); | ||||||
| @@ -454,14 +459,7 @@ class CsvxmlPage { | |||||||
|  |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     listValidationErrors(validator) { |     generateDialogueCloseButton() { | ||||||
|  |  | ||||||
|         console.log("Listing validation errors"); |  | ||||||
|  |  | ||||||
|         const dialogueContent = document.createElement("div"); |  | ||||||
|  |  | ||||||
|         const headline = document.createElement("h3"); |  | ||||||
|         headline.textContent = this.tls.validation_errors; |  | ||||||
|  |  | ||||||
|         const cancelB = document.createElement("a"); |         const cancelB = document.createElement("a"); | ||||||
|         cancelB.classList.add("icons"); |         cancelB.classList.add("icons"); | ||||||
| @@ -472,8 +470,19 @@ class CsvxmlPage { | |||||||
|         cancelB.title = "Close"; |         cancelB.title = "Close"; | ||||||
|         cancelB.href = "#" + location.href; |         cancelB.href = "#" + location.href; | ||||||
|         cancelB.addEventListener('click', CsvxmlDialogue.closeDialogue); |         cancelB.addEventListener('click', CsvxmlDialogue.closeDialogue); | ||||||
|         headline.appendChild(cancelB); |         return cancelB; | ||||||
|  |  | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     listValidationErrors(validator) { | ||||||
|  |  | ||||||
|  |         console.log("Listing validation errors"); | ||||||
|  |  | ||||||
|  |         const dialogueContent = document.createElement("div"); | ||||||
|  |  | ||||||
|  |         const headline = document.createElement("h3"); | ||||||
|  |         headline.textContent = this.tls.validation_errors; | ||||||
|  |         headline.appendChild(this.generateDialogueCloseButton()); | ||||||
|         dialogueContent.appendChild(headline); |         dialogueContent.appendChild(headline); | ||||||
|  |  | ||||||
|         const domErrorsSection = document.createElement("div"); |         const domErrorsSection = document.createElement("div"); | ||||||
| @@ -655,11 +664,63 @@ class CsvxmlPage { | |||||||
|  |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     renderHelpTexts() { | ||||||
|  |  | ||||||
|  |         let app = this; | ||||||
|  |         (async function() { | ||||||
|  |  | ||||||
|  |             function appendQA(question, answer) { | ||||||
|  |  | ||||||
|  |                 const div = document.createElement("div"); | ||||||
|  |                 div.classList.add("qaDiv"); | ||||||
|  |  | ||||||
|  |                 const qElem = document.createElement("h3"); | ||||||
|  |                 qElem.textContent = question; | ||||||
|  |                 qElem.style.cursor = "pointer"; | ||||||
|  |                 div.appendChild(qElem); | ||||||
|  |  | ||||||
|  |                 qElem.addEventListener('click', function() { | ||||||
|  |  | ||||||
|  |                     console.log("Listing validation errors"); | ||||||
|  |  | ||||||
|  |                     const dialogueContent = document.createElement("div"); | ||||||
|  |  | ||||||
|  |                     const headline = document.createElement("h3"); | ||||||
|  |                     headline.textContent = question; | ||||||
|  |                     headline.appendChild(app.generateDialogueCloseButton()); | ||||||
|  |                     dialogueContent.appendChild(headline); | ||||||
|  |  | ||||||
|  |                     const answerDiv = document.createElement("div"); | ||||||
|  |                     answerDiv.textContent = answer; | ||||||
|  |                     dialogueContent.appendChild(answerDiv); | ||||||
|  |                     CsvxmlDialogue.drawDialogue(dialogueContent); | ||||||
|  |                 }); | ||||||
|  |  | ||||||
|  |                 return div; | ||||||
|  |  | ||||||
|  |             } | ||||||
|  |  | ||||||
|  |             const div = document.createElement("div"); | ||||||
|  |  | ||||||
|  |             div.appendChild(appendQA(app.tls.help_where_am_i, app.tls.help_where_am_i_content)); | ||||||
|  |  | ||||||
|  |             app.domHelpWrapper.appendChild(div); | ||||||
|  |  | ||||||
|  |         })(); | ||||||
|  |  | ||||||
|  |         document.body.appendChild(this.domHelpWrapper); | ||||||
|  |  | ||||||
|  |     } | ||||||
|  |  | ||||||
|     renderUploader() { |     renderUploader() { | ||||||
|  |  | ||||||
|         let app = this; |         let app = this; | ||||||
|         (async function() { |         (async function() { | ||||||
|  |  | ||||||
|  |             const h2 = document.createElement("h2"); | ||||||
|  |             h2.textContent = app.tls.upload; | ||||||
|  |             app.domUploaderWrapper.appendChild(h2); | ||||||
|  |  | ||||||
|             const form = document.createElement("form"); |             const form = document.createElement("form"); | ||||||
|  |  | ||||||
|             const label = document.createElement("label"); |             const label = document.createElement("label"); | ||||||
| @@ -961,6 +1022,7 @@ class CsvxmlPage { | |||||||
|         const page = new CsvxmlPage(fieldList, tls); |         const page = new CsvxmlPage(fieldList, tls); | ||||||
|         page.renderGenHeader(); |         page.renderGenHeader(); | ||||||
|         page.renderHeader(); |         page.renderHeader(); | ||||||
|  |         page.renderHelpTexts(); | ||||||
|         page.renderUploader(); |         page.renderUploader(); | ||||||
|         page.renderMain(); |         page.renderMain(); | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										13
									
								
								public/assets/js/csvxmlV2.min.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										13
									
								
								public/assets/js/csvxmlV2.min.js
									
									
									
									
										vendored
									
									
								
							| @@ -32,8 +32,8 @@ let dialogueArea=document.getElementById("dialogueArea");if(dialogueArea!==null& | |||||||
| dialogueArea.parentElement.removeChild(dialogueArea);document.removeEventListener('keydown',CsvxmlDialogue.closeDialogueByEscape,false);}} | dialogueArea.parentElement.removeChild(dialogueArea);document.removeEventListener('keydown',CsvxmlDialogue.closeDialogueByEscape,false);}} | ||||||
| static closeDialogueByEscape(e){if(e.keyCode===27){CsvxmlDialogue.closeDialogue(e);}} | static closeDialogueByEscape(e){if(e.keyCode===27){CsvxmlDialogue.closeDialogue(e);}} | ||||||
| static drawDialogue(contents){let dialogueArea=document.createElement("div");dialogueArea.id="dialogueArea";let dialogue=document.createElement("div");dialogue.id="dialogue";dialogue.appendChild(contents);dialogueArea.appendChild(dialogue);document.body.appendChild(dialogueArea);document.addEventListener('keydown',CsvxmlDialogue.closeDialogueByEscape);return dialogue;}} | static drawDialogue(contents){let dialogueArea=document.createElement("div");dialogueArea.id="dialogueArea";let dialogue=document.createElement("div");dialogue.id="dialogue";dialogue.appendChild(contents);dialogueArea.appendChild(dialogue);document.body.appendChild(dialogueArea);document.addEventListener('keydown',CsvxmlDialogue.closeDialogueByEscape);return dialogue;}} | ||||||
| class CsvxmlPage{fieldList;fieldListFlat;tls;domUploaderWrapper;domMainWrapper;selectedFields;csvBySelectionButton;unsetSelectionButton;constructor(fieldList,tls){this.fieldList=Object.freeze(fieldList);let list={};for(let sectionName in fieldList){list=Object.assign(list,fieldList[sectionName]);} | class CsvxmlPage{fieldList;fieldListFlat;tls;domHelpWrapper;domUploaderWrapper;domMainWrapper;selectedFields;csvBySelectionButton;unsetSelectionButton;constructor(fieldList,tls){this.fieldList=Object.freeze(fieldList);let list={};for(let sectionName in fieldList){list=Object.assign(list,fieldList[sectionName]);} | ||||||
| this.fieldListFlat=Object.freeze(list);this.tls=Object.freeze(tls);let domUploaderWrapper=document.createElement("div");domUploaderWrapper.id="uploader";domUploaderWrapper.classList.add("uploader");this.domUploaderWrapper=domUploaderWrapper;let domMainWrapper=document.createElement("main");this.domMainWrapper=domMainWrapper;this.selectedFields=[];} | this.fieldListFlat=Object.freeze(list);this.tls=Object.freeze(tls);let domHelpWrapper=document.createElement("div");domHelpWrapper.id="helpSection";this.domHelpWrapper=domHelpWrapper;let domUploaderWrapper=document.createElement("div");domUploaderWrapper.id="uploader";domUploaderWrapper.classList.add("uploader");this.domUploaderWrapper=domUploaderWrapper;let domMainWrapper=document.createElement("main");this.domMainWrapper=domMainWrapper;this.selectedFields=[];} | ||||||
| generateCsv(selectedFields=[]){let line1=[];let line2=[];let line3=[];for(let fieldName in this.fieldListFlat){console.log(fieldName);console.log(selectedFields);if(selectedFields.length!==0&&selectedFields.includes(fieldName)===false)continue;const field=this.fieldListFlat[fieldName];line1.push(fieldName);line2.push(field.name_human_readable);if(field.allowedValues!==undefined){let values=[];for(let key in field.allowedValues)values.push(field.allowedValues[key]);line3.push(values.join(","));} | generateCsv(selectedFields=[]){let line1=[];let line2=[];let line3=[];for(let fieldName in this.fieldListFlat){console.log(fieldName);console.log(selectedFields);if(selectedFields.length!==0&&selectedFields.includes(fieldName)===false)continue;const field=this.fieldListFlat[fieldName];line1.push(fieldName);line2.push(field.name_human_readable);if(field.allowedValues!==undefined){let values=[];for(let key in field.allowedValues)values.push(field.allowedValues[key]);line3.push(values.join(","));} | ||||||
| else line3.push("");} | else line3.push("");} | ||||||
| const csvLine1='"'+line1.join('";"')+'"';const csvLine2='"'+line2.join('";"')+'"';const csvLine3='"'+line3.join('";"')+'"';const toStore=csvLine1+"\n"+csvLine2+"\n"+csvLine3;const triggerLink=document.createElement('a');triggerLink.setAttribute('href','data:text/plain;charset=utf-8,'+encodeURIComponent(toStore));triggerLink.setAttribute('download',"csvxml_museum-digital_template.csv");triggerLink.style.display='none';document.body.appendChild(triggerLink);triggerLink.click();document.body.removeChild(triggerLink);} | const csvLine1='"'+line1.join('";"')+'"';const csvLine2='"'+line2.join('";"')+'"';const csvLine3='"'+line3.join('";"')+'"';const toStore=csvLine1+"\n"+csvLine2+"\n"+csvLine3;const triggerLink=document.createElement('a');triggerLink.setAttribute('href','data:text/plain;charset=utf-8,'+encodeURIComponent(toStore));triggerLink.setAttribute('download',"csvxml_museum-digital_template.csv");triggerLink.style.display='none';document.body.appendChild(triggerLink);triggerLink.click();document.body.removeChild(triggerLink);} | ||||||
| @@ -41,7 +41,8 @@ zipUploadToXml(validator){function runZipping(){let zip=new JSZip();let xmlFiles | |||||||
| zip.generateAsync({type:"blob"}).then(function(content){const triggerLink=document.createElement('a');triggerLink.href=window.URL.createObjectURL(content);triggerLink.setAttribute('download',"csvxml.zip");triggerLink.style.display='none';document.body.appendChild(triggerLink);triggerLink.click();document.body.removeChild(triggerLink);});} | zip.generateAsync({type:"blob"}).then(function(content){const triggerLink=document.createElement('a');triggerLink.href=window.URL.createObjectURL(content);triggerLink.setAttribute('download',"csvxml.zip");triggerLink.style.display='none';document.body.appendChild(triggerLink);triggerLink.click();document.body.removeChild(triggerLink);});} | ||||||
| if(typeof JSZip==="undefined"){const loadScript=document.createElement("script");loadScript.setAttribute("src","assets/js/jszip/dist/jszip.min.js");loadScript.addEventListener('load',function(){runZipping();},{passive:true,once:true});document.body.appendChild(loadScript);} | if(typeof JSZip==="undefined"){const loadScript=document.createElement("script");loadScript.setAttribute("src","assets/js/jszip/dist/jszip.min.js");loadScript.addEventListener('load',function(){runZipping();},{passive:true,once:true});document.body.appendChild(loadScript);} | ||||||
| else{runZipping();}} | else{runZipping();}} | ||||||
| listValidationErrors(validator){console.log("Listing validation errors");const dialogueContent=document.createElement("div");const headline=document.createElement("h3");headline.textContent=this.tls.validation_errors;const cancelB=document.createElement("a");cancelB.classList.add("icons");cancelB.classList.add("iconsClose");cancelB.classList.add("dialogueCloseX");cancelB.id="dialogueClose";cancelB.textContent="X";cancelB.title="Close";cancelB.href="#"+location.href;cancelB.addEventListener('click',CsvxmlDialogue.closeDialogue);headline.appendChild(cancelB);dialogueContent.appendChild(headline);const domErrorsSection=document.createElement("div");for(let errorType in validator.errors){if(validator.errors[errorType].length===0)continue;const ulHl=document.createElement("h4");ulHl.textContent=this.tls['errors_'+errorType]+" ("+validator.errors[errorType].length+")";ulHl.style.cursor="pointer";domErrorsSection.appendChild(ulHl);const ul=document.createElement("ul");for(let error of validator.errors[errorType]){const li=document.createElement("li");li.textContent=error;ul.appendChild(li);} | generateDialogueCloseButton(){const cancelB=document.createElement("a");cancelB.classList.add("icons");cancelB.classList.add("iconsClose");cancelB.classList.add("dialogueCloseX");cancelB.id="dialogueClose";cancelB.textContent="X";cancelB.title="Close";cancelB.href="#"+location.href;cancelB.addEventListener('click',CsvxmlDialogue.closeDialogue);return cancelB;} | ||||||
|  | listValidationErrors(validator){console.log("Listing validation errors");const dialogueContent=document.createElement("div");const headline=document.createElement("h3");headline.textContent=this.tls.validation_errors;headline.appendChild(this.generateDialogueCloseButton());dialogueContent.appendChild(headline);const domErrorsSection=document.createElement("div");for(let errorType in validator.errors){if(validator.errors[errorType].length===0)continue;const ulHl=document.createElement("h4");ulHl.textContent=this.tls['errors_'+errorType]+" ("+validator.errors[errorType].length+")";ulHl.style.cursor="pointer";domErrorsSection.appendChild(ulHl);const ul=document.createElement("ul");for(let error of validator.errors[errorType]){const li=document.createElement("li");li.textContent=error;ul.appendChild(li);} | ||||||
| ulHl.addEventListener('click',function(){ul.classList.toggle("minimized");});domErrorsSection.appendChild(ul);} | ulHl.addEventListener('click',function(){ul.classList.toggle("minimized");});domErrorsSection.appendChild(ul);} | ||||||
| dialogueContent.appendChild(domErrorsSection);const domDlSection=document.createElement("div");const domDlA=document.createElement("span");domDlA.textContent=this.tls.download;domDlA.classList.add("buttonLike");let app=this;domDlA.addEventListener('click',function(){app.zipUploadToXml(validator);});domDlSection.appendChild(domDlA);dialogueContent.appendChild(domDlSection);dialogue=CsvxmlDialogue.drawDialogue(dialogueContent);} | dialogueContent.appendChild(domErrorsSection);const domDlSection=document.createElement("div");const domDlA=document.createElement("span");domDlA.textContent=this.tls.download;domDlA.classList.add("buttonLike");let app=this;domDlA.addEventListener('click',function(){app.zipUploadToXml(validator);});domDlSection.appendChild(domDlA);dialogueContent.appendChild(domDlSection);dialogue=CsvxmlDialogue.drawDialogue(dialogueContent);} | ||||||
| uploadFileForValidation(file){const reader=new FileReader();reader.readAsText(file);let app=this;document.body.classList.add("loading");reader.onload=function(){function handleValidation(){console.log("Read file");let validator=new CsvxmlValidator(app.fieldListFlat,reader.result);document.body.classList.remove("loading");if(validator.isValid()===true){alert("Document is valid. Press ok to download.");app.zipUploadToXml(validator);} | uploadFileForValidation(file){const reader=new FileReader();reader.readAsText(file);let app=this;document.body.classList.add("loading");reader.onload=function(){function handleValidation(){console.log("Read file");let validator=new CsvxmlValidator(app.fieldListFlat,reader.result);document.body.classList.remove("loading");if(validator.isValid()===true){alert("Document is valid. Press ok to download.");app.zipUploadToXml(validator);} | ||||||
| @@ -51,7 +52,9 @@ else{handleValidation();}};reader.onerror=function(){alert(reader.error);};} | |||||||
| renderGenHeader(){const header=document.createElement("header");header.id="mainHeader";const logoArea=document.createElement("a");logoArea.id="logoArea";logoArea.href="https://www.museum-digital.org/";const logoImg=document.createElement("img");logoImg.src="assets/img/mdlogo-code-128px.png";logoImg.alt="Logo of museum-digital";logoArea.appendChild(logoImg);const h2=document.createElement("h2");h2.textContent="museum-digital";logoArea.appendChild(h2);header.appendChild(logoArea);const nav=document.createElement("nav");const lAbout=document.createElement("a");lAbout.href="https://en.about.museum-digital.org/about";lAbout.textContent=this.tls.about;nav.appendChild(lAbout);const lContactList=document.createElement("div");const lContact=document.createElement("a");lContact.textContent=this.tls.contact;lContact.href="https://en.about.museum-digital.org/contact/";lContactList.appendChild(lContact);const lContactDiv=document.createElement("div");const lImprint=document.createElement("a");lImprint.textContent=this.tls.imprint;lImprint.href="https://en.about.museum-digital.org/impressum";lContactDiv.appendChild(lImprint);const lPrivacy=document.createElement("a");lPrivacy.textContent=this.tls.privacy_policy;lPrivacy.href="https://en.about.museum-digital.org/privacy/";lContactDiv.appendChild(lPrivacy);lContactList.appendChild(lContactDiv);nav.appendChild(lContactList);const lNews=document.createElement("a") | renderGenHeader(){const header=document.createElement("header");header.id="mainHeader";const logoArea=document.createElement("a");logoArea.id="logoArea";logoArea.href="https://www.museum-digital.org/";const logoImg=document.createElement("img");logoImg.src="assets/img/mdlogo-code-128px.png";logoImg.alt="Logo of museum-digital";logoArea.appendChild(logoImg);const h2=document.createElement("h2");h2.textContent="museum-digital";logoArea.appendChild(h2);header.appendChild(logoArea);const nav=document.createElement("nav");const lAbout=document.createElement("a");lAbout.href="https://en.about.museum-digital.org/about";lAbout.textContent=this.tls.about;nav.appendChild(lAbout);const lContactList=document.createElement("div");const lContact=document.createElement("a");lContact.textContent=this.tls.contact;lContact.href="https://en.about.museum-digital.org/contact/";lContactList.appendChild(lContact);const lContactDiv=document.createElement("div");const lImprint=document.createElement("a");lImprint.textContent=this.tls.imprint;lImprint.href="https://en.about.museum-digital.org/impressum";lContactDiv.appendChild(lImprint);const lPrivacy=document.createElement("a");lPrivacy.textContent=this.tls.privacy_policy;lPrivacy.href="https://en.about.museum-digital.org/privacy/";lContactDiv.appendChild(lPrivacy);lContactList.appendChild(lContactDiv);nav.appendChild(lContactList);const lNews=document.createElement("a") | ||||||
| lNews.textContent=this.tls.news;lNews.href="https://blog.museum-digital.org/";nav.appendChild(lNews);header.appendChild(nav);document.body.appendChild(header);} | lNews.textContent=this.tls.news;lNews.href="https://blog.museum-digital.org/";nav.appendChild(lNews);header.appendChild(nav);document.body.appendChild(header);} | ||||||
| renderHeader(){const appHeader=document.createElement("header");const h1=document.createElement("h1");const img=document.createElement("img");img.width="70";img.height="70";img.src="assets/img/mdlogo-csvxml.svg";img.alt="";h1.appendChild(img);const h1Span=document.createElement("span");h1Span.textContent="museum-digital:csvxml";h1.appendChild(h1Span);appHeader.appendChild(h1);document.body.appendChild(appHeader);} | renderHeader(){const appHeader=document.createElement("header");const h1=document.createElement("h1");const img=document.createElement("img");img.width="70";img.height="70";img.src="assets/img/mdlogo-csvxml.svg";img.alt="";h1.appendChild(img);const h1Span=document.createElement("span");h1Span.textContent="museum-digital:csvxml";h1.appendChild(h1Span);appHeader.appendChild(h1);document.body.appendChild(appHeader);} | ||||||
| renderUploader(){let app=this;(async function(){const form=document.createElement("form");const label=document.createElement("label");label.textContent=app.tls.select_csv_file_for_upload;label.setAttribute("for","fileToUpload");form.appendChild(label);const input=document.createElement("input");input.type="file";input.id="fileToUpload";input.setAttribute("tabindex","1");input.accept=".csv";input.required="required";input.addEventListener('change',async function(){app.uploadFileForValidation(input.files[0]);});form.appendChild(input);app.domUploaderWrapper.appendChild(form);})();document.body.appendChild(this.domUploaderWrapper);} | renderHelpTexts(){let app=this;(async function(){function appendQA(question,answer){const div=document.createElement("div");div.classList.add("qaDiv");const qElem=document.createElement("h3");qElem.textContent=question;qElem.style.cursor="pointer";div.appendChild(qElem);qElem.addEventListener('click',function(){console.log("Listing validation errors");const dialogueContent=document.createElement("div");const headline=document.createElement("h3");headline.textContent=question;headline.appendChild(app.generateDialogueCloseButton());dialogueContent.appendChild(headline);const answerDiv=document.createElement("div");answerDiv.textContent=answer;dialogueContent.appendChild(answerDiv);CsvxmlDialogue.drawDialogue(dialogueContent);});return div;} | ||||||
|  | const div=document.createElement("div");div.appendChild(appendQA(app.tls.help_where_am_i,app.tls.help_where_am_i_content));app.domHelpWrapper.appendChild(div);})();document.body.appendChild(this.domHelpWrapper);} | ||||||
|  | renderUploader(){let app=this;(async function(){const h2=document.createElement("h2");h2.textContent=app.tls.upload;app.domUploaderWrapper.appendChild(h2);const form=document.createElement("form");const label=document.createElement("label");label.textContent=app.tls.select_csv_file_for_upload;label.setAttribute("for","fileToUpload");form.appendChild(label);const input=document.createElement("input");input.type="file";input.id="fileToUpload";input.setAttribute("tabindex","1");input.accept=".csv";input.required="required";input.addEventListener('change',async function(){app.uploadFileForValidation(input.files[0]);});form.appendChild(input);app.domUploaderWrapper.appendChild(form);})();document.body.appendChild(this.domUploaderWrapper);} | ||||||
| doForFieldList(callback){let fieldLists=document.getElementsByClassName("fieldList");for(let i=0,max=fieldLists.length;i<max;i++){let fields=fieldLists[i].getElementsByTagName("li");for(let j=0,maxj=fields.length;j<maxj;j++){callback(fields[j]);}}} | doForFieldList(callback){let fieldLists=document.getElementsByClassName("fieldList");for(let i=0,max=fieldLists.length;i<max;i++){let fields=fieldLists[i].getElementsByTagName("li");for(let j=0,maxj=fields.length;j<maxj;j++){callback(fields[j]);}}} | ||||||
| toggleListFieldSelectionState(field){let app=this;let newValue=field.getAttribute("data-alt");field.setAttribute("data-alt",field.textContent);field.textContent=newValue;field.classList.toggle("humanTLToggled");if(field.classList.contains("humanTLToggled")===false)return;let dependencies=this.fieldListFlat[field.id].dependsOn;if(dependencies!==undefined&&dependencies!==null){let linkedFields=this.fieldListFlat[field.id].dependsOn;for(let i=0,max=linkedFields.length;i<max;i++){let linkedField=document.getElementById(linkedFields[i]);if(linkedField.classList.contains("humanTLToggled")===true)continue;this.toggleListFieldSelectionState(linkedField);}}} | toggleListFieldSelectionState(field){let app=this;let newValue=field.getAttribute("data-alt");field.setAttribute("data-alt",field.textContent);field.textContent=newValue;field.classList.toggle("humanTLToggled");if(field.classList.contains("humanTLToggled")===false)return;let dependencies=this.fieldListFlat[field.id].dependsOn;if(dependencies!==undefined&&dependencies!==null){let linkedFields=this.fieldListFlat[field.id].dependsOn;for(let i=0,max=linkedFields.length;i<max;i++){let linkedField=document.getElementById(linkedFields[i]);if(linkedField.classList.contains("humanTLToggled")===true)continue;this.toggleListFieldSelectionState(linkedField);}}} | ||||||
| checkCSVBySelectionAccessibility(){let selected=document.getElementsByClassName("humanTLToggled");if(selected.length===0){this.csvBySelectionButton.classList.add("invisible");this.unsetSelectionButton.classList.add("invisible");} | checkCSVBySelectionAccessibility(){let selected=document.getElementsByClassName("humanTLToggled");if(selected.length===0){this.csvBySelectionButton.classList.add("invisible");this.unsetSelectionButton.classList.add("invisible");} | ||||||
| @@ -68,5 +71,5 @@ CsvxmlTooltip.bindTooltipToElement(domLi,field.name_human_readable,tooltipConten | |||||||
| domDiv.appendChild(domUl);this.domMainWrapper.appendChild(domDiv);} | domDiv.appendChild(domUl);this.domMainWrapper.appendChild(domDiv);} | ||||||
| document.body.appendChild(this.domMainWrapper);let app=this;this.doForFieldList(function(field){field.addEventListener('click',function(e){app.toggleListFieldSelectionState(field);app.checkCSVBySelectionAccessibility();});});}} | document.body.appendChild(this.domMainWrapper);let app=this;this.doForFieldList(function(field){field.addEventListener('click',function(e){app.toggleListFieldSelectionState(field);app.checkCSVBySelectionAccessibility();});});}} | ||||||
| (async function(){function getLang(){const allowedLangs=document.documentElement.getAttribute("data-allowed-langs").split(',');if(navigator.language===undefined)return 'en';const browserLang=navigator.language.toLowerCase().substr(0,2);console.log(browserLang);if(allowedLangs.includes(browserLang))return browserLang;else return 'en';} | (async function(){function getLang(){const allowedLangs=document.documentElement.getAttribute("data-allowed-langs").split(',');if(navigator.language===undefined)return 'en';const browserLang=navigator.language.toLowerCase().substr(0,2);console.log(browserLang);if(allowedLangs.includes(browserLang))return browserLang;else return 'en';} | ||||||
| const lang=getLang();document.documentElement.setAttribute("lang",lang);document.body.classList.add("loading");let loaded=0;let fieldList;let tls;function loadPage(){document.body.classList.remove("loading");const page=new CsvxmlPage(fieldList,tls);page.renderGenHeader();page.renderHeader();page.renderUploader();page.renderMain();} | const lang=getLang();document.documentElement.setAttribute("lang",lang);document.body.classList.add("loading");let loaded=0;let fieldList;let tls;function loadPage(){document.body.classList.remove("loading");const page=new CsvxmlPage(fieldList,tls);page.renderGenHeader();page.renderHeader();page.renderHelpTexts();page.renderUploader();page.renderMain();} | ||||||
| window.fetch('/json/fields.'+lang+'.json',{method:'GET',cache:'no-cache',credentials:'same-origin',}).then(function(response){return response.json();}).then(function(elements){fieldList=elements;loaded++;if(loaded===2)loadPage();});window.fetch('/json/tls.'+lang+'.json',{method:'GET',cache:'no-cache',credentials:'same-origin',}).then(function(response){return response.json();}).then(function(elements){tls=elements;loaded++;if(loaded===2)loadPage();});})(); | window.fetch('/json/fields.'+lang+'.json',{method:'GET',cache:'no-cache',credentials:'same-origin',}).then(function(response){return response.json();}).then(function(elements){fieldList=elements;loaded++;if(loaded===2)loadPage();});window.fetch('/json/tls.'+lang+'.json',{method:'GET',cache:'no-cache',credentials:'same-origin',}).then(function(response){return response.json();}).then(function(elements){tls=elements;loaded++;if(loaded===2)loadPage();});})(); | ||||||
| @@ -4,7 +4,7 @@ | |||||||
|  |  | ||||||
|     <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"/> | ||||||
|     <link rel="stylesheet" type="text/css" href="assets/css/csvxml.min.css?v000003" /> |     <link rel="stylesheet" type="text/css" href="assets/css/csvxml.min.css?v000005" /> | ||||||
|     <link rel="manifest" href="/manifest.json" /> |     <link rel="manifest" href="/manifest.json" /> | ||||||
|     <meta name="theme-color" content="#aa4400" /> |     <meta name="theme-color" content="#aa4400" /> | ||||||
|  |  | ||||||
| @@ -27,7 +27,7 @@ | |||||||
| </head> | </head> | ||||||
| <body class="loading"> | <body class="loading"> | ||||||
|  |  | ||||||
| <script src="assets/js/csvxmlV2.min.js?v000003" type="text/javascript" async></script> | <script src="assets/js/csvxmlV2.min.js?v000005" type="text/javascript" async></script> | ||||||
|  |  | ||||||
| </body> | </body> | ||||||
| </html> | </html> | ||||||
| @@ -1 +1 @@ | |||||||
| {"remarks":"Notizen","download":"Download","upload":"Hochladen","select_csv_file_for_upload":"Bitte w\u00e4hlen Sie eine CSV Datei als Basis zum Erstellen von XML Dateien","currently_approved_tags":"Derzeit zum Import verf\u00fcgbare Tags \/ Felder","download_csv_all":"CSV-Vorlage mit allen Feldern runterladen","download_csv_by_selection":"CSV-Vorlage auf Basis der Auswahl herunterladen","select_required_fields":"Pflichtfelder ausw\u00e4hlen","select_all_fields":"Alle Felder ausw\u00e4hlen","unset_selection":"Auswahl entfernen","file_format":"Dateiformat","validation_errors":"Validierungsfehler","errors_parsing":"Parsing-Fehler","errors_mandatoryTags":"Fehlende Pflichtfelder","errors_duplicateInvNos":"Doppelte Inventarnummern","errors_dependentColumns":"Spaltenabh\u00e4ngigkeiten nicht ber\u00fccksichtigt","errors_controlledLists":"Kontrollierte Werte","errors_mainImageResource":"Fehlende Haupt-Bilder oder Ressourcen","allowed_values":"Zugelassene Werte","privacy_policy":"Datenschutzerkl\u00e4rung","contact":"Kontakt","news":"Neuigkeiten","imprint":"Impressum","about":"\u00dcber"} | {"remarks":"Notizen","download":"Download","upload":"Hochladen","select_csv_file_for_upload":"Bitte w\u00e4hlen Sie eine CSV Datei als Basis zum Erstellen von XML Dateien","currently_approved_tags":"Derzeit zum Import verf\u00fcgbare Tags \/ Felder","download_csv_all":"CSV-Vorlage mit allen Feldern runterladen","download_csv_by_selection":"CSV-Vorlage auf Basis der Auswahl herunterladen","select_required_fields":"Pflichtfelder ausw\u00e4hlen","select_all_fields":"Alle Felder ausw\u00e4hlen","unset_selection":"Auswahl entfernen","file_format":"Dateiformat","validation_errors":"Validierungsfehler","errors_parsing":"Parsing-Fehler","errors_mandatoryTags":"Fehlende Pflichtfelder","errors_duplicateInvNos":"Doppelte Inventarnummern","errors_dependentColumns":"Spaltenabh\u00e4ngigkeiten nicht ber\u00fccksichtigt","errors_controlledLists":"Kontrollierte Werte","errors_mainImageResource":"Fehlende Haupt-Bilder oder Ressourcen","allowed_values":"Zugelassene Werte","privacy_policy":"Datenschutzerkl\u00e4rung","contact":"Kontakt","news":"Neuigkeiten","imprint":"Impressum","about":"\u00dcber","help_where_am_i":"What is this page for?","help_where_am_i_content":" CSVXML helps validate import object data for museum-digital following museum-digital's standard import format."} | ||||||
| @@ -1 +1 @@ | |||||||
| {"remarks":"Remarks","download":"Download","upload":"Upload","select_csv_file_for_upload":"Please select a CSV file to create XML files","currently_approved_tags":"Currently approved tags (column names) for md:import","download_csv_all":"Download CSV template with all fields","download_csv_by_selection":"Download CSV template based on selection","select_required_fields":"Select required fields","select_all_fields":"Select all fields","unset_selection":"Unset selection","file_format":"File format","validation_errors":"Validation errors","errors_parsing":"Parse errors","errors_mandatoryTags":"Missing mandatory tags","errors_duplicateInvNos":"Duplicate inventory numbers","errors_dependentColumns":"Column dependencies unresolved","errors_controlledLists":"Controlled lists","errors_mainImageResource":"Missing main images or resources","allowed_values":"Allowed values","privacy_policy":"Privacy policy","contact":"Contact","news":"News","imprint":"Imprint","about":"About"} | {"remarks":"Remarks","download":"Download","upload":"Upload","select_csv_file_for_upload":"Please select a CSV file to create XML files","currently_approved_tags":"Currently approved tags (column names) for md:import","download_csv_all":"Download CSV template with all fields","download_csv_by_selection":"Download CSV template based on selection","select_required_fields":"Select required fields","select_all_fields":"Select all fields","unset_selection":"Unset selection","file_format":"File format","validation_errors":"Validation errors","errors_parsing":"Parse errors","errors_mandatoryTags":"Missing mandatory tags","errors_duplicateInvNos":"Duplicate inventory numbers","errors_dependentColumns":"Column dependencies unresolved","errors_controlledLists":"Controlled lists","errors_mainImageResource":"Missing main images or resources","allowed_values":"Allowed values","privacy_policy":"Privacy policy","contact":"Contact","news":"News","imprint":"Imprint","about":"About","help_where_am_i":"What is this page for?","help_where_am_i_content":" CSVXML helps validate import object data for museum-digital following museum-digital's standard import format."} | ||||||
| @@ -1 +1 @@ | |||||||
| {"remarks":"Megjegyz\u00e9sek","download":"Let\u00f6lt\u00e9s","upload":"Felt\u00f6lt\u00e9s","select_csv_file_for_upload":"Please select a CSV file to create XML files","currently_approved_tags":"Jelenleg j\u00f3v\u00e1hagyott c\u00edmk\u00e9k (oszlopnevek) az md:importhoz","download_csv_all":"Download CSV template with all fields","download_csv_by_selection":"Download CSV template based on selection","select_required_fields":"K\u00f6telez\u0151 mez\u0151k kijel\u00f6l\u00e9se","select_all_fields":"\u00d6sszes mez\u0151 kijel\u00f6l\u00e9s","unset_selection":"Kijel\u00f6l\u00e9s megsz\u00fcntet\u00e9se","file_format":"Kiterjeszt\u00e9s","validation_errors":"Validation errors","errors_parsing":"Parse errors","errors_mandatoryTags":"Missing mandatory tags","errors_duplicateInvNos":"Duplicate inventory numbers","errors_dependentColumns":"Column dependencies unresolved","errors_controlledLists":"Controlled lists","errors_mainImageResource":"Missing main images or resources","allowed_values":"Allowed values","privacy_policy":"Privacy policy","contact":"Contact","news":"News","imprint":"Imprint","about":"About"} | {"remarks":"Megjegyz\u00e9sek","download":"Let\u00f6lt\u00e9s","upload":"Felt\u00f6lt\u00e9s","select_csv_file_for_upload":"Please select a CSV file to create XML files","currently_approved_tags":"Jelenleg j\u00f3v\u00e1hagyott c\u00edmk\u00e9k (oszlopnevek) az md:importhoz","download_csv_all":"Download CSV template with all fields","download_csv_by_selection":"Download CSV template based on selection","select_required_fields":"K\u00f6telez\u0151 mez\u0151k kijel\u00f6l\u00e9se","select_all_fields":"\u00d6sszes mez\u0151 kijel\u00f6l\u00e9s","unset_selection":"Kijel\u00f6l\u00e9s megsz\u00fcntet\u00e9se","file_format":"Kiterjeszt\u00e9s","validation_errors":"Validation errors","errors_parsing":"Parse errors","errors_mandatoryTags":"Missing mandatory tags","errors_duplicateInvNos":"Duplicate inventory numbers","errors_dependentColumns":"Column dependencies unresolved","errors_controlledLists":"Controlled lists","errors_mainImageResource":"Missing main images or resources","allowed_values":"Allowed values","privacy_policy":"Privacy policy","contact":"Contact","news":"News","imprint":"Imprint","about":"About","help_where_am_i":"What is this page for?","help_where_am_i_content":" CSVXML helps validate import object data for museum-digital following museum-digital's standard import format."} | ||||||
| @@ -59,6 +59,9 @@ function generateTranslationFile(string $lang):string { | |||||||
|         'news' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'news'), |         'news' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'news'), | ||||||
|         'imprint' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'imprint'), |         'imprint' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'imprint'), | ||||||
|         'about' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'about'), |         'about' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'about'), | ||||||
|  | 
 | ||||||
|  |         'help_where_am_i' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'help_where_am_i'), | ||||||
|  |         'help_where_am_i_content' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'help_where_am_i_content'), | ||||||
|     ]); |     ]); | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
| @@ -76,7 +79,7 @@ function generateAppShell():string { | |||||||
| 
 | 
 | ||||||
|     <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"/> | ||||||
|     <link rel="stylesheet" type="text/css" href="assets/css/csvxml.min.css?v000003" /> |     <link rel="stylesheet" type="text/css" href="assets/css/csvxml.min.css?v000005" /> | ||||||
|     <link rel="manifest" href="/manifest.json" /> |     <link rel="manifest" href="/manifest.json" /> | ||||||
|     <meta name="theme-color" content="#aa4400" /> |     <meta name="theme-color" content="#aa4400" /> | ||||||
| 
 | 
 | ||||||
| @@ -99,7 +102,7 @@ function generateAppShell():string { | |||||||
| </head> | </head> | ||||||
| <body class="loading"> | <body class="loading"> | ||||||
| 
 | 
 | ||||||
| <script src="assets/js/csvxmlV2.min.js?v000003" type="text/javascript" async></script> | <script src="assets/js/csvxmlV2.min.js?v000005" type="text/javascript" async></script> | ||||||
| 
 | 
 | ||||||
| </body> | </body> | ||||||
| </html>'; | </html>'; | ||||||
| @@ -109,21 +112,29 @@ function generateAppShell():string { | |||||||
| const SERVED_ROOT = __DIR__ . '/../public/'; | const SERVED_ROOT = __DIR__ . '/../public/'; | ||||||
| const SERVED_JSON_ROOT = __DIR__ . '/../public/json/'; | const SERVED_JSON_ROOT = __DIR__ . '/../public/json/'; | ||||||
| 
 | 
 | ||||||
| if (!is_dir(SERVED_JSON_ROOT)) mkdir(SERVED_JSON_ROOT); | if (!is_dir(SERVED_JSON_ROOT)) { | ||||||
|  |     echo "Will generate JSON root directory (" . SERVED_JSON_ROOT . ")" . PHP_EOL; | ||||||
|  |     MD_STD::mkdir(SERVED_JSON_ROOT); | ||||||
|  | } | ||||||
| 
 | 
 | ||||||
| foreach (ALLOWED_LANGS as $lang) { | foreach (ALLOWED_LANGS as $lang) { | ||||||
|  |     echo "Will generate JSON list of fields for language: " . $lang . PHP_EOL; | ||||||
|     file_put_contents(SERVED_JSON_ROOT . 'fields.' . $lang . '.json', generateFieldsIndex($lang)); |     file_put_contents(SERVED_JSON_ROOT . 'fields.' . $lang . '.json', generateFieldsIndex($lang)); | ||||||
|  |     echo "Will generate JSON list of translations for language: " . $lang . PHP_EOL; | ||||||
|     file_put_contents(SERVED_JSON_ROOT . 'tls.' . $lang . '.json', generateTranslationFile($lang)); |     file_put_contents(SERVED_JSON_ROOT . 'tls.' . $lang . '.json', generateTranslationFile($lang)); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | echo "Will generate app shell" . PHP_EOL; | ||||||
| file_put_contents(SERVED_ROOT . 'index.htm', generateAppShell()); | file_put_contents(SERVED_ROOT . 'index.htm', generateAppShell()); | ||||||
| 
 | 
 | ||||||
|  | echo "Will minify CSS" . PHP_EOL; | ||||||
| exec("minify \\ | exec("minify \\ | ||||||
|     -o " . escapeshellarg(__DIR__ . '/../public/assets/css/csvxml.min.css') . '\\ |     -o " . escapeshellarg(__DIR__ . '/../public/assets/css/csvxml.min.css') . '\\ | ||||||
|     ' . escapeshellarg(__DIR__ . '/../public/assets/css/editMenu.css') . '\\ |     ' . escapeshellarg(__DIR__ . '/../public/assets/css/editMenu.css') . '\\ | ||||||
|     ' . escapeshellarg(__DIR__ . '/../public/assets/css/dialogue.css') . '\\ |     ' . escapeshellarg(__DIR__ . '/../public/assets/css/dialogue.css') . '\\ | ||||||
|     ' . escapeshellarg(__DIR__ . '/../public/assets/css/csvxml.css')); |     ' . escapeshellarg(__DIR__ . '/../public/assets/css/csvxml.css')); | ||||||
| 
 | 
 | ||||||
|  | echo "Will minify JS" . PHP_EOL; | ||||||
| exec("minify \\ | exec("minify \\ | ||||||
|     -o " . escapeshellarg(__DIR__ . '/../public/assets/js/csvxmlV2.min.js') . '\ |     -o " . escapeshellarg(__DIR__ . '/../public/assets/js/csvxmlV2.min.js') . '\ | ||||||
|     ' . escapeshellarg(__DIR__ . '/../public/assets/js/csvxmlV2.js')); |     ' . escapeshellarg(__DIR__ . '/../public/assets/js/csvxmlV2.js')); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user