Add refresh button and license statement

Close #25, close #24
This commit is contained in:
Joshua Ramon Enslin 2022-11-28 15:55:05 +01:00
parent 20810aa850
commit 5146305caf
Signed by: jrenslin
GPG Key ID: 46016F84501B70AE
4 changed files with 56 additions and 3 deletions

View File

@ -65,11 +65,21 @@ h1 img:hover { opacity: 1; }
main, main,
body > div, body > div,
body > footer,
body > form { display: block; max-width: 90vw; margin: 0 auto 3em auto; padding-bottom: 3em; } body > form { display: block; max-width: 90vw; margin: 0 auto 3em auto; padding-bottom: 3em; }
form > div { margin-bottom: 1em; } form > div { margin-bottom: 1em; }
label { display: block; font-weight: bold; margin-bottom: .5em; } label { display: block; font-weight: bold; margin-bottom: .5em; }
body > footer { border-top: .1em solid var(--color-borders); }
body > footer > div { display: block; }
body > footer > div a,
body > footer > div span { display: block; font-weight: bold; cursor: pointer;
color: var(--color-fg-less); transition: color .4s; }
body > footer > div a:hover,
body > footer > div span:hover { color: var(--color-accent-hover); }
.invisible { display: none !important; opacity: 0; } .invisible { display: none !important; opacity: 0; }
.buttonLike, .buttonLike,

File diff suppressed because one or more lines are too long

View File

@ -1018,6 +1018,45 @@ class CsvxmlPage {
} }
renderFooter() {
const footer = document.createElement("footer");
const licenseStatement = document.createElement("p");
licenseStatement.textContent = "This work is licensed under the GNU Affero Public License Version 3.";
footer.appendChild(licenseStatement);
const footerOptions = document.createElement("div");
const codeLink = document.createElement("a");
codeLink.textContent = "Source code";
codeLink.href = "https://gitea.armuli.eu/museum-digital/csvxml";
footerOptions.appendChild(codeLink);
if ('serviceWorker' in navigator) {
const refreshB = document.createElement("span");
refreshB.textContent = "Reload application";
refreshB.setAttribute("tabindex", 1);
refreshB.addEventListener('click', function(e) {
Promise.all(['csvxml-cache-v1'].map(function(cache) {
caches.has(cache).then(function(hasCache) {
if (hasCache === true) {
caches.delete(cache).then(function(deletionStatus) {});
}
})
}))
location.reload()
}, {passive: true, once: true});
footerOptions.appendChild(refreshB);
}
footer.appendChild(footerOptions);
document.body.appendChild(footer);
}
} }
(async function() { (async function() {
@ -1056,6 +1095,7 @@ class CsvxmlPage {
page.renderHelpTexts(); page.renderHelpTexts();
page.renderUploader(); page.renderUploader();
page.renderMain(); page.renderMain();
page.renderFooter();
} }

View File

@ -72,7 +72,10 @@ const remarkCont=document.createElement("p");remarkCont=field.remarks;tooltipCon
if(field.allowedValues!==undefined&&Object.values(field.allowedValues).length!==0){const allowedHl=document.createElement("h4");allowedHl.textContent=this.tls.allowed_values;tooltipContent.appendChild(allowedHl);const allowedList=document.createElement("p");allowedList.textContent=Object.values(field.allowedValues).join(', ');tooltipContent.appendChild(allowedList);} if(field.allowedValues!==undefined&&Object.values(field.allowedValues).length!==0){const allowedHl=document.createElement("h4");allowedHl.textContent=this.tls.allowed_values;tooltipContent.appendChild(allowedHl);const allowedList=document.createElement("p");allowedList.textContent=Object.values(field.allowedValues).join(', ');tooltipContent.appendChild(allowedList);}
CsvxmlTooltip.bindTooltipToElement(domLi,field.name_human_readable,tooltipContent);} CsvxmlTooltip.bindTooltipToElement(domLi,field.name_human_readable,tooltipContent);}
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();});});}
renderFooter(){const footer=document.createElement("footer");const licenseStatement=document.createElement("p");licenseStatement.textContent="This work is licensed under the GNU Affero Public License Version 3.";footer.appendChild(licenseStatement);const footerOptions=document.createElement("div");const codeLink=document.createElement("a");codeLink.textContent="Source code";codeLink.href="https://gitea.armuli.eu/museum-digital/csvxml";footerOptions.appendChild(codeLink);if('serviceWorker'in navigator){const refreshB=document.createElement("span");refreshB.textContent="Reload application";refreshB.setAttribute("tabindex",1);refreshB.addEventListener('click',function(e){Promise.all(['csvxml-cache-v1'].map(function(cache){caches.has(cache).then(function(hasCache){if(hasCache===true){caches.delete(cache).then(function(deletionStatus){});}})}))
location.reload()},{passive:true,once:true});footerOptions.appendChild(refreshB);}
footer.appendChild(footerOptions);document.body.appendChild(footer);}}
(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.renderHelpTexts();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();page.renderFooter();}
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();});})();