From fdbc3f79d750fcb1f295fa275b75e6ce86e035f1 Mon Sep 17 00:00:00 2001 From: Code by Ben Date: Wed, 18 Sep 2024 14:05:57 +1000 Subject: [PATCH] releaser function better handles spaces. --- assets/js/artifact-validate.mjs | 6 ++++-- assets/js/editor-artifact.js | 2 ++ public/js/editor-artifact.min.js | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/assets/js/artifact-validate.mjs b/assets/js/artifact-validate.mjs index 9b417049..325095d1 100644 --- a/assets/js/artifact-validate.mjs +++ b/assets/js/artifact-validate.mjs @@ -131,13 +131,15 @@ export function releaser(elm) { throw new Error("The element of the releaser validator is null."); } elm.classList.remove("is-valid", "is-invalid"); - // enforce uppercase - let value = elm.value.trim().toUpperCase(); + // enforce uppercase and remove leading spaces + let value = elm.value.trimStart().toUpperCase(); // replace + with a comma and space for convenience value = value.replace("+", ", "); // valid characters were determined by this document, // space, A-Z, À-Ö, Ø-Þ, 0-9, -, comma, & value = value.replace(/[^ A-ZÀ-ÖØ-Þ0-9\-,&]/g, ""); + // replace multiple spaces with a single space + value = value.replace(/[ ]{2,}/g, " "); elm.value = value; const min = elm.getAttribute("minlength"); diff --git a/assets/js/editor-artifact.js b/assets/js/editor-artifact.js index 12bdfc89..2d2b81b3 100644 --- a/assets/js/editor-artifact.js +++ b/assets/js/editor-artifact.js @@ -231,11 +231,13 @@ import { clipValue, getElmById, titleize } from "./helper.mjs"; throw new Error("The releaser 1 input is missing."); } rel1.addEventListener("input", (e) => validateReleaser(e.target)); + const rel2 = document.getElementById("artifact-editor-releaser-2"); if (rel2 === null) { throw new Error("The releaser 2 input is missing."); } rel2.addEventListener("input", (e) => validateReleaser(e.target)); + const relUndo = document.getElementById("artifact-editor-releaser-undo"); if (relUndo === null) { throw new Error("The releasers reset is missing."); diff --git a/public/js/editor-artifact.min.js b/public/js/editor-artifact.min.js index 56cf2a5c..1a0a8e29 100644 --- a/public/js/editor-artifact.min.js +++ b/public/js/editor-artifact.min.js @@ -1,2 +1,2 @@ /* editor-artifact.min.js © Defacto2 2024 */ -(()=>{function R(t,i,r){if(t==null)throw new Error("The year input element is null.");if(i==null)throw new Error("The month input element is null.");if(r==null)throw new Error("The day input element is null.");t.classList.remove("is-invalid","is-valid"),i.classList.remove("is-invalid","is-valid"),r.classList.remove("is-invalid","is-valid");let a=parseInt(t.value,10);isNaN(a)?t.value="0":t.value=a;let s=parseInt(i.value,10);isNaN(s)?i.value="0":i.value=s;let o=parseInt(r.value,10);isNaN(o)?r.value="0":r.value=o;let l=0,p=new Date().getFullYear(),h=a>=1980&&a<=p;a>l&&!h&&t.classList.add("is-invalid");let C=s>=1&&s<=12;s>l&&!C&&i.classList.add("is-invalid");let L=o>=1&&o<=31;o>l&&!L&&r.classList.add("is-invalid"),isNaN(a)&&(C||L)&&t.classList.add("is-invalid"),(s==l||isNaN(s))&&L&&i.classList.add("is-invalid")}function ge(t){return Ee(t,!0)}function he(t){return Ee(t,!1)}function Ee(t,i){if(t==null)throw new Error("The repository URL element is null.");t.classList.remove("is-valid","is-invalid");let r=t.value.trim();if(r.length===0)return;if(i==!0&&r.startsWith("refs/")){t.classList.add("is-invalid");return}if(r.includes("://")){t.classList.add("is-invalid");return}let s=/[^A-Za-z0-9-._/]/g;r=r.replace(s,""),r=r.replaceAll("//","/");let o=/^\//;r=r.replace(o,""),t.value=r;let l=t.getAttribute("maxlength");if(l===null)throw new Error(`The maxlength attribute is required for ${t.id}.`);if(r.length>l){t.classList.add("is-invalid");return}}function B(t){if(t==null)throw new Error("The element of the releaser validator is null.");t.classList.remove("is-valid","is-invalid");let i=t.value.trim().toUpperCase();i=i.replace("+",", "),i=i.replace(/[^ A-ZÀ-ÖØ-Þ0-9\-,&]/g,""),t.value=i;let r=t.getAttribute("minlength"),a=t.getAttribute("maxlength"),s=t.getAttribute("required");if(r===null)throw new Error(`The minlength attribute is required for ${t.id}.`);if(a===null)throw new Error(`The maxlength attribute is required for ${t.id}.`);let o=document.getElementById("artifact-editor-releasers-error");if(o===null)throw new Error("The releasers error element is null.");let l=i.lengtha;if(s!=null&&l){t.classList.add("is-invalid"),t.id==="-1"&&o.classList.add("d-block");return}let p=i.length>0&&(i.lengtha);if(s==null&&p){t.classList.add("is-invalid");return}t.classList.remove("is-invalid"),o.classList.remove("d-block")}function we(t){if(t==null)throw new Error("The element of the releaser validator is null.");t.classList.remove("is-valid","is-invalid");let i=t.value.trim();i.length>0&&i.length!=11&&t.classList.add("is-invalid")}function Z(t,i){if(t==null)throw new Error("The element of the number validator is null.");t.classList.remove("is-valid","is-invalid");let r=parseInt(t.value,10);isNaN(r)&&t.classList.add("is-invalid"),(r>i||r<0)&&t.classList.add("is-invalid")}function pe(t){let i=["a","an","and","as","but","for","if","of","or","so","the","to"];return t.split(" ").map((r,a)=>a===0||!i.includes(r.toLowerCase())?r.charAt(0).toUpperCase()+r.slice(1).toLowerCase():r.toLowerCase()).join(" ")}async function T(t){let i=c(t);i.focus(),await navigator.clipboard.writeText(`${i.value}`).then(function(){console.log(`Copied ${Te(i.value.length)} to the clipboard`)},function(r){console.error(`could not save any text to the clipboard: ${r}`)})}function c(t){let i=document.getElementById(t);if(i==null)throw new Error(`The ${t} for getElmById() element is null.`);return i}function Te(t=0){let s=Math.pow(1e3,2),o=Math.pow(1e3,3);return t>o?`${(Math.round(t*100/o)/100).toFixed(2)} GB`:t>s?`${(Math.round(t*100/s)/100).toFixed(1)} MB`:t>1e3?`${(Math.round(t*100/1e3)/100).toFixed()} kB`:`${Math.round(t).toFixed()} bytes`}(()=>{"use strict";function t(e){return function(){e.forEach(n=>{n.disabled=!0,n.classList.remove("btn-outline-primary"),n.classList.add("btn-light")})}}function i(e){return function(){e.forEach(n=>{n.disabled=!1,n.classList.remove("btn-light"),n.classList.add("btn-outline-primary")})}}let r=document.getElementById("artifact-editor-modal"),a=document.getElementsByName("artifact-editor-dataeditor");r.addEventListener("shown.bs.modal",()=>{t(a)()}),r.addEventListener("hidden.bs.modal",()=>{i(a)()});let s=document.getElementById("asset-editor-modal"),o=document.getElementsByName("artifact-editor-fileeditor");s.addEventListener("shown.bs.modal",()=>{t(o)()}),s.addEventListener("hidden.bs.modal",()=>{i(o)()});let l=document.getElementById("emulate-editor-modal"),p=document.getElementsByName("artifact-editor-emueditor");l.addEventListener("shown.bs.modal",()=>{t(p)()}),l.addEventListener("hidden.bs.modal",()=>{i(p)()});let h=document.getElementById("emulate-run-program");if(h!==null){let e=document.getElementById("emulate-guess-program");if(e===null)throw new Error("The guess program input is missing.");h.addEventListener("input",()=>{if(h.value=h.value.toUpperCase(),h.value!==""){e.disabled=!0;return}e.disabled=!1})}if(c("artifact-editor-key-value")===null)throw new Error("The key value is missing.");let L=c("artifact-editor-key-label");if(L===null)throw new Error("The key label is missing.");if(L.addEventListener("click",()=>T("artifact-editor-key-value")),c("artifact-editor-unique-id-value")===null)throw new Error("The unique id value is missing.");let O=c("artifact-editor-unique-id-label");if(O===null)throw new Error("The unique id label is missing.");if(O.addEventListener("click",()=>T("artifact-editor-unique-id-value")),c("artifact-editor-location-value")===null)throw new Error("The location value is missing.");let _=c("artifact-editor-location-label");if(_===null)throw new Error("The location label is missing.");if(_.addEventListener("click",()=>T("artifact-editor-location-value")),c("artifact-editor-templocation")!==null&&c("artifact-editor-templocation-label").addEventListener("click",()=>T("artifact-editor-templocation")),document.getElementById("artifact-editor-os-label")===null)throw new Error("The operating system label is missing.");let E=document.getElementById("artifact-editor-operating-system");if(E===null)throw new Error("The operating system input is missing.");E.addEventListener("input",M);let w=document.getElementById("artifact-editor-category");if(w===null)throw new Error("The category input is missing.");w.addEventListener("input",U),M(),U();function M(){E.selectedIndex==0&&(E.classList.remove("is-valid"),E.classList.add("is-invalid"))}function U(){w.selectedIndex==0&&(w.classList.remove("is-valid"),w.classList.add("is-invalid"))}let Y=document.getElementsByName("prereset-classifications");if(Y.length===0)throw new Error("The preset classifications are missing.");for(let e=0;e{W.preventDefault(),E.value=v,E.classList.remove("is-invalid"),w.value=q,w.classList.remove("is-invalid"),M(),U()})}let f=document.getElementById("artifact-editor-filename");if(f===null)throw new Error("The filename input is missing.");f.addEventListener("input",e=>{e.target.classList.remove("is-valid"),e.target.classList.remove("is-invalid"),e.target.value.trim().length===0&&e.target.classList.add("is-invalid")});let J=document.getElementById("artifact-editor-filename-reset");if(J===null)throw new Error("The filename reset is missing.");let D=document.getElementsByName("artifact-editor-filename-undo");if(D.length===0)throw new Error("The filename resetter is missing.");J.addEventListener("click",()=>{if(f.classList.remove("is-valid"),D.length===0)throw new Error("The filename resetter is missing.");f.value=D[0].value,f.classList.add("is-valid"),f.classList.remove("is-invalid"),f.value.trim().length===0&&f.classList.add("is-invalid")});let y=document.getElementById("artifact-editor-releaser-1");if(y===null)throw new Error("The releaser 1 input is missing.");y.addEventListener("input",e=>B(e.target));let b=document.getElementById("artifact-editor-releaser-2");if(b===null)throw new Error("The releaser 2 input is missing.");b.addEventListener("input",e=>B(e.target));let K=document.getElementById("artifact-editor-releaser-undo");if(K===null)throw new Error("The releasers reset is missing.");K.addEventListener("click",ye);function ye(){let e=y.getAttribute("data-reset-rel1");if(e===null)throw new Error("data-reset-rel1 attribute is required for artifact-editor-releaser-1.");y.value=e,B(y);let n=b.getAttribute("data-reset-rel2");if(n===null)throw new Error("data-reset-rel2 attribute is required for artifact-editor-releaser-2.");b.value=n,B(b)}let g=document.getElementById("artifact-editor-title");if(g===null)throw new Error("The title input is missing.");g.addEventListener("input",e=>{e.target.classList.remove("is-valid")});let Q=document.getElementById("artifact-editor-title-undo");if(Q===null)throw new Error("The title reset is missing.");let z=document.getElementsByName("artifact-editor-titleundo");if(z.length===0)throw new Error("The title resetter is missing.");Q.addEventListener("click",()=>{if(g.classList.remove("is-valid"),z.length===0)throw new Error("The title resetter is missing.");g.value=z[0].value,g.classList.add("is-valid")});let X=document.getElementById("artifact-editor-titleize");if(X.length===0)throw new Error("The titleize button is missing.");X.addEventListener("click",()=>{g.value=pe(g.value);let e=new Event("keyup");g.dispatchEvent(e)});let F=document.getElementById("artifact-editor-credit-text");if(F===null)throw new Error("The creator text input is missing.");F.addEventListener("input",e=>{e.target.classList.remove("is-valid")});let S=document.getElementById("artifact-editor-credit-ill");if(S===null)throw new Error("The creator illustrator input is missing.");S.addEventListener("input",e=>{e.target.classList.remove("is-valid")});let G=document.getElementById("artifact-editor-credit-prog");if(G===null)throw new Error("The creator programmer input is missing.");G.addEventListener("input",e=>{e.target.classList.remove("is-valid")});let j=document.getElementById("artifact-editor-credit-audio");if(j===null)throw new Error("The creator audio input is missing.");j.addEventListener("input",e=>{e.target.classList.remove("is-valid")});let H=document.getElementById("artifact-editor-credits-undo");if(H===null)throw new Error("The creator resetter is missing.");let ee=document.getElementById("artifact-editor-credit-undo");if(ee===null)throw new Error("The creator reset is missing.");ee.addEventListener("click",()=>{if(H.length===0)throw new Error("The creator resetter is missing.");let e=H.value.split(";");if(e.length!=4)throw new Error("The creator resetter values are invalid.");let n=e[0],v=e[1],q=e[2],W=e[3];F.value=n,S.value=v,G.value=q,j.value=W});let I=document.getElementById("artifact-editor-comment");if(I===null)throw new Error("The comment input is missing.");I.addEventListener("input",e=>{e.target.classList.remove("is-valid")});let te=document.getElementById("artifact-editor-comment-undo");if(te===null)throw new Error("The comment reset is missing.");let ie=document.getElementById("artifact-editor-comment-resetter");if(ie===null)throw new Error("The comment resetter is missing.");te.addEventListener("click",()=>{I.classList.remove("is-valid"),I.value=ie.value});let re=document.getElementById("artifact-editor-virustotal");if(re===null)throw new Error("The virustotal input is missing.");re.addEventListener("input",e=>{e.target.classList.remove("is-valid","is-invalid");let n=e.target.value.trim();n.length!=0&&(n.startsWith("https://www.virustotal.com/")||e.target.classList.add("is-invalid"))});let d=document.getElementById("artifact-editor-year");if(d===null)throw new Error("The year input is missing.");d.addEventListener("input",()=>{let e=parseInt(d.value,10);e>=79&&e<=99&&(d.value=1900+e),R(d,u,m)});let u=document.getElementById("artifact-editor-month");if(u===null)throw new Error("The month input is missing.");u.addEventListener("input",()=>{R(d,u,m)});let m=document.getElementById("artifact-editor-day");if(m===null)throw new Error("The day input is missing.");m.addEventListener("input",()=>{R(d,u,m)});let ne=document.getElementById("artifact-editor-date-reset");if(ne===null)throw new Error("The date reset is missing.");let se=document.getElementById("artifact-editor-date-resetter");if(se===null)throw new Error("The date resetter is missing.");ne.addEventListener("click",()=>{d.classList.remove("is-invalid","is-valid"),u.classList.remove("is-invalid","is-valid"),m.classList.remove("is-invalid","is-valid");let n=se.value.split("-");if(n.length!=3)throw new Error("The date resetter values are invalid.");d.value=n[0],u.value=n[1],m.value=n[2]});let ae=document.getElementById("artifact-editor-date-lastmod");if(ae!==null){let e=document.getElementById("artifact-editor-date-lastmodder");if(e===null)throw new Error("The date last modder input is missing.");ae.addEventListener("click",()=>{d.classList.remove("is-invalid","is-valid"),u.classList.remove("is-invalid","is-valid"),m.classList.remove("is-invalid","is-valid");let v=e.value.split("-");if(v.length!=3)throw new Error("The date last modder values are invalid.");d.value=v[0],u.value=v[1],m.value=v[2]})}let oe=document.getElementById("artifact-editor-links-reset");if(oe===null)throw new Error("The links reset is missing.");let x=document.getElementById("artifact-editor-youtube"),le=document.getElementById("artifact-editor-youtube-reset");if(x===null||le===null)throw new Error("A YouTube input is missing.");let k=document.getElementById("artifact-editor-demozoo"),de=document.getElementById("artifact-editor-demozoo-reset");if(k===null||de===null)throw new Error("A Demozoo input is missing.");let N=document.getElementById("artifact-editor-pouet"),ce=document.getElementById("artifact-editor-pouet-reset");if(N===null||ce===null)throw new Error("A Pouet input is missing.");let $=document.getElementById("artifact-editor-16colors"),ue=document.getElementById("artifact-editor-16colors-reset");if($===null||ue===null)throw new Error("A 16colors input is missing.");let A=document.getElementById("artifact-editor-github"),me=document.getElementById("artifact-editor-github-reset");if(A===null||me===null)throw new Error("A GitHub input is missing.");let P=document.getElementById("artifact-editor-relations"),ve=document.getElementById("artifact-editor-relations-reset");if(P===null||ve===null)throw new Error("A relations input is missing.");let V=document.getElementById("artifact-editor-websites"),fe=document.getElementById("artifact-editor-websites-reset");if(V===null||fe===null)throw new Error("A websites input is missing.");oe.addEventListener("click",()=>{x.classList.remove("is-invalid","is-valid"),k.classList.remove("is-invalid","is-valid"),N.classList.remove("is-invalid","is-valid"),$.classList.remove("is-invalid","is-valid"),A.classList.remove("is-invalid","is-valid"),P.classList.remove("is-invalid","is-valid"),V.classList.remove("is-invalid","is-valid"),x.value=le.value,k.value=de.value,N.value=ce.value,$.value=ue.value,A.value=me.value,P.value=ve.value,V.value=fe.value});let be=45e4,Be=2e5;x.addEventListener("input",e=>we(e.target)),k.addEventListener("input",e=>Z(e.target,be)),N.addEventListener("input",e=>Z(e.target,Be)),$.addEventListener("input",e=>he(e.target)),A.addEventListener("input",e=>ge(e.target))})();})(); +(()=>{function R(t,i,r){if(t==null)throw new Error("The year input element is null.");if(i==null)throw new Error("The month input element is null.");if(r==null)throw new Error("The day input element is null.");t.classList.remove("is-invalid","is-valid"),i.classList.remove("is-invalid","is-valid"),r.classList.remove("is-invalid","is-valid");let a=parseInt(t.value,10);isNaN(a)?t.value="0":t.value=a;let s=parseInt(i.value,10);isNaN(s)?i.value="0":i.value=s;let o=parseInt(r.value,10);isNaN(o)?r.value="0":r.value=o;let l=0,p=new Date().getFullYear(),h=a>=1980&&a<=p;a>l&&!h&&t.classList.add("is-invalid");let C=s>=1&&s<=12;s>l&&!C&&i.classList.add("is-invalid");let L=o>=1&&o<=31;o>l&&!L&&r.classList.add("is-invalid"),isNaN(a)&&(C||L)&&t.classList.add("is-invalid"),(s==l||isNaN(s))&&L&&i.classList.add("is-invalid")}function ge(t){return Ee(t,!0)}function he(t){return Ee(t,!1)}function Ee(t,i){if(t==null)throw new Error("The repository URL element is null.");t.classList.remove("is-valid","is-invalid");let r=t.value.trim();if(r.length===0)return;if(i==!0&&r.startsWith("refs/")){t.classList.add("is-invalid");return}if(r.includes("://")){t.classList.add("is-invalid");return}let s=/[^A-Za-z0-9-._/]/g;r=r.replace(s,""),r=r.replaceAll("//","/");let o=/^\//;r=r.replace(o,""),t.value=r;let l=t.getAttribute("maxlength");if(l===null)throw new Error(`The maxlength attribute is required for ${t.id}.`);if(r.length>l){t.classList.add("is-invalid");return}}function B(t){if(t==null)throw new Error("The element of the releaser validator is null.");t.classList.remove("is-valid","is-invalid");let i=t.value.trimStart().toUpperCase();i=i.replace("+",", "),i=i.replace(/[^ A-ZÀ-ÖØ-Þ0-9\-,&]/g,""),i=i.replace(/[ ]{2,}/g," "),t.value=i;let r=t.getAttribute("minlength"),a=t.getAttribute("maxlength"),s=t.getAttribute("required");if(r===null)throw new Error(`The minlength attribute is required for ${t.id}.`);if(a===null)throw new Error(`The maxlength attribute is required for ${t.id}.`);let o=document.getElementById("artifact-editor-releasers-error");if(o===null)throw new Error("The releasers error element is null.");let l=i.lengtha;if(s!=null&&l){t.classList.add("is-invalid"),t.id==="-1"&&o.classList.add("d-block");return}let p=i.length>0&&(i.lengtha);if(s==null&&p){t.classList.add("is-invalid");return}t.classList.remove("is-invalid"),o.classList.remove("d-block")}function we(t){if(t==null)throw new Error("The element of the releaser validator is null.");t.classList.remove("is-valid","is-invalid");let i=t.value.trim();i.length>0&&i.length!=11&&t.classList.add("is-invalid")}function Z(t,i){if(t==null)throw new Error("The element of the number validator is null.");t.classList.remove("is-valid","is-invalid");let r=parseInt(t.value,10);isNaN(r)&&t.classList.add("is-invalid"),(r>i||r<0)&&t.classList.add("is-invalid")}function pe(t){let i=["a","an","and","as","but","for","if","of","or","so","the","to"];return t.split(" ").map((r,a)=>a===0||!i.includes(r.toLowerCase())?r.charAt(0).toUpperCase()+r.slice(1).toLowerCase():r.toLowerCase()).join(" ")}async function T(t){let i=c(t);i.focus(),await navigator.clipboard.writeText(`${i.value}`).then(function(){console.log(`Copied ${Te(i.value.length)} to the clipboard`)},function(r){console.error(`could not save any text to the clipboard: ${r}`)})}function c(t){let i=document.getElementById(t);if(i==null)throw new Error(`The ${t} for getElmById() element is null.`);return i}function Te(t=0){let s=Math.pow(1e3,2),o=Math.pow(1e3,3);return t>o?`${(Math.round(t*100/o)/100).toFixed(2)} GB`:t>s?`${(Math.round(t*100/s)/100).toFixed(1)} MB`:t>1e3?`${(Math.round(t*100/1e3)/100).toFixed()} kB`:`${Math.round(t).toFixed()} bytes`}(()=>{"use strict";function t(e){return function(){e.forEach(n=>{n.disabled=!0,n.classList.remove("btn-outline-primary"),n.classList.add("btn-light")})}}function i(e){return function(){e.forEach(n=>{n.disabled=!1,n.classList.remove("btn-light"),n.classList.add("btn-outline-primary")})}}let r=document.getElementById("artifact-editor-modal"),a=document.getElementsByName("artifact-editor-dataeditor");r.addEventListener("shown.bs.modal",()=>{t(a)()}),r.addEventListener("hidden.bs.modal",()=>{i(a)()});let s=document.getElementById("asset-editor-modal"),o=document.getElementsByName("artifact-editor-fileeditor");s.addEventListener("shown.bs.modal",()=>{t(o)()}),s.addEventListener("hidden.bs.modal",()=>{i(o)()});let l=document.getElementById("emulate-editor-modal"),p=document.getElementsByName("artifact-editor-emueditor");l.addEventListener("shown.bs.modal",()=>{t(p)()}),l.addEventListener("hidden.bs.modal",()=>{i(p)()});let h=document.getElementById("emulate-run-program");if(h!==null){let e=document.getElementById("emulate-guess-program");if(e===null)throw new Error("The guess program input is missing.");h.addEventListener("input",()=>{if(h.value=h.value.toUpperCase(),h.value!==""){e.disabled=!0;return}e.disabled=!1})}if(c("artifact-editor-key-value")===null)throw new Error("The key value is missing.");let L=c("artifact-editor-key-label");if(L===null)throw new Error("The key label is missing.");if(L.addEventListener("click",()=>T("artifact-editor-key-value")),c("artifact-editor-unique-id-value")===null)throw new Error("The unique id value is missing.");let O=c("artifact-editor-unique-id-label");if(O===null)throw new Error("The unique id label is missing.");if(O.addEventListener("click",()=>T("artifact-editor-unique-id-value")),c("artifact-editor-location-value")===null)throw new Error("The location value is missing.");let _=c("artifact-editor-location-label");if(_===null)throw new Error("The location label is missing.");if(_.addEventListener("click",()=>T("artifact-editor-location-value")),c("artifact-editor-templocation")!==null&&c("artifact-editor-templocation-label").addEventListener("click",()=>T("artifact-editor-templocation")),document.getElementById("artifact-editor-os-label")===null)throw new Error("The operating system label is missing.");let E=document.getElementById("artifact-editor-operating-system");if(E===null)throw new Error("The operating system input is missing.");E.addEventListener("input",M);let w=document.getElementById("artifact-editor-category");if(w===null)throw new Error("The category input is missing.");w.addEventListener("input",U),M(),U();function M(){E.selectedIndex==0&&(E.classList.remove("is-valid"),E.classList.add("is-invalid"))}function U(){w.selectedIndex==0&&(w.classList.remove("is-valid"),w.classList.add("is-invalid"))}let Y=document.getElementsByName("prereset-classifications");if(Y.length===0)throw new Error("The preset classifications are missing.");for(let e=0;e{W.preventDefault(),E.value=v,E.classList.remove("is-invalid"),w.value=q,w.classList.remove("is-invalid"),M(),U()})}let f=document.getElementById("artifact-editor-filename");if(f===null)throw new Error("The filename input is missing.");f.addEventListener("input",e=>{e.target.classList.remove("is-valid"),e.target.classList.remove("is-invalid"),e.target.value.trim().length===0&&e.target.classList.add("is-invalid")});let J=document.getElementById("artifact-editor-filename-reset");if(J===null)throw new Error("The filename reset is missing.");let D=document.getElementsByName("artifact-editor-filename-undo");if(D.length===0)throw new Error("The filename resetter is missing.");J.addEventListener("click",()=>{if(f.classList.remove("is-valid"),D.length===0)throw new Error("The filename resetter is missing.");f.value=D[0].value,f.classList.add("is-valid"),f.classList.remove("is-invalid"),f.value.trim().length===0&&f.classList.add("is-invalid")});let y=document.getElementById("artifact-editor-releaser-1");if(y===null)throw new Error("The releaser 1 input is missing.");y.addEventListener("input",e=>B(e.target));let b=document.getElementById("artifact-editor-releaser-2");if(b===null)throw new Error("The releaser 2 input is missing.");b.addEventListener("input",e=>B(e.target));let K=document.getElementById("artifact-editor-releaser-undo");if(K===null)throw new Error("The releasers reset is missing.");K.addEventListener("click",ye);function ye(){let e=y.getAttribute("data-reset-rel1");if(e===null)throw new Error("data-reset-rel1 attribute is required for artifact-editor-releaser-1.");y.value=e,B(y);let n=b.getAttribute("data-reset-rel2");if(n===null)throw new Error("data-reset-rel2 attribute is required for artifact-editor-releaser-2.");b.value=n,B(b)}let g=document.getElementById("artifact-editor-title");if(g===null)throw new Error("The title input is missing.");g.addEventListener("input",e=>{e.target.classList.remove("is-valid")});let Q=document.getElementById("artifact-editor-title-undo");if(Q===null)throw new Error("The title reset is missing.");let z=document.getElementsByName("artifact-editor-titleundo");if(z.length===0)throw new Error("The title resetter is missing.");Q.addEventListener("click",()=>{if(g.classList.remove("is-valid"),z.length===0)throw new Error("The title resetter is missing.");g.value=z[0].value,g.classList.add("is-valid")});let X=document.getElementById("artifact-editor-titleize");if(X.length===0)throw new Error("The titleize button is missing.");X.addEventListener("click",()=>{g.value=pe(g.value);let e=new Event("keyup");g.dispatchEvent(e)});let F=document.getElementById("artifact-editor-credit-text");if(F===null)throw new Error("The creator text input is missing.");F.addEventListener("input",e=>{e.target.classList.remove("is-valid")});let S=document.getElementById("artifact-editor-credit-ill");if(S===null)throw new Error("The creator illustrator input is missing.");S.addEventListener("input",e=>{e.target.classList.remove("is-valid")});let G=document.getElementById("artifact-editor-credit-prog");if(G===null)throw new Error("The creator programmer input is missing.");G.addEventListener("input",e=>{e.target.classList.remove("is-valid")});let j=document.getElementById("artifact-editor-credit-audio");if(j===null)throw new Error("The creator audio input is missing.");j.addEventListener("input",e=>{e.target.classList.remove("is-valid")});let H=document.getElementById("artifact-editor-credits-undo");if(H===null)throw new Error("The creator resetter is missing.");let ee=document.getElementById("artifact-editor-credit-undo");if(ee===null)throw new Error("The creator reset is missing.");ee.addEventListener("click",()=>{if(H.length===0)throw new Error("The creator resetter is missing.");let e=H.value.split(";");if(e.length!=4)throw new Error("The creator resetter values are invalid.");let n=e[0],v=e[1],q=e[2],W=e[3];F.value=n,S.value=v,G.value=q,j.value=W});let I=document.getElementById("artifact-editor-comment");if(I===null)throw new Error("The comment input is missing.");I.addEventListener("input",e=>{e.target.classList.remove("is-valid")});let te=document.getElementById("artifact-editor-comment-undo");if(te===null)throw new Error("The comment reset is missing.");let ie=document.getElementById("artifact-editor-comment-resetter");if(ie===null)throw new Error("The comment resetter is missing.");te.addEventListener("click",()=>{I.classList.remove("is-valid"),I.value=ie.value});let re=document.getElementById("artifact-editor-virustotal");if(re===null)throw new Error("The virustotal input is missing.");re.addEventListener("input",e=>{e.target.classList.remove("is-valid","is-invalid");let n=e.target.value.trim();n.length!=0&&(n.startsWith("https://www.virustotal.com/")||e.target.classList.add("is-invalid"))});let d=document.getElementById("artifact-editor-year");if(d===null)throw new Error("The year input is missing.");d.addEventListener("input",()=>{let e=parseInt(d.value,10);e>=79&&e<=99&&(d.value=1900+e),R(d,u,m)});let u=document.getElementById("artifact-editor-month");if(u===null)throw new Error("The month input is missing.");u.addEventListener("input",()=>{R(d,u,m)});let m=document.getElementById("artifact-editor-day");if(m===null)throw new Error("The day input is missing.");m.addEventListener("input",()=>{R(d,u,m)});let ne=document.getElementById("artifact-editor-date-reset");if(ne===null)throw new Error("The date reset is missing.");let se=document.getElementById("artifact-editor-date-resetter");if(se===null)throw new Error("The date resetter is missing.");ne.addEventListener("click",()=>{d.classList.remove("is-invalid","is-valid"),u.classList.remove("is-invalid","is-valid"),m.classList.remove("is-invalid","is-valid");let n=se.value.split("-");if(n.length!=3)throw new Error("The date resetter values are invalid.");d.value=n[0],u.value=n[1],m.value=n[2]});let ae=document.getElementById("artifact-editor-date-lastmod");if(ae!==null){let e=document.getElementById("artifact-editor-date-lastmodder");if(e===null)throw new Error("The date last modder input is missing.");ae.addEventListener("click",()=>{d.classList.remove("is-invalid","is-valid"),u.classList.remove("is-invalid","is-valid"),m.classList.remove("is-invalid","is-valid");let v=e.value.split("-");if(v.length!=3)throw new Error("The date last modder values are invalid.");d.value=v[0],u.value=v[1],m.value=v[2]})}let oe=document.getElementById("artifact-editor-links-reset");if(oe===null)throw new Error("The links reset is missing.");let x=document.getElementById("artifact-editor-youtube"),le=document.getElementById("artifact-editor-youtube-reset");if(x===null||le===null)throw new Error("A YouTube input is missing.");let k=document.getElementById("artifact-editor-demozoo"),de=document.getElementById("artifact-editor-demozoo-reset");if(k===null||de===null)throw new Error("A Demozoo input is missing.");let N=document.getElementById("artifact-editor-pouet"),ce=document.getElementById("artifact-editor-pouet-reset");if(N===null||ce===null)throw new Error("A Pouet input is missing.");let $=document.getElementById("artifact-editor-16colors"),ue=document.getElementById("artifact-editor-16colors-reset");if($===null||ue===null)throw new Error("A 16colors input is missing.");let A=document.getElementById("artifact-editor-github"),me=document.getElementById("artifact-editor-github-reset");if(A===null||me===null)throw new Error("A GitHub input is missing.");let P=document.getElementById("artifact-editor-relations"),ve=document.getElementById("artifact-editor-relations-reset");if(P===null||ve===null)throw new Error("A relations input is missing.");let V=document.getElementById("artifact-editor-websites"),fe=document.getElementById("artifact-editor-websites-reset");if(V===null||fe===null)throw new Error("A websites input is missing.");oe.addEventListener("click",()=>{x.classList.remove("is-invalid","is-valid"),k.classList.remove("is-invalid","is-valid"),N.classList.remove("is-invalid","is-valid"),$.classList.remove("is-invalid","is-valid"),A.classList.remove("is-invalid","is-valid"),P.classList.remove("is-invalid","is-valid"),V.classList.remove("is-invalid","is-valid"),x.value=le.value,k.value=de.value,N.value=ce.value,$.value=ue.value,A.value=me.value,P.value=ve.value,V.value=fe.value});let be=45e4,Be=2e5;x.addEventListener("input",e=>we(e.target)),k.addEventListener("input",e=>Z(e.target,be)),N.addEventListener("input",e=>Z(e.target,Be)),$.addEventListener("input",e=>he(e.target)),A.addEventListener("input",e=>ge(e.target))})();})();