diff --git a/assets/js/uploader.js b/assets/js/uploader.js index 0ecdf268..a69d52b5 100644 --- a/assets/js/uploader.js +++ b/assets/js/uploader.js @@ -4,94 +4,30 @@ * @module uploader * @requires bootstrap */ +import { + getModalById, + focusModalById, + pagination, + validYear, + validMonth, + validDay, +} from "./uploader.mjs"; + (() => { "use strict"; const invalid = "is-invalid"; - // Poeut modal elements - const pouetM = document.getElementById("uploader-pouet"); - if (pouetM == null) { - throw new Error("The uploader-pouet element is null."); - } - pouetM.addEventListener("shown.bs.modal", function () { - poeutInput.focus(); - }); - const pouetModal = new bootstrap.Modal(pouetM); - const poeutInput = document.getElementById("pouet-submission"); - if (poeutInput == null) { - throw new Error("The pouet-submission element is null."); - } - - // Demozoo modal elements - const demozooM = document.getElementById("uploader-demozoo"); - if (demozooM == null) { - throw new Error("The uploader-demozoo element is null."); - } - demozooM.addEventListener("shown.bs.modal", function () { - demozooInput.focus(); - }); - const demozooModal = new bootstrap.Modal(demozooM); - const demozooInput = document.getElementById("demozoo-submission"); - if (demozooInput == null) { - throw new Error("The demozoo-submission element is null."); - } - - const introM = document.getElementById("uploader-intro"); - if (introM == null) { - throw new Error("The uploader-intro element is null."); - } - introM.addEventListener("shown.bs.modal", function () { - introInput.focus(); - }); - const introModal = new bootstrap.Modal(introM); - const introInput = document.getElementById("uploader-intro-file"); - if (introInput == null) { - throw new Error("The uploader-intro-file element is null."); - } - - const txtM = document.getElementById("uploaderText"); - const imgM = document.getElementById("uploaderImg"); - const magM = document.getElementById("uploaderMag"); - const advM = document.getElementById("uploaderAdv"); - const glossM = document.getElementById("termsModal"); // not part of uploader but still a modal - - // Modal objects - const txtModal = new bootstrap.Modal(txtM); - const imgModal = new bootstrap.Modal(imgM); - const magModal = new bootstrap.Modal(magM); - const advModal = new bootstrap.Modal(advM); - const glossModal = new bootstrap.Modal(glossM); + const pouetModal = focusModalById("uploader-pouet", "pouet-submission"); + const demozooModal = focusModalById("uploader-demozoo", "demozoo-submission"); + const introModal = focusModalById("uploader-intro", "uploader-intro-file"); + const txtModal = getModalById("uploaderText"); + const imgModal = getModalById("uploaderImg"); + const magModal = getModalById("uploaderMag"); + const advModal = getModalById("uploaderAdv"); + const glossModal = getModalById("termsModal"); // TODO: move to layout.js or main.js - // Pagination button elements - const pageS = document.getElementById("paginationStart"); - const pageP = document.getElementById("paginationPrev"); - const pageP2 = document.getElementById("paginationPrev2"); - const pageN = document.getElementById("paginationNext"); - const pageN2 = document.getElementById("paginationNext2"); - const pageE = document.getElementById("paginationEnd"); - - const pageRange = document.getElementById("paginationRange"); - if (typeof pageRange !== "undefined" && pageRange != null) { - pageRange.addEventListener("change", function () { - const range = pageRange.value; - const url = new URL(window.location.href); - const path = url.pathname; - const paths = path.split("/"); - const page = paths[paths.length - 1]; - if (!isNaN(page) && typeof Number(page) === "number") { - paths[paths.length - 1] = range; - } else { - paths.push(range); - } - url.pathname = paths.join("/"); - window.location.href = url.href; - }); - const pageRangeLabel = document.getElementById("paginationRangeLabel"); - pageRange.addEventListener("input", function () { - pageRangeLabel.textContent = "Jump to page " + pageRange.value; - }); - } + pagination("paginationRange"); // Keyboard shortcuts event listener document.addEventListener("keydown", function (event) { @@ -132,6 +68,13 @@ } } + // Pagination button elements + const pageS = document.getElementById("paginationStart"); + const pageP = document.getElementById("paginationPrev"); + const pageP2 = document.getElementById("paginationPrev2"); + const pageN = document.getElementById("paginationNext"); + const pageN2 = document.getElementById("paginationNext2"); + const pageE = document.getElementById("paginationEnd"); const right = "ArrowRight", left = "ArrowLeft"; // Ctrl + Left arrow key to go to the start page @@ -166,52 +109,6 @@ } }); - /** - * Checks if a given year is valid, i.e. between 1980 and the current year. - * @param {number} year - The year to be validated. - * @returns {boolean} - Returns true if the year is valid, false otherwise. - */ - function validYear(year) { - if (`${year}` == "") { - return true; - } - const currentYear = new Date().getFullYear(); - if (year < 1980 || year > currentYear) { - return false; - } - return true; - } - - /** - * Checks if a given month is valid. - * @param {number} month - The month to be validated. - * @returns {boolean} - Returns true if the month is valid, false otherwise. - */ - function validMonth(month) { - if (`${month}` == "") { - return true; - } - if (month < 1 || month > 12) { - return false; - } - return true; - } - - /** - * Checks if a given day is valid. - * @param {number} day - The day to be checked. - * @returns {boolean} - Returns true if the day is valid, false otherwise. - */ - function validDay(day) { - if (`${day}` == "") { - return true; - } - if (day < 1 || day > 31) { - return false; - } - return true; - } - // Uploader forms const introFrm = document.getElementById("introUploader"); const txtFrm = document.getElementById("textUploader"); diff --git a/assets/js/uploader.mjs b/assets/js/uploader.mjs new file mode 100644 index 00000000..b28d31bc --- /dev/null +++ b/assets/js/uploader.mjs @@ -0,0 +1,106 @@ +export default getModalById; + +export function getModalById(uploaderId) { + const element = document.getElementById(uploaderId); + if (element == null) { + throw new Error(`The ${uploaderId} element is null.`); + } + if (bootstrap === undefined) { + throw new Error(`The bootstrap object is undefined.`); + } + const modal = new bootstrap.Modal(element); + return modal; +} + +export function focusModalById(uploaderId, submissionId) { + const element = document.getElementById(uploaderId); + if (element == null) { + throw new Error(`The ${uploaderId} element is null.`); + } + const input = document.getElementById(submissionId); + if (input == null) { + throw new Error(`The ${submissionId} element is null.`); + } + element.addEventListener("shown.bs.modal", function () { + input.focus(); + }); + if (bootstrap === undefined) { + throw new Error(`The bootstrap object is undefined.`); + } + const modal = new bootstrap.Modal(element); + return modal; +} + +export function pagination(elementId) { + const pageRange = document.getElementById(elementId); + if (typeof pageRange === "undefined" || pageRange === null) { + return; + } + pageRange.addEventListener("change", function () { + const range = pageRange.value; + const url = new URL(window.location.href); + const path = url.pathname; + const paths = path.split("/"); + const page = paths[paths.length - 1]; + if (!isNaN(page) && typeof Number(page) === "number") { + paths[paths.length - 1] = range; + } else { + paths.push(range); + } + url.pathname = paths.join("/"); + window.location.href = url.href; + }); + const label = `paginationRangeLabel`; + const pageRangeLabel = document.getElementById(label); + if (pageRangeLabel === null) { + throw new Error(`The ${label} element is null.`); + } + pageRange.addEventListener("input", function () { + pageRangeLabel.textContent = "Jump to page " + pageRange.value; + }); +} +/** + * Checks if a given year is valid, i.e. between 1980 and the current year. + * @param {number} year - The year to be validated. + * @returns {boolean} - Returns true if the year is valid, false otherwise. + */ +export function validYear(year) { + if (`${year}` == "") { + return true; + } + const currentYear = new Date().getFullYear(); + if (year < 1980 || year > currentYear) { + return false; + } + return true; +} + +/** + * Checks if a given month is valid. + * @param {number} month - The month to be validated. + * @returns {boolean} - Returns true if the month is valid, false otherwise. + */ +export function validMonth(month) { + if (`${month}` == "") { + return true; + } + if (month < 1 || month > 12) { + return false; + } + return true; +} + +/** + * Checks if a given day is valid. + * @param {number} day - The day to be checked. + * @returns {boolean} - Returns true if the day is valid, false otherwise. + */ +export function validDay(day) { + if (`${day}` == "") { + return true; + } + if (day < 1 || day > 31) { + return false; + } + return true; +} diff --git a/eslint.config.mjs b/eslint.config.mjs index e1655bab..1cf39a6f 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -8,10 +8,9 @@ export default [ ignores: ["**/*.min.js"], }, { - files: ["assets/js/**/*.js"], + files: ["assets/js/**/*.js", "assets/js/**/*.mjs"], languageOptions: { ecmaVersion: "latest", - sourceType: "script", globals: { ...globals.browser, bootstrap: "readonly", diff --git a/public/js/uploader.min.js b/public/js/uploader.min.js index 74dcd849..59703e34 100644 --- a/public/js/uploader.min.js +++ b/public/js/uploader.min.js @@ -1,2 +1,2 @@ /* uploader.min.js © Defacto2 2024 */ -(()=>{"use strict";const t="is-invalid",r=document.getElementById("uploader-pouet");if(r==null)throw new Error("The uploader-pouet element is null.");r.addEventListener("shown.bs.modal",function(){j.focus()});const me=new bootstrap.Modal(r),j=document.getElementById("pouet-submission");if(j==null)throw new Error("The pouet-submission element is null.");const u=document.getElementById("uploader-demozoo");if(u==null)throw new Error("The uploader-demozoo element is null.");u.addEventListener("shown.bs.modal",function(){J.focus()});const re=new bootstrap.Modal(u),J=document.getElementById("demozoo-submission");if(J==null)throw new Error("The demozoo-submission element is null.");const f=document.getElementById("uploader-intro");if(f==null)throw new Error("The uploader-intro element is null.");f.addEventListener("shown.bs.modal",function(){q.focus()});const ue=new bootstrap.Modal(f),q=document.getElementById("uploader-intro-file");if(q==null)throw new Error("The uploader-intro-file element is null.");const fe=document.getElementById("uploaderText"),ge=document.getElementById("uploaderImg"),ve=document.getElementById("uploaderMag"),Ee=document.getElementById("uploaderAdv"),Le=document.getElementById("termsModal"),ye=new bootstrap.Modal(fe),pe=new bootstrap.Modal(ge),Ie=new bootstrap.Modal(ve),Be=new bootstrap.Modal(Ee),he=new bootstrap.Modal(Le),G=document.getElementById("paginationStart"),H=document.getElementById("paginationPrev"),Q=document.getElementById("paginationPrev2"),V=document.getElementById("paginationNext"),W=document.getElementById("paginationNext2"),X=document.getElementById("paginationEnd"),a=document.getElementById("paginationRange");if(typeof a<"u"&&a!=null){a.addEventListener("change",function(){const s=a.value,i=new URL(window.location.href),n=i.pathname.split("/"),m=n[n.length-1];!isNaN(m)&&typeof Number(m)=="number"?n[n.length-1]=s:n.push(s),i.pathname=n.join("/"),window.location.href=i.href});const e=document.getElementById("paginationRangeLabel");a.addEventListener("input",function(){e.textContent="Jump to page "+a.value})}document.addEventListener("keydown",function(e){const s="d",i="p",ce="i",n="n",m="g",we="m",be="a",Me="t";if(e.ctrlKey&&e.altKey)switch(e.key){case s:re.show();break;case i:me.show();break;case ce:ue.show();break;case n:ye.show();break;case m:pe.show();break;case we:Ie.show();break;case be:Be.show();break;case Me:he.show();break}const O="ArrowRight",$="ArrowLeft";if(e.ctrlKey&&e.key==$){G?.click();return}if(e.ctrlKey&&e.key==O){X?.click();return}if(e.shiftKey&&e.key==$){Q?.click();return}if(e.shiftKey&&e.key==O){W?.click();return}if(e.key==$){H?.click();return}if(e.key==O){V?.click();return}});function o(e){if(`${e}`=="")return!0;const s=new Date().getFullYear();return!(e<1980||e>s)}function l(e){return`${e}`==""?!0:!(e<1||e>12)}function Z(e){return`${e}`==""?!0:!(e<1||e>31)}const _=document.getElementById("introUploader"),ee=document.getElementById("textUploader"),te=document.getElementById("imageUploader"),se=document.getElementById("magUploader"),ne=document.getElementById("advancedUploader"),g=document.getElementById("introFile"),v=document.getElementById("releaseTitle"),E=document.getElementById("introReleasers"),L=document.getElementById("introYear"),y=document.getElementById("introMonth");function ae(){g.classList.remove(t),v.classList.remove(t),E.classList.remove(t),L.classList.remove(t),y.classList.remove(t)}document.getElementById("introSubmit").addEventListener("click",function(){let e=!0;ae(),g.value==""&&(g.classList.add(t),e=!1),v.value==""&&(v.classList.add(t),e=!1),E.value==""&&(E.classList.add(t),e=!1),o(L.value)==!1&&(L.classList.add(t),e=!1),l(y.value)==!1&&(y.classList.add(t),e=!1),e==!0&&_.submit()}),_.addEventListener("reset",ae);const p=document.getElementById("textFile"),I=document.getElementById("textTitle"),B=document.getElementById("textReleasers"),h=document.getElementById("textYear"),w=document.getElementById("textMonth");function oe(){p.classList.remove(t),I.classList.remove(t),B.classList.remove(t),h.classList.remove(t),w.classList.remove(t)}document.getElementById("textSubmit").addEventListener("click",function(){let e=!0;oe(),p.value==""&&(p.classList.add(t),e=!1),I.value==""&&(I.classList.add(t),e=!1),B.value==""&&(B.classList.add(t),e=!1),o(h.value)==!1&&(h.classList.add(t),e=!1),l(w.value)==!1&&(w.classList.add(t),e=!1),e==!0&&ee.submit()}),ee.addEventListener("reset",oe);const b=document.getElementById("imageFile"),M=document.getElementById("imageTitle"),k=document.getElementById("imageReleasers"),x=document.getElementById("imageYear"),R=document.getElementById("imageMonth");function le(){b.classList.remove(t),M.classList.remove(t),k.classList.remove(t),x.classList.remove(t),R.classList.remove(t)}document.getElementById("imageSubmit").addEventListener("click",function(){let e=!0;le(),b.value==""&&(b.classList.add(t),e=!1),M.value==""&&(M.classList.add(t),e=!1),k.value==""&&(k.classList.add(t),e=!1),o(x.value)==!1&&(x.classList.add(t),e=!1),l(R.value)==!1&&(R.classList.add(t),e=!1),e==!0&&te.submit()}),te.addEventListener("reset",le);const T=document.getElementById("magFile"),F=document.getElementById("magTitle"),Y=document.getElementById("magIssue"),S=document.getElementById("magYear"),z=document.getElementById("magMonth"),N=document.getElementById("magDay");function ie(){T.classList.remove(t),F.classList.remove(t),Y.classList.remove(t),S.classList.remove(t),z.classList.remove(t),N.classList.remove(t)}document.getElementById("magSubmit").addEventListener("click",function(){let e=!0;ie(),T.value==""&&(T.classList.add(t),e=!1),F.value==""&&(F.classList.add(t),e=!1),Y.value==""&&(Y.classList.add(t),e=!1),o(S.value)==!1&&(S.classList.add(t),e=!1),l(z.value)==!1&&(z.classList.add(t),e=!1),Z(N.value)==!1&&(N.classList.add(t),e=!1),e==!0&&se.submit()}),se.addEventListener("reset",ie);const D=document.getElementById("advFile"),d=document.getElementById("advSelOS"),c=document.getElementById("advSelCat"),K=document.getElementById("advTitle"),U=document.getElementById("releasersAdv"),A=document.getElementById("advYear"),C=document.getElementById("advMonth"),P=document.getElementById("advDay");function de(){D.classList.remove(t),d.classList.remove(t),c.classList.remove(t),K.classList.remove(t),U.classList.remove(t),A.classList.remove(t),C.classList.remove(t),P.classList.remove(t)}document.getElementById("advSubmit").addEventListener("click",function(){const e="Choose...";let s=!0;de(),D.value==""&&(D.classList.add(t),s=!1),(d.value==""||d.value==e)&&(d.classList.add(t),s=!1),(c.value==""||c.value==e)&&(c.classList.add(t),s=!1),K.value==""&&(K.classList.add(t),s=!1),U.value==""&&(U.classList.add(t),s=!1),o(A.value)==!1&&(A.classList.add(t),s=!1),l(C.value)==!1&&(C.classList.add(t),s=!1),Z(P.value)==!1&&(P.classList.add(t),s=!1),s==!0&&ne.submit()}),ne.addEventListener("reset",de)})(); +(()=>{function i(e){let s=document.getElementById(e);if(s==null)throw new Error(`The ${e} element is null.`);if(bootstrap===void 0)throw new Error("The bootstrap object is undefined.");return new bootstrap.Modal(s)}function v(e,s){let n=document.getElementById(e);if(n==null)throw new Error(`The ${e} element is null.`);let o=document.getElementById(s);if(o==null)throw new Error(`The ${s} element is null.`);if(n.addEventListener("shown.bs.modal",function(){o.focus()}),bootstrap===void 0)throw new Error("The bootstrap object is undefined.");return new bootstrap.Modal(n)}function ce(e){let s=document.getElementById(e);if(typeof s>"u"||s===null)return;s.addEventListener("change",function(){let r=s.value,m=new URL(window.location.href),l=m.pathname.split("/"),u=l[l.length-1];!isNaN(u)&&typeof Number(u)=="number"?l[l.length-1]=r:l.push(r),m.pathname=l.join("/"),window.location.href=m.href});let n="paginationRangeLabel",o=document.getElementById(n);if(o===null)throw new Error(`The ${n} element is null.`);s.addEventListener("input",function(){o.textContent="Jump to page "+s.value})}function d(e){if(`${e}`=="")return!0;let s=new Date().getFullYear();return!(e<1980||e>s)}function c(e){return`${e}`==""?!0:!(e<1||e>12)}function q(e){return`${e}`==""?!0:!(e<1||e>31)}(()=>{"use strict";let e="is-invalid",s=v("uploader-pouet","pouet-submission"),n=v("uploader-demozoo","demozoo-submission"),o=v("uploader-intro","uploader-intro-file"),r=i("uploaderText"),m=i("uploaderImg"),G=i("uploaderMag"),l=i("uploaderAdv"),u=i("termsModal");ce("paginationRange"),document.addEventListener("keydown",function(t){let a="d",re="p",me="i",ue="n",fe="g",ge="m",ve="a",Le="t";if(t.ctrlKey&&t.altKey)switch(t.key){case a:n.show();break;case re:s.show();break;case me:o.show();break;case ue:r.show();break;case fe:m.show();break;case ge:G.show();break;case ve:l.show();break;case Le:u.show();break}let ae=document.getElementById("paginationStart"),ne=document.getElementById("paginationPrev"),le=document.getElementById("paginationPrev2"),oe=document.getElementById("paginationNext"),ie=document.getElementById("paginationNext2"),de=document.getElementById("paginationEnd"),O="ArrowRight",J="ArrowLeft";if(t.ctrlKey&&t.key==J){ae?.click();return}if(t.ctrlKey&&t.key==O){de?.click();return}if(t.shiftKey&&t.key==J){le?.click();return}if(t.shiftKey&&t.key==O){ie?.click();return}if(t.key==J){ne?.click();return}if(t.key==O){oe?.click();return}});let H=document.getElementById("introUploader"),Q=document.getElementById("textUploader"),V=document.getElementById("imageUploader"),W=document.getElementById("magUploader"),X=document.getElementById("advancedUploader"),L=document.getElementById("introFile"),y=document.getElementById("releaseTitle"),E=document.getElementById("introReleasers"),p=document.getElementById("introYear"),B=document.getElementById("introMonth");function Z(){L.classList.remove(e),y.classList.remove(e),E.classList.remove(e),p.classList.remove(e),B.classList.remove(e)}document.getElementById("introSubmit").addEventListener("click",function(){let t=!0;Z(),L.value==""&&(L.classList.add(e),t=!1),y.value==""&&(y.classList.add(e),t=!1),E.value==""&&(E.classList.add(e),t=!1),d(p.value)==!1&&(p.classList.add(e),t=!1),c(B.value)==!1&&(B.classList.add(e),t=!1),t==!0&&H.submit()}),H.addEventListener("reset",Z);let I=document.getElementById("textFile"),h=document.getElementById("textTitle"),b=document.getElementById("textReleasers"),w=document.getElementById("textYear"),M=document.getElementById("textMonth");function _(){I.classList.remove(e),h.classList.remove(e),b.classList.remove(e),w.classList.remove(e),M.classList.remove(e)}document.getElementById("textSubmit").addEventListener("click",function(){let t=!0;_(),I.value==""&&(I.classList.add(e),t=!1),h.value==""&&(h.classList.add(e),t=!1),b.value==""&&(b.classList.add(e),t=!1),d(w.value)==!1&&(w.classList.add(e),t=!1),c(M.value)==!1&&(M.classList.add(e),t=!1),t==!0&&Q.submit()}),Q.addEventListener("reset",_);let k=document.getElementById("imageFile"),x=document.getElementById("imageTitle"),R=document.getElementById("imageReleasers"),T=document.getElementById("imageYear"),F=document.getElementById("imageMonth");function ee(){k.classList.remove(e),x.classList.remove(e),R.classList.remove(e),T.classList.remove(e),F.classList.remove(e)}document.getElementById("imageSubmit").addEventListener("click",function(){let t=!0;ee(),k.value==""&&(k.classList.add(e),t=!1),x.value==""&&(x.classList.add(e),t=!1),R.value==""&&(R.classList.add(e),t=!1),d(T.value)==!1&&(T.classList.add(e),t=!1),c(F.value)==!1&&(F.classList.add(e),t=!1),t==!0&&V.submit()}),V.addEventListener("reset",ee);let Y=document.getElementById("magFile"),S=document.getElementById("magTitle"),D=document.getElementById("magIssue"),N=document.getElementById("magYear"),$=document.getElementById("magMonth"),K=document.getElementById("magDay");function te(){Y.classList.remove(e),S.classList.remove(e),D.classList.remove(e),N.classList.remove(e),$.classList.remove(e),K.classList.remove(e)}document.getElementById("magSubmit").addEventListener("click",function(){let t=!0;te(),Y.value==""&&(Y.classList.add(e),t=!1),S.value==""&&(S.classList.add(e),t=!1),D.value==""&&(D.classList.add(e),t=!1),d(N.value)==!1&&(N.classList.add(e),t=!1),c($.value)==!1&&($.classList.add(e),t=!1),q(K.value)==!1&&(K.classList.add(e),t=!1),t==!0&&W.submit()}),W.addEventListener("reset",te);let U=document.getElementById("advFile"),f=document.getElementById("advSelOS"),g=document.getElementById("advSelCat"),z=document.getElementById("advTitle"),A=document.getElementById("releasersAdv"),C=document.getElementById("advYear"),P=document.getElementById("advMonth"),j=document.getElementById("advDay");function se(){U.classList.remove(e),f.classList.remove(e),g.classList.remove(e),z.classList.remove(e),A.classList.remove(e),C.classList.remove(e),P.classList.remove(e),j.classList.remove(e)}document.getElementById("advSubmit").addEventListener("click",function(){let t="Choose...",a=!0;se(),U.value==""&&(U.classList.add(e),a=!1),(f.value==""||f.value==t)&&(f.classList.add(e),a=!1),(g.value==""||g.value==t)&&(g.classList.add(e),a=!1),z.value==""&&(z.classList.add(e),a=!1),A.value==""&&(A.classList.add(e),a=!1),d(C.value)==!1&&(C.classList.add(e),a=!1),c(P.value)==!1&&(P.classList.add(e),a=!1),q(j.value)==!1&&(j.classList.add(e),a=!1),a==!0&&X.submit()}),X.addEventListener("reset",se)})();})(); diff --git a/runner/runner.go b/runner/runner.go index 5b62bb52..0a83a2d3 100644 --- a/runner/runner.go +++ b/runner/runner.go @@ -30,7 +30,7 @@ func NamedJS() []string { "editor-archive", "editor-forapproval", "readme", - "uploader", + //"uploader", "votes-pouet", } } @@ -74,6 +74,26 @@ func JS(name string) api.BuildOptions { } } +func Uploader() api.BuildOptions { + min := "uploader.min.js" + entryjs := filepath.Join("assets", "js", "uploader.js") + //entrymjs := filepath.Join("assets", "js", "uploader.mjs") + output := filepath.Join("public", "js", min) + return api.BuildOptions{ + EntryPoints: []string{entryjs}, + Outfile: output, + Target: api.ES2020, // specify JS language version + Write: true, // write the output file to disk + Bundle: true, // bundle dependencies into the output file + MinifyWhitespace: true, + MinifyIdentifiers: true, + MinifySyntax: true, + Banner: map[string]string{ + "js": fmt.Sprintf("/* %s %s %s */", min, C, time.Now().Format("2006")), + }, + } +} + func main() { for _, name := range NamedCSS() { result := api.Build(CSS(name)) @@ -87,4 +107,10 @@ func main() { fmt.Fprintf(os.Stderr, "JS build failed: %v\n", result.Errors) } } + { + result := api.Build(Uploader()) + if len(result.Errors) > 0 { + fmt.Fprintf(os.Stderr, "JS build failed: %v\n", result.Errors) + } + } }