diff --git a/assets/js/editor-assets.js b/assets/js/editor-assets.js index f209ab91..1083a70c 100644 --- a/assets/js/editor-assets.js +++ b/assets/js/editor-assets.js @@ -94,12 +94,12 @@ import { getElmById } from "./helper.mjs"; return; } const refresher = "Enter"; - const dataEditor = "F9"; - const assetEditor = "F10"; - const emulateEditor = "F11"; + const dataEditor = "Home"; + const assetEditor = "PageDown"; + const emulateEditor = "PageUp"; const deleteEditor = "Delete"; - const closeEditors = "F12"; - const approveRecord = "ArrowDown"; + const closeEditors = "Backspace"; + const approveRecord = "ArrowUp"; let approve = document.getElementById("editor-online-true"); switch (event.key) { case approveRecord: diff --git a/assets/js/helper.mjs b/assets/js/helper.mjs index cae1da9b..e547ad26 100644 --- a/assets/js/helper.mjs +++ b/assets/js/helper.mjs @@ -175,9 +175,6 @@ export function titleize(text) { "xp", "ys", ]; - - // TODO: replace trailing full stops - text = text.trim(); // Replace all underscores with spaces text = text.replace(/_/g, " "); diff --git a/public/js/editor-assets.min.js b/public/js/editor-assets.min.js index c55adeed..30a7637a 100644 --- a/public/js/editor-assets.min.js +++ b/public/js/editor-assets.min.js @@ -1,2 +1,2 @@ /* editor-assets.min.js © Defacto2 2024 */ -(()=>{function d(r){let t=document.getElementById(r);if(t==null){console.error(`The ${r} for getElmById() element is null.`);return}return t}var L="is-invalid",v="d-none",V=100,y=1024*1024,S=100*y;async function Y(r){if(r==null)throw new Error("The file value of checkSHA is null.");let t=await O(r),a=await fetch(`/uploader/sha384/${t}`,{method:"PATCH",headers:{"Content-Type":"text/plain"},body:t});if(!a.ok)throw new Error(`Hashing is not possible, server response: ${a.status}`);return await a.text()}async function O(r){if(r==null)throw new Error("The file value of sha384 is null.");try{let t=await r.arrayBuffer(),a=await crypto.subtle.digest("SHA-384",t);return Array.from(new Uint8Array(a)).map(c=>c.toString(16).padStart(2,"0")).join("")}catch(t){throw new Error(`Could not use arrayBuffer or crypto.subtle: ${t}`)}}function x(r,t){if(r==null)throw new Error("The formId value of progress is null.");if(t==null)throw new Error("The elementId value of progress is null.");htmx.on(`#${r}`,"htmx:xhr:progress",function(a){a.target.id==`${r}`&&htmx.find(`#${t}`).setAttribute("value",a.detail.loaded/a.detail.total*V)})}function F(r){if(r==null)throw new Error("The file value of checkSize is null.");return r.size>S?`The chosen file is too big at ${Math.round(r.size/y)}MB, maximum size is ${S/y}MB.`:""}function A(r,t,a,c){if(r==null)throw new Error("The errors value of checkErrors is null.");if(t==null)throw new Error("The alert value of checkErrors is null.");if(a==null)throw new Error("The fileInput value of checkErrors is null.");if(c==null)throw new Error("The results value of checkErrors is null.");r=r.filter(h=>h!=""),!(r.length<=0)&&(t.innerText=r.join(" "),t.classList.remove(v),a.innerText="",a.classList.add(L),c.classList.add(v))}async function z(r,t,a,c){if(r==null)throw new Error("The file value of checkDuplicate is null.");if(t==null)throw new Error("The alert value of checkDuplicate is null.");if(a==null)throw new Error("The fileInput value of checkDuplicate is null.");if(c==null)throw new Error("The results value of checkDuplicate is null.");let h=()=>{t.classList.remove(v),a.innerText="",a.classList.add(L),c.classList.add(v)},T="";try{let u=await Y(r);if(u==""){t.innerText="";return}T=u}catch(u){console.log(`${u}`),t.innerText=`${u}`,h();return}t.innerText="The chosen file already exists in the database: ";let f=document.createElement("a");f.href=`/f/${T}`,f.innerText=`${r.name}`,t.appendChild(f),h()}function U(r,t,a){if(r==null)throw new Error("The fileInput value of resetInput is null.");if(t==null)throw new Error("The alert value of resetInput is null.");if(a==null)throw new Error("The results value of resetInput is null.");r.innerText="",r.classList.remove(L),t.innerText="",t.classList.add(v),a.innerText="",a.classList.add(v)}(()=>{"use strict";x("artifact-editor-dl-form","artifact-editor-dl-progress"),x("artifact-editor-preview-form","artifact-editor-preview-progress");let r=d("artifact-editor-preview-reset"),t=d("artifact-editor-replace-preview"),a=d("artifact-editor-preview-submit"),c=d("artifact-editor-dl-alert"),h=d("artifact-editor-dl-reset"),T=d("artifact-editor-last-modified"),f=d("artifact-editor-dl-results"),u=d("artifact-editor-dl-up");u.addEventListener("change",j);async function j(){U(u,c,f);let e=this.files[0],i=[F(e)];A(i,c,u,f),z(e,c,u,f);let n=e.lastModified,o=new Date().getTime(),s=60*60*1e3;o-n{location.reload()},500);return}if(e.detail.failed&&e.detail.xhr){o.classList.add(s),o.innerText=`Something on the server is not working, ${g.status} status: ${g.responseText}.`;return}o.classList.add(s),o.innerText="Something with the browser is not working, please try again or refresh the page."}function I(e,i,n,o){if(e.detail.elt===null||e.detail.elt.id!==`${i}`)return;let s=document.getElementById(n);if(s===null)throw new Error(`The htmx successful input element ${n} is null`);let l=document.getElementById(o);if(l===null)throw new Error(`The htmx successful feedback element ${o} is null`);if(e.detail.successful)return H(e,s,l);if(e.detail.failed&&e.detail.xhr)return R(e,s,l);P(s,l)}function H(e,i,n){let o=e.detail.xhr;n.innerText=`${o.responseText}`,n.classList.remove("invalid-feedback"),n.classList.add("valid-feedback"),i.classList.remove("is-invalid"),i.classList.add("is-valid"),setTimeout(()=>{location.reload()},500)}function R(e,i,n){let o=e.detail.xhr;n.innerText=`Something on the server is not working, ${o.status} status: ${o.responseText}.`,n.classList.remove("valid-feedback"),n.classList.add("invalid-feedback"),i.classList.remove("is-valid"),i.classList.add("is-invalid")}function P(e,i){e.classList.remove("is-valid"),e.classList.add("is-invalid"),i.innerText="Something with the browser is not working, please try again or refresh the page.",i.classList.remove("d-none")}h.addEventListener("click",function(){c.innerText="",c.classList.add("d-none"),u.value="",u.classList.remove("is-invalid","is-valid")}),r.addEventListener("click",function(){t.value="",t.classList.remove("is-invalid","is-valid")}),t.addEventListener("change",function(e){e.target.value.trim()!==""&&(console.log("Submitting the image or photo preview form"),a.click())})})();})(); +(()=>{function d(r){let t=document.getElementById(r);if(t==null){console.error(`The ${r} for getElmById() element is null.`);return}return t}var L="is-invalid",v="d-none",V=100,y=1024*1024,S=100*y;async function Y(r){if(r==null)throw new Error("The file value of checkSHA is null.");let t=await O(r),a=await fetch(`/uploader/sha384/${t}`,{method:"PATCH",headers:{"Content-Type":"text/plain"},body:t});if(!a.ok)throw new Error(`Hashing is not possible, server response: ${a.status}`);return await a.text()}async function O(r){if(r==null)throw new Error("The file value of sha384 is null.");try{let t=await r.arrayBuffer(),a=await crypto.subtle.digest("SHA-384",t);return Array.from(new Uint8Array(a)).map(c=>c.toString(16).padStart(2,"0")).join("")}catch(t){throw new Error(`Could not use arrayBuffer or crypto.subtle: ${t}`)}}function x(r,t){if(r==null)throw new Error("The formId value of progress is null.");if(t==null)throw new Error("The elementId value of progress is null.");htmx.on(`#${r}`,"htmx:xhr:progress",function(a){a.target.id==`${r}`&&htmx.find(`#${t}`).setAttribute("value",a.detail.loaded/a.detail.total*V)})}function A(r){if(r==null)throw new Error("The file value of checkSize is null.");return r.size>S?`The chosen file is too big at ${Math.round(r.size/y)}MB, maximum size is ${S/y}MB.`:""}function F(r,t,a,c){if(r==null)throw new Error("The errors value of checkErrors is null.");if(t==null)throw new Error("The alert value of checkErrors is null.");if(a==null)throw new Error("The fileInput value of checkErrors is null.");if(c==null)throw new Error("The results value of checkErrors is null.");r=r.filter(h=>h!=""),!(r.length<=0)&&(t.innerText=r.join(" "),t.classList.remove(v),a.innerText="",a.classList.add(L),c.classList.add(v))}async function U(r,t,a,c){if(r==null)throw new Error("The file value of checkDuplicate is null.");if(t==null)throw new Error("The alert value of checkDuplicate is null.");if(a==null)throw new Error("The fileInput value of checkDuplicate is null.");if(c==null)throw new Error("The results value of checkDuplicate is null.");let h=()=>{t.classList.remove(v),a.innerText="",a.classList.add(L),c.classList.add(v)},T="";try{let u=await Y(r);if(u==""){t.innerText="";return}T=u}catch(u){console.log(`${u}`),t.innerText=`${u}`,h();return}t.innerText="The chosen file already exists in the database: ";let f=document.createElement("a");f.href=`/f/${T}`,f.innerText=`${r.name}`,t.appendChild(f),h()}function z(r,t,a){if(r==null)throw new Error("The fileInput value of resetInput is null.");if(t==null)throw new Error("The alert value of resetInput is null.");if(a==null)throw new Error("The results value of resetInput is null.");r.innerText="",r.classList.remove(L),t.innerText="",t.classList.add(v),a.innerText="",a.classList.add(v)}(()=>{"use strict";x("artifact-editor-dl-form","artifact-editor-dl-progress"),x("artifact-editor-preview-form","artifact-editor-preview-progress");let r=d("artifact-editor-preview-reset"),t=d("artifact-editor-replace-preview"),a=d("artifact-editor-preview-submit"),c=d("artifact-editor-dl-alert"),h=d("artifact-editor-dl-reset"),T=d("artifact-editor-last-modified"),f=d("artifact-editor-dl-results"),u=d("artifact-editor-dl-up");u.addEventListener("change",H);async function H(){z(u,c,f);let e=this.files[0],s=[A(e)];F(s,c,u,f),U(e,c,u,f);let n=e.lastModified,o=new Date().getTime(),i=60*60*1e3;o-n{location.reload()},500);return}if(e.detail.failed&&e.detail.xhr){o.classList.add(i),o.innerText=`Something on the server is not working, ${g.status} status: ${g.responseText}.`;return}o.classList.add(i),o.innerText="Something with the browser is not working, please try again or refresh the page."}function I(e,s,n,o){if(e.detail.elt===null||e.detail.elt.id!==`${s}`)return;let i=document.getElementById(n);if(i===null)throw new Error(`The htmx successful input element ${n} is null`);let l=document.getElementById(o);if(l===null)throw new Error(`The htmx successful feedback element ${o} is null`);if(e.detail.successful)return P(e,i,l);if(e.detail.failed&&e.detail.xhr)return j(e,i,l);R(i,l)}function P(e,s,n){let o=e.detail.xhr;n.innerText=`${o.responseText}`,n.classList.remove("invalid-feedback"),n.classList.add("valid-feedback"),s.classList.remove("is-invalid"),s.classList.add("is-valid"),setTimeout(()=>{location.reload()},500)}function j(e,s,n){let o=e.detail.xhr;n.innerText=`Something on the server is not working, ${o.status} status: ${o.responseText}.`,n.classList.remove("valid-feedback"),n.classList.add("invalid-feedback"),s.classList.remove("is-valid"),s.classList.add("is-invalid")}function R(e,s){e.classList.remove("is-valid"),e.classList.add("is-invalid"),s.innerText="Something with the browser is not working, please try again or refresh the page.",s.classList.remove("d-none")}h.addEventListener("click",function(){c.innerText="",c.classList.add("d-none"),u.value="",u.classList.remove("is-invalid","is-valid")}),r.addEventListener("click",function(){t.value="",t.classList.remove("is-invalid","is-valid")}),t.addEventListener("change",function(e){e.target.value.trim()!==""&&(console.log("Submitting the image or photo preview form"),a.click())})})();})(); diff --git a/view/app/artifactfooter.tmpl b/view/app/artifactfooter.tmpl index 957ce260..f92cdc9f 100644 --- a/view/app/artifactfooter.tmpl +++ b/view/app/artifactfooter.tmpl @@ -14,19 +14,19 @@
- + Refresh & view artifact - + - + - + - +