diff --git a/assets/js/editor.js b/assets/js/editor.js index 26a2542e..c9580913 100644 --- a/assets/js/editor.js +++ b/assets/js/editor.js @@ -52,7 +52,14 @@ // recordTitle const recTitle = document.getElementById(`recordTitle`); - recTitle.addEventListener(`input`, function (event) {}); + recTitle.addEventListener(`input`, function (event) { + recTitle.value = recTitle.value.trimStart(); + if (recTitle.value == ``) { + recTitle.classList.add(danger); + return; + } + recTitle.classList.remove(danger); + }); // releasers const releasers = document.getElementById(`recordReleasers`); diff --git a/model/update_file.go b/model/update_file.go index 76517e2d..7d79d40d 100644 --- a/model/update_file.go +++ b/model/update_file.go @@ -31,7 +31,6 @@ func UpdateOnline(c echo.Context, id int64) error { if err != nil { return err } - // deletedat="",deletedby="" f.Deletedat = null.TimeFromPtr(nil) f.Deletedby = null.String{} if _, err = f.Update(ctx, db, boil.Infer()); err != nil { diff --git a/public/js/editor.min.js b/public/js/editor.min.js index 2b52d1b0..7f6b86c2 100644 --- a/public/js/editor.min.js +++ b/public/js/editor.min.js @@ -1,2 +1,2 @@ /* editor.min.js */ -(()=>{"use strict";const B="text-danger",U={"Content-type":"application/json; charset=UTF-8"},R=document.getElementById("recordID");if(R==null){console.info("the editor modal is not open so the editor script is not needed");return}const g=document.getElementById("recordOnline"),p=document.getElementById("recordOnlineLabel");g.checked!=!0&&p.classList.add(B),g.addEventListener("change",function(t){let e="/editor/online/false";g.checked==!0&&(e="/editor/online/true"),fetch(e,{method:"POST",body:JSON.stringify({id:parseInt(R.value)}),headers:U}).then(o=>{if(!o.ok)throw new Error(saveErr);return g.checked==!0?p.classList.remove(B):p.classList.add(B),o.json()}).catch(o=>{document.getElementById("recordOnlineErr").textContent=o.message,g.classList.add(err)})}),document.getElementById("recordTitle").addEventListener("input",function(t){});const d=document.getElementById("recordReleasers"),I=document.getElementById("recordReleasersMax");d.addEventListener("input",function(t){if(d.value=d.value.toUpperCase(),d.value=d.value.replace(/[^a-zA-Z0-9-+& ]/g,""),d.value==""){d.classList.add(err);return}d.classList.remove(err),d.value.split("+").length>2?(d.classList.add(err),I.classList.add(dang)):(d.classList.remove(err),I.classList.remove(dang))});const c=document.getElementById("recordYear"),r=document.getElementById("recordMonth"),s=document.getElementById("recordDay");c.addEventListener("input",function(t){if(c.value>=1980&&c.value<=2023){c.classList.remove(err);return}if(c.value==""&&r.value==""&&s.value==""){c.classList.remove(err),r.classList.remove(err),s.classList.remove(err);return}c.classList.add(err)}),r.addEventListener("input",function(t){if(r.value>=1&&r.value<=12){r.classList.remove(err);return}if(c.value==""&&r.value==""&&s.value==""){c.classList.remove(err),r.classList.remove(err),s.classList.remove(err);return}if(r.value==""&&s.value==""){r.classList.remove(err),s.classList.remove(err);return}r.classList.add(err)}),s.addEventListener("input",function(t){if(r.value>=1&&r.value<=31){r.classList.remove(err);return}if(c.value==""&&r.value==""&&s.value==""){c.classList.remove(err),r.classList.remove(err),s.classList.remove(err);return}if(r.value==""&&s.value==""){r.classList.remove(err),s.classList.remove(err);return}if(s.value==""){s.classList.remove(err);return}s.classList.add(err)});const b=document.getElementById("recordLMBtn"),C=document.getElementById("recordLastMod");typeof b<"u"&&b!==null&&b.addEventListener("click",function(t){const e=C.value.split("-");e.length==3&&(c.value=e[0],r.value=e[1],s.value=e[2])});function h(t){let e=t;return e=e.toLowerCase(),e=e.replace(/[^A-Za-z0-9À-ÖØ-öø-ÿ\s,]/g,""),e}const w=document.getElementById("recordArtist"),T=document.getElementById("recordCoder"),k=document.getElementById("recordMusic"),x=document.getElementById("recordWriter");w.addEventListener("input",function(t){w.value=h(w.value)}),T.addEventListener("input",function(t){T.value=h(T.value)}),k.addEventListener("input",function(t){k.value=h(k.value)}),x.addEventListener("input",function(t){x.value=h(x.value)});const n=document.getElementById("recordDemozoo");n.addEventListener("paste",function(t){setTimeout(()=>{try{if(new URL(`${n.value}`).hostname!="demozoo.org"){n.classList.add(err);return}}catch{return}try{const f=new URL(`${n.value}`).pathname.split("/").filter(Boolean);if(f.length!=2){n.classList.add(err);return}switch(f[0]){case"productions":n.value=f[1];break;case"graphics":n.value=f[1];break;default:n.classList.add(err);return}n.classList.remove(err)}catch{n.classList.add(err)}},0)}),n.addEventListener("input",function(t){let e=Number(n.value);if(isNaN(e)){n.classList.add(err);return}if(e<0||e>999999){n.classList.add(err);return}e==0&&(n.value=""),n.classList.remove(err)});const a=document.getElementById("recordPouet");a.addEventListener("paste",function(t){setTimeout(()=>{try{const e=new URL(`${a.value}`);if(console.log(e.hostname),e.hostname!="www.pouet.net"){a.classList.add(err);return}}catch{return}try{const e=new URL(`${a.value}`);if(e.pathname!="/prod.php"){a.classList.add(err);return}const j=new URLSearchParams(e.search).get("which");a.value=j,a.classList.remove(err)}catch{a.classList.add(err)}},0)}),a.addEventListener("input",function(t){let e=Number(a.value);if(isNaN(e)){a.classList.add(err);return}if(e<0||e>199999){a.classList.add(err);return}e==0&&(a.value=""),a.classList.remove(err)});const L=document.getElementById("record16colors");L.addEventListener("paste",function(t){setTimeout(()=>{try{const e=new URL(`${L.value}`);if(e.hostname!="16colo.rs"){L.classList.add(err);return}const o=e.pathname;L.value=o,L.classList.remove(err)}catch{}},0)}),L.addEventListener("input",function(t){if(L.value==""){L.classList.remove(err);return}});const u=document.getElementById("recordGitHub");u.addEventListener("paste",function(t){setTimeout(()=>{try{const e=new URL(`${u.value}`);if(e.hostname!="github.com"){u.classList.add(err);return}const o=e.pathname;u.value=o,u.classList.remove(err)}catch{}},0)}),u.addEventListener("input",function(t){if(u.value==""){u.classList.remove(err);return}});const l=document.getElementById("recordYouTube");l.addEventListener("paste",function(t){setTimeout(()=>{try{const e=new URL(`${l.value}`);if(e.hostname!="youtube.com"&&e.hostname!="www.youtube.com"){l.classList.add(err);return}const f=new URLSearchParams(e.search).get("v");l.value=f,u.classList.remove(err)}catch{}},0)}),l.addEventListener("input",function(t){setTimeout(()=>{if(l.value==""){l.classList.remove(err);return}if(new RegExp("^[a-zA-Z0-9_-]{11}$").test(l.value)){l.classList.remove(err);return}l.classList.add(err)},0)});const E=document.getElementById("recordFilename");E.addEventListener("input",function(){if(E.value=E.value.trimStart(),E.value==""){E.classList.add(err);return}E.classList.remove(err)});const v=document.getElementById("recordPlatform"),i=document.getElementById("recordTag"),O=document.getElementById("recordReleasersLabel"),z=document.getElementById("recordTitleLabel");i.addEventListener("change",function(t){setTimeout(()=>{if(i.value=="magazine"){y();return}m()},0)});function y(){O.textContent="Magazine",z.textContent="Issue"}function m(){O.textContent="Releasers",z.textContent="Title"}document.getElementById("recordDosText").addEventListener("click",function(t){v.value="text",i.value="",m()}),document.getElementById("recordAmigaText").addEventListener("click",function(t){v.value="textamiga",i.value="",m()}),document.getElementById("recordProof").addEventListener("click",function(t){v.value="image",i.value="releaseproof",m()}),document.getElementById("recordDostro").addEventListener("click",function(t){v.value="dos",i.value="releaseadvert",m()}),document.getElementById("recordWintro").addEventListener("click",function(t){v.value="windows",i.value="releaseadvert",m()}),document.getElementById("recordBBStro").addEventListener("click",function(t){v.value="dos",i.value="bbs",m()}),document.getElementById("recordBBSAnsi").addEventListener("click",function(t){v.value="ansi",i.value="bbs",m()}),document.getElementById("recordTextMag").addEventListener("click",function(t){v.value="text",i.value="magazine",y()}),document.getElementById("recordDosMag").addEventListener("click",function(t){v.value="dos",i.value="magazine",y()}),document.getElementById("recordReset").addEventListener("click",function(t){setTimeout(()=>{g.checked!=!0?p.classList.add(dang):p.classList.remove(dang),I.classList.remove(dang),i.value=="magazine"?y():m(),document.querySelectorAll("input").forEach(o=>{o.classList.remove(err)},0)})})})(); +(()=>{"use strict";const p="text-danger",M={"Content-type":"application/json; charset=UTF-8"},O=document.getElementById("recordID");if(O==null){console.info("the editor modal is not open so the editor script is not needed");return}const h=document.getElementById("recordOnline"),y=document.getElementById("recordOnlineLabel");h.checked!=!0&&y.classList.add(p),h.addEventListener("change",function(t){let e="/editor/online/false";h.checked==!0&&(e="/editor/online/true"),fetch(e,{method:"POST",body:JSON.stringify({id:parseInt(O.value)}),headers:M}).then(o=>{if(!o.ok)throw new Error(saveErr);return h.checked==!0?y.classList.remove(p):y.classList.add(p),o.json()}).catch(o=>{console.log(o.message)})});const g=document.getElementById("recordTitle");g.addEventListener("input",function(t){if(g.value=g.value.trimStart(),g.value==""){g.classList.add(p);return}g.classList.remove(p)});const l=document.getElementById("recordReleasers"),b=document.getElementById("recordReleasersMax");l.addEventListener("input",function(t){if(l.value=l.value.toUpperCase(),l.value=l.value.replace(/[^a-zA-Z0-9-+& ]/g,""),l.value==""){l.classList.add(err);return}l.classList.remove(err),l.value.split("+").length>2?(l.classList.add(err),b.classList.add(dang)):(l.classList.remove(err),b.classList.remove(dang))});const c=document.getElementById("recordYear"),r=document.getElementById("recordMonth"),s=document.getElementById("recordDay");c.addEventListener("input",function(t){if(c.value>=1980&&c.value<=2023){c.classList.remove(err);return}if(c.value==""&&r.value==""&&s.value==""){c.classList.remove(err),r.classList.remove(err),s.classList.remove(err);return}c.classList.add(err)}),r.addEventListener("input",function(t){if(r.value>=1&&r.value<=12){r.classList.remove(err);return}if(c.value==""&&r.value==""&&s.value==""){c.classList.remove(err),r.classList.remove(err),s.classList.remove(err);return}if(r.value==""&&s.value==""){r.classList.remove(err),s.classList.remove(err);return}r.classList.add(err)}),s.addEventListener("input",function(t){if(r.value>=1&&r.value<=31){r.classList.remove(err);return}if(c.value==""&&r.value==""&&s.value==""){c.classList.remove(err),r.classList.remove(err),s.classList.remove(err);return}if(r.value==""&&s.value==""){r.classList.remove(err),s.classList.remove(err);return}if(s.value==""){s.classList.remove(err);return}s.classList.add(err)});const w=document.getElementById("recordLMBtn"),S=document.getElementById("recordLastMod");typeof w<"u"&&w!==null&&w.addEventListener("click",function(t){const e=S.value.split("-");e.length==3&&(c.value=e[0],r.value=e[1],s.value=e[2])});function B(t){let e=t;return e=e.toLowerCase(),e=e.replace(/[^A-Za-z0-9À-ÖØ-öø-ÿ\s,]/g,""),e}const T=document.getElementById("recordArtist"),k=document.getElementById("recordCoder"),x=document.getElementById("recordMusic"),R=document.getElementById("recordWriter");T.addEventListener("input",function(t){T.value=B(T.value)}),k.addEventListener("input",function(t){k.value=B(k.value)}),x.addEventListener("input",function(t){x.value=B(x.value)}),R.addEventListener("input",function(t){R.value=B(R.value)});const n=document.getElementById("recordDemozoo");n.addEventListener("paste",function(t){setTimeout(()=>{try{if(new URL(`${n.value}`).hostname!="demozoo.org"){n.classList.add(err);return}}catch{return}try{const f=new URL(`${n.value}`).pathname.split("/").filter(Boolean);if(f.length!=2){n.classList.add(err);return}switch(f[0]){case"productions":n.value=f[1];break;case"graphics":n.value=f[1];break;default:n.classList.add(err);return}n.classList.remove(err)}catch{n.classList.add(err)}},0)}),n.addEventListener("input",function(t){let e=Number(n.value);if(isNaN(e)){n.classList.add(err);return}if(e<0||e>999999){n.classList.add(err);return}e==0&&(n.value=""),n.classList.remove(err)});const a=document.getElementById("recordPouet");a.addEventListener("paste",function(t){setTimeout(()=>{try{const e=new URL(`${a.value}`);if(console.log(e.hostname),e.hostname!="www.pouet.net"){a.classList.add(err);return}}catch{return}try{const e=new URL(`${a.value}`);if(e.pathname!="/prod.php"){a.classList.add(err);return}const U=new URLSearchParams(e.search).get("which");a.value=U,a.classList.remove(err)}catch{a.classList.add(err)}},0)}),a.addEventListener("input",function(t){let e=Number(a.value);if(isNaN(e)){a.classList.add(err);return}if(e<0||e>199999){a.classList.add(err);return}e==0&&(a.value=""),a.classList.remove(err)});const L=document.getElementById("record16colors");L.addEventListener("paste",function(t){setTimeout(()=>{try{const e=new URL(`${L.value}`);if(e.hostname!="16colo.rs"){L.classList.add(err);return}const o=e.pathname;L.value=o,L.classList.remove(err)}catch{}},0)}),L.addEventListener("input",function(t){if(L.value==""){L.classList.remove(err);return}});const u=document.getElementById("recordGitHub");u.addEventListener("paste",function(t){setTimeout(()=>{try{const e=new URL(`${u.value}`);if(e.hostname!="github.com"){u.classList.add(err);return}const o=e.pathname;u.value=o,u.classList.remove(err)}catch{}},0)}),u.addEventListener("input",function(t){if(u.value==""){u.classList.remove(err);return}});const d=document.getElementById("recordYouTube");d.addEventListener("paste",function(t){setTimeout(()=>{try{const e=new URL(`${d.value}`);if(e.hostname!="youtube.com"&&e.hostname!="www.youtube.com"){d.classList.add(err);return}const f=new URLSearchParams(e.search).get("v");d.value=f,u.classList.remove(err)}catch{}},0)}),d.addEventListener("input",function(t){setTimeout(()=>{if(d.value==""){d.classList.remove(err);return}if(new RegExp("^[a-zA-Z0-9_-]{11}$").test(d.value)){d.classList.remove(err);return}d.classList.add(err)},0)});const E=document.getElementById("recordFilename");E.addEventListener("input",function(){if(E.value=E.value.trimStart(),E.value==""){E.classList.add(err);return}E.classList.remove(err)});const v=document.getElementById("recordPlatform"),i=document.getElementById("recordTag"),z=document.getElementById("recordReleasersLabel"),j=document.getElementById("recordTitleLabel");i.addEventListener("change",function(t){setTimeout(()=>{if(i.value=="magazine"){I();return}m()},0)});function I(){z.textContent="Magazine",j.textContent="Issue"}function m(){z.textContent="Releasers",j.textContent="Title"}document.getElementById("recordDosText").addEventListener("click",function(t){v.value="text",i.value="",m()}),document.getElementById("recordAmigaText").addEventListener("click",function(t){v.value="textamiga",i.value="",m()}),document.getElementById("recordProof").addEventListener("click",function(t){v.value="image",i.value="releaseproof",m()}),document.getElementById("recordDostro").addEventListener("click",function(t){v.value="dos",i.value="releaseadvert",m()}),document.getElementById("recordWintro").addEventListener("click",function(t){v.value="windows",i.value="releaseadvert",m()}),document.getElementById("recordBBStro").addEventListener("click",function(t){v.value="dos",i.value="bbs",m()}),document.getElementById("recordBBSAnsi").addEventListener("click",function(t){v.value="ansi",i.value="bbs",m()}),document.getElementById("recordTextMag").addEventListener("click",function(t){v.value="text",i.value="magazine",I()}),document.getElementById("recordDosMag").addEventListener("click",function(t){v.value="dos",i.value="magazine",I()}),document.getElementById("recordReset").addEventListener("click",function(t){setTimeout(()=>{h.checked!=!0?y.classList.add(dang):y.classList.remove(dang),b.classList.remove(dang),i.value=="magazine"?I():m(),document.querySelectorAll("input").forEach(o=>{o.classList.remove(err)},0)})})})();