Make render.js standalone

Despite that, it still expects the existence of a so-called main script
in "page" variable, and also expects to be loaded by it instead,
with an internal check to load itself if the main script fails to call
itself within the expected conditions.

Improved button colors in SweetAlert prompts.

Refactored window.onload() to DOMContentLoaded's event listener.
This should essentially allow pages to have multiple scripts that listen
to that event.

Bumped v1 version string and rebuilt client assets.
This commit is contained in:
Bobby Wibowo 2020-06-20 02:30:57 +07:00
parent 51c8df71bc
commit d29621d5ff
No known key found for this signature in database
GPG Key ID: 51C3A1E1E22D26CF
19 changed files with 181 additions and 132 deletions

View File

@ -1,2 +1,2 @@
.swal-modal{background-color:#282828}.swal-modal .field{text-align:left;text-align:initial}.swal-modal.is-expanded{width:auto;max-width:90%}.swal-text,.swal-title{color:#eff0f1}.swal-text{text-align:center}.swal-content .checkbox,.swal-content .label,.swal-content .radio{color:#eff0f1}.swal-content .checkbox:hover,.swal-content .radio:hover{color:#bdc3c7}.swal-button{background-color:#3794d2;color:#eff0f1}.swal-button:hover{background-color:#1496ed}.swal-button:focus{box-shadow:0 0 0 1px #030303,0 0 0 3px rgba(55,148,210,.29)}.swal-button--loading{color:transparent}.swal-button--danger{background-color:#da4453}.swal-icon--info{border-color:#3794d2}.swal-icon--info:after,.swal-icon--info:before{background-color:#3794d2}.swal-icon--error{border-color:#da4453}.swal-icon--error__line{background-color:#da4453}.swal-icon--warning{border-color:#f67400;-webkit-animation:pulseWarning .5s infinite alternate;animation:pulseWarning .5s infinite alternate}.swal-icon--warning__body,.swal-icon--warning__dot{background-color:#f67400;-webkit-animation:pulseWarningBody .5s infinite alternate;animation:pulseWarningBody .5s infinite alternate}@-webkit-keyframes pulseWarning{0%{border-color:#ffaa60}to{border-color:#f67400}}@keyframes pulseWarning{0%{border-color:#ffaa60}to{border-color:#f67400}}@-webkit-keyframes pulseWarningBody{0%{background-color:#ffaa60}to{background-color:#f67400}}@keyframes pulseWarningBody{0%{background-color:#ffaa60}to{background-color:#f67400}}.swal-icon--success{border-color:#27ae60}.swal-icon--success__line{background-color:#27ae60}.swal-icon--success__hide-corners{background-color:#282828}.swal-icon--success:after,.swal-icon--success:before{background:#282828}.swal-display-thumb-container{min-width:200px;min-height:200px;display:flex;align-items:center;justify-content:center}
.swal-modal{background-color:#282828}.swal-modal .field{text-align:left;text-align:initial}.swal-modal.is-expanded{width:auto;max-width:90%}.swal-text,.swal-title{color:#eff0f1}.swal-text{text-align:center}.swal-content .checkbox,.swal-content .label,.swal-content .radio{color:#eff0f1}.swal-content .checkbox:hover,.swal-content .radio:hover{color:#bdc3c7}.swal-button--confirm:not(.swal-button--danger){background-color:#209cee}.swal-button--confirm:not(.swal-button--danger):hover{background-color:#67c3ff}.swal-button--confirm:not(.swal-button--danger):focus{box-shadow:0 0 0 1px #030303,0 0 0 3px rgba(32,156,238,.29)}.swal-button--danger{background-color:#ff3860}.swal-button--danger:hover{background-color:#ff2b56}.swal-button--danger:focus{box-shadow:0 0 0 1px #030303,0 0 0 3px rgba(255,56,96,.29)}.swal-button--cancel{background-color:#00d1b2;color:#fff}.swal-button--cancel:hover{background-color:#00c4a7}.swal-button--cancel:focus{box-shadow:0 0 0 1px #030303,0 0 0 3px rgba(0,209,178,.29)}.swal-button--loading{color:transparent}.swal-icon--info{border-color:#3794d2}.swal-icon--info:after,.swal-icon--info:before{background-color:#3794d2}.swal-icon--error{border-color:#da4453}.swal-icon--error__line{background-color:#da4453}.swal-icon--warning{border-color:#f67400;-webkit-animation:pulseWarning .5s infinite alternate;animation:pulseWarning .5s infinite alternate}.swal-icon--warning__body,.swal-icon--warning__dot{background-color:#f67400;-webkit-animation:pulseWarningBody .5s infinite alternate;animation:pulseWarningBody .5s infinite alternate}@-webkit-keyframes pulseWarning{0%{border-color:#ffaa60}to{border-color:#f67400}}@keyframes pulseWarning{0%{border-color:#ffaa60}to{border-color:#f67400}}@-webkit-keyframes pulseWarningBody{0%{background-color:#ffaa60}to{background-color:#f67400}}@keyframes pulseWarningBody{0%{background-color:#ffaa60}to{background-color:#f67400}}.swal-icon--success{border-color:#27ae60}.swal-icon--success__line{background-color:#27ae60}.swal-icon--success__hide-corners{background-color:#282828}.swal-icon--success:after,.swal-icon--success:before{background:#282828}.swal-display-thumb-container{min-width:200px;min-height:200px;display:flex;align-items:center;justify-content:center}
/*# sourceMappingURL=sweetalert.css.map */

View File

@ -1 +1 @@
{"version":3,"sources":["css/sweetalert.css"],"names":[],"mappings":"AAAA,YACE,wBACF,CAEA,mBACE,eAAkB,CAAlB,kBACF,CAEA,wBACE,UAAW,CACX,aACF,CAEA,uBAEE,aACF,CAEA,WACE,iBACF,CAEA,kEAGE,aACF,CAEA,yDAEE,aACF,CAEA,aACE,wBAAyB,CACzB,aACF,CAEA,mBACE,wBACF,CAEA,mBACE,2DACF,CAEA,sBACE,iBACF,CAEA,qBACE,wBACF,CAEA,iBACE,oBACF,CAEA,+CAEE,wBACF,CAEA,kBACE,oBACF,CAEA,wBACE,wBACF,CAEA,oBACE,oBAAqB,CACrB,qDAA8C,CAA9C,6CACF,CAEA,mDAEE,wBAAyB,CACzB,yDAAkD,CAAlD,iDACF,CAEA,gCACE,GACE,oBACF,CAEA,GACE,oBACF,CACF,CAEA,wBACE,GACE,oBACF,CAEA,GACE,oBACF,CACF,CAEA,oCACE,GACE,wBACF,CAEA,GACE,wBACF,CACF,CAEA,4BACE,GACE,wBACF,CAEA,GACE,wBACF,CACF,CAEA,oBACE,oBACF,CAEA,0BACE,wBACF,CAEA,kCACE,wBACF,CAEA,qDAEE,kBACF,CAEA,8BACE,eAAgB,CAChB,gBAAiB,CACjB,YAAa,CACb,kBAAmB,CACnB,sBACF","file":"sweetalert.css","sourcesContent":[".swal-modal {\n background-color: #282828\n}\n\n.swal-modal .field {\n text-align: initial\n}\n\n.swal-modal.is-expanded {\n width: auto;\n max-width: 90%\n}\n\n.swal-title,\n.swal-text {\n color: #eff0f1\n}\n\n.swal-text {\n text-align: center\n}\n\n.swal-content .label,\n.swal-content .checkbox,\n.swal-content .radio {\n color: #eff0f1\n}\n\n.swal-content .checkbox:hover,\n.swal-content .radio:hover {\n color: #bdc3c7\n}\n\n.swal-button {\n background-color: #3794d2;\n color: #eff0f1\n}\n\n.swal-button:hover {\n background-color: #1496ed\n}\n\n.swal-button:focus {\n box-shadow: 0 0 0 1px #030303, 0 0 0 3px rgba(55, 148, 210, 0.29)\n}\n\n.swal-button--loading {\n color: transparent\n}\n\n.swal-button--danger {\n background-color: #da4453\n}\n\n.swal-icon--info {\n border-color: #3794d2\n}\n\n.swal-icon--info::after,\n.swal-icon--info::before {\n background-color: #3794d2\n}\n\n.swal-icon--error {\n border-color: #da4453\n}\n\n.swal-icon--error__line {\n background-color: #da4453\n}\n\n.swal-icon--warning {\n border-color: #f67400;\n animation: pulseWarning 0.5s infinite alternate\n}\n\n.swal-icon--warning__body,\n.swal-icon--warning__dot {\n background-color: #f67400;\n animation: pulseWarningBody 0.5s infinite alternate\n}\n\n@-webkit-keyframes pulseWarning {\n 0% {\n border-color: #ffaa60\n }\n\n to {\n border-color: #f67400\n }\n}\n\n@keyframes pulseWarning {\n 0% {\n border-color: #ffaa60\n }\n\n to {\n border-color: #f67400\n }\n}\n\n@-webkit-keyframes pulseWarningBody {\n 0% {\n background-color: #ffaa60\n }\n\n to {\n background-color: #f67400\n }\n}\n\n@keyframes pulseWarningBody {\n 0% {\n background-color: #ffaa60\n }\n\n to {\n background-color: #f67400\n }\n}\n\n.swal-icon--success {\n border-color: #27ae60\n}\n\n.swal-icon--success__line {\n background-color: #27ae60\n}\n\n.swal-icon--success__hide-corners {\n background-color: #282828\n}\n\n.swal-icon--success::after,\n.swal-icon--success::before {\n background: #282828\n}\n\n.swal-display-thumb-container {\n min-width: 200px;\n min-height: 200px;\n display: flex;\n align-items: center;\n justify-content: center\n}\n"]}
{"version":3,"sources":["css/sweetalert.css"],"names":[],"mappings":"AAAA,YACE,wBACF,CAEA,mBACE,eAAkB,CAAlB,kBACF,CAEA,wBACE,UAAW,CACX,aACF,CAEA,uBAEE,aACF,CAEA,WACE,iBACF,CAEA,kEAGE,aACF,CAEA,yDAEE,aACF,CAEA,gDACE,wBACF,CAEA,sDACE,wBACF,CAEA,sDACE,2DACF,CAEA,qBACE,wBACF,CAEA,2BACE,wBACF,CAEA,2BACE,0DACF,CAEA,qBACE,wBAAyB,CACzB,UACF,CAEA,2BACE,wBACF,CAEA,2BACE,0DACF,CAEA,sBACE,iBACF,CAEA,iBACE,oBACF,CAEA,+CAEE,wBACF,CAEA,kBACE,oBACF,CAEA,wBACE,wBACF,CAEA,oBACE,oBAAqB,CACrB,qDAA8C,CAA9C,6CACF,CAEA,mDAEE,wBAAyB,CACzB,yDAAkD,CAAlD,iDACF,CAEA,gCACE,GACE,oBACF,CAEA,GACE,oBACF,CACF,CAEA,wBACE,GACE,oBACF,CAEA,GACE,oBACF,CACF,CAEA,oCACE,GACE,wBACF,CAEA,GACE,wBACF,CACF,CAEA,4BACE,GACE,wBACF,CAEA,GACE,wBACF,CACF,CAEA,oBACE,oBACF,CAEA,0BACE,wBACF,CAEA,kCACE,wBACF,CAEA,qDAEE,kBACF,CAEA,8BACE,eAAgB,CAChB,gBAAiB,CACjB,YAAa,CACb,kBAAmB,CACnB,sBACF","file":"sweetalert.css","sourcesContent":[".swal-modal {\n background-color: #282828\n}\n\n.swal-modal .field {\n text-align: initial\n}\n\n.swal-modal.is-expanded {\n width: auto;\n max-width: 90%\n}\n\n.swal-title,\n.swal-text {\n color: #eff0f1\n}\n\n.swal-text {\n text-align: center\n}\n\n.swal-content .label,\n.swal-content .checkbox,\n.swal-content .radio {\n color: #eff0f1\n}\n\n.swal-content .checkbox:hover,\n.swal-content .radio:hover {\n color: #bdc3c7\n}\n\n.swal-button--confirm:not(.swal-button--danger) {\n background-color: #209cee\n}\n\n.swal-button--confirm:not(.swal-button--danger):hover {\n background-color: #67c3ff\n}\n\n.swal-button--confirm:not(.swal-button--danger):focus {\n box-shadow: 0 0 0 1px #030303, 0 0 0 3px rgba(32, 156, 238, 0.29)\n}\n\n.swal-button--danger {\n background-color: #ff3860\n}\n\n.swal-button--danger:hover {\n background-color: #ff2b56\n}\n\n.swal-button--danger:focus {\n box-shadow: 0 0 0 1px #030303, 0 0 0 3px rgba(255, 56, 96, 0.29)\n}\n\n.swal-button--cancel {\n background-color: #00d1b2;\n color: #fff\n}\n\n.swal-button--cancel:hover {\n background-color: #00c4a7\n}\n\n.swal-button--cancel:focus {\n box-shadow: 0 0 0 1px #030303, 0 0 0 3px rgba(0, 209, 178, 0.29)\n}\n\n.swal-button--loading {\n color: transparent\n}\n\n.swal-icon--info {\n border-color: #3794d2\n}\n\n.swal-icon--info::after,\n.swal-icon--info::before {\n background-color: #3794d2\n}\n\n.swal-icon--error {\n border-color: #da4453\n}\n\n.swal-icon--error__line {\n background-color: #da4453\n}\n\n.swal-icon--warning {\n border-color: #f67400;\n animation: pulseWarning 0.5s infinite alternate\n}\n\n.swal-icon--warning__body,\n.swal-icon--warning__dot {\n background-color: #f67400;\n animation: pulseWarningBody 0.5s infinite alternate\n}\n\n@-webkit-keyframes pulseWarning {\n 0% {\n border-color: #ffaa60\n }\n\n to {\n border-color: #f67400\n }\n}\n\n@keyframes pulseWarning {\n 0% {\n border-color: #ffaa60\n }\n\n to {\n border-color: #f67400\n }\n}\n\n@-webkit-keyframes pulseWarningBody {\n 0% {\n background-color: #ffaa60\n }\n\n to {\n background-color: #f67400\n }\n}\n\n@keyframes pulseWarningBody {\n 0% {\n background-color: #ffaa60\n }\n\n to {\n background-color: #f67400\n }\n}\n\n.swal-icon--success {\n border-color: #27ae60\n}\n\n.swal-icon--success__line {\n background-color: #27ae60\n}\n\n.swal-icon--success__hide-corners {\n background-color: #282828\n}\n\n.swal-icon--success::after,\n.swal-icon--success::before {\n background: #282828\n}\n\n.swal-display-thumb-container {\n min-width: 200px;\n min-height: 200px;\n display: flex;\n align-items: center;\n justify-content: center\n}\n"]}

2
dist/js/album.js vendored
View File

@ -1,2 +1,2 @@
var lsKeys={},page={lazyLoad:null};window.onload=function(){for(var e=document.querySelectorAll(".file-size"),a=0;a<e.length;a++)e[a].innerHTML=page.getPrettyBytes(parseInt(e[a].innerHTML.replace(/\s*B$/i,"")));page.lazyLoad=new LazyLoad};
var lsKeys={},page={lazyLoad:null};window.addEventListener("DOMContentLoaded",(function(){for(var e=document.querySelectorAll(".file-size"),n=0;n<e.length;n++)e[n].innerHTML=page.getPrettyBytes(parseInt(e[n].innerHTML.replace(/\s*B$/i,"")));page.lazyLoad=new LazyLoad}));
//# sourceMappingURL=album.js.map

View File

@ -1 +1 @@
{"version":3,"sources":["album.js"],"names":["const","lsKeys","page","lazyLoad","window","onload","elements","document","querySelectorAll","i","length","innerHTML","getPrettyBytes","parseInt","replace","LazyLoad"],"mappings":"AAGAA,IAAMC,OAAS,GAETC,KAAO,CACXC,SAAU,MAGZC,OAAOC,OAAM,WAEX,IADAL,IAAMM,EAAWC,SAASC,iBAAiB,cAClCC,EAAI,EAAGA,EAAIH,EAASI,OAAQD,IACnCH,EAASG,GAAGE,UAAYT,KAAKU,eAAeC,SAASP,EAASG,GAAGE,UAAUG,QAAQ,SAAU,MAE/FZ,KAAKC,SAAW,IAAIY","file":"album.js","sourcesContent":["/* global LazyLoad */\n\n// eslint-disable-next-line no-unused-vars\nconst lsKeys = {}\n\nconst page = {\n lazyLoad: null\n}\n\nwindow.onload = () => {\n const elements = document.querySelectorAll('.file-size')\n for (let i = 0; i < elements.length; i++)\n elements[i].innerHTML = page.getPrettyBytes(parseInt(elements[i].innerHTML.replace(/\\s*B$/i, '')))\n\n page.lazyLoad = new LazyLoad()\n}\n"]}
{"version":3,"sources":["album.js"],"names":["const","lsKeys","page","lazyLoad","window","addEventListener","elements","document","querySelectorAll","i","length","innerHTML","getPrettyBytes","parseInt","replace","LazyLoad"],"mappings":"AAGAA,IAAMC,OAAS,GAETC,KAAO,CACXC,SAAU,MAGZC,OAAOC,iBAAiB,oBAAkB,WAExC,IADAL,IAAMM,EAAWC,SAASC,iBAAiB,cAClCC,EAAI,EAAGA,EAAIH,EAASI,OAAQD,IACnCH,EAASG,GAAGE,UAAYT,KAAKU,eAAeC,SAASP,EAASG,GAAGE,UAAUG,QAAQ,SAAU,MAE/FZ,KAAKC,SAAW,IAAIY","file":"album.js","sourcesContent":["/* global LazyLoad */\n\n// eslint-disable-next-line no-unused-vars\nconst lsKeys = {}\n\nconst page = {\n lazyLoad: null\n}\n\nwindow.addEventListener('DOMContentLoaded', () => {\n const elements = document.querySelectorAll('.file-size')\n for (let i = 0; i < elements.length; i++)\n elements[i].innerHTML = page.getPrettyBytes(parseInt(elements[i].innerHTML.replace(/\\s*B$/i, '')))\n\n page.lazyLoad = new LazyLoad()\n})\n"]}

2
dist/js/auth.js vendored
View File

@ -1,2 +1,2 @@
var lsKeys={token:"token"},page={token:localStorage[lsKeys.token],user:null,pass:null,unhide:function(){var e=document.querySelector("#loader");e&&e.classList.add("is-hidden");var r=document.querySelector("#login.is-hidden");r&&r.classList.remove("is-hidden");var o=document.querySelector(".floating-home-button.is-hidden");o&&o.classList.remove("is-hidden")},onAxiosError:function(e){console.error(e);var r={520:"Unknown Error",521:"Web Server Is Down",522:"Connection Timed Out",523:"Origin Is Unreachable",524:"A Timeout Occurred",525:"SSL Handshake Failed",526:"Invalid SSL Certificate",527:"Railgun Error",530:"Origin DNS Error"}[e.response.status]||e.response.statusText,o=e.response.data&&e.response.data.description?e.response.data.description:"There was an error with the request, please check the console for more information.";return swal(e.response.status+" "+r,o,"error")},do:function(e,r){var o=page.user.value.trim();if(!o)return swal("An error occurred!","You need to specify a username.","error");var n=page.pass.value.trim();if(!n)return swal("An error occurred!","You need to specify a password.","error");r.classList.add("is-loading"),axios.post("api/"+e,{username:o,password:n}).then((function(o){if(!1===o.data.success)return r.classList.remove("is-loading"),swal("Unable to "+e+"!",o.data.description,"error");localStorage.token=o.data.token,window.location="dashboard"})).catch((function(e){r.classList.remove("is-loading"),page.onAxiosError(e)}))},verify:function(){axios.post("api/tokens/verify",{token:page.token}).then((function(e){if(!1===e.data.success)return page.unhide(),swal("An error occurred!",e.data.description,"error");window.location="dashboard"})).catch((function(e){page.unhide(),page.onAxiosError(e)}))}};window.onload=function(){page.user=document.querySelector("#user"),page.pass=document.querySelector("#pass");var e=document.querySelector("#authForm");e.addEventListener("submit",(function(e){e.preventDefault()}));var r=document.querySelector("#loginBtn");r&&r.addEventListener("click",(function(r){e.checkValidity()&&page.do("login",r.currentTarget)}));var o=document.querySelector("#registerBtn");o&&o.addEventListener("click",(function(r){e.checkValidity()&&page.do("register",r.currentTarget)})),page.token?page.verify():page.unhide()};
var lsKeys={token:"token"},page={token:localStorage[lsKeys.token],user:null,pass:null,unhide:function(){var e=document.querySelector("#loader");e&&e.classList.add("is-hidden");var r=document.querySelector("#login.is-hidden");r&&r.classList.remove("is-hidden");var o=document.querySelector(".floating-home-button.is-hidden");o&&o.classList.remove("is-hidden")},onAxiosError:function(e){console.error(e);var r={520:"Unknown Error",521:"Web Server Is Down",522:"Connection Timed Out",523:"Origin Is Unreachable",524:"A Timeout Occurred",525:"SSL Handshake Failed",526:"Invalid SSL Certificate",527:"Railgun Error",530:"Origin DNS Error"}[e.response.status]||e.response.statusText,o=e.response.data&&e.response.data.description?e.response.data.description:"There was an error with the request, please check the console for more information.";return swal(e.response.status+" "+r,o,"error")},do:function(e,r){var o=page.user.value.trim();if(!o)return swal("An error occurred!","You need to specify a username.","error");var n=page.pass.value.trim();if(!n)return swal("An error occurred!","You need to specify a password.","error");r.classList.add("is-loading"),axios.post("api/"+e,{username:o,password:n}).then((function(o){if(!1===o.data.success)return r.classList.remove("is-loading"),swal("Unable to "+e+"!",o.data.description,"error");localStorage.token=o.data.token,window.location="dashboard"})).catch((function(e){r.classList.remove("is-loading"),page.onAxiosError(e)}))},verify:function(){axios.post("api/tokens/verify",{token:page.token}).then((function(e){if(!1===e.data.success)return page.unhide(),swal("An error occurred!",e.data.description,"error");window.location="dashboard"})).catch((function(e){page.unhide(),page.onAxiosError(e)}))}};window.addEventListener("DOMContentLoaded",(function(){page.user=document.querySelector("#user"),page.pass=document.querySelector("#pass");var e=document.querySelector("#authForm");e.addEventListener("submit",(function(e){e.preventDefault()}));var r=document.querySelector("#loginBtn");r&&r.addEventListener("click",(function(r){e.checkValidity()&&page.do("login",r.currentTarget)}));var o=document.querySelector("#registerBtn");o&&o.addEventListener("click",(function(r){e.checkValidity()&&page.do("register",r.currentTarget)})),page.token?page.verify():page.unhide()}));
//# sourceMappingURL=auth.js.map

2
dist/js/auth.js.map vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2
dist/js/home.js vendored

File diff suppressed because one or more lines are too long

2
dist/js/home.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -1,2 +1,2 @@
lsKeys.render="render",page.renderType="miku",page.renderConfig={al:{name:"ship waifu~",root:"render/al/",array:["admiral_graf_spee_1.png","admiral_hipper_1.png","akagi_1.png","akashi_1.png","akashi_2.png","atago_1.png","atago_3.png","atago_4.png","atago_5.png","belfast_2.png","choukai_1.png","deutschland_1.png","enterprise_1.png","glorious_1.png","hammann_1.png","hammann_2.png","hammann_3.png","hatsuharu_1.png","kaga_1.png","kaga_2.png","kaga_3.png","laffey_1.png","laffey_2.png","laffey_3.png","prinz_eugen_3.png","san_diego_1.png","takao_3.png","unicorn_1.png","unicorn_2.png","unicorn_3.png","unicorn_4.png","unicorn_6.png","unicorn_7.png","unicorn_8.png","yamashiro_1.png","yamashiro_2.png","yamashiro_3.png","yukikaze_1.png"]},miku:{name:"miku ❤️~",root:"render/miku/",array:[]}};for(var i=1;i<=50;i++)page.renderConfig.miku.array.push(("00"+i).slice(-3)+".png");page.config=null,page.render=null,page.doRenderSwal=function(){var e=document.createElement("div");e.innerHTML='\n <div class="field">\n <div class="control">\n <label class="checkbox">\n <input id="swalRender" type="checkbox" '+("0"===localStorage[lsKeys.render]?"":"checked")+">\n Enable random render of "+page.config.name+'\n </label>\n </div>\n <p class="help">If disabled, you will still be able to see a small button on the bottom right corner of the screen to re-enable it.</p>\n </div>\n ',swal({content:e,buttons:{confirm:!0}}).then((function(n){if(n){var a=e.querySelector("#swalRender").checked?void 0:"0";if(a!==localStorage[lsKeys.render])a?localStorage[lsKeys.render]=a:localStorage.removeItem(lsKeys.render),swal("","Random render is now "+(a?"disabled":"enabled")+".","success",{buttons:!1,timer:1500}),document.querySelector("body > .render").remove(),page.doRender()}}))},page.getRenderVersion=function(){var e=document.querySelector("#renderScript");return e&&e.dataset.version?"?v="+e.dataset.version:""},page.doRender=function(){var e;(page.config=page.renderConfig[page.renderType],page.config&&page.config.array.length)&&("0"===localStorage[lsKeys.render]?((e=document.createElement("a")).className="button is-info is-hidden-mobile",e.title=page.config.name,e.innerHTML='<i class="icon-picture"></i>'):(page.render=page.config.array[Math.floor(Math.random()*page.config.array.length)],(e=document.createElement("img")).alt=e.title=page.config.name,e.className="is-hidden-mobile",e.src=""+page.config.root+page.render+page.getRenderVersion()),e.classList.add("render"),e.addEventListener("click",page.doRenderSwal),document.body.appendChild(e))};
for(var render={lsKey:"render",type:"miku",configs:{al:{name:"ship waifu~",root:"render/al/",array:["admiral_graf_spee_1.png","admiral_hipper_1.png","akagi_1.png","akashi_1.png","akashi_2.png","atago_1.png","atago_3.png","atago_4.png","atago_5.png","belfast_2.png","choukai_1.png","deutschland_1.png","enterprise_1.png","glorious_1.png","hammann_1.png","hammann_2.png","hammann_3.png","hatsuharu_1.png","kaga_1.png","kaga_2.png","kaga_3.png","laffey_1.png","laffey_2.png","laffey_3.png","prinz_eugen_3.png","san_diego_1.png","takao_3.png","unicorn_1.png","unicorn_2.png","unicorn_3.png","unicorn_4.png","unicorn_6.png","unicorn_7.png","unicorn_8.png","yamashiro_1.png","yamashiro_2.png","yamashiro_3.png","yukikaze_1.png"]},miku:{name:"miku ❤️~",root:"render/miku/",array:[]}},config:null,selected:null,triggered:!1},i=1;i<=50;i++)render.configs.miku.array.push(("00"+i).slice(-3)+".png");render.showTogglePrompt=function(){var e=!("0"===localStorage[render.lsKey]),n=document.createElement("div");n.innerHTML='\n <div class="field">\n <div class="control">\n <label class="checkbox">\n <input id="swalRender" type="checkbox" '+(e?"checked":"")+">\n Enable random render of "+render.config.name+'\n </label>\n </div>\n <p class="help">If disabled, you will still be able to see a small button on the bottom right corner of the screen to re-enable it.</p>\n </div>\n ';var r={};e&&(r.reload={text:"Nah fam, show me a different render",className:"swal-button--cancel"}),r.confirm=!0,swal({content:n,buttons:r}).then((function(e){if("reload"===e)render.do(!0);else if(e){var r=n.querySelector("#swalRender").checked?void 0:"0";r!==localStorage[render.lsKey]&&(r?localStorage[render.lsKey]=r:localStorage.removeItem(render.lsKey),swal("","Random render is now "+(r?"disabled":"enabled")+".","success",{buttons:!1,timer:1500}),render.do())}}))},render.parseVersion=function(){var e=document.querySelector("#renderScript");return e&&e.dataset.version?"?v="+e.dataset.version:""},render.do=function(e){if(render.triggered||(render.triggered=!0),render.config=render.configs[render.type],render.config&&render.config.array.length){var n=document.querySelector("body > .render");n&&n.remove();var r;e||"0"!==localStorage[render.lsKey]?(void 0===render.version&&(render.version=render.parseVersion()),render.selected=render.config.array[Math.floor(Math.random()*render.config.array.length)],(r=document.createElement("img")).alt=r.title=render.config.name,r.className="is-hidden-mobile",r.src=""+render.config.root+render.selected+render.version):((r=document.createElement("a")).className="button is-info is-hidden-mobile",r.title=render.config.name,r.innerHTML='<i class="icon-picture"></i>'),r.classList.add("render"),r.addEventListener("click",render.showTogglePrompt),document.body.appendChild(r)}},window.addEventListener("DOMContentLoaded",(function(){void 0!==page&&page.apiChecked&&!render.triggered&&render.do()}));
//# sourceMappingURL=render.js.map

File diff suppressed because one or more lines are too long

View File

@ -31,27 +31,47 @@
color: #bdc3c7
}
.swal-button {
background-color: #3794d2;
color: #eff0f1
.swal-button--confirm:not(.swal-button--danger) {
background-color: #209cee
}
.swal-button:hover {
background-color: #1496ed
.swal-button--confirm:not(.swal-button--danger):hover {
background-color: #67c3ff
}
.swal-button:focus {
box-shadow: 0 0 0 1px #030303, 0 0 0 3px rgba(55, 148, 210, 0.29)
.swal-button--confirm:not(.swal-button--danger):focus {
box-shadow: 0 0 0 1px #030303, 0 0 0 3px rgba(32, 156, 238, 0.29)
}
.swal-button--danger {
background-color: #ff3860
}
.swal-button--danger:hover {
background-color: #ff2b56
}
.swal-button--danger:focus {
box-shadow: 0 0 0 1px #030303, 0 0 0 3px rgba(255, 56, 96, 0.29)
}
.swal-button--cancel {
background-color: #00d1b2;
color: #fff
}
.swal-button--cancel:hover {
background-color: #00c4a7
}
.swal-button--cancel:focus {
box-shadow: 0 0 0 1px #030303, 0 0 0 3px rgba(0, 209, 178, 0.29)
}
.swal-button--loading {
color: transparent
}
.swal-button--danger {
background-color: #da4453
}
.swal-icon--info {
border-color: #3794d2
}

View File

@ -7,10 +7,10 @@ const page = {
lazyLoad: null
}
window.onload = () => {
window.addEventListener('DOMContentLoaded', () => {
const elements = document.querySelectorAll('.file-size')
for (let i = 0; i < elements.length; i++)
elements[i].innerHTML = page.getPrettyBytes(parseInt(elements[i].innerHTML.replace(/\s*B$/i, '')))
page.lazyLoad = new LazyLoad()
}
})

View File

@ -96,7 +96,7 @@ page.verify = () => {
})
}
window.onload = () => {
window.addEventListener('DOMContentLoaded', () => {
page.user = document.querySelector('#user')
page.pass = document.querySelector('#pass')
@ -124,4 +124,4 @@ window.onload = () => {
page.verify()
else
page.unhide()
}
})

View File

@ -934,9 +934,9 @@ page.displayPreview = id => {
if (isimage || isvideo) {
div.innerHTML += `
<div class="field has-text-centered">
<div class="field has-text-right">
<div class="controls">
<a id="swalOriginal" type="button" class="button is-info is-outlined is-fullwidth" data-original="${file.file}">
<a id="swalOriginal" type="button" class="button is-info" data-original="${file.file}">
<span class="icon">
<i class="icon-arrows-cw"></i>
</span>
@ -2909,7 +2909,7 @@ page.getStatistics = (params = {}) => {
})
}
window.onload = () => {
window.addEventListener('DOMContentLoaded', () => {
// Polyfill Object.assign()
// eslint-disable-next-line compat/compat
if (typeof Object.assign !== 'function')
@ -2958,4 +2958,4 @@ window.onload = () => {
page.clipboardJS.on('error', page.onError)
page.lazyLoad = new LazyLoad()
}
})

View File

@ -1,4 +1,4 @@
/* global swal, axios, Dropzone, ClipboardJS, LazyLoad */
/* global render, swal, axios, Dropzone, ClipboardJS, LazyLoad */
const lsKeys = {
token: 'token',
@ -16,6 +16,7 @@ const page = {
token: localStorage[lsKeys.token],
// configs from api/check
apiChecked: false,
private: null,
enableUserAccounts: null,
maxSize: null,
@ -154,14 +155,13 @@ page.checkClientVersion = apiVersion => {
}
page.checkIfPublic = () => {
let renderShown = false
return axios.get('api/check', {
onDownloadProgress: () => {
// Only show render after this request has been initiated to avoid blocking
if (!renderShown && typeof page.doRender === 'function') {
page.doRender()
renderShown = true
}
// Only load render after this request has been initiated to avoid blocking
if (render !== undefined && !render.triggered)
render.do()
else if (!page.apiChecked)
page.apiChecked = true
}
}).then(response => {
if (response.data.version)
@ -1092,7 +1092,7 @@ window.addEventListener('paste', event => {
}
})
window.onload = () => {
window.addEventListener('DOMContentLoaded', () => {
if (window.cookieconsent)
window.cookieconsent.initialise({
cookie: {
@ -1141,4 +1141,4 @@ window.onload = () => {
document.querySelector('#createAlbum').addEventListener('click', () => {
page.createAlbum()
})
}
})

View File

@ -1,133 +1,162 @@
/* global lsKeys, page, swal */
/* global page, swal */
// keys for localStorage
lsKeys.render = 'render'
page.renderType = 'miku'
page.renderConfig = {
al: {
name: 'ship waifu~',
root: 'render/al/',
array: [
'admiral_graf_spee_1.png',
'admiral_hipper_1.png',
'akagi_1.png',
'akashi_1.png',
'akashi_2.png',
'atago_1.png',
'atago_3.png',
'atago_4.png',
'atago_5.png',
'belfast_2.png',
'choukai_1.png',
'deutschland_1.png',
'enterprise_1.png',
'glorious_1.png',
'hammann_1.png',
'hammann_2.png',
'hammann_3.png',
'hatsuharu_1.png',
'kaga_1.png',
'kaga_2.png',
'kaga_3.png',
'laffey_1.png',
'laffey_2.png',
'laffey_3.png',
'prinz_eugen_3.png',
'san_diego_1.png',
'takao_3.png',
'unicorn_1.png',
'unicorn_2.png',
'unicorn_3.png',
'unicorn_4.png',
'unicorn_6.png',
'unicorn_7.png',
'unicorn_8.png',
'yamashiro_1.png',
'yamashiro_2.png',
'yamashiro_3.png',
'yukikaze_1.png'
]
const render = {
lsKey: 'render',
type: 'miku', // This is intended to be hard-coded
configs: {
al: {
name: 'ship waifu~',
root: 'render/al/',
array: [
'admiral_graf_spee_1.png',
'admiral_hipper_1.png',
'akagi_1.png',
'akashi_1.png',
'akashi_2.png',
'atago_1.png',
'atago_3.png',
'atago_4.png',
'atago_5.png',
'belfast_2.png',
'choukai_1.png',
'deutschland_1.png',
'enterprise_1.png',
'glorious_1.png',
'hammann_1.png',
'hammann_2.png',
'hammann_3.png',
'hatsuharu_1.png',
'kaga_1.png',
'kaga_2.png',
'kaga_3.png',
'laffey_1.png',
'laffey_2.png',
'laffey_3.png',
'prinz_eugen_3.png',
'san_diego_1.png',
'takao_3.png',
'unicorn_1.png',
'unicorn_2.png',
'unicorn_3.png',
'unicorn_4.png',
'unicorn_6.png',
'unicorn_7.png',
'unicorn_8.png',
'yamashiro_1.png',
'yamashiro_2.png',
'yamashiro_3.png',
'yukikaze_1.png'
]
},
miku: {
name: 'miku ❤️~',
root: 'render/miku/',
array: []
}
},
miku: {
name: 'miku ❤️~',
root: 'render/miku/',
array: []
}
config: null,
selected: null,
triggered: false
}
// miku: Generate an array of file names from 001.png to 050.png
for (let i = 1; i <= 50; i++)
page.renderConfig.miku.array.push(`${('00' + i).slice(-3)}.png`)
render.configs.miku.array.push(`${('00' + i).slice(-3)}.png`)
page.config = null
page.render = null
page.doRenderSwal = () => {
render.showTogglePrompt = () => {
const renderEnabled = !(localStorage[render.lsKey] === '0')
const div = document.createElement('div')
div.innerHTML = `
<div class="field">
<div class="control">
<label class="checkbox">
<input id="swalRender" type="checkbox" ${localStorage[lsKeys.render] === '0' ? '' : 'checked'}>
Enable random render of ${page.config.name}
<input id="swalRender" type="checkbox" ${renderEnabled ? 'checked' : ''}>
Enable random render of ${render.config.name}
</label>
</div>
<p class="help">If disabled, you will still be able to see a small button on the bottom right corner of the screen to re-enable it.</p>
</div>
`
const buttons = {}
if (renderEnabled)
buttons.reload = {
text: 'Nah fam, show me a different render',
className: 'swal-button--cancel'
}
buttons.confirm = true
swal({
content: div,
buttons: {
confirm: true
}
buttons
}).then(value => {
if (!value) return
const newValue = div.querySelector('#swalRender').checked ? undefined : '0'
if (newValue !== localStorage[lsKeys.render]) {
if (newValue)
localStorage[lsKeys.render] = newValue
else
localStorage.removeItem(lsKeys.render)
swal('', `Random render is now ${newValue ? 'disabled' : 'enabled'}.`, 'success', {
buttons: false,
timer: 1500
})
const element = document.querySelector('body > .render')
element.remove()
page.doRender()
if (value === 'reload') {
render.do(true)
} else if (value) {
const newValue = div.querySelector('#swalRender').checked ? undefined : '0'
if (newValue !== localStorage[render.lsKey]) {
if (newValue)
localStorage[render.lsKey] = newValue
else
localStorage.removeItem(render.lsKey)
swal('', `Random render is now ${newValue ? 'disabled' : 'enabled'}.`, 'success', {
buttons: false,
timer: 1500
})
render.do()
}
}
})
}
page.getRenderVersion = () => {
render.parseVersion = () => {
const renderScript = document.querySelector('#renderScript')
if (renderScript && renderScript.dataset.version)
return `?v=${renderScript.dataset.version}`
return ''
}
page.doRender = () => {
page.config = page.renderConfig[page.renderType]
if (!page.config || !page.config.array.length) return
render.do = reload => {
if (!render.triggered)
render.triggered = true
render.config = render.configs[render.type]
if (!render.config || !render.config.array.length) return
const previousElement = document.querySelector('body > .render')
if (previousElement)
previousElement.remove()
const doRender = () => {
if (render.version === undefined)
render.version = render.parseVersion()
// Let us just allow people to get new render when toggling the option
render.selected = render.config.array[Math.floor(Math.random() * render.config.array.length)]
element = document.createElement('img')
element.alt = element.title = render.config.name
element.className = 'is-hidden-mobile'
element.src = `${render.config.root}${render.selected}${render.version}`
}
let element
if (localStorage[lsKeys.render] === '0') {
if (!reload && localStorage[render.lsKey] === '0') {
element = document.createElement('a')
element.className = 'button is-info is-hidden-mobile'
element.title = page.config.name
element.title = render.config.name
element.innerHTML = '<i class="icon-picture"></i>'
} else {
// Let us just allow people to get new render when toggling the option
page.render = page.config.array[Math.floor(Math.random() * page.config.array.length)]
element = document.createElement('img')
element.alt = element.title = page.config.name
element.className = 'is-hidden-mobile'
element.src = `${page.config.root}${page.render}${page.getRenderVersion()}`
doRender()
}
element.classList.add('render')
element.addEventListener('click', page.doRenderSwal)
element.addEventListener('click', render.showTogglePrompt)
document.body.appendChild(element)
}
window.addEventListener('DOMContentLoaded', () => {
// If the main script had already done its API check, yet render haven't been triggered, do it
// This would only happen if this render script only gets loaded after the main script's API check
if (page !== undefined && page.apiChecked && !render.triggered)
render.do()
})

View File

@ -1,5 +1,5 @@
{
"1": "1592591301",
"1": "1592594865",
"2": "1589010026",
"3": "1581416390",
"4": "1581416390",