1 line
21 KiB
JavaScript
Raw Normal View History

"use strict";const MAX_INPUT_SIZE=1048576;'serviceWorker'in navigator&&(console.log("Registering service worker"),navigator.serviceWorker.register('/sw.js'));class QaPage{lang;tls;domWrapper;domUploaderWrapper;domUploaderCurrentWrapper;domMainWrapper;parser;selectedActivity;selectedApi;constructor(d,e){this.lang=d,this.tls=Object.freeze(e);let b=document.createElement("div");b.id="contentWrapper",this.domWrapper=b;let a=document.createElement("div");a.id="uploader",a.classList.add("uploader"),this.domUploaderWrapper=a;let c=document.createElement("div");c.id="uploaderMenu",this.domUploaderCurrentWrapper=c;let f=document.createElement("main");this.domMainWrapper=f}goForwardInMenuPages(b){const a=this;switch(b){case"parserSelection":a.drawUpActivitySelection();break;case"activityTypeSelection":a.drawUpApiTypeSelection();break;case"apiTypeSelection":a.drawUpUploadTypeSelection();break;default:console.log("Invalid page to go forward from selected.")}}generateDialogueCloseButton(){const a=document.createElement("a");return a.classList.add("icons"),a.classList.add("iconsClose"),a.classList.add("dialogueCloseX"),a.id="dialogueClose",a.textContent="X",a.title=this.tls.close,a.href="#"+location.href,a.addEventListener('click',QaDialogue.closeDialogue),a}setSelectedActivity(a){['evaluate','convert_to_xml'].includes(a)?this.selectedActivity=a:window.alert("Invalid activity selected")}setSelectedApi(b){let a;switch(this.selectedActivity){case"evaluate":a=['object','count_vocabulary_entries_to_be_added','minimaldatensatz'];break;case"convert_to_xml":const b=document.documentElement.getAttribute("data-allowed-xml-conversion-targets").split(',');a=b;break;default:window.alert("Invalid activity set: "+this.selectedActivity)}a.includes(b)?this.selectedApi=b:window.alert("Invalid activity selected")}downloadFromString(b,c){const d=new Blob([c],{type:"text/plain"}),a=document.createElement("a");a.download=b,a.href=window.URL.createObjectURL(d),a.dataset.downloadurl=["text/plain",a.download,a.href].join(":");const e=new MouseEvent("click",{view:window,bubbles:!0,cancelable:!0});a.dispatchEvent(e),a.remove()}generateValidationOutputsForCountNewToVocabs(c){const b=document.getElementById("validation_overlay_intro");b!==void 0&&b!==null&&b.parentElement.removeChild(b);const a=document.createElement("div"),d=document.createElement("h5");d.textContent=this.tls.count_new_to_vocabs,a.appendChild(d);const e=document.createElement("table");function f(d,e){const a=document.createElement("tr"),b=document.createElement("th");b.textContent=d,a.appendChild(b);const c=document.createElement("td");return c.textContent=e,a.appendChild(c),a}for(let a of c.count)e.appendChild(f(a.category_name,a.count));a.appendChild(e);const g=document.createElement("h6");g.textContent=this.tls.samples,a.appendChild(g);const h=document.createElement("table");for(let a of c.samples)h.appendChild(f(a.category_name,a.entries.join(", ")));return a.appendChild(h),a}generateValidationOutputsForMinimaldatensatz(b){const a=document.createElement("div");for(let d of b){const c=document.createElement("div"),e=document.createElement("h5");e.textContent=this.tls.inventory_number+': '+d.invno,c.appendChild(e);const f=document.createElement("table");for(let c of d.evaluations){const b=document.createElement("tr"),a=document.createElement("td");a.style.width="40px",c.passed===!0?a.style.background="var(--color-green)":a.style.background="var(--color-red)",b.appendChild(a);const e=document.createElement("td");e.textContent=c.text,b.appendChild(e),f.appendChild(b)}c.appendChild(f),a.appendChild(c)}return a}generateRegularValidationOutputs(c){const b=document.createElement("div");function a(d,e){const a=document.createElement("tr"),b=document.createElement("th");b.textContent=d,a.appendChild(b);const c=document.createElement("td");return c.appendChild(e),a.appendChild(c),a}for(let d of c){const g=document.createElement("div"),j=document.createElement("h5");j.textContent=this.tls.inventory_number+': '+d.invno,g.appendChild(j);const e=document.createElement("div"),f=document.createElement("tab