diff --git a/dist/js/auth.js b/dist/js/auth.js index ed65e9763..db493d2fd 100644 --- a/dist/js/auth.js +++ b/dist/js/auth.js @@ -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.\nPlease 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(o){if(!e.checkValidity())return r.click();page.do("register",o.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.\nPlease 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){e.response.data&&10001===e.response.data.code&&localStorage.removeItem(lsKeys.token),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(o){if(!e.checkValidity())return r.click();page.do("register",o.currentTarget)})),page.token?page.verify():page.unhide()})); //# sourceMappingURL=auth.js.map diff --git a/dist/js/auth.js.map b/dist/js/auth.js.map index 06e6fc61a..a1185bb67 100644 --- a/dist/js/auth.js.map +++ b/dist/js/auth.js.map @@ -1 +1 @@ -{"version":3,"sources":["auth.js"],"names":["const","lsKeys","token","page","localStorage","user","pass","loaderSection","document","querySelector","classList","add","loginSection","remove","floatingBtn","error","console","statusText","response","status","description","data","swal","dest","trigger","value","trim","axios","post","username","password","then","success","window","location","catch","onAxiosError","unhide","addEventListener","form","event","preventDefault","loginBtn","checkValidity","do","currentTarget","registerBtn","click","verify"],"mappings":"AAEAA,IAAMC,OAAS,CACbC,MAAO,SAGHC,KAAO,CAEXD,MAAOE,aAAaH,OAAOC,OAG3BG,KAAM,KACNC,KAAM,KAGRH,OAAW,WACTH,IAAMO,EAAgBC,SAASC,cAAc,WACzCF,GAAeA,EAAcG,UAAUC,IAAI,aAE/CX,IAAMY,EAAeJ,SAASC,cAAc,oBACxCG,GAAcA,EAAaF,UAAUG,OAAO,aAEhDb,IAAMc,EAAcN,SAASC,cAAc,mCACvCK,GAAaA,EAAYJ,UAAUG,OAAO,cAIhDV,aAAiB,SAAGY,GAClBC,QAAQD,MAAMA,GAGdf,IAYMiB,EAZmB,CACvB,IAAK,gBACL,IAAK,qBACL,IAAK,uBACL,IAAK,wBACL,IAAK,qBACL,IAAK,uBACL,IAAK,0BACL,IAAK,gBACL,IAAK,oBAG6BF,EAAMG,SAASC,SAAWJ,EAAMG,SAASD,WACvEG,EAAcL,EAAMG,SAASG,MAAQN,EAAMG,SAASG,KAAKD,YAC3DL,EAAMG,SAASG,KAAKD,YACpB,uFAEJ,OAAOE,KAAQP,EAAMG,SAAS,OAAM,IAAID,EAAcG,EAAa,UAGrEjB,GAAO,SAAIoB,EAAMC,GACfxB,IAAMK,EAAOF,KAAKE,KAAKoB,MAAMC,OAC7B,IAAKrB,EAAM,OAAOiB,KAAK,qBAAsB,kCAAmC,SAEhFtB,IAAMM,EAAOH,KAAKG,KAAKmB,MAAMC,OA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ourcesContent":["/* global swal, axios */\n\nconst lsKeys = {\n token: 'token'\n}\n\nconst page = {\n // user token\n token: localStorage[lsKeys.token],\n\n // HTML elements\n user: null,\n pass: null\n}\n\npage.unhide = () => {\n const loaderSection = document.querySelector('#loader')\n if (loaderSection) loaderSection.classList.add('is-hidden')\n\n const loginSection = document.querySelector('#login.is-hidden')\n if (loginSection) loginSection.classList.remove('is-hidden')\n\n const floatingBtn = document.querySelector('.floating-home-button.is-hidden')\n if (floatingBtn) floatingBtn.classList.remove('is-hidden')\n}\n\n// Handler for Axios errors\npage.onAxiosError = error => {\n console.error(error)\n\n // Better Cloudflare errors\n const cloudflareErrors = {\n 520: 'Unknown Error',\n 521: 'Web Server Is Down',\n 522: 'Connection Timed Out',\n 523: 'Origin Is Unreachable',\n 524: 'A Timeout Occurred',\n 525: 'SSL Handshake Failed',\n 526: 'Invalid SSL Certificate',\n 527: 'Railgun Error',\n 530: 'Origin DNS Error'\n }\n\n const statusText = cloudflareErrors[error.response.status] || error.response.statusText\n const description = error.response.data && error.response.data.description\n ? error.response.data.description\n : 'There was an error with the request.\\nPlease check the console for more information.'\n\n return swal(`${error.response.status} ${statusText}`, description, 'error')\n}\n\npage.do = (dest, trigger) => {\n const user = page.user.value.trim()\n if (!user) return swal('An error occurred!', 'You need to specify a username.', 'error')\n\n const pass = page.pass.value.trim()\n if (!pass) return swal('An error occurred!', 'You need to specify a password.', 'error')\n\n trigger.classList.add('is-loading')\n axios.post(`api/${dest}`, {\n username: user,\n password: pass\n }).then(response => {\n if (response.data.success === false) {\n trigger.classList.remove('is-loading')\n return swal(`Unable to ${dest}!`, response.data.description, 'error')\n }\n\n localStorage.token = response.data.token\n window.location = 'dashboard'\n }).catch(error => {\n trigger.classList.remove('is-loading')\n page.onAxiosError(error)\n })\n}\n\npage.verify = () => {\n axios.post('api/tokens/verify', {\n token: page.token\n }).then(response => {\n if (response.data.success === false) {\n page.unhide()\n return swal('An error occurred!', response.data.description, 'error')\n }\n\n // Redirect to dashboard if token is valid\n window.location = 'dashboard'\n }).catch(error => {\n page.unhide()\n page.onAxiosError(error)\n })\n}\n\nwindow.addEventListener('DOMContentLoaded', () => {\n page.user = document.querySelector('#user')\n page.pass = document.querySelector('#pass')\n\n // Prevent default form's submit action\n const form = document.querySelector('#authForm')\n form.addEventListener('submit', event => {\n event.preventDefault()\n })\n\n const loginBtn = document.querySelector('#loginBtn')\n if (loginBtn) {\n loginBtn.addEventListener('click', event => {\n if (!form.checkValidity()) return\n page.do('login', event.currentTarget)\n })\n }\n\n const registerBtn = document.querySelector('#registerBtn')\n if (registerBtn) {\n registerBtn.addEventListener('click', event => {\n if (!form.checkValidity()) {\n // Workaround for browsers to display native form error messages\n return loginBtn.click()\n }\n page.do('register', event.currentTarget)\n })\n }\n\n if (page.token) page.verify()\n else page.unhide()\n})\n"]} \ No newline at end of file +{"version":3,"sources":["auth.js"],"names":["const","lsKeys","token","page","localStorage","user","pass","loaderSection","document","querySelector","classList","add","loginSection","remove","floatingBtn","error","console","statusText","response","status","description","data","swal","dest","trigger","value","trim","axios","post","username","password","then","success","window","location","catch","onAxiosError","unhide","code","removeItem","addEventListener","form","event","preventDefault","loginBtn","checkValidity","do","currentTarget","registerBtn","click","verify"],"mappings":"AAEAA,IAAMC,OAAS,CACbC,MAAO,SAGHC,KAAO,CAEXD,MAAOE,aAAaH,OAAOC,OAG3BG,KAAM,KACNC,KAAM,KAGRH,OAAW,WACTH,IAAMO,EAAgBC,SAASC,cAAc,WACzCF,GAAeA,EAAcG,UAAUC,IAAI,aAE/CX,IAAMY,EAAeJ,SAASC,cAAc,oBACxCG,GAAcA,EAAaF,UAAUG,OAAO,aAEhDb,IAAMc,EAAcN,SAASC,cAAc,mCACvCK,GAAaA,EAAYJ,UAAUG,OAAO,cAIhDV,aAAiB,SAAGY,GAClBC,QAAQD,MAAMA,GAGdf,IAYMiB,EAZmB,CACvB,IAAK,gBACL,IAAK,qBACL,IAAK,uBACL,IAAK,wBACL,IAAK,qBACL,IAAK,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KAAOG,SAASC,cAAc,SACnCN,KAAKG,KAAOE,SAASC,cAAc,SAGnCT,IAAMyC,EAAOjC,SAASC,cAAc,aACpCgC,EAAKD,iBAAiB,UAAQ,SAAEE,GAC9BA,EAAMC,oBAGR3C,IAAM4C,EAAWpC,SAASC,cAAc,aACpCmC,GACFA,EAASJ,iBAAiB,SAAO,SAAEE,GAC5BD,EAAKI,iBACV1C,KAAK2C,GAAG,QAASJ,EAAMK,kBAI3B/C,IAAMgD,EAAcxC,SAASC,cAAc,gBACvCuC,GACFA,EAAYR,iBAAiB,SAAO,SAAEE,GACpC,IAAKD,EAAKI,gBAER,OAAOD,EAASK,QAElB9C,KAAK2C,GAAG,WAAYJ,EAAMK,kBAI1B5C,KAAKD,MAAOC,KAAK+C,SAChB/C,KAAKkC","file":"auth.js","sourcesContent":["/* global swal, axios */\n\nconst lsKeys = {\n token: 'token'\n}\n\nconst page = {\n // user token\n token: localStorage[lsKeys.token],\n\n // HTML elements\n user: null,\n pass: null\n}\n\npage.unhide = () => {\n const loaderSection = document.querySelector('#loader')\n if (loaderSection) loaderSection.classList.add('is-hidden')\n\n const loginSection = document.querySelector('#login.is-hidden')\n if (loginSection) loginSection.classList.remove('is-hidden')\n\n const floatingBtn = document.querySelector('.floating-home-button.is-hidden')\n if (floatingBtn) floatingBtn.classList.remove('is-hidden')\n}\n\n// Handler for Axios errors\npage.onAxiosError = error => {\n console.error(error)\n\n // Better Cloudflare errors\n const cloudflareErrors = {\n 520: 'Unknown Error',\n 521: 'Web Server Is Down',\n 522: 'Connection Timed Out',\n 523: 'Origin Is Unreachable',\n 524: 'A Timeout Occurred',\n 525: 'SSL Handshake Failed',\n 526: 'Invalid SSL Certificate',\n 527: 'Railgun Error',\n 530: 'Origin DNS Error'\n }\n\n const statusText = cloudflareErrors[error.response.status] || error.response.statusText\n const description = error.response.data && error.response.data.description\n ? error.response.data.description\n : 'There was an error with the request.\\nPlease check the console for more information.'\n\n return swal(`${error.response.status} ${statusText}`, description, 'error')\n}\n\npage.do = (dest, trigger) => {\n const user = page.user.value.trim()\n if (!user) return swal('An error occurred!', 'You need to specify a username.', 'error')\n\n const pass = page.pass.value.trim()\n if (!pass) return swal('An error occurred!', 'You need to specify a password.', 'error')\n\n trigger.classList.add('is-loading')\n axios.post(`api/${dest}`, {\n username: user,\n password: pass\n }).then(response => {\n if (response.data.success === false) {\n trigger.classList.remove('is-loading')\n return swal(`Unable to ${dest}!`, response.data.description, 'error')\n }\n\n localStorage.token = response.data.token\n window.location = 'dashboard'\n }).catch(error => {\n trigger.classList.remove('is-loading')\n page.onAxiosError(error)\n })\n}\n\npage.verify = () => {\n axios.post('api/tokens/verify', {\n token: page.token\n }).then(response => {\n if (response.data.success === false) {\n page.unhide()\n return swal('An error occurred!', response.data.description, 'error')\n }\n\n // Redirect to dashboard if token is valid\n window.location = 'dashboard'\n }).catch(error => {\n if (error.response.data && error.response.data.code === 10001) {\n localStorage.removeItem(lsKeys.token)\n }\n page.unhide()\n page.onAxiosError(error)\n })\n}\n\nwindow.addEventListener('DOMContentLoaded', () => {\n page.user = document.querySelector('#user')\n page.pass = document.querySelector('#pass')\n\n // Prevent default form's submit action\n const form = document.querySelector('#authForm')\n form.addEventListener('submit', event => {\n event.preventDefault()\n })\n\n const loginBtn = document.querySelector('#loginBtn')\n if (loginBtn) {\n loginBtn.addEventListener('click', event => {\n if (!form.checkValidity()) return\n page.do('login', event.currentTarget)\n })\n }\n\n const registerBtn = document.querySelector('#registerBtn')\n if (registerBtn) {\n registerBtn.addEventListener('click', event => {\n if (!form.checkValidity()) {\n // Workaround for browsers to display native form error messages\n return loginBtn.click()\n }\n page.do('register', event.currentTarget)\n })\n }\n\n if (page.token) page.verify()\n else page.unhide()\n})\n"]} \ No newline at end of file diff --git a/dist/js/dashboard.js b/dist/js/dashboard.js index 752cccbe3..805385e1f 100644 --- a/dist/js/dashboard.js +++ b/dist/js/dashboard.js @@ -1,2 +1,2 @@ -var lsKeys={token:"token",viewType:{uploads:"viewTypeUploads",uploadsAll:"viewTypeUploadsAll"},selected:{uploads:"selectedUploads",uploadsAll:"selectedUploadsAll",albums:"selectedAlbums",albumsAll:"selectedAlbumsAll",users:"selectedUsers"},originalNames:{uploads:"originalNames",uploadsAll:"originalNamesAll"}},page={section:null,dom:null,token:localStorage[lsKeys.token],username:null,permissions:null,menusContainer:null,menus:[],currentView:null,views:{uploads:{type:localStorage[lsKeys.viewType.uploads],originalNames:"1"===localStorage[lsKeys.originalNames.uploads],album:null,pageNum:null},uploadsAll:{type:localStorage[lsKeys.viewType.uploadsAll],originalNames:"1"===localStorage[lsKeys.originalNames.uploadsAll],filters:null,pageNum:null,all:!0},albums:{filters:null,pageNum:null},albumsAll:{filters:null,pageNum:null,all:!0},users:{filters:null,pageNum:null}},prevPageNums:{uploads:null,uploadsAll:null,albums:null,albumsAll:null,users:null},selected:{uploads:[],uploadsAll:[],albums:[],albumsAll:[],users:[]},checkboxes:[],lastSelected:[],selectAlbumContainer:null,cache:{},clipboardJS:null,lazyLoad:null,albumsSidebarCollapse:null,albumsSidebarCollapsible:null,imageExts:[".gif",".jpeg",".jpg",".png",".svg",".tif",".tiff",".webp"],videoExts:[".3g2",".3gp",".asf",".avchd",".avi",".divx",".evo",".flv",".h264",".h265",".hevc",".m2p",".m2ts",".m4v",".mk3d",".mkv",".mov",".mp4",".mpeg",".mpg",".mxf",".ogg",".ogv",".ps",".qt",".rmvb",".ts",".vob",".webm",".wmv"],audioExts:[".flac",".mp3",".wav",".wma"],isSomethingLoading:!1,fadingIn:null,albumTitleMaxLength:70,albumDescMaxLength:4e3,unhide:function(){document.querySelector("#loader").classList.add("is-hidden"),page.section.classList.remove("is-hidden")},onError:function(e){console.error(e);var a=document.createElement("div");return a.innerHTML="\n

"+e.toString()+"

\n

Please check your console for more information.

\n ",swal({title:"An error occurred!",icon:"error",content:a})},onAxiosError:function(e){console.error(e);var a={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,t=e.response.data&&e.response.data.description?e.response.data.description:"There was an error with the request.\nPlease check the console for more information.";return swal(e.response.status+" "+a,t,"error")},preparePage:function(){page.token?page.verifyToken(page.token,!0):window.location="auth"},checkClientVersion:function(e){var a=document.querySelector("#mainScript").src.match(/\?_=(\d+)$/);if(a&&a[1]&&a[1]!==e)return swal({title:"Update detected!",text:"Client assets have been updated. Reload to display the latest version?",icon:"info",buttons:{confirm:{text:"Reload",closeModal:!1}}}).then((function(){window.location.reload()}))},verifyToken:function(e,a){axios.post("api/tokens/verify",{token:e}).then((function(t){if(!1===t.data.success)return swal({title:"An error occurred!",text:t.data.description,icon:"error"}).then((function(){a&&(localStorage.removeItem(lsKeys.token),window.location="auth")}));axios.defaults.headers.common.token=e,localStorage[lsKeys.token]=e,t.data.version&&page.checkClientVersion(t.data.version),page.token=e,page.username=t.data.username,page.permissions=t.data.permissions,page.prepareDashboard()})).catch(page.onAxiosError)},prepareDashboard:function(){page.section=document.querySelector("#dashboard"),page.dom=page.section.querySelector("#page"),page.dom.addEventListener("click",page.domClick,!0),page.dom.addEventListener("submit",(function(e){if(e.target&&e.target.classList.contains("prevent-default"))return e.preventDefault()}),!0),page.menusContainer=document.querySelector("#menu");for(var e=[{selector:"#itemUploads",onclick:page.getUploads},{selector:"#itemDeleteUploadsByNames",onclick:page.deleteUploadsByNames},{selector:"#itemManageYourAlbums",onclick:page.getAlbums},{selector:"#itemManageToken",onclick:page.changeToken},{selector:"#itemChangePassword",onclick:page.changePassword},{selector:"#itemLogout",onclick:page.logout},{selector:"#itemManageUploads",onclick:page.getUploads,params:{all:!0},group:"moderator"},{selector:"#itemManageAlbums",onclick:page.getAlbums,params:{all:!0},group:"moderator"},{selector:"#itemStatistics",onclick:page.getStatistics,group:"admin"},{selector:"#itemManageUsers",onclick:page.getUsers,group:"admin"}],a=function(a){if(!e[a].group||page.permissions[e[a].group]){var t=document.querySelector(e[a].selector);t.addEventListener("click",(function(t){if(page.isSomethingLoading)return page.warnSomethingLoading();e[a].onclick.call(null,Object.assign(e[a].params||{},{trigger:t.currentTarget,forceScroll:!0}))})),t.classList.remove("is-hidden"),page.menus.push(t)}},t=0;t\n '+('\n
\n
\n
\n
\n \n
\n
\n \n
\n
\n \n
\n
\n
\n
\n ')+'\n
\n
\n
\n
\n \n
\n
\n \n
\n
\n
\n
\n \n ',d='\n
\n \n \n \n
\n ',c=r.replace(/id="filters"/,'id="bFilters"').replace(/(data-action="filter-uploads")/,'$1 data-filtersid="bFilters"').replace(/id="jumpToPage"/,'id="bJumpToPage"').replace(/(data-action="jump-to-page")/g,'$1 data-jumpid="bJumpToPage"'),p=o.replace(/(data-action="page-ellipsis")/g,'$1 data-jumpid="bJumpToPage"'),u=!1,g=page.views[page.currentView].originalNames,m=n.some((function(e){return void 0!==e.expirydate})),b=0;b\n \n '+d+"\n "+c+"\n "+p+"\n ";for(var v=document.querySelector("#table"),f=0;f'+w.name+'':y.innerHTML='

'+(w.extname||"N/A")+"

",y.innerHTML+='\n \n
\n '+(w.previewable?'\n \n \n \n ':"")+'\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n
\n

'+w.name+"

\n "+(g?'

'+w.original+"

":"")+'\n

'+(w.appendix?""+w.appendix+" – ":"")+w.prettyBytes+"

\n "+(m&&w.prettyExpiryDate?'

EXP: "+w.prettyExpiryDate+"

":"")+"\n
\n ",v.appendChild(y),page.checkboxes=v.querySelectorAll('.checkbox[data-action="select"]')}}else{var k=e.all&&e.filters&&e.filters.includes("albumid:");page.dom.innerHTML="\n "+o+"\n "+r+"\n "+d+'\n
\n \n \n \n \n \n '+(g?'':"")+"\n "+(void 0===e.album?'":"")+"\n "+(k?'':"")+'\n \n '+(e.all?'':"")+'\n \n '+(m?'':"")+'\n \n \n \n \n \n
File nameOriginal nameUser':'albumid">Album')+"AlbumSizeIPUpload dateExpiry date('+a.data.count+' total)
\n
\n '+d+"\n "+c+"\n "+p+"\n ";for(var x=document.querySelector("#table"),S=0;S\n '+T.name+"\n "+(g?''+T.original+"":"")+"\n "+(void 0===e.album?''+T.appendix+"":"")+"\n "+(k?''+(T.albumid&&s[T.albumid]||"")+"":"")+'\n '+T.prettyBytes+"\n "+(e.all?''+(T.ip||"")+"":"")+'\n '+T.prettyDate+"\n "+(m?'"+(T.prettyExpiryDate||"-")+"":"")+'\n \n \n \n \n \n \n \n \n \n \n \n '+(e.all?"":'\n \n \n \n ')+'\n \n \n \n \n \n \n ',x.appendChild(A),page.checkboxes=x.querySelectorAll('.checkbox[data-action="select"]')}}var N=document.querySelector("#selectAll");N&&!u&&n.length&&(N.checked=!0,N.title="Unselect all"),page.fadeInDom();var L=n.length?e.pageNum:0;if(e.forceScroll||null===page.prevPageNums[page.currentView]||page.prevPageNums[page.currentView]!==L){var V=!e.forceScroll&&"thumbs"===page.views[page.currentView].type;page.scrollToDom(V)}"thumbs"===page.views[page.currentView].type&&page.lazyLoad.update(),page.updateTrigger(e.trigger,"active"),"uploads"===page.currentView&&(page.views.uploads.album=e.album),page.views[page.currentView].filters=e.filters,page.views[page.currentView].pageNum=page.prevPageNums[page.currentView]=L})).catch((function(a){page.updateTrigger(e.trigger),page.onAxiosError(a)}))},setUploadsView:function(e,a){if(page.isSomethingLoading)return page.warnSomethingLoading();"list"===e?(delete localStorage[lsKeys.viewType[page.currentView]],page.views[page.currentView].type=void 0):(localStorage[lsKeys.viewType[page.currentView]]=e,page.views[page.currentView].type=e),page.getUploads(Object.assign(page.views[page.currentView],{trigger:a}))},toggleOriginalNames:function(e){if(page.isSomethingLoading)return page.warnSomethingLoading();page.views[page.currentView].originalNames?(delete localStorage[lsKeys.originalNames[page.currentView]],page.views[page.currentView].originalNames=!1):(localStorage[lsKeys.originalNames[page.currentView]]="1",page.views[page.currentView].originalNames=!0),page.getUploads(Object.assign(page.views[page.currentView],{trigger:e}))},displayPreview:function(e){var a=page.cache[e];if(a.previewable){var t=document.createElement("div");if(t.innerHTML='\n
\n

\n

'+a.name+"
\n
"+a.original+"
\n

\n "+(a.thumb?'

\n \n

':"")+"\n
\n ",a.file&&["picture","video","audio"].includes(a.type))if(t.innerHTML+='\n \n ","picture"===a.type)t.querySelector("#swalOriginal").addEventListener("click",(function(e){var n=e.currentTarget;if(!n.classList.contains("is-danger")){n.classList.add("is-loading");var s=t.querySelector("#swalThumb");s.src=a.file,s.onload=function(){n.classList.add("is-hidden"),document.body.querySelector(".swal-overlay .swal-modal:not(.is-expanded)").classList.add("is-expanded")},s.onerror=function(e){e.currentTarget.classList.add("is-hidden"),n.className="button is-danger is-fullwidth",n.innerHTML='\n \n \n \n Unable to load original\n '}}}));else{var n=a.file.match(/.*\/(.*)$/);(n||n[1])&&(t.querySelector("#swalOriginal").setAttribute("href","v/"+n[1]),t.querySelector("#swalOriginal").setAttribute("target","_blank"))}return swal({content:t,buttons:!1}).then((function(){document.body.querySelector(".swal-overlay .swal-modal").classList.remove("is-expanded")}))}},selectAll:function(e){for(var a=0;an&&s>n&&st&&suser (username) and ip.\n These keys can be specified more than once.\n For usernames with whitespaces, wrap them with double quotes (\").\n Special cases such as uploads by non-registered users or have no IPs respectively, use user:- or ip:-.\n\n To exclude certain users/ips while still listing every other uploads, add negation sign (-) before the keys.\n Negation sign can also be used to exclude the special cases mentioned above (i.e. -user:- or -ip:-).\n\n If you know the ID of a user's album, you can list its uploads with albumid key.\n Negation sign works for this key as well.":"There is only 1 filter key, namely albumid.\n This key can be specified more than once.\n Special case such as uploads with no albums, use albumid:-.\n\n To exclude certain albums while still listing every other uploads, add negation sign (-) before the keys.\n Negation sign can also be used to exclude the special case mentioned above (i.e. -albumid:-).")+'\n\n There are 2 range keys: date (upload date) and expiry (expiry date).\n Their format is: "YYYY/MM/DD HH:MM:SS-YYYY/MM/DD HH:MM:SS" ("from" date and "to" date respectively).\n You may specify only one of the dates.\n If "to" date is missing, \'now\' will be used. If "from" date is missing, \'beginning of time\' will be used.\n If any of the subsequent date or time units are not specified, their first value will be used (e.g. January for month, 1 for day, and so on).\n If only time is specified, today\'s date will be used.\n If you do not need to specify both date and time, you may omit the double quotes.\n In conclusion, the following examples are all valid: date:"2020/01/01 01:23-2018/01/01 06", expiry:-2020/05, date:12:34:56.\n These keys can only be specified once each.\n\n Timezone? Feel free to query the dates with your own timezone.\n API requests to the filter endpoint will attach your browser\'s timezone offset, so the server will automatically calculate timezone differences.\n\n Matches can also be sorted with sort keys.\n Their formats are: sort:columnName[:d[escending]], where :d[escending] is an optional tag to set the direction to descending.\n This key must be used with internal column names used in the database (id, '+(a?"userid":"albumid")+", and so on),\n but there are 2 shortcuts available: date for timestamp column and expiry for expirydate column.\n This key can also be specified more than once, where their order will decide the sorting steps.\n\n Finally, there are type-is keys to refine by types.\n You can use is:image, is:video, and is:audio to list images, videos, audios respectively.\n This will only use image, video and audio extensions that are whitelisted internally in the safe.\n For images and videos specifically, they will be the ones whose thumbnails can be generated by the safe.\n Negation sign works for this key as well.\n Mixing inclusion and exclusion is not allowed (i.e. is:image -is:video, since the second key is redundant).\n\n Any leftover keywords which do not use keys (non-keyed keywords) will be matched against the matches' file names.\n Excluding certain keywords is also supported by adding negation sign before the keywords.\n\n Internal steps:\n "+(a?"- Query uploads passing ALL exclusion filter keys OR matching ANY filter keys, if any.\n - Refine matches":"- Filter uploads")+" using date key, if any.\n - Refine matches using expiry key, if any.\n - Refine matches using type-is keys, if any.\n - Refine matches using ANY non-keyed keywords, if any.\n - Filter matches using ALL exclusion non-keyed keywords, if any.\n - Sort matches using sorting keys, if any.\n\n Examples:\n "+(a?'- Uploads from users named "demo" AND/OR "John Doe" AND/OR non-registered users:\n user:demo user:"John Doe" user:-\n - ALL uploads, but NOT the ones from user named "demo" AND "John Doe":\n -user:demo -user:"John Doe"\n - Uploads from IP "127.0.0.1" AND which file names match "*.rar" OR "*.zip":\n ip:127.0.0.1 *.rar *.zip\n ':"")+'- Uploads without albums:\n albumid:-\n - ALL uploads, but NOT the ones from album with ID 69:\n -albumid:69\n - Uploads uploaded since "1 June 2019 00:00:00":\n date:2019/06\n - Uploads uploaded between "7 April 2020 12:00:00" and "7 April 2020 23:59:59":\n date:"2020/04/07 12-2020/04/07 23:59:59"\n - Uploads uploaded before "5 February 2020 00:00:00":\n date:-2020/02/05\n - Uploads which file names match "*.gz" but NOT "*.tar.gz":\n *.gz -*.tar.gz\n - Sort matches by "size" column in ascending and descending order respectively:\n '+(a?'user:"John Doe"':"*.txt")+" sort:size\n *.mp4 "+(a?"user:- ":"")+"sort:size:d\n "+(page.permissions.moderator?"":"Notice: Regular users may face some limitations in the amount of keys that can be used at a time.")+"\n Friendly reminder: This window can be scrolled up!\n ").trim().replace(/^\s*/g,"").replace(/\n/g,"
"),swal({content:t}).then((function(){document.body.querySelector(".swal-overlay .swal-modal").classList.remove("is-expanded")})),document.body.querySelector(".swal-overlay .swal-modal:not(.is-expanded)").classList.add("is-expanded")},filterUploads:function(e){var a=document.querySelector("#"+(e.dataset.filtersid||"filters")).value.trim().replace(/\t/g," ").replace(/(^|\s)((albumid|ip|user|date|expiry|is|sort|orderby):)\s+/g,"$2");page.getUploads(Object.assign(page.views[page.currentView],{filters:a,pageNum:0,trigger:e}))},viewUserUploads:function(e,a){var t=page.cache[e];if(t){a.classList.add("is-loading");var n=t.username.includes(" ")?'"'+t.username+'"':t.username;page.getUploads({all:!0,filters:"user:"+n,trigger:document.querySelector("#itemManageUploads")})}},viewAlbumUploads:function(e,a){if(page.cache[e]){a.classList.add("is-loading");var t="albumsAll"===page.currentView&&page.permissions.moderator;page.getUploads({all:t,filters:"albumid:"+e,trigger:t?document.querySelector("#itemManageUploads"):document.querySelector("#itemUploads")})}},deleteUpload:function(e){page.postBulkDeleteUploads({all:"uploadsAll"===page.currentView,field:"id",values:[e],cb:function(a){!a.length&&page.selected[page.currentView].includes(e)&&page.selected[page.currentView].splice(page.selected[page.currentView].indexOf(e),1),page.selected[page.currentView].length?localStorage[lsKeys.selected[page.currentView]]=JSON.stringify(page.selected[page.currentView]):delete localStorage[lsKeys.selected[page.currentView]],page.getUploads(Object.assign(page.views[page.currentView],{autoPage:!0}))}})},bulkDeleteUploads:function(){if(!page.selected[page.currentView].length)return swal("An error occurred!","You have not selected any uploads.","error");page.postBulkDeleteUploads({all:"uploadsAll"===page.currentView,field:"id",values:page.selected[page.currentView],cb:function(e){e.length?page.selected[page.currentView]=page.selected[page.currentView].filter((function(a){return e.includes(a)})):page.selected[page.currentView]=[],page.selected[page.currentView].length?localStorage[lsKeys.selected[page.currentView]]=JSON.stringify(page.selected[page.currentView]):delete localStorage[lsKeys.selected[page.currentView]],page.getUploads(Object.assign(page.views[page.currentView],{autoPage:!0}))}})},deleteUploadsByNames:function(e){void 0===e&&(e={});var a="";page.permissions.moderator&&(a="
Hint: You can use this feature to delete uploads by other users."),page.dom.innerHTML='\n
\n
\n \n
\n \n
\n

Separate each entry with a new line.'+a+'

\n
\n
\n
\n \n
\n
\n
\n ',page.fadeInDom(),page.scrollToDom(),page.updateTrigger(e.trigger,"active"),document.querySelector("#submitBulkDelete").addEventListener("click",(function(){if(page.isSomethingLoading)return page.warnSomethingLoading();var e=document.querySelector("#bulkDeleteNames"),a={},t=e.value.split(/\r?\n/).map((function(e){var a=e.trim();return/^[^\s]+$/.test(a)?a:""})).filter((function(e){return!(!e||Object.prototype.hasOwnProperty.call(a,e))&&(a[e]=!0)}));if(e.value=t.join("\n"),!t.length)return swal("An error occurred!","You have not entered any upload names.","error");page.postBulkDeleteUploads({all:!0,field:"name",values:t,cb:function(a){e.value=a.join("\n")}})}))},postBulkDeleteUploads:function(e){void 0===e&&(e={});var a=e.values.length,t=e.values.length+" upload"+(1===a?"":"s"),n="

You won't be able to recover "+t.replace(/^(\d*)(.*)/,"$1$2")+"!

";e.all&&(n+="\n

Warning: You may be nuking "+(1===a?"an upload":"some uploads")+" by "+(1===a?"another user":"other users")+"!

");var s=document.createElement("div");s.innerHTML=n,swal({title:"Are you sure?",content:s,icon:"warning",dangerMode:!0,buttons:{cancel:!0,confirm:{text:"Yes, nuke "+(1===e.values.length?"it":"them")+"!",closeModal:!1}}}).then((function(n){n&&axios.post("api/upload/bulkdelete",{field:e.field,values:e.values}).then((function(n){if(n){if(!1===n.data.success)return"No token provided"===n.data.description?page.verifyToken(page.token):swal("An error occurred!",n.data.description,"error");var s=Array.isArray(n.data.failed)?n.data.failed:[];s.length===e.values.length?swal("An error occurred!","Unable to delete any of the "+t+".","error"):s.length&&s.length\n

You are about to add '+t+" upload"+(1===t?"":"s")+' to an album.

\n

If an upload is already in an album, it will be moved.

\n \n
\n
\n
\n \n
\n
\n
\n ',swal({icon:"warning",content:n,buttons:{cancel:!0,confirm:{text:"OK",closeModal:!1}}}).then((function(t){if(t){var n=parseInt(document.querySelector("#swalAlbum").value);if(isNaN(n))return swal("An error occurred!","You did not choose an album.","error");axios.post("api/albums/addfiles",{ids:e,albumid:n}).then((function(t){if(t)if(!1!==t.data.success){var s=e.length;t.data.failed&&t.data.failed.length&&(s-=t.data.failed.length);var i="upload"+(1===e.length?"":"s");if(!s)return swal("An error occurred!","Could not add the "+i+" to the album.","error");swal("Woohoo!","Successfully "+(n<0?"removed":"added")+" "+s+" "+i+" "+(n<0?"from":"to")+" the album.","success",{buttons:!1,timer:1500}),a(t.data.failed)}else"No token provided"===t.data.description?page.verifyToken(page.token):swal("An error occurred!",t.data.description,"error")})).catch(page.onAxiosError)}})),axios.get("api/albums",{headers:{simple:"1"}}).then((function(e){if(!1!==e.data.success){var a=document.querySelector("#swalAlbum");a&&(a.innerHTML+=e.data.albums.map((function(e){return'"})).join("\n"),a.getElementsByTagName("option")[1].innerHTML="Choose an album",a.removeAttribute("disabled"))}else"No token provided"===e.data.description?page.verifyToken(page.token):swal("An error occurred!",e.data.description,"error")})).catch(page.onAxiosError)},getAlbums:function(e){if(void 0===e&&(e={}),e&&e.all&&!page.permissions.moderator)return swal("An error occurred!","You cannot do this!","error");if(page.isSomethingLoading)return page.warnSomethingLoading();page.updateTrigger(e.trigger,"loading"),"number"!=typeof e.pageNum&&(e.pageNum=0);var a={};e.all&&(a.all="1");var t="api/albums/"+e.pageNum;axios.get(t,{headers:a}).then((function(a){if(a){if(!1===a.data.success)return"No token provided"===a.data.description?page.verifyToken(page.token):(page.updateTrigger(e.trigger),swal("An error occurred!",a.data.description,"error"));var t=Math.ceil(a.data.count/25),n=a.data.albums;if(e.pageNum&&0===n.length)return page.updateTrigger(e.trigger),e.autoPage?(e.pageNum=t-1,page.getAlbums(e)):swal("An error occurred!","There are no more albums to populate page "+(e.pageNum+1)+".","error");page.currentView=e.all?"albumsAll":"albums",page.cache={};var s=a.data.users,i=a.data.homeDomain;e.pageNum<0&&(e.pageNum=Math.max(0,t+e.pageNum));var l=page.paginate(a.data.count,25,e.pageNum),o='\n
\n '+('\n
\n
\n
\n
\n \n
\n
\n \n
\n
\n \n
\n
\n
\n
\n ')+'\n
\n
\n
\n
\n \n
\n
\n \n
\n
\n
\n
\n
\n ',r='\n \n ",d=o.replace(/id="filters"/,'id="bFilters"').replace(/(data-action="filter-uploads")/,'$1 data-filtersid="bFilters"').replace(/id="jumpToPage"/,'id="bJumpToPage"').replace(/(data-action="jump-to-page")/g,'$1 data-jumpid="bJumpToPage"'),c=l.replace(/(data-action="page-ellipsis")/g,'$1 data-jumpid="bJumpToPage"'),p=!1,u='\n

Create new album

\n
\n
\n
\n \n
\n

Max length is '+page.albumTitleMaxLength+' characters.

\n
\n
\n
\n \n
\n

Max length is '+page.albumDescMaxLength+' characters.

\n
\n
\n
\n \n
\n
\n
\n
\n ';page.dom.innerHTML="\n "+(e.all?"":u)+"\n "+l+"\n "+o+"\n "+r+'\n
\n \n \n \n \n \n \n '+(e.all?"":"")+'\n \n \n \n \n \n \n \n \n \n \n \n
IDNameUserUploadsSizeCreated atZIP sizeZIP generated atPublic link('+a.data.count+' total)
\n
\n '+r+"\n "+d+"\n "+c+"\n ";for(var g=document.querySelector("#table"),m=0;mb.editedAt);var w=0!==b.enabled;page.cache[b.id]={name:b.name,download:b.download,public:b.public,description:b.description,descriptionHtml:b.descriptionHtml,enabled:w,homeDomain:i,urlPath:"/a/",identifier:b.identifier};var y=document.createElement("tr");y.dataset.id=b.id,y.innerHTML='\n \n "+b.id+"\n "+b.name+"\n "+(e.all?""+(b.userid&&s[b.userid]||"")+"":"")+"\n "+b.uploads+'\n '+page.getPrettyBytes(b.size)+'\n '+b.prettyDate+"\n "+(b.hasZip?page.getPrettyBytes(b.zipSize):"-")+"\n "+(b.hasZip?b.prettyZipDate:"-")+"\n '+h+'\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n '+(e.all?'\n \n \n \n ':"")+"\n \n ",g.appendChild(y),page.checkboxes=g.querySelectorAll('.checkbox[data-action="select"]')}var k=document.querySelector("#selectAll");k&&!p&&(k.checked=!0,k.title="Unselect all"),page.fadeInDom();var x=n.length?e.pageNum:0;(e.forceScroll||null===page.prevPageNums[page.currentView]||page.prevPageNums[page.currentView]!==x)&&page.scrollToDom(),page.updateTrigger(e.trigger,"active"),"albumsAll"===page.currentView&&(page.views[page.currentView].filters=e.filters),page.views[page.currentView].pageNum=page.prevPageNums[page.currentView]=x}})).catch((function(a){page.updateTrigger(e.trigger),page.onAxiosError(a)}))},editAlbum:function(e){var a=page.cache[e];if(a){var t=a.urlPath+a.identifier,n=a.homeDomain+t,s=document.createElement("div");s.innerHTML='\n
\n
\n \n
\n

Max length is '+page.albumTitleMaxLength+' characters.

\n
\n
\n
\n \n
\n

Markdown supported. Max length is '+page.albumDescMaxLength+" characters.

\n
\n "+(a.descriptionHtml?'
\n
\n '+a.descriptionHtml+'\n
\n

Save changes then re-open this Edit prompt to refresh this preview.

\n
':"")+"\n "+("albumsAll"===page.currentView&&page.permissions.moderator?'
\n
\n \n
\n
":"")+'\n
\n
\n \n
\n
\n
\n
\n \n
\n
\n
\n
\n \n
\n
\n
\n

Current public link: '+t+"

\n
\n ",swal({title:"Edit album",icon:"info",content:s,buttons:{cancel:!0,confirm:{closeModal:!1}}}).then((function(t){if(t){var n={id:e,name:document.querySelector("#swalName").value.trim(),description:document.querySelector("#swalDescription").value.trim(),download:document.querySelector("#swalDownload").checked,public:document.querySelector("#swalPublic").checked,requestLink:document.querySelector("#swalRequestLink").checked};"albumsAll"===page.currentView&&page.permissions.moderator&&(n.enabled=document.querySelector("#swalEnabled").checked),axios.post("api/albums/edit",n).then((function(e){if(e){if(!1===e.data.success)return"No token provided"===e.data.description?page.verifyToken(page.token):swal("An error occurred!",e.data.description,"error");e.data.identifier?swal("Success!","The album's new identifier is: "+e.data.identifier+".","success"):e.data.name!==a.name?swal("Success!","The album was renamed to: "+e.data.name+".","success"):swal("Success!","The album was edited.","success",{buttons:!1,timer:1500}),page.getAlbumsSidebar(),page.getAlbums(Object.assign(page.views[page.currentView],{autoPage:!0}))}})).catch(page.onAxiosError)}}))}},disableAlbum:function(e){swal({title:"Are you sure?",text:"This won't delete the uploads associated with the album!",icon:"warning",dangerMode:!0,buttons:{cancel:!0,confirm:{text:"Yes, disable it!",closeModal:!1},purge:{text:"Umm, delete the uploads, please?",value:"purge",className:"swal-button--danger",closeModal:!1}}}).then((function(a){a&&axios.post("api/albums/disable",{id:e,purge:"purge"===a}).then((function(e){if(!1===e.data.success){var a=Array.isArray(e.data.failed)?e.data.failed:[];return"No token provided"===e.data.description?page.verifyToken(page.token):a.length?swal("An error occurred!","Unable to delete "+a.length+" of the album's upload"+(1===a.length?"":"s")+".","error"):swal("An error occurred!",e.data.description,"error")}swal("Disabled!","The album has been disabled.","success",{buttons:!1,timer:1500}),page.getAlbumsSidebar(),page.getAlbums(Object.assign(page.views[page.currentView],{autoPage:!0}))})).catch(page.onAxiosError)}))},deleteAlbum:function(e){swal({title:"Are you sure?",text:"You won't be able to recover this album!\nThis also won't delete the uploads associated with the album!",icon:"warning",dangerMode:!0,buttons:{cancel:!0,confirm:{text:"Yes, delete it!",closeModal:!1},purge:{text:"Umm, delete the uploads, please?",value:"purge",className:"swal-button--danger",closeModal:!1}}}).then((function(a){a&&axios.post("api/albums/delete",{id:e,purge:"purge"===a}).then((function(e){if(!1===e.data.success){var a=Array.isArray(e.data.failed)?e.data.failed:[];return"No token provided"===e.data.description?page.verifyToken(page.token):a.length?swal("An error occurred!","Unable to delete "+a.length+" of the album's upload"+(1===a.length?"":"s")+".","error"):swal("An error occurred!",e.data.description,"error")}swal("Disabled!","The album has been deleted.","success",{buttons:!1,timer:1500}),page.getAlbumsSidebar(),page.getAlbums(Object.assign(page.views[page.currentView],{autoPage:!0}))})).catch(page.onAxiosError)}))},submitAlbum:function(e){page.updateTrigger(e,"loading"),axios.post("api/albums",{name:document.querySelector("#albumName").value.trim(),description:document.querySelector("#albumDescription").value.trim()}).then((function(a){if(a){if(page.updateTrigger(e),!1===a.data.success)return"No token provided"===a.data.description?page.verifyToken(page.token):swal("An error occurred!",a.data.description,"error");swal("Woohoo!","Album was created successfully.","success",{buttons:!1,timer:1500}),page.getAlbumsSidebar(),page.getAlbums({pageNum:-1})}})).catch((function(a){page.updateTrigger(e),page.onAxiosError(a)}))},getAlbumsSidebar:function(){axios.get("api/albums",{headers:{simple:"1"}}).then((function(e){if(e){if(!1===e.data.success)return"No token provided"===e.data.description?page.verifyToken(page.token):swal("An error occurred!",e.data.description,"error");var a=e.data.albums,t=e.data.count,n=document.querySelector("#albumsSidebar"),s=n.querySelectorAll("li > a"),i=s.length!==t;if(s.length){for(var l=0;l\n \n
\n
\n \n
\n
\n \n \n ',page.fadeInDom(),page.scrollToDom(),page.updateTrigger(e.trigger,"active"),document.querySelector("#getNewToken").addEventListener("click",(function(e){if(page.isSomethingLoading)return page.warnSomethingLoading();var a=e.currentTarget;page.updateTrigger(a,"loading"),axios.post("api/tokens/change").then((function(e){if(!1===e.data.success)return"No token provided"===e.data.description?page.verifyToken(page.token):(page.updateTrigger(a),swal("An error occurred!",e.data.description,"error"));page.updateTrigger(a),swal({title:"Woohoo!",text:"Your token was successfully changed.",icon:"success",buttons:!1,timer:1500}).then((function(){axios.defaults.headers.common.token=e.data.token,localStorage[lsKeys.token]=e.data.token,page.token=e.data.token,page.changeToken()}))})).catch((function(e){page.updateTrigger(a),page.onAxiosError(e)}))}))},changePassword:function(e){void 0===e&&(e={}),page.dom.innerHTML='\n
\n
\n \n
\n \n
\n
\n
\n \n
\n \n
\n
\n
\n
\n \n
\n
\n
\n ',page.fadeInDom(),page.scrollToDom(),page.updateTrigger(e.trigger,"active"),document.querySelector("#sendChangePassword").addEventListener("click",(function(e){if(page.isSomethingLoading)return page.warnSomethingLoading();page.dom.querySelector("form").checkValidity()&&(document.querySelector("#password").value===document.querySelector("#passwordConfirm").value?page.sendNewPassword(document.querySelector("#password").value,e.currentTarget):swal({title:"Password mismatch!",text:"Your passwords do not match, please try again.",icon:"error"}))}))},sendNewPassword:function(e,a){page.updateTrigger(a,"loading"),axios.post("api/password/change",{password:e}).then((function(e){if(!1===e.data.success)return"No token provided"===e.data.description?page.verifyToken(page.token):(page.updateTrigger(a),swal("An error occurred!",e.data.description,"error"));page.updateTrigger(a),swal({title:"Woohoo!",text:"Your password was successfully changed.",icon:"success",buttons:!1,timer:1500}).then((function(){page.changePassword()}))})).catch((function(e){page.updateTrigger(a),page.onAxiosError(e)}))},getUsers:function(e){if(void 0===e&&(e={}),!page.permissions.admin)return swal("An error occurred!","You cannot do this!","error");if(page.isSomethingLoading)return page.warnSomethingLoading();page.updateTrigger(e.trigger,"loading"),"number"!=typeof e.pageNum&&(e.pageNum=0);var a="api/users/"+e.pageNum;axios.get(a).then((function(a){if(!1===a.data.success)return"No token provided"===a.data.description?page.verifyToken(page.token):(page.updateTrigger(e.trigger),swal("An error occurred!",a.data.description,"error"));var t=Math.ceil(a.data.count/25),n=a.data.users;if(e.pageNum&&0===n.length)return page.updateTrigger(e.trigger),e.autoPage?(e.pageNum=t-1,page.getUsers(e)):swal("An error occurred!","There are no more users to populate page "+(e.pageNum+1)+".","error");page.currentView="users",page.cache={},e.pageNum<0&&(e.pageNum=Math.max(0,t+e.pageNum));var s=page.paginate(a.data.count,25,e.pageNum),i='\n
\n '+('\n
\n
\n
\n
\n \n
\n
\n \n
\n
\n \n
\n
\n
\n
\n ')+'\n
\n
\n
\n
\n \n
\n
\n \n
\n
\n
\n
\n
\n ',l='\n \n ',o=i.replace(/id="filters"/,'id="bFilters"').replace(/(data-action="filter-uploads")/,'$1 data-filtersid="bFilters"').replace(/id="jumpToPage"/,'id="bJumpToPage"').replace(/(data-action="jump-to-page")/g,'$1 data-jumpid="bJumpToPage"'),r=s.replace(/(data-action="page-ellipsis")/g,'$1 data-jumpid="bJumpToPage"'),d=!1;page.dom.innerHTML="\n "+s+"\n "+i+"\n "+l+'\n
\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
UsernameUploadsUsageGroupRegistration dateLast token update('+a.data.count+' total)
\n
\n '+l+"\n "+o+"\n "+r+"\n ";for(var c=document.querySelector("#table"),p=0;p\n "+u.username+"\n "+u.uploads+"\n "+page.getPrettyBytes(u.usage)+"\n "+m+"\n "+f+"\n "+w+'\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n ',c.appendChild(y),page.checkboxes=c.querySelectorAll('.checkbox[data-action="select"]')}var k=document.querySelector("#selectAll");k&&!d&&(k.checked=!0,k.title="Unselect all"),page.fadeInDom();var x=n.length?e.pageNum:0;(e.forceScroll||null===page.prevPageNums[page.currentView]||page.prevPageNums[page.currentView]!==x)&&page.scrollToDom(),page.updateTrigger(e.trigger,"active"),page.views[page.currentView].pageNum=page.prevPageNums[page.currentView]=x})).catch((function(a){page.updateTrigger(e.trigger),page.onAxiosError(a)}))},createUser:function(){var e=Object.keys(page.permissions).map((function(e,a,t){return'"})).join("\n"),a=document.createElement("div");a.innerHTML='\n
\n \n
\n \n
\n
\n
\n \n
\n \n
\n
\n
\n \n
\n
\n \n
\n
\n
\n ",swal({title:"Create new user",icon:"info",content:a,buttons:{cancel:!0,confirm:{closeModal:!1}}}).then((function(e){e&&axios.post("api/users/create",{username:document.querySelector("#swalUsername").value,password:document.querySelector("#swalPassword").value,group:document.querySelector("#swalGroup").value}).then((function(e){if(e){if(!1===e.data.success)return"No token provided"===e.data.description?page.verifyToken(page.token):swal("An error occurred!",e.data.description,"error");var a=document.createElement("div");a.innerHTML="\n

Username: "+e.data.username+"

\n

Password: "+e.data.password+"

\n

User group: "+e.data.group+"

\n ",swal({title:"Created a new user!",icon:"success",content:a}),page.getUsers(Object.assign(page.views.users,{pageNum:-1}))}})).catch(page.onAxiosError)}))},editUser:function(e){var a=page.cache[e];if(a){var t=!1,n=Object.keys(page.permissions).map((function(e,n,s){var i=e===a.displayGroup;return i&&(t=void 0!==s[n+1]&&page.permissions[s[n+1]]),'"})).join("\n"),s=t?"":" disabled",i=document.createElement("div");i.innerHTML='\n
\n

User ID: '+e+'

\n
\n
\n \n
\n \n
\n
\n
\n \n
\n
\n \n
\n
\n
\n
\n
\n \n
\n
\n
\n
\n \n
\n
\n "+(t?"":'
\n You cannot modify user in the same or higher group as you.\n
')+"\n ",swal({title:"Edit user",icon:"info",content:i,buttons:{cancel:!0,confirm:{closeModal:!1}}}).then((function(t){t&&axios.post("api/users/edit",{id:e,username:document.querySelector("#swalUsername").value,group:document.querySelector("#swalGroup").value,enabled:document.querySelector("#swalEnabled").checked,resetPassword:document.querySelector("#swalResetPassword").checked}).then((function(e){if(e){if(!1===e.data.success)return"No token provided"===e.data.description?page.verifyToken(page.token):swal("An error occurred!",e.data.description,"error");var t=!0,n=document.createElement("div"),s=a.username;e.data.update.username!==a.username&&(n.innerHTML+="

"+a.username+" was renamed into: "+e.data.update.username+".

",t=!1,s=e.data.update.username),e.data.update.password&&(n.innerHTML+="\n

"+s+"'s new password is:

\n

"+e.data.update.password+"

\n ",t=!1),e.data.update.enabled!==a.enabled&&(n.innerHTML+="

"+s+" has been "+(e.data.update.enabled?"enabled":"disabled")+"!

"),n.innerHTML||(n.innerHTML="

"+s+" was edited!

"),swal({title:"Success!",icon:"success",content:n,buttons:!t,timer:t?1500:null}),page.getUsers(page.views.users)}})).catch(page.onAxiosError)}))}},disableUser:function(e){var a=page.cache[e];if(a&&a.enabled){var t=document.createElement("div");t.innerHTML="\n

You will be disabling a user named "+page.cache[e].username+".

\n

Their files will remain.

\n ",swal({title:"Are you sure?",icon:"warning",content:t,dangerMode:!0,buttons:{cancel:!0,confirm:{text:"Yes, disable them!",closeModal:!1}}}).then((function(a){a&&axios.post("api/users/disable",{id:e}).then((function(a){if(a){if(!1===a.data.success)return"No token provided"===a.data.description?page.verifyToken(page.token):swal("An error occurred!",a.data.description,"error");swal("Success!",page.cache[e].username+" has been disabled.","success",{buttons:!1,timer:1500}),page.getUsers(page.views.users)}})).catch(page.onAxiosError)}))}},deleteUser:function(e){if(page.cache[e]){var a=document.createElement("div");a.innerHTML="\n

You will be deleting a user named "+page.cache[e].username+".

\n

Their uploads will still remain, unless you choose otherwise.

\n ",swal({title:"Are you sure?",icon:"warning",content:a,dangerMode:!0,buttons:{cancel:!0,confirm:{text:"Yes, ONLY the user!",closeModal:!1},purge:{text:"Yes, AND their uploads too!",value:"purge",className:"swal-button--danger",closeModal:!1}}}).then((function(a){a&&axios.post("api/users/delete",{id:e,purge:"purge"===a}).then((function(a){if(a){if(!1===a.data.success){var t=Array.isArray(a.data.failed)?a.data.failed:[];return"No token provided"===a.data.description?page.verifyToken(page.token):t.length?swal("An error occurred!","Unable to delete "+t.length+" of the user's upload"+(1===t.length?"":"s")+".","error"):swal("An error occurred!",a.data.description,"error")}swal("Success!",page.cache[e].username+" has been deleted.","success",{buttons:!1,timer:1500}),page.getUsers(Object.assign(page.views.users,{autoPage:!0}))}})).catch(page.onAxiosError)}))}},paginate:function(e,a,t){t+=1;var n=Math.ceil(e/a),s="",i=function(e,a){for(var n=e;n<=a;++n)s+='
  • '+n+"
  • "},l=function(){s+='\n
  • 1
  • \n
  • \n '},o=function(){s+='\n
  • \n
  • '+n+"
  • \n "};return 7>=n?i(1,n):t<6?(i(1,6),o()):t>n-6+1?(l(),i(n-6+1,n)):(l(),i(t-3+1,t+3-1),o()),'\n \n "},getStatistics:function(e){if(void 0===e&&(e={}),!page.permissions.admin)return swal("An error occurred!","You cannot do this!","error");if(page.isSomethingLoading)return page.warnSomethingLoading();page.updateTrigger(e.trigger,"loading");axios.get("api/stats").then((function(a){if(!1===a.data.success)return"No token provided"===a.data.description?page.verifyToken(page.token):(page.updateTrigger(e.trigger),swal("An error occurred!",a.data.description,"error"));for(var t="",n=Object.keys(a.data.stats),s=0;s\n "+l[o]+"\n "+p+"\n \n "}}catch(e){i="\n \n Error parsing response. Try again?\n \n \n ",page.onError(e)}else i+="\n \n Generating, please try again later…\n \n \n ";t+='\n
    \n \n \n \n \n \n \n \n \n "+i+"\n \n
    '+n[s]+"
    \n
    \n "}Array.isArray(a.data.hrtime)&&(t+='\n
    \n
    \n Time taken: '+a.data.hrtime[0]+"s "+Math.ceil(a.data.hrtime[1]/1e6)+"ms.\n
    \n
    \n "),page.dom.innerHTML=t,page.fadeInDom(),page.scrollToDom(),page.updateTrigger(e.trigger,"active")})).catch((function(a){page.updateTrigger(e.trigger),page.onAxiosError(a)}))}};window.addEventListener("DOMContentLoaded",(function(){"function"!=typeof Object.assign&&Object.defineProperty(Object,"assign",{value:function(e,a){"use strict";var t=arguments;if(null==e)throw new TypeError("Cannot convert undefined or null to object");for(var n=Object(e),s=1;s

    \n

    Please check your console for more information.

    \n ",swal({title:"An error occurred!",icon:"error",content:a})},onAxiosError:function(e){console.error(e);var a={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,t=e.response.data&&e.response.data.description?e.response.data.description:"There was an error with the request.\nPlease check the console for more information.";return swal(e.response.status+" "+a,t,"error")},preparePage:function(){page.token?page.verifyToken(page.token):window.location="auth"},checkClientVersion:function(e){var a=document.querySelector("#mainScript").src.match(/\?_=(\d+)$/);if(a&&a[1]&&a[1]!==e)return swal({title:"Update detected!",text:"Client assets have been updated. Reload to display the latest version?",icon:"info",buttons:{confirm:{text:"Reload",closeModal:!1}}}).then((function(){window.location.reload()}))},verifyToken:function(e){axios.post("api/tokens/verify",{token:e}).then((function(a){axios.defaults.headers.common.token=e,localStorage[lsKeys.token]=e,a.data.version&&page.checkClientVersion(a.data.version),page.token=e,page.username=a.data.username,page.permissions=a.data.permissions,page.prepareDashboard()})).catch((function(e){return swal({title:"An error occurred!",text:e.response.data?e.response.data.description:e.toString(),icon:"error"}).then((function(){e.response.data&&10001===e.response.data.code&&(localStorage.removeItem(lsKeys.token),window.location="auth")}))}))},prepareDashboard:function(){page.section=document.querySelector("#dashboard"),page.dom=page.section.querySelector("#page"),page.dom.addEventListener("click",page.domClick,!0),page.dom.addEventListener("submit",(function(e){if(e.target&&e.target.classList.contains("prevent-default"))return e.preventDefault()}),!0),page.menusContainer=document.querySelector("#menu");for(var e=[{selector:"#itemUploads",onclick:page.getUploads},{selector:"#itemDeleteUploadsByNames",onclick:page.deleteUploadsByNames},{selector:"#itemManageYourAlbums",onclick:page.getAlbums},{selector:"#itemManageToken",onclick:page.changeToken},{selector:"#itemChangePassword",onclick:page.changePassword},{selector:"#itemLogout",onclick:page.logout},{selector:"#itemManageUploads",onclick:page.getUploads,params:{all:!0},group:"moderator"},{selector:"#itemManageAlbums",onclick:page.getAlbums,params:{all:!0},group:"moderator"},{selector:"#itemStatistics",onclick:page.getStatistics,group:"admin"},{selector:"#itemManageUsers",onclick:page.getUsers,group:"admin"}],a=function(a){if(!e[a].group||page.permissions[e[a].group]){var t=document.querySelector(e[a].selector);t.addEventListener("click",(function(t){if(page.isSomethingLoading)return page.warnSomethingLoading();e[a].onclick.call(null,Object.assign(e[a].params||{},{trigger:t.currentTarget,forceScroll:!0}))})),t.classList.remove("is-hidden"),page.menus.push(t)}},t=0;t\n '+('\n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n ')+'\n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n ',d='\n \n ',c=r.replace(/id="filters"/,'id="bFilters"').replace(/(data-action="filter-uploads")/,'$1 data-filtersid="bFilters"').replace(/id="jumpToPage"/,'id="bJumpToPage"').replace(/(data-action="jump-to-page")/g,'$1 data-jumpid="bJumpToPage"'),p=o.replace(/(data-action="page-ellipsis")/g,'$1 data-jumpid="bJumpToPage"'),u=!1,g=page.views[page.currentView].originalNames,m=n.some((function(e){return void 0!==e.expirydate})),b=0;b\n \n '+d+"\n "+c+"\n "+p+"\n ";for(var v=document.querySelector("#table"),f=0;f'+w.name+'':y.innerHTML='

    '+(w.extname||"N/A")+"

    ",y.innerHTML+='\n \n
    \n '+(w.previewable?'\n \n \n \n ':"")+'\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
    \n
    \n

    '+w.name+"

    \n "+(g?'

    '+w.original+"

    ":"")+'\n

    '+(w.appendix?""+w.appendix+" – ":"")+w.prettyBytes+"

    \n "+(m&&w.prettyExpiryDate?'

    EXP: "+w.prettyExpiryDate+"

    ":"")+"\n
    \n ",v.appendChild(y),page.checkboxes=v.querySelectorAll('.checkbox[data-action="select"]')}}else{var k=e.all&&e.filters&&e.filters.includes("albumid:");page.dom.innerHTML="\n "+o+"\n "+r+"\n "+d+'\n
    \n \n \n \n \n \n '+(g?'':"")+"\n "+(void 0===e.album?'":"")+"\n "+(k?'':"")+'\n \n '+(e.all?'':"")+'\n \n '+(m?'':"")+'\n \n \n \n \n \n
    File nameOriginal nameUser':'albumid">Album')+"AlbumSizeIPUpload dateExpiry date('+a.data.count+' total)
    \n
    \n '+d+"\n "+c+"\n "+p+"\n ";for(var x=document.querySelector("#table"),S=0;S\n '+T.name+"\n "+(g?''+T.original+"":"")+"\n "+(void 0===e.album?''+T.appendix+"":"")+"\n "+(k?''+(T.albumid&&s[T.albumid]||"")+"":"")+'\n '+T.prettyBytes+"\n "+(e.all?''+(T.ip||"")+"":"")+'\n '+T.prettyDate+"\n "+(m?'"+(T.prettyExpiryDate||"-")+"":"")+'\n \n \n \n \n \n \n \n \n \n \n \n '+(e.all?"":'\n \n \n \n ')+'\n \n \n \n \n \n \n ',x.appendChild(A),page.checkboxes=x.querySelectorAll('.checkbox[data-action="select"]')}}var N=document.querySelector("#selectAll");N&&!u&&n.length&&(N.checked=!0,N.title="Unselect all"),page.fadeInDom();var L=n.length?e.pageNum:0;if(e.forceScroll||null===page.prevPageNums[page.currentView]||page.prevPageNums[page.currentView]!==L){var V=!e.forceScroll&&"thumbs"===page.views[page.currentView].type;page.scrollToDom(V)}"thumbs"===page.views[page.currentView].type&&page.lazyLoad.update(),page.updateTrigger(e.trigger,"active"),"uploads"===page.currentView&&(page.views.uploads.album=e.album),page.views[page.currentView].filters=e.filters,page.views[page.currentView].pageNum=page.prevPageNums[page.currentView]=L})).catch((function(a){page.updateTrigger(e.trigger),page.onAxiosError(a)}))},setUploadsView:function(e,a){if(page.isSomethingLoading)return page.warnSomethingLoading();"list"===e?(delete localStorage[lsKeys.viewType[page.currentView]],page.views[page.currentView].type=void 0):(localStorage[lsKeys.viewType[page.currentView]]=e,page.views[page.currentView].type=e),page.getUploads(Object.assign(page.views[page.currentView],{trigger:a}))},toggleOriginalNames:function(e){if(page.isSomethingLoading)return page.warnSomethingLoading();page.views[page.currentView].originalNames?(delete localStorage[lsKeys.originalNames[page.currentView]],page.views[page.currentView].originalNames=!1):(localStorage[lsKeys.originalNames[page.currentView]]="1",page.views[page.currentView].originalNames=!0),page.getUploads(Object.assign(page.views[page.currentView],{trigger:e}))},displayPreview:function(e){var a=page.cache[e];if(a.previewable){var t=document.createElement("div");if(t.innerHTML='\n
    \n

    \n

    '+a.name+"
    \n
    "+a.original+"
    \n

    \n "+(a.thumb?'

    \n \n

    ':"")+"\n
    \n ",a.file&&["picture","video","audio"].includes(a.type))if(t.innerHTML+='\n \n ","picture"===a.type)t.querySelector("#swalOriginal").addEventListener("click",(function(e){var n=e.currentTarget;if(!n.classList.contains("is-danger")){n.classList.add("is-loading");var s=t.querySelector("#swalThumb");s.src=a.file,s.onload=function(){n.classList.add("is-hidden"),document.body.querySelector(".swal-overlay .swal-modal:not(.is-expanded)").classList.add("is-expanded")},s.onerror=function(e){e.currentTarget.classList.add("is-hidden"),n.className="button is-danger is-fullwidth",n.innerHTML='\n \n \n \n Unable to load original\n '}}}));else{var n=a.file.match(/.*\/(.*)$/);(n||n[1])&&(t.querySelector("#swalOriginal").setAttribute("href","v/"+n[1]),t.querySelector("#swalOriginal").setAttribute("target","_blank"))}return swal({content:t,buttons:!1}).then((function(){document.body.querySelector(".swal-overlay .swal-modal").classList.remove("is-expanded")}))}},selectAll:function(e){for(var a=0;an&&s>n&&st&&suser (username) and ip.\n These keys can be specified more than once.\n For usernames with whitespaces, wrap them with double quotes (\").\n Special cases such as uploads by non-registered users or have no IPs respectively, use user:- or ip:-.\n\n To exclude certain users/ips while still listing every other uploads, add negation sign (-) before the keys.\n Negation sign can also be used to exclude the special cases mentioned above (i.e. -user:- or -ip:-).\n\n If you know the ID of a user's album, you can list its uploads with albumid key.\n Negation sign works for this key as well.":"There is only 1 filter key, namely albumid.\n This key can be specified more than once.\n Special case such as uploads with no albums, use albumid:-.\n\n To exclude certain albums while still listing every other uploads, add negation sign (-) before the keys.\n Negation sign can also be used to exclude the special case mentioned above (i.e. -albumid:-).")+'\n\n There are 2 range keys: date (upload date) and expiry (expiry date).\n Their format is: "YYYY/MM/DD HH:MM:SS-YYYY/MM/DD HH:MM:SS" ("from" date and "to" date respectively).\n You may specify only one of the dates.\n If "to" date is missing, \'now\' will be used. If "from" date is missing, \'beginning of time\' will be used.\n If any of the subsequent date or time units are not specified, their first value will be used (e.g. January for month, 1 for day, and so on).\n If only time is specified, today\'s date will be used.\n If you do not need to specify both date and time, you may omit the double quotes.\n In conclusion, the following examples are all valid: date:"2020/01/01 01:23-2018/01/01 06", expiry:-2020/05, date:12:34:56.\n These keys can only be specified once each.\n\n Timezone? Feel free to query the dates with your own timezone.\n API requests to the filter endpoint will attach your browser\'s timezone offset, so the server will automatically calculate timezone differences.\n\n Matches can also be sorted with sort keys.\n Their formats are: sort:columnName[:d[escending]], where :d[escending] is an optional tag to set the direction to descending.\n This key must be used with internal column names used in the database (id, '+(a?"userid":"albumid")+", and so on),\n but there are 2 shortcuts available: date for timestamp column and expiry for expirydate column.\n This key can also be specified more than once, where their order will decide the sorting steps.\n\n Finally, there are type-is keys to refine by types.\n You can use is:image, is:video, and is:audio to list images, videos, audios respectively.\n This will only use image, video and audio extensions that are whitelisted internally in the safe.\n For images and videos specifically, they will be the ones whose thumbnails can be generated by the safe.\n Negation sign works for this key as well.\n Mixing inclusion and exclusion is not allowed (i.e. is:image -is:video, since the second key is redundant).\n\n Any leftover keywords which do not use keys (non-keyed keywords) will be matched against the matches' file names.\n Excluding certain keywords is also supported by adding negation sign before the keywords.\n\n Internal steps:\n "+(a?"- Query uploads passing ALL exclusion filter keys OR matching ANY filter keys, if any.\n - Refine matches":"- Filter uploads")+" using date key, if any.\n - Refine matches using expiry key, if any.\n - Refine matches using type-is keys, if any.\n - Refine matches using ANY non-keyed keywords, if any.\n - Filter matches using ALL exclusion non-keyed keywords, if any.\n - Sort matches using sorting keys, if any.\n\n Examples:\n "+(a?'- Uploads from users named "demo" AND/OR "John Doe" AND/OR non-registered users:\n user:demo user:"John Doe" user:-\n - ALL uploads, but NOT the ones from user named "demo" AND "John Doe":\n -user:demo -user:"John Doe"\n - Uploads from IP "127.0.0.1" AND which file names match "*.rar" OR "*.zip":\n ip:127.0.0.1 *.rar *.zip\n ':"")+'- Uploads without albums:\n albumid:-\n - ALL uploads, but NOT the ones from album with ID 69:\n -albumid:69\n - Uploads uploaded since "1 June 2019 00:00:00":\n date:2019/06\n - Uploads uploaded between "7 April 2020 12:00:00" and "7 April 2020 23:59:59":\n date:"2020/04/07 12-2020/04/07 23:59:59"\n - Uploads uploaded before "5 February 2020 00:00:00":\n date:-2020/02/05\n - Uploads which file names match "*.gz" but NOT "*.tar.gz":\n *.gz -*.tar.gz\n - Sort matches by "size" column in ascending and descending order respectively:\n '+(a?'user:"John Doe"':"*.txt")+" sort:size\n *.mp4 "+(a?"user:- ":"")+"sort:size:d\n "+(page.permissions.moderator?"":"Notice: Regular users may face some limitations in the amount of keys that can be used at a time.")+"\n Friendly reminder: This window can be scrolled up!\n ").trim().replace(/^\s*/g,"").replace(/\n/g,"
    "),swal({content:t}).then((function(){document.body.querySelector(".swal-overlay .swal-modal").classList.remove("is-expanded")})),document.body.querySelector(".swal-overlay .swal-modal:not(.is-expanded)").classList.add("is-expanded")},filterUploads:function(e){var a=document.querySelector("#"+(e.dataset.filtersid||"filters")).value.trim().replace(/\t/g," ").replace(/(^|\s)((albumid|ip|user|date|expiry|is|sort|orderby):)\s+/g,"$2");page.getUploads(Object.assign(page.views[page.currentView],{filters:a,pageNum:0,trigger:e}))},viewUserUploads:function(e,a){var t=page.cache[e];if(t){a.classList.add("is-loading");var n=t.username.includes(" ")?'"'+t.username+'"':t.username;page.getUploads({all:!0,filters:"user:"+n,trigger:document.querySelector("#itemManageUploads")})}},viewAlbumUploads:function(e,a){if(page.cache[e]){a.classList.add("is-loading");var t="albumsAll"===page.currentView&&page.permissions.moderator;page.getUploads({all:t,filters:"albumid:"+e,trigger:t?document.querySelector("#itemManageUploads"):document.querySelector("#itemUploads")})}},deleteUpload:function(e){page.postBulkDeleteUploads({all:"uploadsAll"===page.currentView,field:"id",values:[e],cb:function(a){!a.length&&page.selected[page.currentView].includes(e)&&page.selected[page.currentView].splice(page.selected[page.currentView].indexOf(e),1),page.selected[page.currentView].length?localStorage[lsKeys.selected[page.currentView]]=JSON.stringify(page.selected[page.currentView]):delete localStorage[lsKeys.selected[page.currentView]],page.getUploads(Object.assign(page.views[page.currentView],{autoPage:!0}))}})},bulkDeleteUploads:function(){if(!page.selected[page.currentView].length)return swal("An error occurred!","You have not selected any uploads.","error");page.postBulkDeleteUploads({all:"uploadsAll"===page.currentView,field:"id",values:page.selected[page.currentView],cb:function(e){e.length?page.selected[page.currentView]=page.selected[page.currentView].filter((function(a){return e.includes(a)})):page.selected[page.currentView]=[],page.selected[page.currentView].length?localStorage[lsKeys.selected[page.currentView]]=JSON.stringify(page.selected[page.currentView]):delete localStorage[lsKeys.selected[page.currentView]],page.getUploads(Object.assign(page.views[page.currentView],{autoPage:!0}))}})},deleteUploadsByNames:function(e){void 0===e&&(e={});var a="";page.permissions.moderator&&(a="
    Hint: You can use this feature to delete uploads by other users."),page.dom.innerHTML='\n
    \n
    \n \n
    \n \n
    \n

    Separate each entry with a new line.'+a+'

    \n
    \n
    \n
    \n \n
    \n
    \n
    \n ',page.fadeInDom(),page.scrollToDom(),page.updateTrigger(e.trigger,"active"),document.querySelector("#submitBulkDelete").addEventListener("click",(function(){if(page.isSomethingLoading)return page.warnSomethingLoading();var e=document.querySelector("#bulkDeleteNames"),a={},t=e.value.split(/\r?\n/).map((function(e){var a=e.trim();return/^[^\s]+$/.test(a)?a:""})).filter((function(e){return!(!e||Object.prototype.hasOwnProperty.call(a,e))&&(a[e]=!0)}));if(e.value=t.join("\n"),!t.length)return swal("An error occurred!","You have not entered any upload names.","error");page.postBulkDeleteUploads({all:!0,field:"name",values:t,cb:function(a){e.value=a.join("\n")}})}))},postBulkDeleteUploads:function(e){void 0===e&&(e={});var a=e.values.length,t=e.values.length+" upload"+(1===a?"":"s"),n="

    You won't be able to recover "+t.replace(/^(\d*)(.*)/,"$1$2")+"!

    ";e.all&&(n+="\n

    Warning: You may be nuking "+(1===a?"an upload":"some uploads")+" by "+(1===a?"another user":"other users")+"!

    ");var s=document.createElement("div");s.innerHTML=n,swal({title:"Are you sure?",content:s,icon:"warning",dangerMode:!0,buttons:{cancel:!0,confirm:{text:"Yes, nuke "+(1===e.values.length?"it":"them")+"!",closeModal:!1}}}).then((function(n){n&&axios.post("api/upload/bulkdelete",{field:e.field,values:e.values}).then((function(n){if(n){if(!1===n.data.success)return"No token provided"===n.data.description?page.verifyToken(page.token):swal("An error occurred!",n.data.description,"error");var s=Array.isArray(n.data.failed)?n.data.failed:[];s.length===e.values.length?swal("An error occurred!","Unable to delete any of the "+t+".","error"):s.length&&s.length\n

    You are about to add '+t+" upload"+(1===t?"":"s")+' to an album.

    \n

    If an upload is already in an album, it will be moved.

    \n \n
    \n
    \n
    \n \n
    \n
    \n
    \n ',swal({icon:"warning",content:n,buttons:{cancel:!0,confirm:{text:"OK",closeModal:!1}}}).then((function(t){if(t){var n=parseInt(document.querySelector("#swalAlbum").value);if(isNaN(n))return swal("An error occurred!","You did not choose an album.","error");axios.post("api/albums/addfiles",{ids:e,albumid:n}).then((function(t){if(t)if(!1!==t.data.success){var s=e.length;t.data.failed&&t.data.failed.length&&(s-=t.data.failed.length);var i="upload"+(1===e.length?"":"s");if(!s)return swal("An error occurred!","Could not add the "+i+" to the album.","error");swal("Woohoo!","Successfully "+(n<0?"removed":"added")+" "+s+" "+i+" "+(n<0?"from":"to")+" the album.","success",{buttons:!1,timer:1500}),a(t.data.failed)}else"No token provided"===t.data.description?page.verifyToken(page.token):swal("An error occurred!",t.data.description,"error")})).catch(page.onAxiosError)}})),axios.get("api/albums",{headers:{simple:"1"}}).then((function(e){if(!1!==e.data.success){var a=document.querySelector("#swalAlbum");a&&(a.innerHTML+=e.data.albums.map((function(e){return'"})).join("\n"),a.getElementsByTagName("option")[1].innerHTML="Choose an album",a.removeAttribute("disabled"))}else"No token provided"===e.data.description?page.verifyToken(page.token):swal("An error occurred!",e.data.description,"error")})).catch(page.onAxiosError)},getAlbums:function(e){if(void 0===e&&(e={}),e&&e.all&&!page.permissions.moderator)return swal("An error occurred!","You cannot do this!","error");if(page.isSomethingLoading)return page.warnSomethingLoading();page.updateTrigger(e.trigger,"loading"),"number"!=typeof e.pageNum&&(e.pageNum=0);var a={};e.all&&(a.all="1");var t="api/albums/"+e.pageNum;axios.get(t,{headers:a}).then((function(a){if(a){if(!1===a.data.success)return"No token provided"===a.data.description?page.verifyToken(page.token):(page.updateTrigger(e.trigger),swal("An error occurred!",a.data.description,"error"));var t=Math.ceil(a.data.count/25),n=a.data.albums;if(e.pageNum&&0===n.length)return page.updateTrigger(e.trigger),e.autoPage?(e.pageNum=t-1,page.getAlbums(e)):swal("An error occurred!","There are no more albums to populate page "+(e.pageNum+1)+".","error");page.currentView=e.all?"albumsAll":"albums",page.cache={};var s=a.data.users,i=a.data.homeDomain;e.pageNum<0&&(e.pageNum=Math.max(0,t+e.pageNum));var l=page.paginate(a.data.count,25,e.pageNum),o='\n
    \n '+('\n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n ')+'\n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n ',r='\n \n ",d=o.replace(/id="filters"/,'id="bFilters"').replace(/(data-action="filter-uploads")/,'$1 data-filtersid="bFilters"').replace(/id="jumpToPage"/,'id="bJumpToPage"').replace(/(data-action="jump-to-page")/g,'$1 data-jumpid="bJumpToPage"'),c=l.replace(/(data-action="page-ellipsis")/g,'$1 data-jumpid="bJumpToPage"'),p=!1,u='\n

    Create new album

    \n
    \n
    \n
    \n \n
    \n

    Max length is '+page.albumTitleMaxLength+' characters.

    \n
    \n
    \n
    \n \n
    \n

    Max length is '+page.albumDescMaxLength+' characters.

    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n ';page.dom.innerHTML="\n "+(e.all?"":u)+"\n "+l+"\n "+o+"\n "+r+'\n
    \n \n \n \n \n \n \n '+(e.all?"":"")+'\n \n \n \n \n \n \n \n \n \n \n \n
    IDNameUserUploadsSizeCreated atZIP sizeZIP generated atPublic link('+a.data.count+' total)
    \n
    \n '+r+"\n "+d+"\n "+c+"\n ";for(var g=document.querySelector("#table"),m=0;mb.editedAt);var w=0!==b.enabled;page.cache[b.id]={name:b.name,download:b.download,public:b.public,description:b.description,descriptionHtml:b.descriptionHtml,enabled:w,homeDomain:i,urlPath:"/a/",identifier:b.identifier};var y=document.createElement("tr");y.dataset.id=b.id,y.innerHTML='\n \n "+b.id+"\n "+b.name+"\n "+(e.all?""+(b.userid&&s[b.userid]||"")+"":"")+"\n "+b.uploads+'\n '+page.getPrettyBytes(b.size)+'\n '+b.prettyDate+"\n "+(b.hasZip?page.getPrettyBytes(b.zipSize):"-")+"\n "+(b.hasZip?b.prettyZipDate:"-")+"\n '+h+'\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n '+(e.all?'\n \n \n \n ':"")+"\n \n ",g.appendChild(y),page.checkboxes=g.querySelectorAll('.checkbox[data-action="select"]')}var k=document.querySelector("#selectAll");k&&!p&&(k.checked=!0,k.title="Unselect all"),page.fadeInDom();var x=n.length?e.pageNum:0;(e.forceScroll||null===page.prevPageNums[page.currentView]||page.prevPageNums[page.currentView]!==x)&&page.scrollToDom(),page.updateTrigger(e.trigger,"active"),"albumsAll"===page.currentView&&(page.views[page.currentView].filters=e.filters),page.views[page.currentView].pageNum=page.prevPageNums[page.currentView]=x}})).catch((function(a){page.updateTrigger(e.trigger),page.onAxiosError(a)}))},editAlbum:function(e){var a=page.cache[e];if(a){var t=a.urlPath+a.identifier,n=a.homeDomain+t,s=document.createElement("div");s.innerHTML='\n
    \n
    \n \n
    \n

    Max length is '+page.albumTitleMaxLength+' characters.

    \n
    \n
    \n
    \n \n
    \n

    Markdown supported. Max length is '+page.albumDescMaxLength+" characters.

    \n
    \n "+(a.descriptionHtml?'
    \n
    \n '+a.descriptionHtml+'\n
    \n

    Save changes then re-open this Edit prompt to refresh this preview.

    \n
    ':"")+"\n "+("albumsAll"===page.currentView&&page.permissions.moderator?'
    \n
    \n \n
    \n
    ":"")+'\n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n

    Current public link: '+t+"

    \n
    \n ",swal({title:"Edit album",icon:"info",content:s,buttons:{cancel:!0,confirm:{closeModal:!1}}}).then((function(t){if(t){var n={id:e,name:document.querySelector("#swalName").value.trim(),description:document.querySelector("#swalDescription").value.trim(),download:document.querySelector("#swalDownload").checked,public:document.querySelector("#swalPublic").checked,requestLink:document.querySelector("#swalRequestLink").checked};"albumsAll"===page.currentView&&page.permissions.moderator&&(n.enabled=document.querySelector("#swalEnabled").checked),axios.post("api/albums/edit",n).then((function(e){if(e){if(!1===e.data.success)return"No token provided"===e.data.description?page.verifyToken(page.token):swal("An error occurred!",e.data.description,"error");e.data.identifier?swal("Success!","The album's new identifier is: "+e.data.identifier+".","success"):e.data.name!==a.name?swal("Success!","The album was renamed to: "+e.data.name+".","success"):swal("Success!","The album was edited.","success",{buttons:!1,timer:1500}),page.getAlbumsSidebar(),page.getAlbums(Object.assign(page.views[page.currentView],{autoPage:!0}))}})).catch(page.onAxiosError)}}))}},disableAlbum:function(e){swal({title:"Are you sure?",text:"This won't delete the uploads associated with the album!",icon:"warning",dangerMode:!0,buttons:{cancel:!0,confirm:{text:"Yes, disable it!",closeModal:!1},purge:{text:"Umm, delete the uploads, please?",value:"purge",className:"swal-button--danger",closeModal:!1}}}).then((function(a){a&&axios.post("api/albums/disable",{id:e,purge:"purge"===a}).then((function(e){if(!1===e.data.success){var a=Array.isArray(e.data.failed)?e.data.failed:[];return"No token provided"===e.data.description?page.verifyToken(page.token):a.length?swal("An error occurred!","Unable to delete "+a.length+" of the album's upload"+(1===a.length?"":"s")+".","error"):swal("An error occurred!",e.data.description,"error")}swal("Disabled!","The album has been disabled.","success",{buttons:!1,timer:1500}),page.getAlbumsSidebar(),page.getAlbums(Object.assign(page.views[page.currentView],{autoPage:!0}))})).catch(page.onAxiosError)}))},deleteAlbum:function(e){swal({title:"Are you sure?",text:"You won't be able to recover this album!\nThis also won't delete the uploads associated with the album!",icon:"warning",dangerMode:!0,buttons:{cancel:!0,confirm:{text:"Yes, delete it!",closeModal:!1},purge:{text:"Umm, delete the uploads, please?",value:"purge",className:"swal-button--danger",closeModal:!1}}}).then((function(a){a&&axios.post("api/albums/delete",{id:e,purge:"purge"===a}).then((function(e){if(!1===e.data.success){var a=Array.isArray(e.data.failed)?e.data.failed:[];return"No token provided"===e.data.description?page.verifyToken(page.token):a.length?swal("An error occurred!","Unable to delete "+a.length+" of the album's upload"+(1===a.length?"":"s")+".","error"):swal("An error occurred!",e.data.description,"error")}swal("Disabled!","The album has been deleted.","success",{buttons:!1,timer:1500}),page.getAlbumsSidebar(),page.getAlbums(Object.assign(page.views[page.currentView],{autoPage:!0}))})).catch(page.onAxiosError)}))},submitAlbum:function(e){page.updateTrigger(e,"loading"),axios.post("api/albums",{name:document.querySelector("#albumName").value.trim(),description:document.querySelector("#albumDescription").value.trim()}).then((function(a){if(a){if(page.updateTrigger(e),!1===a.data.success)return"No token provided"===a.data.description?page.verifyToken(page.token):swal("An error occurred!",a.data.description,"error");swal("Woohoo!","Album was created successfully.","success",{buttons:!1,timer:1500}),page.getAlbumsSidebar(),page.getAlbums({pageNum:-1})}})).catch((function(a){page.updateTrigger(e),page.onAxiosError(a)}))},getAlbumsSidebar:function(){axios.get("api/albums",{headers:{simple:"1"}}).then((function(e){if(e){if(!1===e.data.success)return"No token provided"===e.data.description?page.verifyToken(page.token):swal("An error occurred!",e.data.description,"error");var a=e.data.albums,t=e.data.count,n=document.querySelector("#albumsSidebar"),s=n.querySelectorAll("li > a"),i=s.length!==t;if(s.length){for(var l=0;l\n \n
    \n
    \n \n
    \n
    \n \n \n ',page.fadeInDom(),page.scrollToDom(),page.updateTrigger(e.trigger,"active"),document.querySelector("#getNewToken").addEventListener("click",(function(e){if(page.isSomethingLoading)return page.warnSomethingLoading();var a=e.currentTarget;page.updateTrigger(a,"loading"),axios.post("api/tokens/change").then((function(e){if(!1===e.data.success)return"No token provided"===e.data.description?page.verifyToken(page.token):(page.updateTrigger(a),swal("An error occurred!",e.data.description,"error"));page.updateTrigger(a),swal({title:"Woohoo!",text:"Your token was successfully changed.",icon:"success",buttons:!1,timer:1500}).then((function(){axios.defaults.headers.common.token=e.data.token,localStorage[lsKeys.token]=e.data.token,page.token=e.data.token,page.changeToken()}))})).catch((function(e){page.updateTrigger(a),page.onAxiosError(e)}))}))},changePassword:function(e){void 0===e&&(e={}),page.dom.innerHTML='\n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n ',page.fadeInDom(),page.scrollToDom(),page.updateTrigger(e.trigger,"active"),document.querySelector("#sendChangePassword").addEventListener("click",(function(e){if(page.isSomethingLoading)return page.warnSomethingLoading();page.dom.querySelector("form").checkValidity()&&(document.querySelector("#password").value===document.querySelector("#passwordConfirm").value?page.sendNewPassword(document.querySelector("#password").value,e.currentTarget):swal({title:"Password mismatch!",text:"Your passwords do not match, please try again.",icon:"error"}))}))},sendNewPassword:function(e,a){page.updateTrigger(a,"loading"),axios.post("api/password/change",{password:e}).then((function(e){if(!1===e.data.success)return"No token provided"===e.data.description?page.verifyToken(page.token):(page.updateTrigger(a),swal("An error occurred!",e.data.description,"error"));page.updateTrigger(a),swal({title:"Woohoo!",text:"Your password was successfully changed.",icon:"success",buttons:!1,timer:1500}).then((function(){page.changePassword()}))})).catch((function(e){page.updateTrigger(a),page.onAxiosError(e)}))},getUsers:function(e){if(void 0===e&&(e={}),!page.permissions.admin)return swal("An error occurred!","You cannot do this!","error");if(page.isSomethingLoading)return page.warnSomethingLoading();page.updateTrigger(e.trigger,"loading"),"number"!=typeof e.pageNum&&(e.pageNum=0);var a="api/users/"+e.pageNum;axios.get(a).then((function(a){if(!1===a.data.success)return"No token provided"===a.data.description?page.verifyToken(page.token):(page.updateTrigger(e.trigger),swal("An error occurred!",a.data.description,"error"));var t=Math.ceil(a.data.count/25),n=a.data.users;if(e.pageNum&&0===n.length)return page.updateTrigger(e.trigger),e.autoPage?(e.pageNum=t-1,page.getUsers(e)):swal("An error occurred!","There are no more users to populate page "+(e.pageNum+1)+".","error");page.currentView="users",page.cache={},e.pageNum<0&&(e.pageNum=Math.max(0,t+e.pageNum));var s=page.paginate(a.data.count,25,e.pageNum),i='\n
    \n '+('\n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n ')+'\n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n ',l='\n \n ',o=i.replace(/id="filters"/,'id="bFilters"').replace(/(data-action="filter-uploads")/,'$1 data-filtersid="bFilters"').replace(/id="jumpToPage"/,'id="bJumpToPage"').replace(/(data-action="jump-to-page")/g,'$1 data-jumpid="bJumpToPage"'),r=s.replace(/(data-action="page-ellipsis")/g,'$1 data-jumpid="bJumpToPage"'),d=!1;page.dom.innerHTML="\n "+s+"\n "+i+"\n "+l+'\n
    \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
    UsernameUploadsUsageGroupRegistration dateLast token update('+a.data.count+' total)
    \n
    \n '+l+"\n "+o+"\n "+r+"\n ";for(var c=document.querySelector("#table"),p=0;p\n "+u.username+"\n "+u.uploads+"\n "+page.getPrettyBytes(u.usage)+"\n "+m+"\n "+f+"\n "+w+'\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n ',c.appendChild(y),page.checkboxes=c.querySelectorAll('.checkbox[data-action="select"]')}var k=document.querySelector("#selectAll");k&&!d&&(k.checked=!0,k.title="Unselect all"),page.fadeInDom();var x=n.length?e.pageNum:0;(e.forceScroll||null===page.prevPageNums[page.currentView]||page.prevPageNums[page.currentView]!==x)&&page.scrollToDom(),page.updateTrigger(e.trigger,"active"),page.views[page.currentView].pageNum=page.prevPageNums[page.currentView]=x})).catch((function(a){page.updateTrigger(e.trigger),page.onAxiosError(a)}))},createUser:function(){var e=Object.keys(page.permissions).map((function(e,a,t){return'"})).join("\n"),a=document.createElement("div");a.innerHTML='\n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n ",swal({title:"Create new user",icon:"info",content:a,buttons:{cancel:!0,confirm:{closeModal:!1}}}).then((function(e){e&&axios.post("api/users/create",{username:document.querySelector("#swalUsername").value,password:document.querySelector("#swalPassword").value,group:document.querySelector("#swalGroup").value}).then((function(e){if(e){if(!1===e.data.success)return"No token provided"===e.data.description?page.verifyToken(page.token):swal("An error occurred!",e.data.description,"error");var a=document.createElement("div");a.innerHTML="\n

    Username: "+e.data.username+"

    \n

    Password: "+e.data.password+"

    \n

    User group: "+e.data.group+"

    \n ",swal({title:"Created a new user!",icon:"success",content:a}),page.getUsers(Object.assign(page.views.users,{pageNum:-1}))}})).catch(page.onAxiosError)}))},editUser:function(e){var a=page.cache[e];if(a){var t=!1,n=Object.keys(page.permissions).map((function(e,n,s){var i=e===a.displayGroup;return i&&(t=void 0!==s[n+1]&&page.permissions[s[n+1]]),'"})).join("\n"),s=t?"":" disabled",i=document.createElement("div");i.innerHTML='\n
    \n

    User ID: '+e+'

    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n "+(t?"":'
    \n You cannot modify user in the same or higher group as you.\n
    ')+"\n ",swal({title:"Edit user",icon:"info",content:i,buttons:{cancel:!0,confirm:{closeModal:!1}}}).then((function(t){t&&axios.post("api/users/edit",{id:e,username:document.querySelector("#swalUsername").value,group:document.querySelector("#swalGroup").value,enabled:document.querySelector("#swalEnabled").checked,resetPassword:document.querySelector("#swalResetPassword").checked}).then((function(e){if(e){if(!1===e.data.success)return"No token provided"===e.data.description?page.verifyToken(page.token):swal("An error occurred!",e.data.description,"error");var t=!0,n=document.createElement("div"),s=a.username;e.data.update.username!==a.username&&(n.innerHTML+="

    "+a.username+" was renamed into: "+e.data.update.username+".

    ",t=!1,s=e.data.update.username),e.data.update.password&&(n.innerHTML+="\n

    "+s+"'s new password is:

    \n

    "+e.data.update.password+"

    \n ",t=!1),e.data.update.enabled!==a.enabled&&(n.innerHTML+="

    "+s+" has been "+(e.data.update.enabled?"enabled":"disabled")+"!

    "),n.innerHTML||(n.innerHTML="

    "+s+" was edited!

    "),swal({title:"Success!",icon:"success",content:n,buttons:!t,timer:t?1500:null}),page.getUsers(page.views.users)}})).catch(page.onAxiosError)}))}},disableUser:function(e){var a=page.cache[e];if(a&&a.enabled){var t=document.createElement("div");t.innerHTML="\n

    You will be disabling a user named "+page.cache[e].username+".

    \n

    Their files will remain.

    \n ",swal({title:"Are you sure?",icon:"warning",content:t,dangerMode:!0,buttons:{cancel:!0,confirm:{text:"Yes, disable them!",closeModal:!1}}}).then((function(a){a&&axios.post("api/users/disable",{id:e}).then((function(a){if(a){if(!1===a.data.success)return"No token provided"===a.data.description?page.verifyToken(page.token):swal("An error occurred!",a.data.description,"error");swal("Success!",page.cache[e].username+" has been disabled.","success",{buttons:!1,timer:1500}),page.getUsers(page.views.users)}})).catch(page.onAxiosError)}))}},deleteUser:function(e){if(page.cache[e]){var a=document.createElement("div");a.innerHTML="\n

    You will be deleting a user named "+page.cache[e].username+".

    \n

    Their uploads will still remain, unless you choose otherwise.

    \n ",swal({title:"Are you sure?",icon:"warning",content:a,dangerMode:!0,buttons:{cancel:!0,confirm:{text:"Yes, ONLY the user!",closeModal:!1},purge:{text:"Yes, AND their uploads too!",value:"purge",className:"swal-button--danger",closeModal:!1}}}).then((function(a){a&&axios.post("api/users/delete",{id:e,purge:"purge"===a}).then((function(a){if(a){if(!1===a.data.success){var t=Array.isArray(a.data.failed)?a.data.failed:[];return"No token provided"===a.data.description?page.verifyToken(page.token):t.length?swal("An error occurred!","Unable to delete "+t.length+" of the user's upload"+(1===t.length?"":"s")+".","error"):swal("An error occurred!",a.data.description,"error")}swal("Success!",page.cache[e].username+" has been deleted.","success",{buttons:!1,timer:1500}),page.getUsers(Object.assign(page.views.users,{autoPage:!0}))}})).catch(page.onAxiosError)}))}},paginate:function(e,a,t){t+=1;var n=Math.ceil(e/a),s="",i=function(e,a){for(var n=e;n<=a;++n)s+='
  • '+n+"
  • "},l=function(){s+='\n
  • 1
  • \n
  • \n '},o=function(){s+='\n
  • \n
  • '+n+"
  • \n "};return 7>=n?i(1,n):t<6?(i(1,6),o()):t>n-6+1?(l(),i(n-6+1,n)):(l(),i(t-3+1,t+3-1),o()),'\n \n "},getStatistics:function(e){if(void 0===e&&(e={}),!page.permissions.admin)return swal("An error occurred!","You cannot do this!","error");if(page.isSomethingLoading)return page.warnSomethingLoading();page.updateTrigger(e.trigger,"loading");axios.get("api/stats").then((function(a){if(!1===a.data.success)return"No token provided"===a.data.description?page.verifyToken(page.token):(page.updateTrigger(e.trigger),swal("An error occurred!",a.data.description,"error"));for(var t="",n=Object.keys(a.data.stats),s=0;s\n "+l[o]+"\n "+p+"\n \n "}}catch(e){i="\n \n Error parsing response. Try again?\n \n \n ",page.onError(e)}else i+="\n \n Generating, please try again later…\n \n \n ";t+='\n
    \n \n \n \n \n \n \n \n \n "+i+"\n \n
    '+n[s]+"
    \n
    \n "}Array.isArray(a.data.hrtime)&&(t+='\n
    \n
    \n Time taken: '+a.data.hrtime[0]+"s "+Math.ceil(a.data.hrtime[1]/1e6)+"ms.\n
    \n
    \n "),page.dom.innerHTML=t,page.fadeInDom(),page.scrollToDom(),page.updateTrigger(e.trigger,"active")})).catch((function(a){page.updateTrigger(e.trigger),page.onAxiosError(a)}))}};window.addEventListener("DOMContentLoaded",(function(){"function"!=typeof Object.assign&&Object.defineProperty(Object,"assign",{value:function(e,a){"use strict";var t=arguments;if(null==e)throw new TypeError("Cannot convert undefined or null to object");for(var n=Object(e),s=1;s {\n document.querySelector('#loader').classList.add('is-hidden')\n page.section.classList.remove('is-hidden')\n}\n\n// Handler for regular JS errors\npage.onError = error => {\n console.error(error)\n\n const content = document.createElement('div')\n content.innerHTML = `\n

    ${error.toString()}

    \n

    Please check your console for more information.

    \n `\n return swal({\n title: 'An error occurred!',\n icon: 'error',\n content\n })\n}\n\n// Handler for Axios errors\npage.onAxiosError = error => {\n console.error(error)\n\n // Better Cloudflare errors\n const cloudflareErrors = {\n 520: 'Unknown Error',\n 521: 'Web Server Is Down',\n 522: 'Connection Timed Out',\n 523: 'Origin Is Unreachable',\n 524: 'A Timeout Occurred',\n 525: 'SSL Handshake Failed',\n 526: 'Invalid SSL Certificate',\n 527: 'Railgun Error',\n 530: 'Origin DNS Error'\n }\n\n const statusText = cloudflareErrors[error.response.status] || error.response.statusText\n const description = error.response.data && error.response.data.description\n ? error.response.data.description\n : 'There was an error with the request.\\nPlease check the console for more information.'\n\n return swal(`${error.response.status} ${statusText}`, description, 'error')\n}\n\npage.preparePage = () => {\n if (page.token) page.verifyToken(page.token, true)\n else window.location = 'auth'\n}\n\npage.checkClientVersion = apiVersion => {\n const self = document.querySelector('#mainScript')\n const match = self.src.match(/\\?_=(\\d+)$/)\n if (match && match[1] && match[1] !== apiVersion) {\n return swal({\n title: 'Update detected!',\n text: 'Client assets have been updated. Reload to display the latest version?',\n icon: 'info',\n buttons: {\n confirm: {\n text: 'Reload',\n closeModal: false\n }\n }\n }).then(() => {\n window.location.reload()\n })\n }\n}\n\npage.verifyToken = (token, reloadOnError) => {\n axios.post('api/tokens/verify', { token }).then(response => {\n if (response.data.success === false) {\n return swal({\n title: 'An error occurred!',\n text: response.data.description,\n icon: 'error'\n }).then(() => {\n if (!reloadOnError) return\n localStorage.removeItem(lsKeys.token)\n window.location = 'auth'\n })\n }\n\n axios.defaults.headers.common.token = token\n localStorage[lsKeys.token] = token\n\n if (response.data.version) {\n page.checkClientVersion(response.data.version)\n }\n\n page.token = token\n page.username = response.data.username\n page.permissions = response.data.permissions\n page.prepareDashboard()\n }).catch(page.onAxiosError)\n}\n\npage.prepareDashboard = () => {\n page.section = document.querySelector('#dashboard')\n page.dom = page.section.querySelector('#page')\n\n // Capture all click events\n page.dom.addEventListener('click', page.domClick, true)\n\n // Capture all submit events\n page.dom.addEventListener('submit', event => {\n // Prevent default if necessary\n if (event.target && event.target.classList.contains('prevent-default')) {\n return event.preventDefault()\n }\n }, true)\n\n page.menusContainer = document.querySelector('#menu')\n\n // All item menus in the sidebar\n const itemMenus = [\n { selector: '#itemUploads', onclick: page.getUploads },\n { selector: '#itemDeleteUploadsByNames', onclick: page.deleteUploadsByNames },\n { selector: '#itemManageYourAlbums', onclick: page.getAlbums },\n { selector: '#itemManageToken', onclick: page.changeToken },\n { selector: '#itemChangePassword', onclick: page.changePassword },\n { selector: '#itemLogout', onclick: page.logout },\n { selector: '#itemManageUploads', onclick: page.getUploads, params: { all: true }, group: 'moderator' },\n { selector: '#itemManageAlbums', onclick: page.getAlbums, params: { all: true }, group: 'moderator' },\n { selector: '#itemStatistics', onclick: page.getStatistics, group: 'admin' },\n { selector: '#itemManageUsers', onclick: page.getUsers, group: 'admin' }\n ]\n\n for (let i = 0; i < itemMenus.length; i++) {\n // Skip item menu if not enough permission\n if (itemMenus[i].group && !page.permissions[itemMenus[i].group]) continue\n\n // Add onclick event listener\n const item = document.querySelector(itemMenus[i].selector)\n item.addEventListener('click', event => {\n if (page.isSomethingLoading) return page.warnSomethingLoading()\n\n // eslint-disable-next-line compat/compat\n itemMenus[i].onclick.call(null, Object.assign(itemMenus[i].params || {}, {\n trigger: event.currentTarget,\n forceScroll: true\n }))\n })\n\n item.classList.remove('is-hidden')\n page.menus.push(item)\n }\n\n // If at least a moderator, show administration section\n if (page.permissions.moderator) {\n document.querySelector('#itemLabelAdmin').classList.remove('is-hidden')\n document.querySelector('#itemListAdmin').classList.remove('is-hidden')\n }\n\n // Update text of logout button\n document.querySelector('#itemLogout').innerHTML = `Logout ( ${page.username} )`\n\n // Finally display dashboard\n page.unhide()\n\n // Load albums sidebar\n page.getAlbumsSidebar()\n\n if (typeof page.prepareShareX === 'function') page.prepareShareX()\n}\n\npage.logout = params => {\n page.updateTrigger(params.trigger, 'active')\n localStorage.removeItem(lsKeys.token)\n window.location = 'auth'\n}\n\npage.warnSomethingLoading = () => {\n swal('Please wait!', 'Something else is still loading\\u2026', 'warning', {\n buttons: false,\n timer: 3000\n })\n}\n\npage.updateTrigger = (trigger, newState) => {\n if (!trigger) return\n\n // Disable menus container and pagination when loading\n if (newState === 'loading') {\n page.isSomethingLoading = true\n page.section.classList.add('is-loading')\n } else {\n page.section.classList.remove('is-loading')\n page.isSomethingLoading = false\n }\n\n if (newState === 'loading') {\n trigger.classList.add('is-loading')\n } else if (newState === 'active') {\n if (trigger.parentNode.tagName === 'LI' && !trigger.className.includes('pagination-link')) {\n for (let i = 0; i < page.menus.length; i++) {\n page.menus[i].classList.remove('is-active')\n }\n trigger.classList.add('is-active')\n }\n trigger.classList.remove('is-loading')\n } else {\n trigger.classList.remove('is-loading')\n trigger.classList.remove('is-active')\n }\n}\n\npage.getItemID = element => {\n // This expects the item's parent to have the item's ID\n let parent = element.parentNode\n // If the element is part of a set of controls, use the container's parent instead\n if (element.parentNode.classList.contains('controls')) parent = parent.parentNode\n return parseInt(parent.dataset.id)\n}\n\npage.domClick = event => {\n // We are processing clicks this way to avoid using \"onclick\" attribute\n // Apparently we will need to use \"unsafe-inline\" for \"script-src\" directive\n // of Content Security Policy (CSP), if we want to use \"onclick\" attribute\n // Though I think that only applies to some browsers (?)\n // Of course it wouldn't have mattered if we didn't use CSP to begin with\n // Anyway, I personally would rather not use \"onclick\" attribute\n let element = event.target\n if (!element) return\n\n // Delegate click events to their A or BUTTON parents\n if (['I'].includes(element.tagName) && ['SPAN'].includes(element.parentNode.tagName)) {\n element = element.parentNode\n }\n if (['SPAN'].includes(element.tagName) && ['A', 'BUTTON'].includes(element.parentNode.tagName)) {\n element = element.parentNode\n }\n\n // Skip elements that have no action data\n if (!element.dataset || !element.dataset.action) return\n\n // Skip disabled elements\n if (element.hasAttribute('disabled')) return\n\n event.stopPropagation() // maybe necessary\n const id = page.getItemID(element)\n const action = element.dataset.action\n\n switch (action) {\n // Uploads\n case 'view-list':\n return page.setUploadsView('list', element)\n case 'view-thumbs':\n return page.setUploadsView('thumbs', element)\n case 'toggle-original-names':\n return page.toggleOriginalNames(element)\n case 'add-to-album':\n return page.addToAlbum(id)\n case 'delete-upload':\n return page.deleteUpload(id)\n case 'add-selected-uploads-to-album':\n return page.addSelectedUploadsToAlbum()\n case 'bulk-delete-uploads':\n return page.bulkDeleteUploads()\n case 'display-preview':\n return page.displayPreview(id)\n // Manage uploads\n case 'upload-filters-help':\n return page.uploadFiltersHelp(element)\n case 'filter-uploads':\n return page.filterUploads(element)\n // Manage your albums\n case 'submit-album':\n return page.submitAlbum(element)\n case 'edit-album':\n return page.editAlbum(id)\n case 'disable-album':\n return page.disableAlbum(id)\n case 'delete-album':\n return page.deleteAlbum(id)\n case 'view-album-uploads':\n return page.viewAlbumUploads(id, element)\n // Manage users\n case 'create-user':\n return page.createUser()\n case 'edit-user':\n return page.editUser(id)\n case 'disable-user':\n return page.disableUser(id)\n case 'delete-user':\n return page.deleteUser(id)\n case 'view-user-uploads':\n return page.viewUserUploads(id, element)\n // Others\n case 'get-new-token':\n return page.getNewToken(element)\n // Uploads & Users\n case 'clear-selection':\n return page.clearSelection()\n case 'select':\n return page.select(element, event)\n case 'select-all':\n return page.selectAll(element)\n case 'page-ellipsis':\n return page.focusJumpToPage(element)\n case 'page-prev':\n case 'page-next':\n case 'page-goto':\n case 'jump-to-page':\n return page.switchPage(action, element)\n }\n}\n\npage.fadeInDom = disableFading => {\n if (page.fadingIn) {\n clearTimeout(page.fadingIn)\n page.dom.classList.remove('fade-in')\n }\n\n if (!disableFading) {\n page.dom.classList.add('fade-in')\n page.fadingIn = setTimeout(() => {\n page.dom.classList.remove('fade-in')\n }, 500)\n }\n}\n\npage.scrollToDom = disableSmooth => {\n page.dom.scrollIntoView({\n behavior: disableSmooth ? 'auto' : 'smooth',\n block: 'start',\n inline: 'nearest'\n })\n}\n\npage.getByView = (view, get) => {\n switch (view) {\n case 'uploads':\n case 'uploadsAll':\n return {\n type: 'uploads',\n func: page.getUploads\n }[get]\n case 'albums':\n case 'albumsAll':\n return {\n type: 'albums',\n func: page.getAlbums\n }[get]\n case 'users':\n return {\n type: 'users',\n func: page.getUsers\n }[get]\n default:\n return null\n }\n}\n\npage.switchPage = (action, element) => {\n if (page.isSomethingLoading) return page.warnSomethingLoading()\n\n // eslint-disable-next-line compat/compat\n const params = Object.assign(page.views[page.currentView], {\n trigger: element\n })\n\n const func = page.getByView(page.currentView, 'func')\n\n switch (action) {\n case 'page-prev':\n params.pageNum = page.views[page.currentView].pageNum - 1\n if (params.pageNum < 0) {\n return swal('An error occurred!', 'This is already the first page.', 'error')\n }\n return func(params)\n case 'page-next':\n params.pageNum = page.views[page.currentView].pageNum + 1\n return func(params)\n case 'page-goto':\n params.pageNum = parseInt(element.dataset.goto)\n return func(params)\n case 'jump-to-page': {\n const jumpToPage = document.querySelector(`#${element.dataset.jumpid || 'jumpToPage'}`)\n if (!jumpToPage.checkValidity()) return\n const parsed = parseInt(jumpToPage.value)\n params.pageNum = isNaN(parsed) ? 0 : (parsed - 1)\n if (params.pageNum < 0) params.pageNum = 0\n return func(params)\n }\n }\n}\n\npage.focusJumpToPage = element => {\n const jumpToPage = document.querySelector(`#${element.dataset.jumpid || 'jumpToPage'}`)\n if (!jumpToPage) return\n jumpToPage.focus()\n jumpToPage.select()\n}\n\npage.getUploads = (params = {}) => {\n if (params && params.all && !page.permissions.moderator) {\n return swal('An error occurred!', 'You cannot do this!', 'error')\n }\n\n if (page.isSomethingLoading) return page.warnSomethingLoading()\n\n page.updateTrigger(params.trigger, 'loading')\n\n if (typeof params.pageNum !== 'number' || params.pageNum < 0) {\n params.pageNum = 0\n }\n\n const url = typeof params.album !== 'undefined'\n ? `api/album/${params.album}/${params.pageNum}`\n : `api/uploads/${params.pageNum}`\n\n const headers = {}\n if (params.all) headers.all = '1'\n if (params.filters) {\n headers.filters = params.filters\n // Send client timezone offset if properly using date: and/or :expiry filters\n // Server will pretend client is on UTC if unset\n if (/(^|\\s)(date|expiry):[\\d\"]/.test(params.filters)) {\n headers.minoffset = new Date().getTimezoneOffset()\n }\n }\n\n axios.get(url, { headers }).then(response => {\n if (response.data.success === false) {\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n page.updateTrigger(params.trigger)\n return swal('An error occurred!', response.data.description, 'error')\n }\n }\n\n const pages = Math.ceil(response.data.count / 25)\n const files = response.data.files\n if (params.pageNum && (files.length === 0)) {\n page.updateTrigger(params.trigger)\n if (params.autoPage) {\n params.pageNum = pages - 1\n return page.getUploads(params)\n } else {\n return swal('An error occurred!', `There are no more uploads to populate page ${params.pageNum + 1}.`, 'error')\n }\n }\n\n page.currentView = params.all ? 'uploadsAll' : 'uploads'\n page.cache = {}\n\n const albums = response.data.albums\n const users = response.data.users\n const basedomain = response.data.basedomain\n\n if (params.pageNum < 0) params.pageNum = Math.max(0, pages + params.pageNum)\n const pagination = page.paginate(response.data.count, 25, params.pageNum)\n\n const filter = `\n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n `\n const extraControls = `\n
    \n ${filter}\n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n `\n\n const controls = `\n \n `\n\n // Do some string replacements for bottom controls\n const bottomFiltersId = 'bFilters'\n const bottomJumpId = 'bJumpToPage'\n const bottomExtraControls = extraControls\n .replace(/id=\"filters\"/, `id=\"${bottomFiltersId}\"`)\n .replace(/(data-action=\"filter-uploads\")/, `$1 data-filtersid=\"${bottomFiltersId}\"`)\n .replace(/id=\"jumpToPage\"/, `id=\"${bottomJumpId}\"`)\n .replace(/(data-action=\"jump-to-page\")/g, `$1 data-jumpid=\"${bottomJumpId}\"`)\n const bottomPagination = pagination\n .replace(/(data-action=\"page-ellipsis\")/g, `$1 data-jumpid=\"${bottomJumpId}\"`)\n\n // Whether there are any unselected items\n let unselected = false\n\n const showOriginalNames = page.views[page.currentView].originalNames\n const hasExpiryDateColumn = files.some(file => typeof file.expirydate !== 'undefined')\n\n for (let i = 0; i < files.length; i++) {\n // Build full URLs\n files[i].file = `${basedomain}/${files[i].name}`\n if (files[i].thumb) {\n files[i].thumb = `${basedomain}/${files[i].thumb}`\n }\n\n // Determine types\n const extname = files[i].extname.toLowerCase()\n if (page.imageExts.includes(extname)) {\n files[i].type = 'picture'\n } else if (page.videoExts.includes(extname)) {\n files[i].type = 'video'\n } else if (page.audioExts.includes(extname)) {\n files[i].type = 'audio'\n } else {\n files[i].type = 'other'\n }\n\n files[i].previewable = files[i].thumb || files[i].type === 'audio'\n\n // Cache bare minimum data for thumbnails viewer\n page.cache[files[i].id] = {\n name: files[i].name,\n original: files[i].original,\n extname: files[i].extname,\n thumb: files[i].thumb,\n file: files[i].file,\n type: files[i].type,\n previewable: files[i].previewable\n }\n\n // Prettify\n files[i].prettyBytes = page.getPrettyBytes(parseInt(files[i].size))\n files[i].prettyDate = page.getPrettyDate(new Date(files[i].timestamp * 1000))\n\n if (hasExpiryDateColumn) {\n files[i].prettyExpiryDate = files[i].expirydate\n ? page.getPrettyDate(new Date(files[i].expirydate * 1000))\n : null\n }\n\n // Update selected status\n files[i].selected = page.selected[page.currentView].includes(files[i].id)\n if (!files[i].selected) unselected = true\n\n // Appendix (display album or user)\n if (params.all) {\n files[i].appendix = files[i].userid\n ? users[files[i].userid] || ''\n : ''\n } else if (typeof params.album === 'undefined') {\n files[i].appendix = files[i].albumid\n ? albums[files[i].albumid] || ''\n : ''\n }\n }\n\n if (page.views[page.currentView].type === 'thumbs') {\n page.dom.innerHTML = `\n ${pagination}\n ${extraControls}\n ${controls}\n
    \n
    \n ${controls}\n ${bottomExtraControls}\n ${bottomPagination}\n `\n\n const table = document.querySelector('#table')\n\n for (let i = 0; i < files.length; i++) {\n const upload = files[i]\n const div = document.createElement('div')\n div.className = 'image-container column'\n div.dataset.id = upload.id\n\n if (typeof upload.thumb !== 'undefined') {\n div.innerHTML = `\"${upload.name}\"`\n } else {\n div.innerHTML = `

    ${upload.extname || 'N/A'}

    `\n }\n\n div.innerHTML += `\n \n
    \n ${upload.previewable\n ? `\n \n \n \n `\n : ''}\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
    \n
    \n

    ${upload.name}

    \n ${showOriginalNames ? `

    ${upload.original}

    ` : ''}\n

    ${upload.appendix ? `${upload.appendix} – ` : ''}${upload.prettyBytes}

    \n ${hasExpiryDateColumn && upload.prettyExpiryDate\n ? `

    EXP: ${upload.prettyExpiryDate}

    `\n : ''}\n
    \n `\n\n table.appendChild(div)\n page.checkboxes = table.querySelectorAll('.checkbox[data-action=\"select\"]')\n }\n } else {\n const allAlbums = params.all && params.filters && params.filters.includes('albumid:')\n page.dom.innerHTML = `\n ${pagination}\n ${extraControls}\n ${controls}\n
    \n \n \n \n \n \n ${showOriginalNames ? '' : ''}\n ${typeof params.album === 'undefined' ? `` : ''}\n ${allAlbums ? '' : ''}\n \n ${params.all ? '' : ''}\n \n ${hasExpiryDateColumn ? '' : ''}\n \n \n \n \n \n
    File nameOriginal nameUser' : 'albumid\">Album'}AlbumSizeIPUpload dateExpiry date(${response.data.count} total)
    \n
    \n ${controls}\n ${bottomExtraControls}\n ${bottomPagination}\n `\n\n const table = document.querySelector('#table')\n\n for (let i = 0; i < files.length; i++) {\n const upload = files[i]\n const tr = document.createElement('tr')\n tr.dataset.id = upload.id\n tr.innerHTML = `\n \n ${upload.name}\n ${showOriginalNames ? `${upload.original}` : ''}\n ${typeof params.album === 'undefined' ? `${upload.appendix}` : ''}\n ${allAlbums ? `${upload.albumid ? (albums[upload.albumid] || '') : ''}` : ''}\n ${upload.prettyBytes}\n ${params.all ? `${upload.ip || ''}` : ''}\n ${upload.prettyDate}\n ${hasExpiryDateColumn ? `${upload.prettyExpiryDate || '-'}` : ''}\n \n \n \n \n \n \n \n \n \n \n \n ${params.all\n ? ''\n : `\n \n \n \n `}\n \n \n \n \n \n \n `\n\n table.appendChild(tr)\n page.checkboxes = table.querySelectorAll('.checkbox[data-action=\"select\"]')\n }\n }\n\n const selectAll = document.querySelector('#selectAll')\n if (selectAll && !unselected && files.length) {\n selectAll.checked = true\n selectAll.title = 'Unselect all'\n }\n\n page.fadeInDom()\n\n const pageNum = files.length ? params.pageNum : 0\n if (params.forceScroll ||\n page.prevPageNums[page.currentView] === null ||\n page.prevPageNums[page.currentView] !== pageNum) {\n const disableSmooth = !params.forceScroll && page.views[page.currentView].type === 'thumbs'\n page.scrollToDom(disableSmooth)\n }\n\n if (page.views[page.currentView].type === 'thumbs') {\n page.lazyLoad.update()\n }\n\n page.updateTrigger(params.trigger, 'active')\n\n if (page.currentView === 'uploads') {\n page.views.uploads.album = params.album\n }\n page.views[page.currentView].filters = params.filters\n page.views[page.currentView].pageNum = page.prevPageNums[page.currentView] = pageNum\n }).catch(error => {\n page.updateTrigger(params.trigger)\n page.onAxiosError(error)\n })\n}\n\npage.setUploadsView = (view, element) => {\n if (page.isSomethingLoading) return page.warnSomethingLoading()\n\n if (view === 'list') {\n delete localStorage[lsKeys.viewType[page.currentView]]\n page.views[page.currentView].type = undefined\n } else {\n localStorage[lsKeys.viewType[page.currentView]] = view\n page.views[page.currentView].type = view\n }\n\n // eslint-disable-next-line compat/compat\n page.getUploads(Object.assign(page.views[page.currentView], {\n trigger: element\n }))\n}\n\npage.toggleOriginalNames = element => {\n if (page.isSomethingLoading) return page.warnSomethingLoading()\n\n if (page.views[page.currentView].originalNames) {\n delete localStorage[lsKeys.originalNames[page.currentView]]\n page.views[page.currentView].originalNames = false\n } else {\n localStorage[lsKeys.originalNames[page.currentView]] = '1'\n page.views[page.currentView].originalNames = true\n }\n\n // eslint-disable-next-line compat/compat\n page.getUploads(Object.assign(page.views[page.currentView], {\n trigger: element\n }))\n}\n\npage.displayPreview = id => {\n const file = page.cache[id]\n if (!file.previewable) return\n\n const div = document.createElement('div')\n div.innerHTML = `\n
    \n

    \n

    ${file.name}
    \n
    ${file.original}
    \n

    \n ${file.thumb\n ? `

    \n \n

    `\n : ''}\n
    \n `\n\n if (file.file && ['picture', 'video', 'audio'].includes(file.type)) {\n div.innerHTML += `\n \n `\n\n if (file.type === 'picture') {\n div.querySelector('#swalOriginal').addEventListener('click', event => {\n const trigger = event.currentTarget\n if (trigger.classList.contains('is-danger')) return\n\n trigger.classList.add('is-loading')\n const thumb = div.querySelector('#swalThumb')\n\n thumb.src = file.file\n thumb.onload = () => {\n trigger.classList.add('is-hidden')\n document.body.querySelector('.swal-overlay .swal-modal:not(.is-expanded)').classList.add('is-expanded')\n }\n thumb.onerror = event => {\n event.currentTarget.classList.add('is-hidden')\n trigger.className = 'button is-danger is-fullwidth'\n trigger.innerHTML = `\n \n \n \n Unable to load original\n `\n }\n })\n } else {\n const match = file.file.match(/.*\\/(.*)$/)\n if (match || match[1]) {\n div.querySelector('#swalOriginal').setAttribute('href', `v/${match[1]}`)\n div.querySelector('#swalOriginal').setAttribute('target', '_blank')\n }\n }\n }\n\n return swal({\n content: div,\n buttons: false\n }).then(() => {\n // Restore modal size\n document.body.querySelector('.swal-overlay .swal-modal').classList.remove('is-expanded')\n })\n}\n\npage.selectAll = element => {\n for (let i = 0; i < page.checkboxes.length; i++) {\n const id = page.getItemID(page.checkboxes[i])\n if (isNaN(id)) continue\n if (page.checkboxes[i].checked !== element.checked) {\n page.checkboxes[i].checked = element.checked\n if (page.checkboxes[i].checked) {\n page.selected[page.currentView].push(id)\n } else {\n page.selected[page.currentView].splice(page.selected[page.currentView].indexOf(id), 1)\n }\n }\n }\n\n if (page.selected[page.currentView].length) {\n localStorage[lsKeys.selected[page.currentView]] = JSON.stringify(page.selected[page.currentView])\n } else {\n delete localStorage[lsKeys.selected[page.currentView]]\n }\n\n element.title = element.checked ? 'Unselect all' : 'Select all'\n}\n\npage.selectInBetween = (element, lastElement) => {\n const thisIndex = parseInt(element.dataset.index)\n const lastIndex = parseInt(lastElement.dataset.index)\n\n const distance = Math.abs(thisIndex - lastIndex)\n if (distance < 2) return\n\n for (let i = 0; i < page.checkboxes.length; i++) {\n if ((thisIndex > lastIndex && i > lastIndex && i < thisIndex) ||\n (thisIndex < lastIndex && i > thisIndex && i < lastIndex)) {\n // Check or uncheck depending on the state of the initial checkbox\n const checked = page.checkboxes[i].checked = lastElement.checked\n const id = page.getItemID(page.checkboxes[i])\n if (!page.selected[page.currentView].includes(id) && checked) {\n page.selected[page.currentView].push(id)\n } else if (page.selected[page.currentView].includes(id) && !checked) {\n page.selected[page.currentView].splice(page.selected[page.currentView].indexOf(id), 1)\n }\n }\n }\n}\n\npage.select = (element, event) => {\n const id = page.getItemID(element)\n if (isNaN(id)) return\n\n if (event.shiftKey && page.lastSelected) {\n page.selectInBetween(element, page.lastSelected)\n // Check or uncheck depending on the state of the initial checkbox\n element.checked = page.lastSelected.checked\n } else {\n page.lastSelected = element\n }\n\n if (!page.selected[page.currentView].includes(id) && element.checked) {\n page.selected[page.currentView].push(id)\n } else if (page.selected[page.currentView].includes(id) && !element.checked) {\n page.selected[page.currentView].splice(page.selected[page.currentView].indexOf(id), 1)\n }\n\n // Update local storage\n if (page.selected[page.currentView].length) {\n localStorage[lsKeys.selected[page.currentView]] = JSON.stringify(page.selected[page.currentView])\n } else {\n delete localStorage[lsKeys.selected[page.currentView]]\n }\n}\n\npage.clearSelection = () => {\n const selected = page.selected[page.currentView]\n const type = page.getByView(page.currentView, 'type')\n const count = selected.length\n if (!count) return swal('An error occurred!', `You have not selected any ${type}.`, 'error')\n\n const suffix = count === 1 ? type.substring(0, type.length - 1) : type\n return swal({\n title: 'Are you sure?',\n text: `You are going to unselect ${count} ${suffix}.`,\n buttons: true\n }).then(proceed => {\n if (!proceed) return\n\n const checkboxes = page.checkboxes\n for (let i = 0; i < checkboxes.length; i++) {\n if (checkboxes[i].checked) {\n checkboxes[i].checked = false\n }\n }\n\n page.selected[page.currentView] = []\n delete localStorage[lsKeys.selected[page.currentView]]\n\n const selectAll = document.querySelector('#selectAll')\n if (selectAll) selectAll.checked = false\n\n return swal('Cleared selection!', `Unselected ${count} ${suffix}.`, 'success')\n })\n}\n\npage.uploadFiltersHelp = element => {\n const all = Boolean(element.dataset.all)\n const content = document.createElement('div')\n content.style = 'text-align: left'\n content.innerHTML = `${all\n ? `There are 2 filter keys, namely user (username) and ip.\n These keys can be specified more than once.\n For usernames with whitespaces, wrap them with double quotes (\").\n Special cases such as uploads by non-registered users or have no IPs respectively, use user:- or ip:-.\n\n To exclude certain users/ips while still listing every other uploads, add negation sign (-) before the keys.\n Negation sign can also be used to exclude the special cases mentioned above (i.e. -user:- or -ip:-).\n\n If you know the ID of a user's album, you can list its uploads with albumid key.\n Negation sign works for this key as well.`\n : `There is only 1 filter key, namely albumid.\n This key can be specified more than once.\n Special case such as uploads with no albums, use albumid:-.\n\n To exclude certain albums while still listing every other uploads, add negation sign (-) before the keys.\n Negation sign can also be used to exclude the special case mentioned above (i.e. -albumid:-).`}\n\n There are 2 range keys: date (upload date) and expiry (expiry date).\n Their format is: \"YYYY/MM/DD HH:MM:SS-YYYY/MM/DD HH:MM:SS\" (\"from\" date and \"to\" date respectively).\n You may specify only one of the dates.\n If \"to\" date is missing, 'now' will be used. If \"from\" date is missing, 'beginning of time' will be used.\n If any of the subsequent date or time units are not specified, their first value will be used (e.g. January for month, 1 for day, and so on).\n If only time is specified, today's date will be used.\n If you do not need to specify both date and time, you may omit the double quotes.\n In conclusion, the following examples are all valid: date:\"2020/01/01 01:23-2018/01/01 06\", expiry:-2020/05, date:12:34:56.\n These keys can only be specified once each.\n\n Timezone? Feel free to query the dates with your own timezone.\n API requests to the filter endpoint will attach your browser's timezone offset, so the server will automatically calculate timezone differences.\n\n Matches can also be sorted with sort keys.\n Their formats are: sort:columnName[:d[escending]], where :d[escending] is an optional tag to set the direction to descending.\n This key must be used with internal column names used in the database (id, ${all ? 'userid' : 'albumid'}, and so on),\n but there are 2 shortcuts available: date for timestamp column and expiry for expirydate column.\n This key can also be specified more than once, where their order will decide the sorting steps.\n\n Finally, there are type-is keys to refine by types.\n You can use is:image, is:video, and is:audio to list images, videos, audios respectively.\n This will only use image, video and audio extensions that are whitelisted internally in the safe.\n For images and videos specifically, they will be the ones whose thumbnails can be generated by the safe.\n Negation sign works for this key as well.\n Mixing inclusion and exclusion is not allowed (i.e. is:image -is:video, since the second key is redundant).\n\n Any leftover keywords which do not use keys (non-keyed keywords) will be matched against the matches' file names.\n Excluding certain keywords is also supported by adding negation sign before the keywords.\n\n Internal steps:\n ${all\n ? `- Query uploads passing ALL exclusion filter keys OR matching ANY filter keys, if any.\n - Refine matches`\n : '- Filter uploads'} using date key, if any.\n - Refine matches using expiry key, if any.\n - Refine matches using type-is keys, if any.\n - Refine matches using ANY non-keyed keywords, if any.\n - Filter matches using ALL exclusion non-keyed keywords, if any.\n - Sort matches using sorting keys, if any.\n\n Examples:\n ${all\n ? `- Uploads from users named \"demo\" AND/OR \"John Doe\" AND/OR non-registered users:\n user:demo user:\"John Doe\" user:-\n - ALL uploads, but NOT the ones from user named \"demo\" AND \"John Doe\":\n -user:demo -user:\"John Doe\"\n - Uploads from IP \"127.0.0.1\" AND which file names match \"*.rar\" OR \"*.zip\":\n ip:127.0.0.1 *.rar *.zip\n `\n : ''}- Uploads without albums:\n albumid:-\n - ALL uploads, but NOT the ones from album with ID 69:\n -albumid:69\n - Uploads uploaded since \"1 June 2019 00:00:00\":\n date:2019/06\n - Uploads uploaded between \"7 April 2020 12:00:00\" and \"7 April 2020 23:59:59\":\n date:\"2020/04/07 12-2020/04/07 23:59:59\"\n - Uploads uploaded before \"5 February 2020 00:00:00\":\n date:-2020/02/05\n - Uploads which file names match \"*.gz\" but NOT \"*.tar.gz\":\n *.gz -*.tar.gz\n - Sort matches by \"size\" column in ascending and descending order respectively:\n ${all ? 'user:\"John Doe\"' : '*.txt'} sort:size\n *.mp4 ${all ? 'user:- ' : ''}sort:size:d\n ${!page.permissions.moderator\n ? 'Notice: Regular users may face some limitations in the amount of keys that can be used at a time.'\n : ''}\n Friendly reminder: This window can be scrolled up!\n `.trim().replace(/^\\s*/g, '').replace(/\\n/g, '
    ')\n\n swal({ content }).then(() => {\n // Restore modal size\n document.body.querySelector('.swal-overlay .swal-modal').classList.remove('is-expanded')\n })\n\n // Expand modal size\n document.body.querySelector('.swal-overlay .swal-modal:not(.is-expanded)').classList.add('is-expanded')\n}\n\npage.filterUploads = element => {\n const filters = document.querySelector(`#${element.dataset.filtersid || 'filters'}`).value\n .trim()\n .replace(/\\t/g, ' ')\n .replace(/(^|\\s)((albumid|ip|user|date|expiry|is|sort|orderby):)\\s+/g, '$2')\n // eslint-disable-next-line compat/compat\n page.getUploads(Object.assign(page.views[page.currentView], {\n filters,\n pageNum: 0,\n trigger: element\n }))\n}\n\npage.viewUserUploads = (id, element) => {\n const user = page.cache[id]\n if (!user) return\n element.classList.add('is-loading')\n // Wrap username in quotes if it contains whitespaces\n const username = user.username.includes(' ')\n ? `\"${user.username}\"`\n : user.username\n page.getUploads({\n all: true,\n filters: `user:${username}`,\n trigger: document.querySelector('#itemManageUploads')\n })\n}\n\npage.viewAlbumUploads = (id, element) => {\n if (!page.cache[id]) return\n element.classList.add('is-loading')\n // eslint-disable-next-line compat/compat\n const all = page.currentView === 'albumsAll' && page.permissions.moderator\n page.getUploads({\n all,\n filters: `albumid:${id}`,\n trigger: all\n ? document.querySelector('#itemManageUploads')\n : document.querySelector('#itemUploads')\n })\n}\n\npage.deleteUpload = id => {\n page.postBulkDeleteUploads({\n all: page.currentView === 'uploadsAll',\n field: 'id',\n values: [id],\n cb (failed) {\n // Remove from remembered checkboxes if necessary\n if (!failed.length && page.selected[page.currentView].includes(id)) {\n page.selected[page.currentView].splice(page.selected[page.currentView].indexOf(id), 1)\n }\n\n // Update local storage\n if (page.selected[page.currentView].length) {\n localStorage[lsKeys.selected[page.currentView]] = JSON.stringify(page.selected[page.currentView])\n } else {\n delete localStorage[lsKeys.selected[page.currentView]]\n }\n\n // Reload upload list\n // eslint-disable-next-line compat/compat\n page.getUploads(Object.assign(page.views[page.currentView], {\n autoPage: true\n }))\n }\n })\n}\n\npage.bulkDeleteUploads = () => {\n const count = page.selected[page.currentView].length\n if (!count) return swal('An error occurred!', 'You have not selected any uploads.', 'error')\n\n page.postBulkDeleteUploads({\n all: page.currentView === 'uploadsAll',\n field: 'id',\n values: page.selected[page.currentView],\n cb (failed) {\n // Update state of checkboxes\n if (failed.length) {\n page.selected[page.currentView] = page.selected[page.currentView]\n .filter(id => failed.includes(id))\n } else {\n page.selected[page.currentView] = []\n }\n\n // Update local storage\n if (page.selected[page.currentView].length) {\n localStorage[lsKeys.selected[page.currentView]] = JSON.stringify(page.selected[page.currentView])\n } else {\n delete localStorage[lsKeys.selected[page.currentView]]\n }\n\n // Reload uploads list\n // eslint-disable-next-line compat/compat\n page.getUploads(Object.assign(page.views[page.currentView], {\n autoPage: true\n }))\n }\n })\n}\n\npage.deleteUploadsByNames = (params = {}) => {\n let appendix = ''\n if (page.permissions.moderator) {\n appendix = '
    Hint: You can use this feature to delete uploads by other users.'\n }\n\n page.dom.innerHTML = `\n
    \n
    \n \n
    \n \n
    \n

    Separate each entry with a new line.${appendix}

    \n
    \n
    \n
    \n \n
    \n
    \n
    \n `\n page.fadeInDom()\n page.scrollToDom()\n page.updateTrigger(params.trigger, 'active')\n\n document.querySelector('#submitBulkDelete').addEventListener('click', () => {\n if (page.isSomethingLoading) return page.warnSomethingLoading()\n\n const textArea = document.querySelector('#bulkDeleteNames')\n\n // Clean up\n const seen = {}\n const names = textArea.value\n .split(/\\r?\\n/)\n .map(name => {\n const trimmed = name.trim()\n return /^[^\\s]+$/.test(trimmed)\n ? trimmed\n : ''\n })\n .filter(name => {\n // Filter out invalid and duplicate names\n return (!name || Object.prototype.hasOwnProperty.call(seen, name))\n ? false\n : (seen[name] = true)\n })\n\n // Update textarea with cleaned names\n textArea.value = names.join('\\n')\n\n if (!names.length) {\n return swal('An error occurred!', 'You have not entered any upload names.', 'error')\n }\n\n page.postBulkDeleteUploads({\n all: true,\n field: 'name',\n values: names,\n cb (failed) {\n textArea.value = failed.join('\\n')\n }\n })\n })\n}\n\npage.postBulkDeleteUploads = (params = {}) => {\n const count = params.values.length\n\n const objective = `${params.values.length} upload${count === 1 ? '' : 's'}`\n const boldObjective = objective.replace(/^(\\d*)(.*)/, '$1$2')\n let text = `

    You won't be able to recover ${boldObjective}!

    `\n\n if (params.all) {\n const obj1 = count === 1 ? 'an upload' : 'some uploads'\n const obj2 = count === 1 ? 'another user' : 'other users'\n text += `\\n

    Warning: You may be nuking ${obj1} by ${obj2}!

    `\n }\n\n const content = document.createElement('div')\n content.innerHTML = text\n\n swal({\n title: 'Are you sure?',\n content,\n icon: 'warning',\n dangerMode: true,\n buttons: {\n cancel: true,\n confirm: {\n text: `Yes, nuke ${params.values.length === 1 ? 'it' : 'them'}!`,\n closeModal: false\n }\n }\n }).then(proceed => {\n if (!proceed) return\n\n axios.post('api/upload/bulkdelete', {\n field: params.field,\n values: params.values\n }).then(response => {\n if (!response) return\n\n if (response.data.success === false) {\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n return swal('An error occurred!', response.data.description, 'error')\n }\n }\n\n const failed = Array.isArray(response.data.failed) ? response.data.failed : []\n if (failed.length === params.values.length) {\n swal('An error occurred!', `Unable to delete any of the ${objective}.`, 'error')\n } else if (failed.length && failed.length < params.values.length) {\n swal('Warning!', `From ${objective}, unable to delete ${failed.length} of them.`, 'warning')\n } else {\n swal('Deleted!', `${objective} ${count === 1 ? 'has' : 'have'} been deleted.`, 'success', {\n buttons: false,\n timer: 1500\n })\n }\n\n if (typeof params.cb === 'function') params.cb(failed)\n }).catch(page.onAxiosError)\n })\n}\n\npage.addSelectedUploadsToAlbum = () => {\n if (page.currentView !== 'uploads') return\n\n const count = page.selected[page.currentView].length\n if (!count) return swal('An error occurred!', 'You have not selected any uploads.', 'error')\n\n page.addUploadsToAlbum(page.selected[page.currentView], failed => {\n if (!failed) return\n if (failed.length) {\n page.selected[page.currentView] = page.selected[page.currentView]\n .filter(id => failed.includes(id))\n } else {\n page.selected[page.currentView] = []\n }\n\n localStorage[lsKeys.selected[page.currentView]] = JSON.stringify(page.selected[page.currentView])\n page.getUploads(page.views[page.currentView])\n })\n}\n\npage.addToAlbum = id => {\n page.addUploadsToAlbum([id], failed => {\n if (!failed) return\n page.getUploads(page.views[page.currentView])\n })\n}\n\npage.addUploadsToAlbum = (ids, callback) => {\n const count = ids.length\n\n const content = document.createElement('div')\n content.innerHTML = `\n
    \n

    You are about to add ${count} upload${count === 1 ? '' : 's'} to an album.

    \n

    If an upload is already in an album, it will be moved.

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n `\n\n swal({\n icon: 'warning',\n content,\n buttons: {\n cancel: true,\n confirm: {\n text: 'OK',\n closeModal: false\n }\n }\n }).then(choose => {\n if (!choose) return\n\n const albumid = parseInt(document.querySelector('#swalAlbum').value)\n if (isNaN(albumid)) return swal('An error occurred!', 'You did not choose an album.', 'error')\n\n axios.post('api/albums/addfiles', {\n ids,\n albumid\n }).then(add => {\n if (!add) return\n\n if (add.data.success === false) {\n if (add.data.description === 'No token provided') {\n page.verifyToken(page.token)\n } else {\n swal('An error occurred!', add.data.description, 'error')\n }\n return\n }\n\n let added = ids.length\n if (add.data.failed && add.data.failed.length) {\n added -= add.data.failed.length\n }\n\n const suffix = `upload${ids.length === 1 ? '' : 's'}`\n if (!added) return swal('An error occurred!', `Could not add the ${suffix} to the album.`, 'error')\n\n swal('Woohoo!', `Successfully ${albumid < 0 ? 'removed' : 'added'} ${added} ${suffix} ${albumid < 0 ? 'from' : 'to'} the album.`, 'success', {\n buttons: false,\n timer: 1500\n })\n callback(add.data.failed)\n }).catch(page.onAxiosError)\n })\n\n // Get albums list then update content of swal\n axios.get('api/albums', { headers: { simple: '1' } }).then(list => {\n if (list.data.success === false) {\n if (list.data.description === 'No token provided') {\n page.verifyToken(page.token)\n } else {\n swal('An error occurred!', list.data.description, 'error')\n }\n return\n }\n\n // If the prompt was replaced, the container would be missing\n const select = document.querySelector('#swalAlbum')\n if (!select) return\n\n select.innerHTML += list.data.albums\n .map(album => {\n return ``\n })\n .join('\\n')\n\n select.getElementsByTagName('option')[1].innerHTML = 'Choose an album'\n select.removeAttribute('disabled')\n }).catch(page.onAxiosError)\n}\n\npage.getAlbums = (params = {}) => {\n if (params && params.all && !page.permissions.moderator) {\n return swal('An error occurred!', 'You cannot do this!', 'error')\n }\n\n if (page.isSomethingLoading) return page.warnSomethingLoading()\n\n page.updateTrigger(params.trigger, 'loading')\n\n if (typeof params.pageNum !== 'number') params.pageNum = 0\n\n const headers = {}\n if (params.all) headers.all = '1'\n\n const url = `api/albums/${params.pageNum}`\n axios.get(url, { headers }).then(response => {\n if (!response) return\n\n if (response.data.success === false) {\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n page.updateTrigger(params.trigger)\n return swal('An error occurred!', response.data.description, 'error')\n }\n }\n\n const pages = Math.ceil(response.data.count / 25)\n const albums = response.data.albums\n if (params.pageNum && (albums.length === 0)) {\n page.updateTrigger(params.trigger)\n if (params.autoPage) {\n params.pageNum = pages - 1\n return page.getAlbums(params)\n } else {\n return swal('An error occurred!', `There are no more albums to populate page ${params.pageNum + 1}.`, 'error')\n }\n }\n\n page.currentView = params.all ? 'albumsAll' : 'albums'\n page.cache = {}\n\n const users = response.data.users\n const homeDomain = response.data.homeDomain\n\n if (params.pageNum < 0) params.pageNum = Math.max(0, pages + params.pageNum)\n const pagination = page.paginate(response.data.count, 25, params.pageNum)\n\n const filter = `\n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n `\n const extraControls = `\n
    \n ${filter}\n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n `\n\n const controls = `\n \n `\n\n // Do some string replacements for bottom controls\n const bottomFiltersId = 'bFilters'\n const bottomJumpId = 'bJumpToPage'\n const bottomExtraControls = extraControls\n .replace(/id=\"filters\"/, `id=\"${bottomFiltersId}\"`)\n .replace(/(data-action=\"filter-uploads\")/, `$1 data-filtersid=\"${bottomFiltersId}\"`)\n .replace(/id=\"jumpToPage\"/, `id=\"${bottomJumpId}\"`)\n .replace(/(data-action=\"jump-to-page\")/g, `$1 data-jumpid=\"${bottomJumpId}\"`)\n const bottomPagination = pagination\n .replace(/(data-action=\"page-ellipsis\")/g, `$1 data-jumpid=\"${bottomJumpId}\"`)\n\n // Whether there are any unselected items\n let unselected = false\n\n const createNewAlbum = `\n

    Create new album

    \n
    \n
    \n
    \n \n
    \n

    Max length is ${page.albumTitleMaxLength} characters.

    \n
    \n
    \n
    \n \n
    \n

    Max length is ${page.albumDescMaxLength} characters.

    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n `\n\n page.dom.innerHTML = `\n ${!params.all ? createNewAlbum : ''}\n ${pagination}\n ${extraControls}\n ${controls}\n
    \n \n \n \n \n \n \n ${params.all ? '' : ''}\n \n \n \n \n \n \n \n \n \n \n \n
    IDNameUserUploadsSizeCreated atZIP sizeZIP generated atPublic link(${response.data.count} total)
    \n
    \n ${controls}\n ${bottomExtraControls}\n ${bottomPagination}\n `\n\n const table = document.querySelector('#table')\n\n for (let i = 0; i < albums.length; i++) {\n const album = albums[i]\n const urlPath = '/a/'\n const albumUrlText = urlPath + album.identifier\n const albumUrl = homeDomain + albumUrlText\n\n const selected = page.selected[page.currentView].includes(album.id)\n if (!selected) unselected = true\n\n // Prettify\n album.hasZip = album.zipSize !== null\n album.prettyDate = page.getPrettyDate(new Date(album.timestamp * 1000))\n album.prettyZipDate = album.hasZip ? page.getPrettyDate(new Date(album.zipGeneratedAt * 1000)) : null\n album.isZipExpired = album.hasZip && !(album.zipGeneratedAt > album.editedAt)\n\n // Server-side explicitly expect this value to consider an album as disabled\n const enabled = album.enabled !== 0\n page.cache[album.id] = {\n name: album.name,\n download: album.download,\n public: album.public,\n description: album.description,\n descriptionHtml: album.descriptionHtml,\n enabled,\n homeDomain,\n urlPath,\n identifier: album.identifier\n }\n\n const tr = document.createElement('tr')\n tr.dataset.id = album.id\n tr.innerHTML = `\n \n ${album.id}\n ${album.name}\n ${params.all ? `${album.userid ? (users[album.userid] || '') : ''}` : ''}\n ${album.uploads}\n ${page.getPrettyBytes(album.size)}\n ${album.prettyDate}\n ${album.hasZip ? page.getPrettyBytes(album.zipSize) : '-'}\n ${album.hasZip ? album.prettyZipDate : '-'}\n ${albumUrlText}\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n ${params.all\n ? `\n \n \n \n `\n : ''}\n \n `\n\n table.appendChild(tr)\n page.checkboxes = table.querySelectorAll('.checkbox[data-action=\"select\"]')\n }\n\n const selectAll = document.querySelector('#selectAll')\n if (selectAll && !unselected) {\n selectAll.checked = true\n selectAll.title = 'Unselect all'\n }\n\n page.fadeInDom()\n\n const pageNum = albums.length ? params.pageNum : 0\n if (params.forceScroll ||\n page.prevPageNums[page.currentView] === null ||\n page.prevPageNums[page.currentView] !== pageNum) {\n page.scrollToDom()\n }\n\n page.updateTrigger(params.trigger, 'active')\n\n if (page.currentView === 'albumsAll') {\n page.views[page.currentView].filters = params.filters\n }\n page.views[page.currentView].pageNum = page.prevPageNums[page.currentView] = pageNum\n }).catch(error => {\n page.updateTrigger(params.trigger)\n page.onAxiosError(error)\n })\n}\n\npage.editAlbum = id => {\n const album = page.cache[id]\n if (!album) return\n\n const albumUrlText = album.urlPath + album.identifier\n const albumUrl = album.homeDomain + albumUrlText\n\n const div = document.createElement('div')\n div.innerHTML = `\n
    \n
    \n \n
    \n

    Max length is ${page.albumTitleMaxLength} characters.

    \n
    \n
    \n
    \n \n
    \n

    Markdown supported. Max length is ${page.albumDescMaxLength} characters.

    \n
    \n ${album.descriptionHtml\n ? `
    \n
    \n ${album.descriptionHtml}\n
    \n

    Save changes then re-open this Edit prompt to refresh this preview.

    \n
    `\n : ''}\n ${page.currentView === 'albumsAll' && page.permissions.moderator\n ? `
    \n
    \n \n
    \n
    `\n : ''}\n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n

    Current public link: ${albumUrlText}

    \n
    \n `\n\n swal({\n title: 'Edit album',\n icon: 'info',\n content: div,\n buttons: {\n cancel: true,\n confirm: {\n closeModal: false\n }\n }\n }).then(value => {\n if (!value) return\n\n const post = {\n id,\n name: document.querySelector('#swalName').value.trim(),\n description: document.querySelector('#swalDescription').value.trim(),\n download: document.querySelector('#swalDownload').checked,\n public: document.querySelector('#swalPublic').checked,\n requestLink: document.querySelector('#swalRequestLink').checked\n }\n\n if (page.currentView === 'albumsAll' && page.permissions.moderator) {\n post.enabled = document.querySelector('#swalEnabled').checked\n }\n\n axios.post('api/albums/edit', post).then(response => {\n if (!response) return\n\n if (response.data.success === false) {\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n return swal('An error occurred!', response.data.description, 'error')\n }\n }\n\n if (response.data.identifier) {\n swal('Success!', `The album's new identifier is: ${response.data.identifier}.`, 'success')\n } else if (response.data.name !== album.name) {\n swal('Success!', `The album was renamed to: ${response.data.name}.`, 'success')\n } else {\n swal('Success!', 'The album was edited.', 'success', {\n buttons: false,\n timer: 1500\n })\n }\n\n page.getAlbumsSidebar()\n // Reload albums list\n // eslint-disable-next-line compat/compat\n page.getAlbums(Object.assign(page.views[page.currentView], {\n autoPage: true\n }))\n }).catch(page.onAxiosError)\n })\n}\n\npage.disableAlbum = id => {\n swal({\n title: 'Are you sure?',\n text: 'This won\\'t delete the uploads associated with the album!',\n icon: 'warning',\n dangerMode: true,\n buttons: {\n cancel: true,\n confirm: {\n text: 'Yes, disable it!',\n closeModal: false\n },\n purge: {\n text: 'Umm, delete the uploads, please?',\n value: 'purge',\n className: 'swal-button--danger',\n closeModal: false\n }\n }\n }).then(proceed => {\n if (!proceed) return\n\n axios.post('api/albums/disable', {\n id,\n purge: proceed === 'purge'\n }).then(response => {\n if (response.data.success === false) {\n const failed = Array.isArray(response.data.failed)\n ? response.data.failed\n : []\n\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else if (failed.length) {\n return swal('An error occurred!', `Unable to delete ${failed.length} of the album's upload${failed.length === 1 ? '' : 's'}.`, 'error')\n } else {\n return swal('An error occurred!', response.data.description, 'error')\n }\n }\n\n swal('Disabled!', 'The album has been disabled.', 'success', {\n buttons: false,\n timer: 1500\n })\n\n page.getAlbumsSidebar()\n // Reload albums list\n // eslint-disable-next-line compat/compat\n page.getAlbums(Object.assign(page.views[page.currentView], {\n autoPage: true\n }))\n }).catch(page.onAxiosError)\n })\n}\n\npage.deleteAlbum = id => {\n swal({\n title: 'Are you sure?',\n text: 'You won\\'t be able to recover this album!\\n' +\n 'This also won\\'t delete the uploads associated with the album!',\n icon: 'warning',\n dangerMode: true,\n buttons: {\n cancel: true,\n confirm: {\n text: 'Yes, delete it!',\n closeModal: false\n },\n purge: {\n text: 'Umm, delete the uploads, please?',\n value: 'purge',\n className: 'swal-button--danger',\n closeModal: false\n }\n }\n }).then(proceed => {\n if (!proceed) return\n\n axios.post('api/albums/delete', {\n id,\n purge: proceed === 'purge'\n }).then(response => {\n if (response.data.success === false) {\n const failed = Array.isArray(response.data.failed)\n ? response.data.failed\n : []\n\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else if (failed.length) {\n return swal('An error occurred!', `Unable to delete ${failed.length} of the album's upload${failed.length === 1 ? '' : 's'}.`, 'error')\n } else {\n return swal('An error occurred!', response.data.description, 'error')\n }\n }\n\n swal('Disabled!', 'The album has been deleted.', 'success', {\n buttons: false,\n timer: 1500\n })\n\n page.getAlbumsSidebar()\n // Reload albums list\n // eslint-disable-next-line compat/compat\n page.getAlbums(Object.assign(page.views[page.currentView], {\n autoPage: true\n }))\n }).catch(page.onAxiosError)\n })\n}\n\npage.submitAlbum = element => {\n page.updateTrigger(element, 'loading')\n\n axios.post('api/albums', {\n name: document.querySelector('#albumName').value.trim(),\n description: document.querySelector('#albumDescription').value.trim()\n }).then(response => {\n if (!response) return\n\n page.updateTrigger(element)\n if (response.data.success === false) {\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n return swal('An error occurred!', response.data.description, 'error')\n }\n }\n\n swal('Woohoo!', 'Album was created successfully.', 'success', {\n buttons: false,\n timer: 1500\n })\n page.getAlbumsSidebar()\n page.getAlbums({\n pageNum: -1\n })\n }).catch(error => {\n page.updateTrigger(element)\n page.onAxiosError(error)\n })\n}\n\npage.getAlbumsSidebar = () => {\n axios.get('api/albums', { headers: { simple: '1' } }).then(response => {\n if (!response) return\n\n if (response.data.success === false) {\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n return swal('An error occurred!', response.data.description, 'error')\n }\n }\n\n const albums = response.data.albums\n const count = response.data.count\n const albumsSidebar = document.querySelector('#albumsSidebar')\n\n // Clear albums sidebar if necessary\n const oldAlbums = albumsSidebar.querySelectorAll('li > a')\n const diffCount = oldAlbums.length !== count\n if (oldAlbums.length) {\n for (let i = 0; i < oldAlbums.length; i++) {\n page.menus.splice(page.menus.indexOf(oldAlbums[i]), 1)\n }\n albumsSidebar.innerHTML = ''\n }\n\n page.albumsSidebarCollapse.innerText = page.albumsSidebarCollapsible.collapsed()\n ? page.albumsSidebarCollapse.dataset.textExpand\n : page.albumsSidebarCollapse.dataset.textCollapse\n\n if (!albums || !albums.length) {\n page.albumsSidebarCollapsible.collapse()\n page.albumsSidebarCollapse.setAttribute('disabled', 'disabled')\n return\n }\n\n for (let i = 0; i < albums.length; i++) {\n const album = albums[i]\n const li = document.createElement('li')\n const a = document.createElement('a')\n a.id = album.id\n a.className = 'is-relative'\n a.innerHTML = album.name\n\n a.addEventListener('click', event => {\n page.getUploads({\n album: parseInt(event.currentTarget.id),\n trigger: event.currentTarget\n })\n })\n page.menus.push(a)\n\n li.appendChild(a)\n albumsSidebar.appendChild(li)\n }\n\n page.albumsSidebarCollapse.removeAttribute('disabled')\n if (!page.albumsSidebarCollapsible.collapsed() && diffCount) {\n // Since it's not possible to refresh collapsible's height with bulmaCollapsible APIs,\n // forcefully collapse albums sidebar if albums count is different with the previous iteration.\n page.albumsSidebarCollapsible.collapse()\n }\n }).catch(page.onAxiosError)\n}\n\npage.changeToken = (params = {}) => {\n page.dom.innerHTML = `\n
    \n \n
    \n
    \n \n
    \n
    \n
    \n \n `\n page.fadeInDom()\n page.scrollToDom()\n page.updateTrigger(params.trigger, 'active')\n\n document.querySelector('#getNewToken').addEventListener('click', event => {\n if (page.isSomethingLoading) return page.warnSomethingLoading()\n\n const trigger = event.currentTarget\n page.updateTrigger(trigger, 'loading')\n axios.post('api/tokens/change').then(response => {\n if (response.data.success === false) {\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n page.updateTrigger(trigger)\n return swal('An error occurred!', response.data.description, 'error')\n }\n }\n\n page.updateTrigger(trigger)\n swal({\n title: 'Woohoo!',\n text: 'Your token was successfully changed.',\n icon: 'success',\n buttons: false,\n timer: 1500\n }).then(() => {\n axios.defaults.headers.common.token = response.data.token\n localStorage[lsKeys.token] = response.data.token\n page.token = response.data.token\n page.changeToken()\n })\n }).catch(error => {\n page.updateTrigger(trigger)\n page.onAxiosError(error)\n })\n })\n}\n\npage.changePassword = (params = {}) => {\n page.dom.innerHTML = `\n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n `\n page.fadeInDom()\n page.scrollToDom()\n page.updateTrigger(params.trigger, 'active')\n\n document.querySelector('#sendChangePassword').addEventListener('click', event => {\n if (page.isSomethingLoading) return page.warnSomethingLoading()\n\n if (!page.dom.querySelector('form').checkValidity()) return\n\n if (document.querySelector('#password').value === document.querySelector('#passwordConfirm').value) {\n page.sendNewPassword(document.querySelector('#password').value, event.currentTarget)\n } else {\n swal({\n title: 'Password mismatch!',\n text: 'Your passwords do not match, please try again.',\n icon: 'error'\n })\n }\n })\n}\n\npage.sendNewPassword = (pass, element) => {\n page.updateTrigger(element, 'loading')\n\n axios.post('api/password/change', { password: pass }).then(response => {\n if (response.data.success === false) {\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n page.updateTrigger(element)\n return swal('An error occurred!', response.data.description, 'error')\n }\n }\n\n page.updateTrigger(element)\n swal({\n title: 'Woohoo!',\n text: 'Your password was successfully changed.',\n icon: 'success',\n buttons: false,\n timer: 1500\n }).then(() => {\n page.changePassword()\n })\n }).catch(error => {\n page.updateTrigger(element)\n page.onAxiosError(error)\n })\n}\n\npage.getUsers = (params = {}) => {\n if (!page.permissions.admin) return swal('An error occurred!', 'You cannot do this!', 'error')\n\n if (page.isSomethingLoading) return page.warnSomethingLoading()\n\n page.updateTrigger(params.trigger, 'loading')\n\n if (typeof params.pageNum !== 'number') params.pageNum = 0\n\n const url = `api/users/${params.pageNum}`\n axios.get(url).then(response => {\n if (response.data.success === false) {\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n page.updateTrigger(params.trigger)\n return swal('An error occurred!', response.data.description, 'error')\n }\n }\n\n const pages = Math.ceil(response.data.count / 25)\n const users = response.data.users\n if (params.pageNum && (users.length === 0)) {\n page.updateTrigger(params.trigger)\n if (params.autoPage) {\n params.pageNum = pages - 1\n return page.getUsers(params)\n } else {\n return swal('An error occurred!', `There are no more users to populate page ${params.pageNum + 1}.`, 'error')\n }\n }\n\n page.currentView = 'users'\n page.cache = {}\n\n if (params.pageNum < 0) params.pageNum = Math.max(0, pages + params.pageNum)\n const pagination = page.paginate(response.data.count, 25, params.pageNum)\n\n const filter = `\n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n `\n const extraControls = `\n
    \n ${filter}\n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n `\n\n const controls = `\n \n `\n\n // Do some string replacements for bottom controls\n const bottomFiltersId = 'bFilters'\n const bottomJumpId = 'bJumpToPage'\n const bottomExtraControls = extraControls\n .replace(/id=\"filters\"/, `id=\"${bottomFiltersId}\"`)\n .replace(/(data-action=\"filter-uploads\")/, `$1 data-filtersid=\"${bottomFiltersId}\"`)\n .replace(/id=\"jumpToPage\"/, `id=\"${bottomJumpId}\"`)\n .replace(/(data-action=\"jump-to-page\")/g, `$1 data-jumpid=\"${bottomJumpId}\"`)\n const bottomPagination = pagination\n .replace(/(data-action=\"page-ellipsis\")/g, `$1 data-jumpid=\"${bottomJumpId}\"`)\n\n // Whether there are any unselected items\n let unselected = false\n\n page.dom.innerHTML = `\n ${pagination}\n ${extraControls}\n ${controls}\n
    \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
    UsernameUploadsUsageGroupRegistration dateLast token update(${response.data.count} total)
    \n
    \n ${controls}\n ${bottomExtraControls}\n ${bottomPagination}\n `\n\n const table = document.querySelector('#table')\n\n for (let i = 0; i < users.length; i++) {\n const user = users[i]\n const selected = page.selected[page.currentView].includes(user.id)\n if (!selected) unselected = true\n\n let displayGroup = null\n const groups = Object.keys(user.groups)\n for (let i = 0; i < groups.length; i++) {\n if (!user.groups[groups[i]]) break\n displayGroup = groups[i]\n }\n\n // Server-side explicitly expects either of these two values to consider a user as disabled\n const enabled = user.enabled !== false && user.enabled !== 0\n page.cache[user.id] = {\n username: user.username,\n groups: user.groups,\n enabled,\n displayGroup\n }\n\n const prettyDate = user.registration\n ? page.getPrettyDate(new Date(user.registration * 1000))\n : '-'\n const prettyTokenUpdate = user.timestamp\n ? page.getPrettyDate(new Date(user.timestamp * 1000))\n : '-'\n\n const tr = document.createElement('tr')\n tr.dataset.id = user.id\n tr.innerHTML = `\n \n ${user.username}\n ${user.uploads}\n ${page.getPrettyBytes(user.usage)}\n ${displayGroup}\n ${prettyDate}\n ${prettyTokenUpdate}\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n `\n\n table.appendChild(tr)\n page.checkboxes = table.querySelectorAll('.checkbox[data-action=\"select\"]')\n }\n\n const selectAll = document.querySelector('#selectAll')\n if (selectAll && !unselected) {\n selectAll.checked = true\n selectAll.title = 'Unselect all'\n }\n\n page.fadeInDom()\n\n const pageNum = users.length ? params.pageNum : 0\n if (params.forceScroll ||\n page.prevPageNums[page.currentView] === null ||\n page.prevPageNums[page.currentView] !== pageNum) {\n page.scrollToDom()\n }\n\n page.updateTrigger(params.trigger, 'active')\n\n page.views[page.currentView].pageNum = page.prevPageNums[page.currentView] = pageNum\n }).catch(error => {\n page.updateTrigger(params.trigger)\n page.onAxiosError(error)\n })\n}\n\npage.createUser = () => {\n const groupOptions = Object.keys(page.permissions).map((g, i, a) => {\n const disabled = !(a[i + 1] && page.permissions[a[i + 1]])\n return ``\n }).join('\\n')\n\n const div = document.createElement('div')\n div.innerHTML = `\n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n `\n\n swal({\n title: 'Create new user',\n icon: 'info',\n content: div,\n buttons: {\n cancel: true,\n confirm: {\n closeModal: false\n }\n }\n }).then(proceed => {\n if (!proceed) return\n\n axios.post('api/users/create', {\n username: document.querySelector('#swalUsername').value,\n password: document.querySelector('#swalPassword').value,\n group: document.querySelector('#swalGroup').value\n }).then(response => {\n if (!response) return\n\n if (response.data.success === false) {\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n return swal('An error occurred!', response.data.description, 'error')\n }\n }\n\n const div = document.createElement('div')\n div.innerHTML = `\n

    Username: ${response.data.username}

    \n

    Password: ${response.data.password}

    \n

    User group: ${response.data.group}

    \n `\n swal({\n title: 'Created a new user!',\n icon: 'success',\n content: div\n })\n\n // Load last page of users list\n // eslint-disable-next-line compat/compat\n page.getUsers(Object.assign(page.views.users, {\n pageNum: -1\n }))\n }).catch(page.onAxiosError)\n })\n}\n\npage.editUser = id => {\n const user = page.cache[id]\n if (!user) return\n\n let isHigher = false\n const groupOptions = Object.keys(page.permissions).map((g, i, a) => {\n const selected = g === user.displayGroup\n if (selected) {\n isHigher = typeof a[i + 1] !== 'undefined' && page.permissions[a[i + 1]]\n }\n const disabled = !(a[i + 1] && page.permissions[a[i + 1]])\n return ``\n }).join('\\n')\n\n const isDisabledHelper = isHigher ? '' : ' disabled'\n const div = document.createElement('div')\n div.innerHTML = `\n
    \n

    User ID: ${id}

    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n ${isHigher\n ? ''\n : `
    \n You cannot modify user in the same or higher group as you.\n
    `\n }\n `\n\n swal({\n title: 'Edit user',\n icon: 'info',\n content: div,\n buttons: {\n cancel: true,\n confirm: {\n closeModal: false\n }\n }\n }).then(proceed => {\n if (!proceed) return\n\n axios.post('api/users/edit', {\n id,\n username: document.querySelector('#swalUsername').value,\n group: document.querySelector('#swalGroup').value,\n enabled: document.querySelector('#swalEnabled').checked,\n resetPassword: document.querySelector('#swalResetPassword').checked\n }).then(response => {\n if (!response) return\n\n if (response.data.success === false) {\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n return swal('An error occurred!', response.data.description, 'error')\n }\n }\n\n let autoClose = true\n const div = document.createElement('div')\n\n let displayName = user.username\n if (response.data.update.username !== user.username) {\n div.innerHTML += `

    ${user.username} was renamed into: ${response.data.update.username}.

    `\n autoClose = false\n displayName = response.data.update.username\n }\n\n if (response.data.update.password) {\n div.innerHTML += `\n

    ${displayName}'s new password is:

    \n

    ${response.data.update.password}

    \n `\n autoClose = false\n }\n\n if (response.data.update.enabled !== user.enabled) {\n div.innerHTML += `

    ${displayName} has been ${response.data.update.enabled ? 'enabled' : 'disabled'}!

    `\n }\n\n if (!div.innerHTML) {\n div.innerHTML = `

    ${displayName} was edited!

    `\n }\n\n swal({\n title: 'Success!',\n icon: 'success',\n content: div,\n buttons: !autoClose,\n timer: autoClose ? 1500 : null\n })\n page.getUsers(page.views.users)\n }).catch(page.onAxiosError)\n })\n}\n\npage.disableUser = id => {\n const user = page.cache[id]\n if (!user || !user.enabled) return\n\n const content = document.createElement('div')\n content.innerHTML = `\n

    You will be disabling a user named ${page.cache[id].username}.

    \n

    Their files will remain.

    \n `\n\n swal({\n title: 'Are you sure?',\n icon: 'warning',\n content,\n dangerMode: true,\n buttons: {\n cancel: true,\n confirm: {\n text: 'Yes, disable them!',\n closeModal: false\n }\n }\n }).then(proceed => {\n if (!proceed) return\n\n axios.post('api/users/disable', { id }).then(response => {\n if (!response) return\n\n if (response.data.success === false) {\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n return swal('An error occurred!', response.data.description, 'error')\n }\n }\n\n swal('Success!', `${page.cache[id].username} has been disabled.`, 'success', {\n buttons: false,\n timer: 1500\n })\n page.getUsers(page.views.users)\n }).catch(page.onAxiosError)\n })\n}\n\npage.deleteUser = id => {\n const user = page.cache[id]\n if (!user) return\n\n const content = document.createElement('div')\n content.innerHTML = `\n

    You will be deleting a user named ${page.cache[id].username}.

    \n

    Their uploads will still remain, unless you choose otherwise.

    \n `\n\n swal({\n title: 'Are you sure?',\n icon: 'warning',\n content,\n dangerMode: true,\n buttons: {\n cancel: true,\n confirm: {\n text: 'Yes, ONLY the user!',\n closeModal: false\n },\n purge: {\n text: 'Yes, AND their uploads too!',\n value: 'purge',\n className: 'swal-button--danger',\n closeModal: false\n }\n }\n }).then(proceed => {\n if (!proceed) return\n\n axios.post('api/users/delete', {\n id,\n purge: proceed === 'purge'\n }).then(response => {\n if (!response) return\n\n if (response.data.success === false) {\n const failed = Array.isArray(response.data.failed)\n ? response.data.failed\n : []\n\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else if (failed.length) {\n return swal('An error occurred!', `Unable to delete ${failed.length} of the user's upload${failed.length === 1 ? '' : 's'}.`, 'error')\n } else {\n return swal('An error occurred!', response.data.description, 'error')\n }\n }\n\n swal('Success!', `${page.cache[id].username} has been deleted.`, 'success', {\n buttons: false,\n timer: 1500\n })\n\n // Reload users list\n // eslint-disable-next-line compat/compat\n page.getUsers(Object.assign(page.views.users, {\n autoPage: true\n }))\n }).catch(page.onAxiosError)\n })\n}\n\n// Roughly based on https://github.com/mayuska/pagination/blob/master/index.js\npage.paginate = (totalItems, itemsPerPage, currentPage) => {\n currentPage = currentPage + 1\n const step = 3\n const numPages = Math.ceil(totalItems / itemsPerPage)\n\n let template = ''\n const elementsToShow = step * 2\n const add = {\n pageNum (start, end) {\n for (let i = start; i <= end; ++i) {\n template += `
  • ${i}
  • `\n }\n },\n startDots () {\n template += `\n
  • 1
  • \n
  • \n `\n },\n endDots () {\n template += `\n
  • \n
  • ${numPages}
  • \n `\n }\n }\n\n if (elementsToShow + 1 >= numPages) {\n add.pageNum(1, numPages)\n } else if (currentPage < elementsToShow) {\n add.pageNum(1, elementsToShow)\n add.endDots()\n } else if (currentPage > numPages - elementsToShow + 1) {\n add.startDots()\n add.pageNum(numPages - elementsToShow + 1, numPages)\n } else {\n add.startDots()\n add.pageNum(currentPage - step + 1, currentPage + step - 1)\n add.endDots()\n }\n\n return `\n \n `\n}\n\npage.getStatistics = (params = {}) => {\n if (!page.permissions.admin) return swal('An error occurred!', 'You cannot do this!', 'error')\n\n if (page.isSomethingLoading) return page.warnSomethingLoading()\n\n page.updateTrigger(params.trigger, 'loading')\n\n const url = 'api/stats'\n axios.get(url).then(response => {\n if (response.data.success === false) {\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n page.updateTrigger(params.trigger)\n return swal('An error occurred!', response.data.description, 'error')\n }\n }\n\n let content = ''\n const keys = Object.keys(response.data.stats)\n for (let i = 0; i < keys.length; i++) {\n let rows = ''\n if (!response.data.stats[keys[i]]) {\n rows += `\n \n Generating, please try again later\\u2026\n \n \n `\n } else {\n try {\n const valKeys = Object.keys(response.data.stats[keys[i]])\n for (let j = 0; j < valKeys.length; j++) {\n const data = response.data.stats[keys[i]][valKeys[j]]\n const type = typeof data === 'object' ? data.type : 'auto'\n const value = typeof data === 'object' ? data.value : data\n\n let parsed\n switch (type) {\n case 'byte':\n parsed = page.getPrettyBytes(value)\n break\n case 'byteUsage': {\n // Reasoning: https://github.com/sebhildebrandt/systeminformation/issues/464#issuecomment-756406053\n const totalForPercentage = typeof value.available !== 'undefined'\n ? (value.used + value.available)\n : value.total\n parsed = `${page.getPrettyBytes(value.used)} / ${page.getPrettyBytes(value.total)} (${(value.used / totalForPercentage * 100).toFixed(2)}%)`\n break\n }\n case 'uptime':\n parsed = page.getPrettyUptime(value)\n break\n case 'auto':\n switch (typeof value) {\n case 'number':\n parsed = value.toLocaleString()\n break\n default:\n parsed = value\n }\n break\n default:\n parsed = value\n }\n\n rows += `\n \n ${valKeys[j]}\n ${parsed}\n \n `\n }\n } catch (error) {\n rows = `\n \n Error parsing response. Try again?\n \n \n `\n page.onError(error)\n }\n }\n\n content += `\n
    \n \n \n \n \n \n \n \n \n ${rows}\n \n
    ${keys[i]}
    \n
    \n `\n }\n\n if (Array.isArray(response.data.hrtime)) {\n content += `\n
    \n
    \n Time taken: ${response.data.hrtime[0]}s ${Math.ceil(response.data.hrtime[1] / 1000000)}ms.\n
    \n
    \n `\n }\n\n page.dom.innerHTML = content\n page.fadeInDom()\n page.scrollToDom()\n page.updateTrigger(params.trigger, 'active')\n }).catch(error => {\n page.updateTrigger(params.trigger)\n page.onAxiosError(error)\n })\n}\n\nwindow.addEventListener('DOMContentLoaded', () => {\n // Polyfill Object.assign()\n // eslint-disable-next-line compat/compat\n if (typeof Object.assign !== 'function') {\n // Must be writable: true, enumerable: false, configurable: true\n Object.defineProperty(Object, 'assign', {\n value: function assign (target, varArgs) { // .length of function is 2\n 'use strict'\n if (target === null || typeof target === 'undefined') {\n throw new TypeError('Cannot convert undefined or null to object')\n }\n const to = Object(target)\n for (let i = 1; i < arguments.length; i++) {\n const nextSource = arguments[i]\n if (nextSource !== null && typeof nextSource !== 'undefined') {\n for (const nextKey in nextSource) {\n // Avoid bugs when hasOwnProperty is shadowed\n if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {\n to[nextKey] = nextSource[nextKey]\n }\n }\n }\n }\n return to\n },\n writable: true,\n configurable: true\n })\n }\n\n // Add 'no-touch' class to non-touch devices\n if (!('ontouchstart' in document.documentElement)) {\n document.documentElement.classList.add('no-touch')\n }\n\n const selectedKeys = ['uploads', 'uploadsAll', 'albums', 'albumsAll', 'users']\n for (let i = 0; i < selectedKeys.length; i++) {\n const ls = localStorage[lsKeys.selected[selectedKeys[i]]]\n if (ls) page.selected[selectedKeys[i]] = JSON.parse(ls)\n }\n\n page.preparePage()\n\n page.clipboardJS = new ClipboardJS('.clipboard-js')\n\n page.clipboardJS.on('success', () => {\n return swal('', 'The link has been copied to clipboard.', 'success', {\n buttons: false,\n timer: 1500\n })\n })\n\n page.clipboardJS.on('error', page.onError)\n\n page.lazyLoad = new LazyLoad()\n\n page.albumsSidebarCollapse = document.querySelector('#albumsSidebarCollapse')\n\n /* eslint-disable-next-line new-cap */\n page.albumsSidebarCollapsible = new bulmaCollapsible(document.querySelector('#albumsSidebar'))\n page.albumsSidebarCollapsible.on('before:expand', event => {\n page.albumsSidebarCollapse.innerText = page.albumsSidebarCollapse.dataset.textCollapse\n })\n page.albumsSidebarCollapsible.on('before:collapse', event => {\n page.albumsSidebarCollapse.innerText = page.albumsSidebarCollapse.dataset.textExpand\n })\n})\n"]} \ No newline at end of file +{"version":3,"sources":["dashboard.js"],"names":["const","lsKeys","token","viewType","uploads","uploadsAll","selected","albums","albumsAll","users","originalNames","page","section","dom","localStorage","username","permissions","menusContainer","menus","currentView","views","type","album","pageNum","filters","all","prevPageNums","checkboxes","lastSelected","selectAlbumContainer","cache","clipboardJS","lazyLoad","albumsSidebarCollapse","albumsSidebarCollapsible","imageExts","videoExts","audioExts","isSomethingLoading","fadingIn","albumTitleMaxLength","albumDescMaxLength","document","querySelector","classList","add","remove","error","console","content","createElement","innerHTML","toString","swal","title","icon","statusText","response","status","description","data","verifyToken","window","location","apiVersion","match","src","text","buttons","confirm","closeModal","then","reload","axios","post","defaults","headers","common","version","checkClientVersion","prepareDashboard","catch","code","removeItem","addEventListener","domClick","event","target","contains","preventDefault","itemMenus","selector","onclick","getUploads","deleteUploadsByNames","getAlbums","changeToken","changePassword","logout","params","group","getStatistics","getUsers","loop","i","item","warnSomethingLoading","call","Object","assign","trigger","currentTarget","forceScroll","push","length","moderator","unhide","getAlbumsSidebar","prepareShareX","updateTrigger","timer","newState","parentNode","tagName","className","includes","let","element","parent","parseInt","dataset","id","action","hasAttribute","stopPropagation","getItemID","setUploadsView","toggleOriginalNames","addToAlbum","deleteUpload","addSelectedUploadsToAlbum","bulkDeleteUploads","displayPreview","uploadFiltersHelp","filterUploads","submitAlbum","editAlbum","disableAlbum","deleteAlbum","viewAlbumUploads","createUser","editUser","disableUser","deleteUser","viewUserUploads","getNewToken","clearSelection","select","selectAll","focusJumpToPage","switchPage","disableFading","clearTimeout","setTimeout","disableSmooth","scrollIntoView","behavior","block","inline","view","get","func","getByView","goto","jumpToPage","jumpid","checkValidity","parsed","value","isNaN","focus","url","test","minoffset","Date","getTimezoneOffset","success","pages","Math","ceil","count","files","autoPage","basedomain","max","pagination","paginate","extraControls","escape","controls","bottomExtraControls","replace","bottomPagination","unselected","showOriginalNames","hasExpiryDateColumn","some","file","expirydate","thumb","extname","toLowerCase","previewable","name","original","prettyBytes","getPrettyBytes","size","prettyDate","getPrettyDate","timestamp","prettyExpiryDate","appendix","userid","albumid","table","upload","div","appendChild","querySelectorAll","allAlbums","tr","ip","checked","fadeInDom","scrollToDom","update","onAxiosError","undefined","onload","body","onerror","setAttribute","splice","indexOf","JSON","stringify","lastElement","thisIndex","index","lastIndex","abs","shiftKey","selectInBetween","suffix","substring","proceed","Boolean","style","trim","filtersid","user","postBulkDeleteUploads","field","values","cb","failed","filter","textArea","seen","names","split","map","trimmed","prototype","hasOwnProperty","join","objective","dangerMode","cancel","Array","isArray","addUploadsToAlbum","ids","callback","choose","added","simple","list","getElementsByTagName","removeAttribute","homeDomain","createNewAlbum","albumUrlText","identifier","albumUrl","hasZip","zipSize","prettyZipDate","zipGeneratedAt","isZipExpired","editedAt","enabled","download","public","descriptionHtml","urlPath","requestLink","purge","albumsSidebar","oldAlbums","diffCount","innerText","collapsed","textExpand","textCollapse","collapse","li","a","sendNewPassword","pass","password","admin","displayGroup","groups","keys","registration","prettyTokenUpdate","usage","groupOptions","g","isHigher","isDisabledHelper","resetPassword","autoClose","displayName","totalItems","itemsPerPage","currentPage","numPages","template","start","end","elementsToShow","step","stats","rows","valKeys","j","totalForPercentage","available","used","total","toFixed","getPrettyUptime","toLocaleString","onError","hrtime","defineProperty","varArgs","arguments$1","arguments","TypeError","to","nextSource","nextKey","writable","configurable","documentElement","selectedKeys","ls","parse","preparePage","ClipboardJS","on","LazyLoad","bulmaCollapsible"],"mappings":"AAEAA,IAAMC,OAAS,CACbC,MAAO,QACPC,SAAU,CACRC,QAAS,kBACTC,WAAY,sBAEdC,SAAU,CACRF,QAAS,kBACTC,WAAY,qBACZE,OAAQ,iBACRC,UAAW,oBACXC,MAAO,iBAETC,cAAe,CACbN,QAAS,gBACTC,WAAY,qBAIVM,KAAO,CAEXC,QAAS,KAETC,IAAK,KAGLX,MAAOY,aAAab,OAAOC,OAG3Ba,SAAU,KACVC,YAAa,KAGbC,eAAgB,KAChBC,MAAO,GAEPC,YAAa,KACbC,MAAO,CAELhB,QAAS,CACPiB,KAAMP,aAAab,OAAOE,SAASC,SACnCM,cAA8D,MAA/CI,aAAab,OAAOS,cAAcN,SACjDkB,MAAO,KACPC,QAAS,MAGXlB,WAAY,CACVgB,KAAMP,aAAab,OAAOE,SAASE,YACnCK,cAAiE,MAAlDI,aAAab,OAAOS,cAAcL,YACjDmB,QAAS,KACTD,QAAS,KACTE,KAAK,GAGPlB,OAAQ,CACNiB,QAAS,KACTD,QAAS,MAGXf,UAAW,CACTgB,QAAS,KACTD,QAAS,KACTE,KAAK,GAGPhB,MAAO,CACLe,QAAS,KACTD,QAAS,OAGbG,aAAc,CACZtB,QAAS,KACTC,WAAY,KACZE,OAAQ,KACRC,UAAW,KACXC,MAAO,MAITH,SAAU,CACRF,QAAS,GACTC,WAAY,GACZE,OAAQ,GACRC,UAAW,GACXC,MAAO,IAETkB,WAAY,GACZC,aAAc,GAGdC,qBAAsB,KAGtBC,MAAO,GAEPC,YAAa,KACbC,SAAU,KACVC,sBAAuB,KACvBC,y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0BAGpDhC,KAAKuB,yBAA2B,IAAIsV,iBAAiB9U,SAASC,cAAc,mBAC5EhC,KAAKuB,yBAAyBoV,GAAG,iBAAe,SAAEhS,GAChD3E,KAAKsB,sBAAsBuR,UAAY7S,KAAKsB,sBAAsBiG,QAAQyL,gBAE5EhT,KAAKuB,yBAAyBoV,GAAG,mBAAiB,SAAEhS,GAClD3E,KAAKsB,sBAAsBuR,UAAY7S,KAAKsB,sBAAsBiG,QAAQwL","file":"dashboard.js","sourcesContent":["/* global swal, axios, ClipboardJS, LazyLoad, bulmaCollapsible */\n\nconst lsKeys = {\n token: 'token',\n viewType: {\n uploads: 'viewTypeUploads',\n uploadsAll: 'viewTypeUploadsAll'\n },\n selected: {\n uploads: 'selectedUploads',\n uploadsAll: 'selectedUploadsAll',\n albums: 'selectedAlbums',\n albumsAll: 'selectedAlbumsAll',\n users: 'selectedUsers'\n },\n originalNames: {\n uploads: 'originalNames',\n uploadsAll: 'originalNamesAll'\n }\n}\n\nconst page = {\n // #dashboard\n section: null,\n // #page\n dom: null,\n\n // user token\n token: localStorage[lsKeys.token],\n\n // from api/tokens/verify\n username: null,\n permissions: null,\n\n // sidebar menus\n menusContainer: null,\n menus: [],\n\n currentView: null,\n views: {\n // params of uploads view\n uploads: {\n type: localStorage[lsKeys.viewType.uploads],\n originalNames: localStorage[lsKeys.originalNames.uploads] === '1',\n album: null, // album's id\n pageNum: null\n },\n // params of uploads view (all)\n uploadsAll: {\n type: localStorage[lsKeys.viewType.uploadsAll],\n originalNames: localStorage[lsKeys.originalNames.uploadsAll] === '1',\n filters: null,\n pageNum: null,\n all: true\n },\n // params of albums view\n albums: {\n filters: null,\n pageNum: null\n },\n // params of albums view (all)\n albumsAll: {\n filters: null,\n pageNum: null,\n all: true\n },\n // params of users view\n users: {\n filters: null,\n pageNum: null\n }\n },\n prevPageNums: {\n uploads: null,\n uploadsAll: null,\n albums: null,\n albumsAll: null,\n users: null\n },\n\n // ids of selected items (shared across pages and will be synced with localStorage)\n selected: {\n uploads: [],\n uploadsAll: [],\n albums: [],\n albumsAll: [],\n users: []\n },\n checkboxes: [],\n lastSelected: [],\n\n // select album dom for dialogs/modals\n selectAlbumContainer: null,\n\n // cache for dialogs/modals\n cache: {},\n\n clipboardJS: null,\n lazyLoad: null,\n albumsSidebarCollapse: null,\n albumsSidebarCollapsible: null,\n\n imageExts: ['.gif', '.jpeg', '.jpg', '.png', '.svg', '.tif', '.tiff', '.webp'],\n videoExts: ['.3g2', '.3gp', '.asf', '.avchd', '.avi', '.divx', '.evo', '.flv', '.h264', '.h265', '.hevc', '.m2p', '.m2ts', '.m4v', '.mk3d', '.mkv', '.mov', '.mp4', '.mpeg', '.mpg', '.mxf', '.ogg', '.ogv', '.ps', '.qt', '.rmvb', '.ts', '.vob', '.webm', '.wmv'],\n audioExts: ['.flac', '.mp3', '.wav', '.wma'],\n\n isSomethingLoading: false,\n fadingIn: null,\n\n albumTitleMaxLength: 70,\n albumDescMaxLength: 4000\n}\n\npage.unhide = () => {\n document.querySelector('#loader').classList.add('is-hidden')\n page.section.classList.remove('is-hidden')\n}\n\n// Handler for regular JS errors\npage.onError = error => {\n console.error(error)\n\n const content = document.createElement('div')\n content.innerHTML = `\n

    ${error.toString()}

    \n

    Please check your console for more information.

    \n `\n return swal({\n title: 'An error occurred!',\n icon: 'error',\n content\n })\n}\n\n// Handler for Axios errors\npage.onAxiosError = error => {\n console.error(error)\n\n // Better Cloudflare errors\n const cloudflareErrors = {\n 520: 'Unknown Error',\n 521: 'Web Server Is Down',\n 522: 'Connection Timed Out',\n 523: 'Origin Is Unreachable',\n 524: 'A Timeout Occurred',\n 525: 'SSL Handshake Failed',\n 526: 'Invalid SSL Certificate',\n 527: 'Railgun Error',\n 530: 'Origin DNS Error'\n }\n\n const statusText = cloudflareErrors[error.response.status] || error.response.statusText\n const description = error.response.data && error.response.data.description\n ? error.response.data.description\n : 'There was an error with the request.\\nPlease check the console for more information.'\n\n return swal(`${error.response.status} ${statusText}`, description, 'error')\n}\n\npage.preparePage = () => {\n if (page.token) page.verifyToken(page.token)\n else window.location = 'auth'\n}\n\npage.checkClientVersion = apiVersion => {\n const self = document.querySelector('#mainScript')\n const match = self.src.match(/\\?_=(\\d+)$/)\n if (match && match[1] && match[1] !== apiVersion) {\n return swal({\n title: 'Update detected!',\n text: 'Client assets have been updated. Reload to display the latest version?',\n icon: 'info',\n buttons: {\n confirm: {\n text: 'Reload',\n closeModal: false\n }\n }\n }).then(() => {\n window.location.reload()\n })\n }\n}\n\npage.verifyToken = token => {\n axios.post('api/tokens/verify', { token }).then(response => {\n axios.defaults.headers.common.token = token\n localStorage[lsKeys.token] = token\n\n if (response.data.version) {\n page.checkClientVersion(response.data.version)\n }\n\n page.token = token\n page.username = response.data.username\n page.permissions = response.data.permissions\n page.prepareDashboard()\n }).catch(error => {\n return swal({\n title: 'An error occurred!',\n text: error.response.data ? error.response.data.description : error.toString(),\n icon: 'error'\n }).then(() => {\n if (error.response.data && error.response.data.code === 10001) {\n localStorage.removeItem(lsKeys.token)\n window.location = 'auth'\n }\n })\n })\n}\n\npage.prepareDashboard = () => {\n page.section = document.querySelector('#dashboard')\n page.dom = page.section.querySelector('#page')\n\n // Capture all click events\n page.dom.addEventListener('click', page.domClick, true)\n\n // Capture all submit events\n page.dom.addEventListener('submit', event => {\n // Prevent default if necessary\n if (event.target && event.target.classList.contains('prevent-default')) {\n return event.preventDefault()\n }\n }, true)\n\n page.menusContainer = document.querySelector('#menu')\n\n // All item menus in the sidebar\n const itemMenus = [\n { selector: '#itemUploads', onclick: page.getUploads },\n { selector: '#itemDeleteUploadsByNames', onclick: page.deleteUploadsByNames },\n { selector: '#itemManageYourAlbums', onclick: page.getAlbums },\n { selector: '#itemManageToken', onclick: page.changeToken },\n { selector: '#itemChangePassword', onclick: page.changePassword },\n { selector: '#itemLogout', onclick: page.logout },\n { selector: '#itemManageUploads', onclick: page.getUploads, params: { all: true }, group: 'moderator' },\n { selector: '#itemManageAlbums', onclick: page.getAlbums, params: { all: true }, group: 'moderator' },\n { selector: '#itemStatistics', onclick: page.getStatistics, group: 'admin' },\n { selector: '#itemManageUsers', onclick: page.getUsers, group: 'admin' }\n ]\n\n for (let i = 0; i < itemMenus.length; i++) {\n // Skip item menu if not enough permission\n if (itemMenus[i].group && !page.permissions[itemMenus[i].group]) continue\n\n // Add onclick event listener\n const item = document.querySelector(itemMenus[i].selector)\n item.addEventListener('click', event => {\n if (page.isSomethingLoading) return page.warnSomethingLoading()\n\n // eslint-disable-next-line compat/compat\n itemMenus[i].onclick.call(null, Object.assign(itemMenus[i].params || {}, {\n trigger: event.currentTarget,\n forceScroll: true\n }))\n })\n\n item.classList.remove('is-hidden')\n page.menus.push(item)\n }\n\n // If at least a moderator, show administration section\n if (page.permissions.moderator) {\n document.querySelector('#itemLabelAdmin').classList.remove('is-hidden')\n document.querySelector('#itemListAdmin').classList.remove('is-hidden')\n }\n\n // Update text of logout button\n document.querySelector('#itemLogout').innerHTML = `Logout ( ${page.username} )`\n\n // Finally display dashboard\n page.unhide()\n\n // Load albums sidebar\n page.getAlbumsSidebar()\n\n if (typeof page.prepareShareX === 'function') page.prepareShareX()\n}\n\npage.logout = params => {\n page.updateTrigger(params.trigger, 'active')\n localStorage.removeItem(lsKeys.token)\n window.location = 'auth'\n}\n\npage.warnSomethingLoading = () => {\n swal('Please wait!', 'Something else is still loading\\u2026', 'warning', {\n buttons: false,\n timer: 3000\n })\n}\n\npage.updateTrigger = (trigger, newState) => {\n if (!trigger) return\n\n // Disable menus container and pagination when loading\n if (newState === 'loading') {\n page.isSomethingLoading = true\n page.section.classList.add('is-loading')\n } else {\n page.section.classList.remove('is-loading')\n page.isSomethingLoading = false\n }\n\n if (newState === 'loading') {\n trigger.classList.add('is-loading')\n } else if (newState === 'active') {\n if (trigger.parentNode.tagName === 'LI' && !trigger.className.includes('pagination-link')) {\n for (let i = 0; i < page.menus.length; i++) {\n page.menus[i].classList.remove('is-active')\n }\n trigger.classList.add('is-active')\n }\n trigger.classList.remove('is-loading')\n } else {\n trigger.classList.remove('is-loading')\n trigger.classList.remove('is-active')\n }\n}\n\npage.getItemID = element => {\n // This expects the item's parent to have the item's ID\n let parent = element.parentNode\n // If the element is part of a set of controls, use the container's parent instead\n if (element.parentNode.classList.contains('controls')) parent = parent.parentNode\n return parseInt(parent.dataset.id)\n}\n\npage.domClick = event => {\n // We are processing clicks this way to avoid using \"onclick\" attribute\n // Apparently we will need to use \"unsafe-inline\" for \"script-src\" directive\n // of Content Security Policy (CSP), if we want to use \"onclick\" attribute\n // Though I think that only applies to some browsers (?)\n // Of course it wouldn't have mattered if we didn't use CSP to begin with\n // Anyway, I personally would rather not use \"onclick\" attribute\n let element = event.target\n if (!element) return\n\n // Delegate click events to their A or BUTTON parents\n if (['I'].includes(element.tagName) && ['SPAN'].includes(element.parentNode.tagName)) {\n element = element.parentNode\n }\n if (['SPAN'].includes(element.tagName) && ['A', 'BUTTON'].includes(element.parentNode.tagName)) {\n element = element.parentNode\n }\n\n // Skip elements that have no action data\n if (!element.dataset || !element.dataset.action) return\n\n // Skip disabled elements\n if (element.hasAttribute('disabled')) return\n\n event.stopPropagation() // maybe necessary\n const id = page.getItemID(element)\n const action = element.dataset.action\n\n switch (action) {\n // Uploads\n case 'view-list':\n return page.setUploadsView('list', element)\n case 'view-thumbs':\n return page.setUploadsView('thumbs', element)\n case 'toggle-original-names':\n return page.toggleOriginalNames(element)\n case 'add-to-album':\n return page.addToAlbum(id)\n case 'delete-upload':\n return page.deleteUpload(id)\n case 'add-selected-uploads-to-album':\n return page.addSelectedUploadsToAlbum()\n case 'bulk-delete-uploads':\n return page.bulkDeleteUploads()\n case 'display-preview':\n return page.displayPreview(id)\n // Manage uploads\n case 'upload-filters-help':\n return page.uploadFiltersHelp(element)\n case 'filter-uploads':\n return page.filterUploads(element)\n // Manage your albums\n case 'submit-album':\n return page.submitAlbum(element)\n case 'edit-album':\n return page.editAlbum(id)\n case 'disable-album':\n return page.disableAlbum(id)\n case 'delete-album':\n return page.deleteAlbum(id)\n case 'view-album-uploads':\n return page.viewAlbumUploads(id, element)\n // Manage users\n case 'create-user':\n return page.createUser()\n case 'edit-user':\n return page.editUser(id)\n case 'disable-user':\n return page.disableUser(id)\n case 'delete-user':\n return page.deleteUser(id)\n case 'view-user-uploads':\n return page.viewUserUploads(id, element)\n // Others\n case 'get-new-token':\n return page.getNewToken(element)\n // Uploads & Users\n case 'clear-selection':\n return page.clearSelection()\n case 'select':\n return page.select(element, event)\n case 'select-all':\n return page.selectAll(element)\n case 'page-ellipsis':\n return page.focusJumpToPage(element)\n case 'page-prev':\n case 'page-next':\n case 'page-goto':\n case 'jump-to-page':\n return page.switchPage(action, element)\n }\n}\n\npage.fadeInDom = disableFading => {\n if (page.fadingIn) {\n clearTimeout(page.fadingIn)\n page.dom.classList.remove('fade-in')\n }\n\n if (!disableFading) {\n page.dom.classList.add('fade-in')\n page.fadingIn = setTimeout(() => {\n page.dom.classList.remove('fade-in')\n }, 500)\n }\n}\n\npage.scrollToDom = disableSmooth => {\n page.dom.scrollIntoView({\n behavior: disableSmooth ? 'auto' : 'smooth',\n block: 'start',\n inline: 'nearest'\n })\n}\n\npage.getByView = (view, get) => {\n switch (view) {\n case 'uploads':\n case 'uploadsAll':\n return {\n type: 'uploads',\n func: page.getUploads\n }[get]\n case 'albums':\n case 'albumsAll':\n return {\n type: 'albums',\n func: page.getAlbums\n }[get]\n case 'users':\n return {\n type: 'users',\n func: page.getUsers\n }[get]\n default:\n return null\n }\n}\n\npage.switchPage = (action, element) => {\n if (page.isSomethingLoading) return page.warnSomethingLoading()\n\n // eslint-disable-next-line compat/compat\n const params = Object.assign(page.views[page.currentView], {\n trigger: element\n })\n\n const func = page.getByView(page.currentView, 'func')\n\n switch (action) {\n case 'page-prev':\n params.pageNum = page.views[page.currentView].pageNum - 1\n if (params.pageNum < 0) {\n return swal('An error occurred!', 'This is already the first page.', 'error')\n }\n return func(params)\n case 'page-next':\n params.pageNum = page.views[page.currentView].pageNum + 1\n return func(params)\n case 'page-goto':\n params.pageNum = parseInt(element.dataset.goto)\n return func(params)\n case 'jump-to-page': {\n const jumpToPage = document.querySelector(`#${element.dataset.jumpid || 'jumpToPage'}`)\n if (!jumpToPage.checkValidity()) return\n const parsed = parseInt(jumpToPage.value)\n params.pageNum = isNaN(parsed) ? 0 : (parsed - 1)\n if (params.pageNum < 0) params.pageNum = 0\n return func(params)\n }\n }\n}\n\npage.focusJumpToPage = element => {\n const jumpToPage = document.querySelector(`#${element.dataset.jumpid || 'jumpToPage'}`)\n if (!jumpToPage) return\n jumpToPage.focus()\n jumpToPage.select()\n}\n\npage.getUploads = (params = {}) => {\n if (params && params.all && !page.permissions.moderator) {\n return swal('An error occurred!', 'You cannot do this!', 'error')\n }\n\n if (page.isSomethingLoading) return page.warnSomethingLoading()\n\n page.updateTrigger(params.trigger, 'loading')\n\n if (typeof params.pageNum !== 'number' || params.pageNum < 0) {\n params.pageNum = 0\n }\n\n const url = typeof params.album !== 'undefined'\n ? `api/album/${params.album}/${params.pageNum}`\n : `api/uploads/${params.pageNum}`\n\n const headers = {}\n if (params.all) headers.all = '1'\n if (params.filters) {\n headers.filters = params.filters\n // Send client timezone offset if properly using date: and/or :expiry filters\n // Server will pretend client is on UTC if unset\n if (/(^|\\s)(date|expiry):[\\d\"]/.test(params.filters)) {\n headers.minoffset = new Date().getTimezoneOffset()\n }\n }\n\n axios.get(url, { headers }).then(response => {\n if (response.data.success === false) {\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n page.updateTrigger(params.trigger)\n return swal('An error occurred!', response.data.description, 'error')\n }\n }\n\n const pages = Math.ceil(response.data.count / 25)\n const files = response.data.files\n if (params.pageNum && (files.length === 0)) {\n page.updateTrigger(params.trigger)\n if (params.autoPage) {\n params.pageNum = pages - 1\n return page.getUploads(params)\n } else {\n return swal('An error occurred!', `There are no more uploads to populate page ${params.pageNum + 1}.`, 'error')\n }\n }\n\n page.currentView = params.all ? 'uploadsAll' : 'uploads'\n page.cache = {}\n\n const albums = response.data.albums\n const users = response.data.users\n const basedomain = response.data.basedomain\n\n if (params.pageNum < 0) params.pageNum = Math.max(0, pages + params.pageNum)\n const pagination = page.paginate(response.data.count, 25, params.pageNum)\n\n const filter = `\n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n `\n const extraControls = `\n
    \n ${filter}\n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n `\n\n const controls = `\n \n `\n\n // Do some string replacements for bottom controls\n const bottomFiltersId = 'bFilters'\n const bottomJumpId = 'bJumpToPage'\n const bottomExtraControls = extraControls\n .replace(/id=\"filters\"/, `id=\"${bottomFiltersId}\"`)\n .replace(/(data-action=\"filter-uploads\")/, `$1 data-filtersid=\"${bottomFiltersId}\"`)\n .replace(/id=\"jumpToPage\"/, `id=\"${bottomJumpId}\"`)\n .replace(/(data-action=\"jump-to-page\")/g, `$1 data-jumpid=\"${bottomJumpId}\"`)\n const bottomPagination = pagination\n .replace(/(data-action=\"page-ellipsis\")/g, `$1 data-jumpid=\"${bottomJumpId}\"`)\n\n // Whether there are any unselected items\n let unselected = false\n\n const showOriginalNames = page.views[page.currentView].originalNames\n const hasExpiryDateColumn = files.some(file => typeof file.expirydate !== 'undefined')\n\n for (let i = 0; i < files.length; i++) {\n // Build full URLs\n files[i].file = `${basedomain}/${files[i].name}`\n if (files[i].thumb) {\n files[i].thumb = `${basedomain}/${files[i].thumb}`\n }\n\n // Determine types\n const extname = files[i].extname.toLowerCase()\n if (page.imageExts.includes(extname)) {\n files[i].type = 'picture'\n } else if (page.videoExts.includes(extname)) {\n files[i].type = 'video'\n } else if (page.audioExts.includes(extname)) {\n files[i].type = 'audio'\n } else {\n files[i].type = 'other'\n }\n\n files[i].previewable = files[i].thumb || files[i].type === 'audio'\n\n // Cache bare minimum data for thumbnails viewer\n page.cache[files[i].id] = {\n name: files[i].name,\n original: files[i].original,\n extname: files[i].extname,\n thumb: files[i].thumb,\n file: files[i].file,\n type: files[i].type,\n previewable: files[i].previewable\n }\n\n // Prettify\n files[i].prettyBytes = page.getPrettyBytes(parseInt(files[i].size))\n files[i].prettyDate = page.getPrettyDate(new Date(files[i].timestamp * 1000))\n\n if (hasExpiryDateColumn) {\n files[i].prettyExpiryDate = files[i].expirydate\n ? page.getPrettyDate(new Date(files[i].expirydate * 1000))\n : null\n }\n\n // Update selected status\n files[i].selected = page.selected[page.currentView].includes(files[i].id)\n if (!files[i].selected) unselected = true\n\n // Appendix (display album or user)\n if (params.all) {\n files[i].appendix = files[i].userid\n ? users[files[i].userid] || ''\n : ''\n } else if (typeof params.album === 'undefined') {\n files[i].appendix = files[i].albumid\n ? albums[files[i].albumid] || ''\n : ''\n }\n }\n\n if (page.views[page.currentView].type === 'thumbs') {\n page.dom.innerHTML = `\n ${pagination}\n ${extraControls}\n ${controls}\n
    \n
    \n ${controls}\n ${bottomExtraControls}\n ${bottomPagination}\n `\n\n const table = document.querySelector('#table')\n\n for (let i = 0; i < files.length; i++) {\n const upload = files[i]\n const div = document.createElement('div')\n div.className = 'image-container column'\n div.dataset.id = upload.id\n\n if (typeof upload.thumb !== 'undefined') {\n div.innerHTML = `\"${upload.name}\"`\n } else {\n div.innerHTML = `

    ${upload.extname || 'N/A'}

    `\n }\n\n div.innerHTML += `\n \n
    \n ${upload.previewable\n ? `\n \n \n \n `\n : ''}\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
    \n
    \n

    ${upload.name}

    \n ${showOriginalNames ? `

    ${upload.original}

    ` : ''}\n

    ${upload.appendix ? `${upload.appendix} – ` : ''}${upload.prettyBytes}

    \n ${hasExpiryDateColumn && upload.prettyExpiryDate\n ? `

    EXP: ${upload.prettyExpiryDate}

    `\n : ''}\n
    \n `\n\n table.appendChild(div)\n page.checkboxes = table.querySelectorAll('.checkbox[data-action=\"select\"]')\n }\n } else {\n const allAlbums = params.all && params.filters && params.filters.includes('albumid:')\n page.dom.innerHTML = `\n ${pagination}\n ${extraControls}\n ${controls}\n
    \n \n \n \n \n \n ${showOriginalNames ? '' : ''}\n ${typeof params.album === 'undefined' ? `` : ''}\n ${allAlbums ? '' : ''}\n \n ${params.all ? '' : ''}\n \n ${hasExpiryDateColumn ? '' : ''}\n \n \n \n \n \n
    File nameOriginal nameUser' : 'albumid\">Album'}AlbumSizeIPUpload dateExpiry date(${response.data.count} total)
    \n
    \n ${controls}\n ${bottomExtraControls}\n ${bottomPagination}\n `\n\n const table = document.querySelector('#table')\n\n for (let i = 0; i < files.length; i++) {\n const upload = files[i]\n const tr = document.createElement('tr')\n tr.dataset.id = upload.id\n tr.innerHTML = `\n \n ${upload.name}\n ${showOriginalNames ? `${upload.original}` : ''}\n ${typeof params.album === 'undefined' ? `${upload.appendix}` : ''}\n ${allAlbums ? `${upload.albumid ? (albums[upload.albumid] || '') : ''}` : ''}\n ${upload.prettyBytes}\n ${params.all ? `${upload.ip || ''}` : ''}\n ${upload.prettyDate}\n ${hasExpiryDateColumn ? `${upload.prettyExpiryDate || '-'}` : ''}\n \n \n \n \n \n \n \n \n \n \n \n ${params.all\n ? ''\n : `\n \n \n \n `}\n \n \n \n \n \n \n `\n\n table.appendChild(tr)\n page.checkboxes = table.querySelectorAll('.checkbox[data-action=\"select\"]')\n }\n }\n\n const selectAll = document.querySelector('#selectAll')\n if (selectAll && !unselected && files.length) {\n selectAll.checked = true\n selectAll.title = 'Unselect all'\n }\n\n page.fadeInDom()\n\n const pageNum = files.length ? params.pageNum : 0\n if (params.forceScroll ||\n page.prevPageNums[page.currentView] === null ||\n page.prevPageNums[page.currentView] !== pageNum) {\n const disableSmooth = !params.forceScroll && page.views[page.currentView].type === 'thumbs'\n page.scrollToDom(disableSmooth)\n }\n\n if (page.views[page.currentView].type === 'thumbs') {\n page.lazyLoad.update()\n }\n\n page.updateTrigger(params.trigger, 'active')\n\n if (page.currentView === 'uploads') {\n page.views.uploads.album = params.album\n }\n page.views[page.currentView].filters = params.filters\n page.views[page.currentView].pageNum = page.prevPageNums[page.currentView] = pageNum\n }).catch(error => {\n page.updateTrigger(params.trigger)\n page.onAxiosError(error)\n })\n}\n\npage.setUploadsView = (view, element) => {\n if (page.isSomethingLoading) return page.warnSomethingLoading()\n\n if (view === 'list') {\n delete localStorage[lsKeys.viewType[page.currentView]]\n page.views[page.currentView].type = undefined\n } else {\n localStorage[lsKeys.viewType[page.currentView]] = view\n page.views[page.currentView].type = view\n }\n\n // eslint-disable-next-line compat/compat\n page.getUploads(Object.assign(page.views[page.currentView], {\n trigger: element\n }))\n}\n\npage.toggleOriginalNames = element => {\n if (page.isSomethingLoading) return page.warnSomethingLoading()\n\n if (page.views[page.currentView].originalNames) {\n delete localStorage[lsKeys.originalNames[page.currentView]]\n page.views[page.currentView].originalNames = false\n } else {\n localStorage[lsKeys.originalNames[page.currentView]] = '1'\n page.views[page.currentView].originalNames = true\n }\n\n // eslint-disable-next-line compat/compat\n page.getUploads(Object.assign(page.views[page.currentView], {\n trigger: element\n }))\n}\n\npage.displayPreview = id => {\n const file = page.cache[id]\n if (!file.previewable) return\n\n const div = document.createElement('div')\n div.innerHTML = `\n
    \n

    \n

    ${file.name}
    \n
    ${file.original}
    \n

    \n ${file.thumb\n ? `

    \n \n

    `\n : ''}\n
    \n `\n\n if (file.file && ['picture', 'video', 'audio'].includes(file.type)) {\n div.innerHTML += `\n \n `\n\n if (file.type === 'picture') {\n div.querySelector('#swalOriginal').addEventListener('click', event => {\n const trigger = event.currentTarget\n if (trigger.classList.contains('is-danger')) return\n\n trigger.classList.add('is-loading')\n const thumb = div.querySelector('#swalThumb')\n\n thumb.src = file.file\n thumb.onload = () => {\n trigger.classList.add('is-hidden')\n document.body.querySelector('.swal-overlay .swal-modal:not(.is-expanded)').classList.add('is-expanded')\n }\n thumb.onerror = event => {\n event.currentTarget.classList.add('is-hidden')\n trigger.className = 'button is-danger is-fullwidth'\n trigger.innerHTML = `\n \n \n \n Unable to load original\n `\n }\n })\n } else {\n const match = file.file.match(/.*\\/(.*)$/)\n if (match || match[1]) {\n div.querySelector('#swalOriginal').setAttribute('href', `v/${match[1]}`)\n div.querySelector('#swalOriginal').setAttribute('target', '_blank')\n }\n }\n }\n\n return swal({\n content: div,\n buttons: false\n }).then(() => {\n // Restore modal size\n document.body.querySelector('.swal-overlay .swal-modal').classList.remove('is-expanded')\n })\n}\n\npage.selectAll = element => {\n for (let i = 0; i < page.checkboxes.length; i++) {\n const id = page.getItemID(page.checkboxes[i])\n if (isNaN(id)) continue\n if (page.checkboxes[i].checked !== element.checked) {\n page.checkboxes[i].checked = element.checked\n if (page.checkboxes[i].checked) {\n page.selected[page.currentView].push(id)\n } else {\n page.selected[page.currentView].splice(page.selected[page.currentView].indexOf(id), 1)\n }\n }\n }\n\n if (page.selected[page.currentView].length) {\n localStorage[lsKeys.selected[page.currentView]] = JSON.stringify(page.selected[page.currentView])\n } else {\n delete localStorage[lsKeys.selected[page.currentView]]\n }\n\n element.title = element.checked ? 'Unselect all' : 'Select all'\n}\n\npage.selectInBetween = (element, lastElement) => {\n const thisIndex = parseInt(element.dataset.index)\n const lastIndex = parseInt(lastElement.dataset.index)\n\n const distance = Math.abs(thisIndex - lastIndex)\n if (distance < 2) return\n\n for (let i = 0; i < page.checkboxes.length; i++) {\n if ((thisIndex > lastIndex && i > lastIndex && i < thisIndex) ||\n (thisIndex < lastIndex && i > thisIndex && i < lastIndex)) {\n // Check or uncheck depending on the state of the initial checkbox\n const checked = page.checkboxes[i].checked = lastElement.checked\n const id = page.getItemID(page.checkboxes[i])\n if (!page.selected[page.currentView].includes(id) && checked) {\n page.selected[page.currentView].push(id)\n } else if (page.selected[page.currentView].includes(id) && !checked) {\n page.selected[page.currentView].splice(page.selected[page.currentView].indexOf(id), 1)\n }\n }\n }\n}\n\npage.select = (element, event) => {\n const id = page.getItemID(element)\n if (isNaN(id)) return\n\n if (event.shiftKey && page.lastSelected) {\n page.selectInBetween(element, page.lastSelected)\n // Check or uncheck depending on the state of the initial checkbox\n element.checked = page.lastSelected.checked\n } else {\n page.lastSelected = element\n }\n\n if (!page.selected[page.currentView].includes(id) && element.checked) {\n page.selected[page.currentView].push(id)\n } else if (page.selected[page.currentView].includes(id) && !element.checked) {\n page.selected[page.currentView].splice(page.selected[page.currentView].indexOf(id), 1)\n }\n\n // Update local storage\n if (page.selected[page.currentView].length) {\n localStorage[lsKeys.selected[page.currentView]] = JSON.stringify(page.selected[page.currentView])\n } else {\n delete localStorage[lsKeys.selected[page.currentView]]\n }\n}\n\npage.clearSelection = () => {\n const selected = page.selected[page.currentView]\n const type = page.getByView(page.currentView, 'type')\n const count = selected.length\n if (!count) return swal('An error occurred!', `You have not selected any ${type}.`, 'error')\n\n const suffix = count === 1 ? type.substring(0, type.length - 1) : type\n return swal({\n title: 'Are you sure?',\n text: `You are going to unselect ${count} ${suffix}.`,\n buttons: true\n }).then(proceed => {\n if (!proceed) return\n\n const checkboxes = page.checkboxes\n for (let i = 0; i < checkboxes.length; i++) {\n if (checkboxes[i].checked) {\n checkboxes[i].checked = false\n }\n }\n\n page.selected[page.currentView] = []\n delete localStorage[lsKeys.selected[page.currentView]]\n\n const selectAll = document.querySelector('#selectAll')\n if (selectAll) selectAll.checked = false\n\n return swal('Cleared selection!', `Unselected ${count} ${suffix}.`, 'success')\n })\n}\n\npage.uploadFiltersHelp = element => {\n const all = Boolean(element.dataset.all)\n const content = document.createElement('div')\n content.style = 'text-align: left'\n content.innerHTML = `${all\n ? `There are 2 filter keys, namely user (username) and ip.\n These keys can be specified more than once.\n For usernames with whitespaces, wrap them with double quotes (\").\n Special cases such as uploads by non-registered users or have no IPs respectively, use user:- or ip:-.\n\n To exclude certain users/ips while still listing every other uploads, add negation sign (-) before the keys.\n Negation sign can also be used to exclude the special cases mentioned above (i.e. -user:- or -ip:-).\n\n If you know the ID of a user's album, you can list its uploads with albumid key.\n Negation sign works for this key as well.`\n : `There is only 1 filter key, namely albumid.\n This key can be specified more than once.\n Special case such as uploads with no albums, use albumid:-.\n\n To exclude certain albums while still listing every other uploads, add negation sign (-) before the keys.\n Negation sign can also be used to exclude the special case mentioned above (i.e. -albumid:-).`}\n\n There are 2 range keys: date (upload date) and expiry (expiry date).\n Their format is: \"YYYY/MM/DD HH:MM:SS-YYYY/MM/DD HH:MM:SS\" (\"from\" date and \"to\" date respectively).\n You may specify only one of the dates.\n If \"to\" date is missing, 'now' will be used. If \"from\" date is missing, 'beginning of time' will be used.\n If any of the subsequent date or time units are not specified, their first value will be used (e.g. January for month, 1 for day, and so on).\n If only time is specified, today's date will be used.\n If you do not need to specify both date and time, you may omit the double quotes.\n In conclusion, the following examples are all valid: date:\"2020/01/01 01:23-2018/01/01 06\", expiry:-2020/05, date:12:34:56.\n These keys can only be specified once each.\n\n Timezone? Feel free to query the dates with your own timezone.\n API requests to the filter endpoint will attach your browser's timezone offset, so the server will automatically calculate timezone differences.\n\n Matches can also be sorted with sort keys.\n Their formats are: sort:columnName[:d[escending]], where :d[escending] is an optional tag to set the direction to descending.\n This key must be used with internal column names used in the database (id, ${all ? 'userid' : 'albumid'}, and so on),\n but there are 2 shortcuts available: date for timestamp column and expiry for expirydate column.\n This key can also be specified more than once, where their order will decide the sorting steps.\n\n Finally, there are type-is keys to refine by types.\n You can use is:image, is:video, and is:audio to list images, videos, audios respectively.\n This will only use image, video and audio extensions that are whitelisted internally in the safe.\n For images and videos specifically, they will be the ones whose thumbnails can be generated by the safe.\n Negation sign works for this key as well.\n Mixing inclusion and exclusion is not allowed (i.e. is:image -is:video, since the second key is redundant).\n\n Any leftover keywords which do not use keys (non-keyed keywords) will be matched against the matches' file names.\n Excluding certain keywords is also supported by adding negation sign before the keywords.\n\n Internal steps:\n ${all\n ? `- Query uploads passing ALL exclusion filter keys OR matching ANY filter keys, if any.\n - Refine matches`\n : '- Filter uploads'} using date key, if any.\n - Refine matches using expiry key, if any.\n - Refine matches using type-is keys, if any.\n - Refine matches using ANY non-keyed keywords, if any.\n - Filter matches using ALL exclusion non-keyed keywords, if any.\n - Sort matches using sorting keys, if any.\n\n Examples:\n ${all\n ? `- Uploads from users named \"demo\" AND/OR \"John Doe\" AND/OR non-registered users:\n user:demo user:\"John Doe\" user:-\n - ALL uploads, but NOT the ones from user named \"demo\" AND \"John Doe\":\n -user:demo -user:\"John Doe\"\n - Uploads from IP \"127.0.0.1\" AND which file names match \"*.rar\" OR \"*.zip\":\n ip:127.0.0.1 *.rar *.zip\n `\n : ''}- Uploads without albums:\n albumid:-\n - ALL uploads, but NOT the ones from album with ID 69:\n -albumid:69\n - Uploads uploaded since \"1 June 2019 00:00:00\":\n date:2019/06\n - Uploads uploaded between \"7 April 2020 12:00:00\" and \"7 April 2020 23:59:59\":\n date:\"2020/04/07 12-2020/04/07 23:59:59\"\n - Uploads uploaded before \"5 February 2020 00:00:00\":\n date:-2020/02/05\n - Uploads which file names match \"*.gz\" but NOT \"*.tar.gz\":\n *.gz -*.tar.gz\n - Sort matches by \"size\" column in ascending and descending order respectively:\n ${all ? 'user:\"John Doe\"' : '*.txt'} sort:size\n *.mp4 ${all ? 'user:- ' : ''}sort:size:d\n ${!page.permissions.moderator\n ? 'Notice: Regular users may face some limitations in the amount of keys that can be used at a time.'\n : ''}\n Friendly reminder: This window can be scrolled up!\n `.trim().replace(/^\\s*/g, '').replace(/\\n/g, '
    ')\n\n swal({ content }).then(() => {\n // Restore modal size\n document.body.querySelector('.swal-overlay .swal-modal').classList.remove('is-expanded')\n })\n\n // Expand modal size\n document.body.querySelector('.swal-overlay .swal-modal:not(.is-expanded)').classList.add('is-expanded')\n}\n\npage.filterUploads = element => {\n const filters = document.querySelector(`#${element.dataset.filtersid || 'filters'}`).value\n .trim()\n .replace(/\\t/g, ' ')\n .replace(/(^|\\s)((albumid|ip|user|date|expiry|is|sort|orderby):)\\s+/g, '$2')\n // eslint-disable-next-line compat/compat\n page.getUploads(Object.assign(page.views[page.currentView], {\n filters,\n pageNum: 0,\n trigger: element\n }))\n}\n\npage.viewUserUploads = (id, element) => {\n const user = page.cache[id]\n if (!user) return\n element.classList.add('is-loading')\n // Wrap username in quotes if it contains whitespaces\n const username = user.username.includes(' ')\n ? `\"${user.username}\"`\n : user.username\n page.getUploads({\n all: true,\n filters: `user:${username}`,\n trigger: document.querySelector('#itemManageUploads')\n })\n}\n\npage.viewAlbumUploads = (id, element) => {\n if (!page.cache[id]) return\n element.classList.add('is-loading')\n // eslint-disable-next-line compat/compat\n const all = page.currentView === 'albumsAll' && page.permissions.moderator\n page.getUploads({\n all,\n filters: `albumid:${id}`,\n trigger: all\n ? document.querySelector('#itemManageUploads')\n : document.querySelector('#itemUploads')\n })\n}\n\npage.deleteUpload = id => {\n page.postBulkDeleteUploads({\n all: page.currentView === 'uploadsAll',\n field: 'id',\n values: [id],\n cb (failed) {\n // Remove from remembered checkboxes if necessary\n if (!failed.length && page.selected[page.currentView].includes(id)) {\n page.selected[page.currentView].splice(page.selected[page.currentView].indexOf(id), 1)\n }\n\n // Update local storage\n if (page.selected[page.currentView].length) {\n localStorage[lsKeys.selected[page.currentView]] = JSON.stringify(page.selected[page.currentView])\n } else {\n delete localStorage[lsKeys.selected[page.currentView]]\n }\n\n // Reload upload list\n // eslint-disable-next-line compat/compat\n page.getUploads(Object.assign(page.views[page.currentView], {\n autoPage: true\n }))\n }\n })\n}\n\npage.bulkDeleteUploads = () => {\n const count = page.selected[page.currentView].length\n if (!count) return swal('An error occurred!', 'You have not selected any uploads.', 'error')\n\n page.postBulkDeleteUploads({\n all: page.currentView === 'uploadsAll',\n field: 'id',\n values: page.selected[page.currentView],\n cb (failed) {\n // Update state of checkboxes\n if (failed.length) {\n page.selected[page.currentView] = page.selected[page.currentView]\n .filter(id => failed.includes(id))\n } else {\n page.selected[page.currentView] = []\n }\n\n // Update local storage\n if (page.selected[page.currentView].length) {\n localStorage[lsKeys.selected[page.currentView]] = JSON.stringify(page.selected[page.currentView])\n } else {\n delete localStorage[lsKeys.selected[page.currentView]]\n }\n\n // Reload uploads list\n // eslint-disable-next-line compat/compat\n page.getUploads(Object.assign(page.views[page.currentView], {\n autoPage: true\n }))\n }\n })\n}\n\npage.deleteUploadsByNames = (params = {}) => {\n let appendix = ''\n if (page.permissions.moderator) {\n appendix = '
    Hint: You can use this feature to delete uploads by other users.'\n }\n\n page.dom.innerHTML = `\n
    \n
    \n \n
    \n \n
    \n

    Separate each entry with a new line.${appendix}

    \n
    \n
    \n
    \n \n
    \n
    \n
    \n `\n page.fadeInDom()\n page.scrollToDom()\n page.updateTrigger(params.trigger, 'active')\n\n document.querySelector('#submitBulkDelete').addEventListener('click', () => {\n if (page.isSomethingLoading) return page.warnSomethingLoading()\n\n const textArea = document.querySelector('#bulkDeleteNames')\n\n // Clean up\n const seen = {}\n const names = textArea.value\n .split(/\\r?\\n/)\n .map(name => {\n const trimmed = name.trim()\n return /^[^\\s]+$/.test(trimmed)\n ? trimmed\n : ''\n })\n .filter(name => {\n // Filter out invalid and duplicate names\n return (!name || Object.prototype.hasOwnProperty.call(seen, name))\n ? false\n : (seen[name] = true)\n })\n\n // Update textarea with cleaned names\n textArea.value = names.join('\\n')\n\n if (!names.length) {\n return swal('An error occurred!', 'You have not entered any upload names.', 'error')\n }\n\n page.postBulkDeleteUploads({\n all: true,\n field: 'name',\n values: names,\n cb (failed) {\n textArea.value = failed.join('\\n')\n }\n })\n })\n}\n\npage.postBulkDeleteUploads = (params = {}) => {\n const count = params.values.length\n\n const objective = `${params.values.length} upload${count === 1 ? '' : 's'}`\n const boldObjective = objective.replace(/^(\\d*)(.*)/, '$1$2')\n let text = `

    You won't be able to recover ${boldObjective}!

    `\n\n if (params.all) {\n const obj1 = count === 1 ? 'an upload' : 'some uploads'\n const obj2 = count === 1 ? 'another user' : 'other users'\n text += `\\n

    Warning: You may be nuking ${obj1} by ${obj2}!

    `\n }\n\n const content = document.createElement('div')\n content.innerHTML = text\n\n swal({\n title: 'Are you sure?',\n content,\n icon: 'warning',\n dangerMode: true,\n buttons: {\n cancel: true,\n confirm: {\n text: `Yes, nuke ${params.values.length === 1 ? 'it' : 'them'}!`,\n closeModal: false\n }\n }\n }).then(proceed => {\n if (!proceed) return\n\n axios.post('api/upload/bulkdelete', {\n field: params.field,\n values: params.values\n }).then(response => {\n if (!response) return\n\n if (response.data.success === false) {\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n return swal('An error occurred!', response.data.description, 'error')\n }\n }\n\n const failed = Array.isArray(response.data.failed) ? response.data.failed : []\n if (failed.length === params.values.length) {\n swal('An error occurred!', `Unable to delete any of the ${objective}.`, 'error')\n } else if (failed.length && failed.length < params.values.length) {\n swal('Warning!', `From ${objective}, unable to delete ${failed.length} of them.`, 'warning')\n } else {\n swal('Deleted!', `${objective} ${count === 1 ? 'has' : 'have'} been deleted.`, 'success', {\n buttons: false,\n timer: 1500\n })\n }\n\n if (typeof params.cb === 'function') params.cb(failed)\n }).catch(page.onAxiosError)\n })\n}\n\npage.addSelectedUploadsToAlbum = () => {\n if (page.currentView !== 'uploads') return\n\n const count = page.selected[page.currentView].length\n if (!count) return swal('An error occurred!', 'You have not selected any uploads.', 'error')\n\n page.addUploadsToAlbum(page.selected[page.currentView], failed => {\n if (!failed) return\n if (failed.length) {\n page.selected[page.currentView] = page.selected[page.currentView]\n .filter(id => failed.includes(id))\n } else {\n page.selected[page.currentView] = []\n }\n\n localStorage[lsKeys.selected[page.currentView]] = JSON.stringify(page.selected[page.currentView])\n page.getUploads(page.views[page.currentView])\n })\n}\n\npage.addToAlbum = id => {\n page.addUploadsToAlbum([id], failed => {\n if (!failed) return\n page.getUploads(page.views[page.currentView])\n })\n}\n\npage.addUploadsToAlbum = (ids, callback) => {\n const count = ids.length\n\n const content = document.createElement('div')\n content.innerHTML = `\n
    \n

    You are about to add ${count} upload${count === 1 ? '' : 's'} to an album.

    \n

    If an upload is already in an album, it will be moved.

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n `\n\n swal({\n icon: 'warning',\n content,\n buttons: {\n cancel: true,\n confirm: {\n text: 'OK',\n closeModal: false\n }\n }\n }).then(choose => {\n if (!choose) return\n\n const albumid = parseInt(document.querySelector('#swalAlbum').value)\n if (isNaN(albumid)) return swal('An error occurred!', 'You did not choose an album.', 'error')\n\n axios.post('api/albums/addfiles', {\n ids,\n albumid\n }).then(add => {\n if (!add) return\n\n if (add.data.success === false) {\n if (add.data.description === 'No token provided') {\n page.verifyToken(page.token)\n } else {\n swal('An error occurred!', add.data.description, 'error')\n }\n return\n }\n\n let added = ids.length\n if (add.data.failed && add.data.failed.length) {\n added -= add.data.failed.length\n }\n\n const suffix = `upload${ids.length === 1 ? '' : 's'}`\n if (!added) return swal('An error occurred!', `Could not add the ${suffix} to the album.`, 'error')\n\n swal('Woohoo!', `Successfully ${albumid < 0 ? 'removed' : 'added'} ${added} ${suffix} ${albumid < 0 ? 'from' : 'to'} the album.`, 'success', {\n buttons: false,\n timer: 1500\n })\n callback(add.data.failed)\n }).catch(page.onAxiosError)\n })\n\n // Get albums list then update content of swal\n axios.get('api/albums', { headers: { simple: '1' } }).then(list => {\n if (list.data.success === false) {\n if (list.data.description === 'No token provided') {\n page.verifyToken(page.token)\n } else {\n swal('An error occurred!', list.data.description, 'error')\n }\n return\n }\n\n // If the prompt was replaced, the container would be missing\n const select = document.querySelector('#swalAlbum')\n if (!select) return\n\n select.innerHTML += list.data.albums\n .map(album => {\n return ``\n })\n .join('\\n')\n\n select.getElementsByTagName('option')[1].innerHTML = 'Choose an album'\n select.removeAttribute('disabled')\n }).catch(page.onAxiosError)\n}\n\npage.getAlbums = (params = {}) => {\n if (params && params.all && !page.permissions.moderator) {\n return swal('An error occurred!', 'You cannot do this!', 'error')\n }\n\n if (page.isSomethingLoading) return page.warnSomethingLoading()\n\n page.updateTrigger(params.trigger, 'loading')\n\n if (typeof params.pageNum !== 'number') params.pageNum = 0\n\n const headers = {}\n if (params.all) headers.all = '1'\n\n const url = `api/albums/${params.pageNum}`\n axios.get(url, { headers }).then(response => {\n if (!response) return\n\n if (response.data.success === false) {\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n page.updateTrigger(params.trigger)\n return swal('An error occurred!', response.data.description, 'error')\n }\n }\n\n const pages = Math.ceil(response.data.count / 25)\n const albums = response.data.albums\n if (params.pageNum && (albums.length === 0)) {\n page.updateTrigger(params.trigger)\n if (params.autoPage) {\n params.pageNum = pages - 1\n return page.getAlbums(params)\n } else {\n return swal('An error occurred!', `There are no more albums to populate page ${params.pageNum + 1}.`, 'error')\n }\n }\n\n page.currentView = params.all ? 'albumsAll' : 'albums'\n page.cache = {}\n\n const users = response.data.users\n const homeDomain = response.data.homeDomain\n\n if (params.pageNum < 0) params.pageNum = Math.max(0, pages + params.pageNum)\n const pagination = page.paginate(response.data.count, 25, params.pageNum)\n\n const filter = `\n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n `\n const extraControls = `\n
    \n ${filter}\n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n `\n\n const controls = `\n \n `\n\n // Do some string replacements for bottom controls\n const bottomFiltersId = 'bFilters'\n const bottomJumpId = 'bJumpToPage'\n const bottomExtraControls = extraControls\n .replace(/id=\"filters\"/, `id=\"${bottomFiltersId}\"`)\n .replace(/(data-action=\"filter-uploads\")/, `$1 data-filtersid=\"${bottomFiltersId}\"`)\n .replace(/id=\"jumpToPage\"/, `id=\"${bottomJumpId}\"`)\n .replace(/(data-action=\"jump-to-page\")/g, `$1 data-jumpid=\"${bottomJumpId}\"`)\n const bottomPagination = pagination\n .replace(/(data-action=\"page-ellipsis\")/g, `$1 data-jumpid=\"${bottomJumpId}\"`)\n\n // Whether there are any unselected items\n let unselected = false\n\n const createNewAlbum = `\n

    Create new album

    \n
    \n
    \n
    \n \n
    \n

    Max length is ${page.albumTitleMaxLength} characters.

    \n
    \n
    \n
    \n \n
    \n

    Max length is ${page.albumDescMaxLength} characters.

    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n `\n\n page.dom.innerHTML = `\n ${!params.all ? createNewAlbum : ''}\n ${pagination}\n ${extraControls}\n ${controls}\n
    \n \n \n \n \n \n \n ${params.all ? '' : ''}\n \n \n \n \n \n \n \n \n \n \n \n
    IDNameUserUploadsSizeCreated atZIP sizeZIP generated atPublic link(${response.data.count} total)
    \n
    \n ${controls}\n ${bottomExtraControls}\n ${bottomPagination}\n `\n\n const table = document.querySelector('#table')\n\n for (let i = 0; i < albums.length; i++) {\n const album = albums[i]\n const urlPath = '/a/'\n const albumUrlText = urlPath + album.identifier\n const albumUrl = homeDomain + albumUrlText\n\n const selected = page.selected[page.currentView].includes(album.id)\n if (!selected) unselected = true\n\n // Prettify\n album.hasZip = album.zipSize !== null\n album.prettyDate = page.getPrettyDate(new Date(album.timestamp * 1000))\n album.prettyZipDate = album.hasZip ? page.getPrettyDate(new Date(album.zipGeneratedAt * 1000)) : null\n album.isZipExpired = album.hasZip && !(album.zipGeneratedAt > album.editedAt)\n\n // Server-side explicitly expect this value to consider an album as disabled\n const enabled = album.enabled !== 0\n page.cache[album.id] = {\n name: album.name,\n download: album.download,\n public: album.public,\n description: album.description,\n descriptionHtml: album.descriptionHtml,\n enabled,\n homeDomain,\n urlPath,\n identifier: album.identifier\n }\n\n const tr = document.createElement('tr')\n tr.dataset.id = album.id\n tr.innerHTML = `\n \n ${album.id}\n ${album.name}\n ${params.all ? `${album.userid ? (users[album.userid] || '') : ''}` : ''}\n ${album.uploads}\n ${page.getPrettyBytes(album.size)}\n ${album.prettyDate}\n ${album.hasZip ? page.getPrettyBytes(album.zipSize) : '-'}\n ${album.hasZip ? album.prettyZipDate : '-'}\n ${albumUrlText}\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n ${params.all\n ? `\n \n \n \n `\n : ''}\n \n `\n\n table.appendChild(tr)\n page.checkboxes = table.querySelectorAll('.checkbox[data-action=\"select\"]')\n }\n\n const selectAll = document.querySelector('#selectAll')\n if (selectAll && !unselected) {\n selectAll.checked = true\n selectAll.title = 'Unselect all'\n }\n\n page.fadeInDom()\n\n const pageNum = albums.length ? params.pageNum : 0\n if (params.forceScroll ||\n page.prevPageNums[page.currentView] === null ||\n page.prevPageNums[page.currentView] !== pageNum) {\n page.scrollToDom()\n }\n\n page.updateTrigger(params.trigger, 'active')\n\n if (page.currentView === 'albumsAll') {\n page.views[page.currentView].filters = params.filters\n }\n page.views[page.currentView].pageNum = page.prevPageNums[page.currentView] = pageNum\n }).catch(error => {\n page.updateTrigger(params.trigger)\n page.onAxiosError(error)\n })\n}\n\npage.editAlbum = id => {\n const album = page.cache[id]\n if (!album) return\n\n const albumUrlText = album.urlPath + album.identifier\n const albumUrl = album.homeDomain + albumUrlText\n\n const div = document.createElement('div')\n div.innerHTML = `\n
    \n
    \n \n
    \n

    Max length is ${page.albumTitleMaxLength} characters.

    \n
    \n
    \n
    \n \n
    \n

    Markdown supported. Max length is ${page.albumDescMaxLength} characters.

    \n
    \n ${album.descriptionHtml\n ? `
    \n
    \n ${album.descriptionHtml}\n
    \n

    Save changes then re-open this Edit prompt to refresh this preview.

    \n
    `\n : ''}\n ${page.currentView === 'albumsAll' && page.permissions.moderator\n ? `
    \n
    \n \n
    \n
    `\n : ''}\n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n

    Current public link: ${albumUrlText}

    \n
    \n `\n\n swal({\n title: 'Edit album',\n icon: 'info',\n content: div,\n buttons: {\n cancel: true,\n confirm: {\n closeModal: false\n }\n }\n }).then(value => {\n if (!value) return\n\n const post = {\n id,\n name: document.querySelector('#swalName').value.trim(),\n description: document.querySelector('#swalDescription').value.trim(),\n download: document.querySelector('#swalDownload').checked,\n public: document.querySelector('#swalPublic').checked,\n requestLink: document.querySelector('#swalRequestLink').checked\n }\n\n if (page.currentView === 'albumsAll' && page.permissions.moderator) {\n post.enabled = document.querySelector('#swalEnabled').checked\n }\n\n axios.post('api/albums/edit', post).then(response => {\n if (!response) return\n\n if (response.data.success === false) {\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n return swal('An error occurred!', response.data.description, 'error')\n }\n }\n\n if (response.data.identifier) {\n swal('Success!', `The album's new identifier is: ${response.data.identifier}.`, 'success')\n } else if (response.data.name !== album.name) {\n swal('Success!', `The album was renamed to: ${response.data.name}.`, 'success')\n } else {\n swal('Success!', 'The album was edited.', 'success', {\n buttons: false,\n timer: 1500\n })\n }\n\n page.getAlbumsSidebar()\n // Reload albums list\n // eslint-disable-next-line compat/compat\n page.getAlbums(Object.assign(page.views[page.currentView], {\n autoPage: true\n }))\n }).catch(page.onAxiosError)\n })\n}\n\npage.disableAlbum = id => {\n swal({\n title: 'Are you sure?',\n text: 'This won\\'t delete the uploads associated with the album!',\n icon: 'warning',\n dangerMode: true,\n buttons: {\n cancel: true,\n confirm: {\n text: 'Yes, disable it!',\n closeModal: false\n },\n purge: {\n text: 'Umm, delete the uploads, please?',\n value: 'purge',\n className: 'swal-button--danger',\n closeModal: false\n }\n }\n }).then(proceed => {\n if (!proceed) return\n\n axios.post('api/albums/disable', {\n id,\n purge: proceed === 'purge'\n }).then(response => {\n if (response.data.success === false) {\n const failed = Array.isArray(response.data.failed)\n ? response.data.failed\n : []\n\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else if (failed.length) {\n return swal('An error occurred!', `Unable to delete ${failed.length} of the album's upload${failed.length === 1 ? '' : 's'}.`, 'error')\n } else {\n return swal('An error occurred!', response.data.description, 'error')\n }\n }\n\n swal('Disabled!', 'The album has been disabled.', 'success', {\n buttons: false,\n timer: 1500\n })\n\n page.getAlbumsSidebar()\n // Reload albums list\n // eslint-disable-next-line compat/compat\n page.getAlbums(Object.assign(page.views[page.currentView], {\n autoPage: true\n }))\n }).catch(page.onAxiosError)\n })\n}\n\npage.deleteAlbum = id => {\n swal({\n title: 'Are you sure?',\n text: 'You won\\'t be able to recover this album!\\n' +\n 'This also won\\'t delete the uploads associated with the album!',\n icon: 'warning',\n dangerMode: true,\n buttons: {\n cancel: true,\n confirm: {\n text: 'Yes, delete it!',\n closeModal: false\n },\n purge: {\n text: 'Umm, delete the uploads, please?',\n value: 'purge',\n className: 'swal-button--danger',\n closeModal: false\n }\n }\n }).then(proceed => {\n if (!proceed) return\n\n axios.post('api/albums/delete', {\n id,\n purge: proceed === 'purge'\n }).then(response => {\n if (response.data.success === false) {\n const failed = Array.isArray(response.data.failed)\n ? response.data.failed\n : []\n\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else if (failed.length) {\n return swal('An error occurred!', `Unable to delete ${failed.length} of the album's upload${failed.length === 1 ? '' : 's'}.`, 'error')\n } else {\n return swal('An error occurred!', response.data.description, 'error')\n }\n }\n\n swal('Disabled!', 'The album has been deleted.', 'success', {\n buttons: false,\n timer: 1500\n })\n\n page.getAlbumsSidebar()\n // Reload albums list\n // eslint-disable-next-line compat/compat\n page.getAlbums(Object.assign(page.views[page.currentView], {\n autoPage: true\n }))\n }).catch(page.onAxiosError)\n })\n}\n\npage.submitAlbum = element => {\n page.updateTrigger(element, 'loading')\n\n axios.post('api/albums', {\n name: document.querySelector('#albumName').value.trim(),\n description: document.querySelector('#albumDescription').value.trim()\n }).then(response => {\n if (!response) return\n\n page.updateTrigger(element)\n if (response.data.success === false) {\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n return swal('An error occurred!', response.data.description, 'error')\n }\n }\n\n swal('Woohoo!', 'Album was created successfully.', 'success', {\n buttons: false,\n timer: 1500\n })\n page.getAlbumsSidebar()\n page.getAlbums({\n pageNum: -1\n })\n }).catch(error => {\n page.updateTrigger(element)\n page.onAxiosError(error)\n })\n}\n\npage.getAlbumsSidebar = () => {\n axios.get('api/albums', { headers: { simple: '1' } }).then(response => {\n if (!response) return\n\n if (response.data.success === false) {\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n return swal('An error occurred!', response.data.description, 'error')\n }\n }\n\n const albums = response.data.albums\n const count = response.data.count\n const albumsSidebar = document.querySelector('#albumsSidebar')\n\n // Clear albums sidebar if necessary\n const oldAlbums = albumsSidebar.querySelectorAll('li > a')\n const diffCount = oldAlbums.length !== count\n if (oldAlbums.length) {\n for (let i = 0; i < oldAlbums.length; i++) {\n page.menus.splice(page.menus.indexOf(oldAlbums[i]), 1)\n }\n albumsSidebar.innerHTML = ''\n }\n\n page.albumsSidebarCollapse.innerText = page.albumsSidebarCollapsible.collapsed()\n ? page.albumsSidebarCollapse.dataset.textExpand\n : page.albumsSidebarCollapse.dataset.textCollapse\n\n if (!albums || !albums.length) {\n page.albumsSidebarCollapsible.collapse()\n page.albumsSidebarCollapse.setAttribute('disabled', 'disabled')\n return\n }\n\n for (let i = 0; i < albums.length; i++) {\n const album = albums[i]\n const li = document.createElement('li')\n const a = document.createElement('a')\n a.id = album.id\n a.className = 'is-relative'\n a.innerHTML = album.name\n\n a.addEventListener('click', event => {\n page.getUploads({\n album: parseInt(event.currentTarget.id),\n trigger: event.currentTarget\n })\n })\n page.menus.push(a)\n\n li.appendChild(a)\n albumsSidebar.appendChild(li)\n }\n\n page.albumsSidebarCollapse.removeAttribute('disabled')\n if (!page.albumsSidebarCollapsible.collapsed() && diffCount) {\n // Since it's not possible to refresh collapsible's height with bulmaCollapsible APIs,\n // forcefully collapse albums sidebar if albums count is different with the previous iteration.\n page.albumsSidebarCollapsible.collapse()\n }\n }).catch(page.onAxiosError)\n}\n\npage.changeToken = (params = {}) => {\n page.dom.innerHTML = `\n
    \n \n
    \n
    \n \n
    \n
    \n
    \n \n `\n page.fadeInDom()\n page.scrollToDom()\n page.updateTrigger(params.trigger, 'active')\n\n document.querySelector('#getNewToken').addEventListener('click', event => {\n if (page.isSomethingLoading) return page.warnSomethingLoading()\n\n const trigger = event.currentTarget\n page.updateTrigger(trigger, 'loading')\n axios.post('api/tokens/change').then(response => {\n if (response.data.success === false) {\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n page.updateTrigger(trigger)\n return swal('An error occurred!', response.data.description, 'error')\n }\n }\n\n page.updateTrigger(trigger)\n swal({\n title: 'Woohoo!',\n text: 'Your token was successfully changed.',\n icon: 'success',\n buttons: false,\n timer: 1500\n }).then(() => {\n axios.defaults.headers.common.token = response.data.token\n localStorage[lsKeys.token] = response.data.token\n page.token = response.data.token\n page.changeToken()\n })\n }).catch(error => {\n page.updateTrigger(trigger)\n page.onAxiosError(error)\n })\n })\n}\n\npage.changePassword = (params = {}) => {\n page.dom.innerHTML = `\n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n `\n page.fadeInDom()\n page.scrollToDom()\n page.updateTrigger(params.trigger, 'active')\n\n document.querySelector('#sendChangePassword').addEventListener('click', event => {\n if (page.isSomethingLoading) return page.warnSomethingLoading()\n\n if (!page.dom.querySelector('form').checkValidity()) return\n\n if (document.querySelector('#password').value === document.querySelector('#passwordConfirm').value) {\n page.sendNewPassword(document.querySelector('#password').value, event.currentTarget)\n } else {\n swal({\n title: 'Password mismatch!',\n text: 'Your passwords do not match, please try again.',\n icon: 'error'\n })\n }\n })\n}\n\npage.sendNewPassword = (pass, element) => {\n page.updateTrigger(element, 'loading')\n\n axios.post('api/password/change', { password: pass }).then(response => {\n if (response.data.success === false) {\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n page.updateTrigger(element)\n return swal('An error occurred!', response.data.description, 'error')\n }\n }\n\n page.updateTrigger(element)\n swal({\n title: 'Woohoo!',\n text: 'Your password was successfully changed.',\n icon: 'success',\n buttons: false,\n timer: 1500\n }).then(() => {\n page.changePassword()\n })\n }).catch(error => {\n page.updateTrigger(element)\n page.onAxiosError(error)\n })\n}\n\npage.getUsers = (params = {}) => {\n if (!page.permissions.admin) return swal('An error occurred!', 'You cannot do this!', 'error')\n\n if (page.isSomethingLoading) return page.warnSomethingLoading()\n\n page.updateTrigger(params.trigger, 'loading')\n\n if (typeof params.pageNum !== 'number') params.pageNum = 0\n\n const url = `api/users/${params.pageNum}`\n axios.get(url).then(response => {\n if (response.data.success === false) {\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n page.updateTrigger(params.trigger)\n return swal('An error occurred!', response.data.description, 'error')\n }\n }\n\n const pages = Math.ceil(response.data.count / 25)\n const users = response.data.users\n if (params.pageNum && (users.length === 0)) {\n page.updateTrigger(params.trigger)\n if (params.autoPage) {\n params.pageNum = pages - 1\n return page.getUsers(params)\n } else {\n return swal('An error occurred!', `There are no more users to populate page ${params.pageNum + 1}.`, 'error')\n }\n }\n\n page.currentView = 'users'\n page.cache = {}\n\n if (params.pageNum < 0) params.pageNum = Math.max(0, pages + params.pageNum)\n const pagination = page.paginate(response.data.count, 25, params.pageNum)\n\n const filter = `\n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n `\n const extraControls = `\n
    \n ${filter}\n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n `\n\n const controls = `\n \n `\n\n // Do some string replacements for bottom controls\n const bottomFiltersId = 'bFilters'\n const bottomJumpId = 'bJumpToPage'\n const bottomExtraControls = extraControls\n .replace(/id=\"filters\"/, `id=\"${bottomFiltersId}\"`)\n .replace(/(data-action=\"filter-uploads\")/, `$1 data-filtersid=\"${bottomFiltersId}\"`)\n .replace(/id=\"jumpToPage\"/, `id=\"${bottomJumpId}\"`)\n .replace(/(data-action=\"jump-to-page\")/g, `$1 data-jumpid=\"${bottomJumpId}\"`)\n const bottomPagination = pagination\n .replace(/(data-action=\"page-ellipsis\")/g, `$1 data-jumpid=\"${bottomJumpId}\"`)\n\n // Whether there are any unselected items\n let unselected = false\n\n page.dom.innerHTML = `\n ${pagination}\n ${extraControls}\n ${controls}\n
    \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
    UsernameUploadsUsageGroupRegistration dateLast token update(${response.data.count} total)
    \n
    \n ${controls}\n ${bottomExtraControls}\n ${bottomPagination}\n `\n\n const table = document.querySelector('#table')\n\n for (let i = 0; i < users.length; i++) {\n const user = users[i]\n const selected = page.selected[page.currentView].includes(user.id)\n if (!selected) unselected = true\n\n let displayGroup = null\n const groups = Object.keys(user.groups)\n for (let i = 0; i < groups.length; i++) {\n if (!user.groups[groups[i]]) break\n displayGroup = groups[i]\n }\n\n // Server-side explicitly expects either of these two values to consider a user as disabled\n const enabled = user.enabled !== false && user.enabled !== 0\n page.cache[user.id] = {\n username: user.username,\n groups: user.groups,\n enabled,\n displayGroup\n }\n\n const prettyDate = user.registration\n ? page.getPrettyDate(new Date(user.registration * 1000))\n : '-'\n const prettyTokenUpdate = user.timestamp\n ? page.getPrettyDate(new Date(user.timestamp * 1000))\n : '-'\n\n const tr = document.createElement('tr')\n tr.dataset.id = user.id\n tr.innerHTML = `\n \n ${user.username}\n ${user.uploads}\n ${page.getPrettyBytes(user.usage)}\n ${displayGroup}\n ${prettyDate}\n ${prettyTokenUpdate}\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n `\n\n table.appendChild(tr)\n page.checkboxes = table.querySelectorAll('.checkbox[data-action=\"select\"]')\n }\n\n const selectAll = document.querySelector('#selectAll')\n if (selectAll && !unselected) {\n selectAll.checked = true\n selectAll.title = 'Unselect all'\n }\n\n page.fadeInDom()\n\n const pageNum = users.length ? params.pageNum : 0\n if (params.forceScroll ||\n page.prevPageNums[page.currentView] === null ||\n page.prevPageNums[page.currentView] !== pageNum) {\n page.scrollToDom()\n }\n\n page.updateTrigger(params.trigger, 'active')\n\n page.views[page.currentView].pageNum = page.prevPageNums[page.currentView] = pageNum\n }).catch(error => {\n page.updateTrigger(params.trigger)\n page.onAxiosError(error)\n })\n}\n\npage.createUser = () => {\n const groupOptions = Object.keys(page.permissions).map((g, i, a) => {\n const disabled = !(a[i + 1] && page.permissions[a[i + 1]])\n return ``\n }).join('\\n')\n\n const div = document.createElement('div')\n div.innerHTML = `\n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n `\n\n swal({\n title: 'Create new user',\n icon: 'info',\n content: div,\n buttons: {\n cancel: true,\n confirm: {\n closeModal: false\n }\n }\n }).then(proceed => {\n if (!proceed) return\n\n axios.post('api/users/create', {\n username: document.querySelector('#swalUsername').value,\n password: document.querySelector('#swalPassword').value,\n group: document.querySelector('#swalGroup').value\n }).then(response => {\n if (!response) return\n\n if (response.data.success === false) {\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n return swal('An error occurred!', response.data.description, 'error')\n }\n }\n\n const div = document.createElement('div')\n div.innerHTML = `\n

    Username: ${response.data.username}

    \n

    Password: ${response.data.password}

    \n

    User group: ${response.data.group}

    \n `\n swal({\n title: 'Created a new user!',\n icon: 'success',\n content: div\n })\n\n // Load last page of users list\n // eslint-disable-next-line compat/compat\n page.getUsers(Object.assign(page.views.users, {\n pageNum: -1\n }))\n }).catch(page.onAxiosError)\n })\n}\n\npage.editUser = id => {\n const user = page.cache[id]\n if (!user) return\n\n let isHigher = false\n const groupOptions = Object.keys(page.permissions).map((g, i, a) => {\n const selected = g === user.displayGroup\n if (selected) {\n isHigher = typeof a[i + 1] !== 'undefined' && page.permissions[a[i + 1]]\n }\n const disabled = !(a[i + 1] && page.permissions[a[i + 1]])\n return ``\n }).join('\\n')\n\n const isDisabledHelper = isHigher ? '' : ' disabled'\n const div = document.createElement('div')\n div.innerHTML = `\n
    \n

    User ID: ${id}

    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n ${isHigher\n ? ''\n : `
    \n You cannot modify user in the same or higher group as you.\n
    `\n }\n `\n\n swal({\n title: 'Edit user',\n icon: 'info',\n content: div,\n buttons: {\n cancel: true,\n confirm: {\n closeModal: false\n }\n }\n }).then(proceed => {\n if (!proceed) return\n\n axios.post('api/users/edit', {\n id,\n username: document.querySelector('#swalUsername').value,\n group: document.querySelector('#swalGroup').value,\n enabled: document.querySelector('#swalEnabled').checked,\n resetPassword: document.querySelector('#swalResetPassword').checked\n }).then(response => {\n if (!response) return\n\n if (response.data.success === false) {\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n return swal('An error occurred!', response.data.description, 'error')\n }\n }\n\n let autoClose = true\n const div = document.createElement('div')\n\n let displayName = user.username\n if (response.data.update.username !== user.username) {\n div.innerHTML += `

    ${user.username} was renamed into: ${response.data.update.username}.

    `\n autoClose = false\n displayName = response.data.update.username\n }\n\n if (response.data.update.password) {\n div.innerHTML += `\n

    ${displayName}'s new password is:

    \n

    ${response.data.update.password}

    \n `\n autoClose = false\n }\n\n if (response.data.update.enabled !== user.enabled) {\n div.innerHTML += `

    ${displayName} has been ${response.data.update.enabled ? 'enabled' : 'disabled'}!

    `\n }\n\n if (!div.innerHTML) {\n div.innerHTML = `

    ${displayName} was edited!

    `\n }\n\n swal({\n title: 'Success!',\n icon: 'success',\n content: div,\n buttons: !autoClose,\n timer: autoClose ? 1500 : null\n })\n page.getUsers(page.views.users)\n }).catch(page.onAxiosError)\n })\n}\n\npage.disableUser = id => {\n const user = page.cache[id]\n if (!user || !user.enabled) return\n\n const content = document.createElement('div')\n content.innerHTML = `\n

    You will be disabling a user named ${page.cache[id].username}.

    \n

    Their files will remain.

    \n `\n\n swal({\n title: 'Are you sure?',\n icon: 'warning',\n content,\n dangerMode: true,\n buttons: {\n cancel: true,\n confirm: {\n text: 'Yes, disable them!',\n closeModal: false\n }\n }\n }).then(proceed => {\n if (!proceed) return\n\n axios.post('api/users/disable', { id }).then(response => {\n if (!response) return\n\n if (response.data.success === false) {\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n return swal('An error occurred!', response.data.description, 'error')\n }\n }\n\n swal('Success!', `${page.cache[id].username} has been disabled.`, 'success', {\n buttons: false,\n timer: 1500\n })\n page.getUsers(page.views.users)\n }).catch(page.onAxiosError)\n })\n}\n\npage.deleteUser = id => {\n const user = page.cache[id]\n if (!user) return\n\n const content = document.createElement('div')\n content.innerHTML = `\n

    You will be deleting a user named ${page.cache[id].username}.

    \n

    Their uploads will still remain, unless you choose otherwise.

    \n `\n\n swal({\n title: 'Are you sure?',\n icon: 'warning',\n content,\n dangerMode: true,\n buttons: {\n cancel: true,\n confirm: {\n text: 'Yes, ONLY the user!',\n closeModal: false\n },\n purge: {\n text: 'Yes, AND their uploads too!',\n value: 'purge',\n className: 'swal-button--danger',\n closeModal: false\n }\n }\n }).then(proceed => {\n if (!proceed) return\n\n axios.post('api/users/delete', {\n id,\n purge: proceed === 'purge'\n }).then(response => {\n if (!response) return\n\n if (response.data.success === false) {\n const failed = Array.isArray(response.data.failed)\n ? response.data.failed\n : []\n\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else if (failed.length) {\n return swal('An error occurred!', `Unable to delete ${failed.length} of the user's upload${failed.length === 1 ? '' : 's'}.`, 'error')\n } else {\n return swal('An error occurred!', response.data.description, 'error')\n }\n }\n\n swal('Success!', `${page.cache[id].username} has been deleted.`, 'success', {\n buttons: false,\n timer: 1500\n })\n\n // Reload users list\n // eslint-disable-next-line compat/compat\n page.getUsers(Object.assign(page.views.users, {\n autoPage: true\n }))\n }).catch(page.onAxiosError)\n })\n}\n\n// Roughly based on https://github.com/mayuska/pagination/blob/master/index.js\npage.paginate = (totalItems, itemsPerPage, currentPage) => {\n currentPage = currentPage + 1\n const step = 3\n const numPages = Math.ceil(totalItems / itemsPerPage)\n\n let template = ''\n const elementsToShow = step * 2\n const add = {\n pageNum (start, end) {\n for (let i = start; i <= end; ++i) {\n template += `
  • ${i}
  • `\n }\n },\n startDots () {\n template += `\n
  • 1
  • \n
  • \n `\n },\n endDots () {\n template += `\n
  • \n
  • ${numPages}
  • \n `\n }\n }\n\n if (elementsToShow + 1 >= numPages) {\n add.pageNum(1, numPages)\n } else if (currentPage < elementsToShow) {\n add.pageNum(1, elementsToShow)\n add.endDots()\n } else if (currentPage > numPages - elementsToShow + 1) {\n add.startDots()\n add.pageNum(numPages - elementsToShow + 1, numPages)\n } else {\n add.startDots()\n add.pageNum(currentPage - step + 1, currentPage + step - 1)\n add.endDots()\n }\n\n return `\n \n `\n}\n\npage.getStatistics = (params = {}) => {\n if (!page.permissions.admin) return swal('An error occurred!', 'You cannot do this!', 'error')\n\n if (page.isSomethingLoading) return page.warnSomethingLoading()\n\n page.updateTrigger(params.trigger, 'loading')\n\n const url = 'api/stats'\n axios.get(url).then(response => {\n if (response.data.success === false) {\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n page.updateTrigger(params.trigger)\n return swal('An error occurred!', response.data.description, 'error')\n }\n }\n\n let content = ''\n const keys = Object.keys(response.data.stats)\n for (let i = 0; i < keys.length; i++) {\n let rows = ''\n if (!response.data.stats[keys[i]]) {\n rows += `\n \n Generating, please try again later\\u2026\n \n \n `\n } else {\n try {\n const valKeys = Object.keys(response.data.stats[keys[i]])\n for (let j = 0; j < valKeys.length; j++) {\n const data = response.data.stats[keys[i]][valKeys[j]]\n const type = typeof data === 'object' ? data.type : 'auto'\n const value = typeof data === 'object' ? data.value : data\n\n let parsed\n switch (type) {\n case 'byte':\n parsed = page.getPrettyBytes(value)\n break\n case 'byteUsage': {\n // Reasoning: https://github.com/sebhildebrandt/systeminformation/issues/464#issuecomment-756406053\n const totalForPercentage = typeof value.available !== 'undefined'\n ? (value.used + value.available)\n : value.total\n parsed = `${page.getPrettyBytes(value.used)} / ${page.getPrettyBytes(value.total)} (${(value.used / totalForPercentage * 100).toFixed(2)}%)`\n break\n }\n case 'uptime':\n parsed = page.getPrettyUptime(value)\n break\n case 'auto':\n switch (typeof value) {\n case 'number':\n parsed = value.toLocaleString()\n break\n default:\n parsed = value\n }\n break\n default:\n parsed = value\n }\n\n rows += `\n \n ${valKeys[j]}\n ${parsed}\n \n `\n }\n } catch (error) {\n rows = `\n \n Error parsing response. Try again?\n \n \n `\n page.onError(error)\n }\n }\n\n content += `\n
    \n \n \n \n \n \n \n \n \n ${rows}\n \n
    ${keys[i]}
    \n
    \n `\n }\n\n if (Array.isArray(response.data.hrtime)) {\n content += `\n
    \n
    \n Time taken: ${response.data.hrtime[0]}s ${Math.ceil(response.data.hrtime[1] / 1000000)}ms.\n
    \n
    \n `\n }\n\n page.dom.innerHTML = content\n page.fadeInDom()\n page.scrollToDom()\n page.updateTrigger(params.trigger, 'active')\n }).catch(error => {\n page.updateTrigger(params.trigger)\n page.onAxiosError(error)\n })\n}\n\nwindow.addEventListener('DOMContentLoaded', () => {\n // Polyfill Object.assign()\n // eslint-disable-next-line compat/compat\n if (typeof Object.assign !== 'function') {\n // Must be writable: true, enumerable: false, configurable: true\n Object.defineProperty(Object, 'assign', {\n value: function assign (target, varArgs) { // .length of function is 2\n 'use strict'\n if (target === null || typeof target === 'undefined') {\n throw new TypeError('Cannot convert undefined or null to object')\n }\n const to = Object(target)\n for (let i = 1; i < arguments.length; i++) {\n const nextSource = arguments[i]\n if (nextSource !== null && typeof nextSource !== 'undefined') {\n for (const nextKey in nextSource) {\n // Avoid bugs when hasOwnProperty is shadowed\n if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {\n to[nextKey] = nextSource[nextKey]\n }\n }\n }\n }\n return to\n },\n writable: true,\n configurable: true\n })\n }\n\n // Add 'no-touch' class to non-touch devices\n if (!('ontouchstart' in document.documentElement)) {\n document.documentElement.classList.add('no-touch')\n }\n\n const selectedKeys = ['uploads', 'uploadsAll', 'albums', 'albumsAll', 'users']\n for (let i = 0; i < selectedKeys.length; i++) {\n const ls = localStorage[lsKeys.selected[selectedKeys[i]]]\n if (ls) page.selected[selectedKeys[i]] = JSON.parse(ls)\n }\n\n page.preparePage()\n\n page.clipboardJS = new ClipboardJS('.clipboard-js')\n\n page.clipboardJS.on('success', () => {\n return swal('', 'The link has been copied to clipboard.', 'success', {\n buttons: false,\n timer: 1500\n })\n })\n\n page.clipboardJS.on('error', page.onError)\n\n page.lazyLoad = new LazyLoad()\n\n page.albumsSidebarCollapse = document.querySelector('#albumsSidebarCollapse')\n\n /* eslint-disable-next-line new-cap */\n page.albumsSidebarCollapsible = new bulmaCollapsible(document.querySelector('#albumsSidebar'))\n page.albumsSidebarCollapsible.on('before:expand', event => {\n page.albumsSidebarCollapse.innerText = page.albumsSidebarCollapse.dataset.textCollapse\n })\n page.albumsSidebarCollapsible.on('before:collapse', event => {\n page.albumsSidebarCollapse.innerText = page.albumsSidebarCollapse.dataset.textExpand\n })\n})\n"]} \ No newline at end of file diff --git a/dist/js/home.js b/dist/js/home.js index d4266c257..1feefcc27 100644 --- a/dist/js/home.js +++ b/dist/js/home.js @@ -1,2 +1,2 @@ -var lsKeys={token:"token",chunkSize:"chunkSize",parallelUploads:"parallelUploads",uploadsHistoryOrder:"uploadsHistoryOrder",previewImages:"previewImages",fileLength:"fileLength",uploadAge:"uploadAge",stripTags:"stripTags"},page={token:localStorage[lsKeys.token],apiChecked:!1,private:null,enableUserAccounts:null,maxSize:null,chunkSizeConfig:null,temporaryUploadAges:null,fileIdentifierLength:null,stripTagsConfig:null,album:null,parallelUploads:null,previewImages:null,fileLength:null,uploadAge:null,stripTags:null,maxSizeBytes:null,urlMaxSize:null,urlMaxSizeBytes:null,chunkSize:null,tabs:[],activeTab:null,albumSelect:null,albumSelectOnChange:null,previewTemplate:null,dropzone:null,clipboardJS:null,lazyLoad:null,urlsQueue:[],activeUrlsQueue:0,imageExts:[".gif",".jpeg",".jpg",".png",".svg",".tif",".tiff",".webp",".bmp"],videoExts:[".avi",".m2ts",".m4v",".mkv",".mov",".mp4",".webm",".wmv"],albumTitleMaxLength:70,albumDescMaxLength:4e3,onInitError:function(e){document.querySelector("#albumDiv").classList.add("is-hidden"),document.querySelector("#tabs").classList.add("is-hidden"),document.querySelectorAll(".tab-content").forEach((function(e){return e.classList.add("is-hidden")}));var a=document.querySelector("#loginToUpload");a.innerText="An error occurred. Try to reload?",a.classList.remove("is-loading"),a.classList.remove("is-hidden"),a.addEventListener("click",(function(){window.location.reload()})),e.response?page.onAxiosError(e):page.onError(e)},onError:function(e){console.error(e);var a=document.createElement("div");return a.innerHTML="\n

    "+e.toString()+"

    \n

    Please check your console for more information.

    \n ",swal({title:"An error occurred!",icon:"error",content:a})},onAxiosError:function(e,a){a||console.error(e);var t={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;if(a)return e.response.data&&e.response.data.description?e.response:{data:{success:!1,description:e.response?e.response.status+" "+t:e.toString()}};var n=e.response.data&&e.response.data.description?e.response.data.description:"There was an error with the request.\nPlease check the console for more information.";return swal(e.response.status+" "+t,n,"error")},checkClientVersion:function(e){var a=document.querySelector("#mainScript").src.match(/\?_=(\d+)$/);if(a&&a[1]&&a[1]!==e)return swal({title:"Update detected!",text:"Client assets have been updated. Reload to display the latest version?",icon:"info",buttons:{confirm:{text:"Reload",closeModal:!1}}}).then((function(){window.location.reload()}))},checkIfPublic:function(){return axios.get("api/check",{onDownloadProgress:function(){"undefined"==typeof render||render.done||render.do(),"undefined"==typeof newsfeed||newsfeed.done||newsfeed.do(),page.apiChecked||(page.apiChecked=!0)}}).then((function(e){return e.data.version&&page.checkClientVersion(e.data.version),page.private=e.data.private,page.enableUserAccounts=e.data.enableUserAccounts,page.maxSize=parseInt(e.data.maxSize),page.maxSizeBytes=1e6*page.maxSize,page.chunkSizeConfig={max:e.data.chunkSize&&parseInt(e.data.chunkSize.max)||95,default:e.data.chunkSize&&parseInt(e.data.chunkSize.default)},page.temporaryUploadAges=e.data.temporaryUploadAges,page.fileIdentifierLength=e.data.fileIdentifierLength,page.stripTagsConfig=e.data.stripTags,page.preparePage()})).catch(page.onInitError)},preparePage:function(){if(!page.private)return page.prepareUpload();if(page.token)return page.verifyToken(page.token,!0);var e=document.querySelector("#loginToUpload");e.href="auth",e.classList.remove("is-loading"),page.enableUserAccounts?e.innerText="Anonymous upload is disabled.\nLog in or register to upload.":e.innerText="Running in private mode.\nLog in to upload."},verifyToken:function(e,a){return axios.post("api/tokens/verify",{token:e}).then((function(t){return!1===t.data.success?swal({title:"An error occurred!",text:t.data.description,icon:"error"}).then((function(){a&&(localStorage.removeItem("token"),window.location.reload())})):(localStorage[lsKeys.token]=e,page.token=e,page.prepareUpload())})).catch(page.onInitError)},prepareUpload:function(){if(page.token){var e=document.querySelector('#linksColumn a[href="auth"]');e&&e.setAttribute("href","dashboard"),document.querySelector("#albumDiv").classList.remove("is-hidden"),page.albumSelect=document.querySelector("#albumSelect"),page.albumSelectOnChange=function(){page.album=parseInt(page.albumSelect.value),"function"==typeof page.prepareShareX&&page.prepareShareX()},page.albumSelect.addEventListener("change",page.albumSelectOnChange),page.fetchAlbums()}else page.enableUserAccounts&&(document.querySelector("#loginLinkText").innerHTML="Create an account and keep track of your uploads");page.prepareUploadConfig(),document.querySelector("#maxSize > span").innerHTML=page.getPrettyBytes(page.maxSizeBytes),document.querySelector("#loginToUpload").classList.add("is-hidden"),page.prepareDropzone(),"function"==typeof page.prepareShareX&&page.prepareShareX();var a=document.querySelector("#urlMaxSize");a&&(page.urlMaxSize=parseInt(a.innerHTML),page.urlMaxSizeBytes=1e6*page.urlMaxSize,a.innerHTML=page.getPrettyBytes(page.urlMaxSizeBytes));var t=document.querySelector("#uploadUrls");t&&t.addEventListener("click",(function(e){page.addUrlsToQueue()}));for(var n=document.querySelector("#tabs"),r=n.querySelectorAll("li"),i=function(e){var a=r[e].dataset.id,t=document.querySelector("#"+a);t&&(r[e].addEventListener("click",(function(){page.setActiveTab(e)})),page.tabs.push({tab:r[e],content:t}))},l=0;l2){for(var f=0,h=0,v=!1,b=m-1;b--;)if(v)l._uplSpeedCalc.data.splice(b,1);else if((f=c-l._uplSpeedCalc.data[b].timestamp)>1e3){var y=f-1e3,S=f-(c-l._uplSpeedCalc.data[b+1].timestamp);h+=(S-y)/S*l._uplSpeedCalc.data[b+1].bytes,v=!0}else h+=l._uplSpeedCalc.data[b+1].bytes;v||(h*=1e3/f),t=page.getPrettyBytes(h)}}e.previewElement.querySelector(".descriptive-progress").innerHTML=o+" "+r+"%"+(t?" at "+t+"/s":"")})),this.on("success",(function(e,a){a&&(e.previewElement.querySelector(".descriptive-progress").classList.add("is-hidden"),!1===a.success&&(e.previewElement.querySelector(".error").innerHTML=a.description,e.previewElement.querySelector(".error").classList.remove("is-hidden")),Array.isArray(a.files)&&a.files[0]&&page.updateTemplate(e,a.files[0]))})),this.on("error",(function(e,a,t){var n=a;"object"==typeof a&&a.description?n=a.description:t?n=page.onAxiosError({response:{status:t.status,statusText:t.statusText}},!0).data.description:a instanceof Error&&(n=a.toString()),(/^File is too big/.test(n)||/File too large/.test(n))&&(n="File too large ("+page.getPrettyBytes(e.size)+")."),e.previewElement.querySelector(".descriptive-progress").classList.add("is-hidden"),e.previewElement.querySelector(".error").innerHTML=n,e.previewElement.querySelector(".error").classList.remove("is-hidden"),page.updateTemplateIcon(e.previewElement,"icon-block")}))},chunksUploaded:function(e,a){return e.previewElement.querySelector(".descriptive-progress").innerHTML="Rebuilding "+e.upload.totalChunkCount+" chunks…",axios.post("api/upload/finishchunks",{files:[{uuid:e.upload.uuid,original:e.name,type:e.type,albumid:page.album,filelength:page.fileLength,age:page.uploadAge}]},{headers:{token:page.token,striptags:page.stripTags}}).catch((function(e){return page.onAxiosError(e,!0)})).then((function(t){return e.previewElement.querySelector(".descriptive-progress").classList.add("is-hidden"),!1===t.data.success&&(e.previewElement.querySelector(".error").innerHTML=t.data.description,e.previewElement.querySelector(".error").classList.remove("is-hidden"),page.updateTemplateIcon(e.previewElement,"icon-block")),t.data.files&&t.data.files[0]&&page.updateTemplate(e,t.data.files[0]),a()}))}})},addUrlsToQueue:function(){var e=document.querySelector("#urls").value.split(/\r?\n/).filter((function(e){return e.trim().length}));if(!e.length)return swal("An error occurred!","You have not entered any URLs.","error");var a=document.querySelector("#tab-urls");a.querySelector(".uploads").classList.remove("is-hidden");for(var t=0;t .clipboard-js");n.href=n.innerHTML=r.dataset.clipboardText=a.url,t.classList.remove("is-hidden"),r.parentElement.classList.remove("is-hidden");var i=/.[\w]+$/.exec(a.url),l=i&&i[0]?i[0].toLowerCase():null;if(page.imageExts.includes(l))if(page.previewImages){var o=e.previewElement.querySelector("img");o.setAttribute("alt",a.name||""),o.dataset.src=a.url,o.classList.remove("is-hidden"),o.onerror=function(a){a.currentTarget.classList.add("is-hidden"),page.updateTemplateIcon(e.previewElement,"icon-picture")},page.lazyLoad.update(e.previewElement.querySelectorAll("img"))}else page.updateTemplateIcon(e.previewElement,"icon-picture");else page.videoExts.includes(l)?page.updateTemplateIcon(e.previewElement,"icon-video"):page.updateTemplateIcon(e.previewElement,"icon-doc-inv");if(a.expirydate){var s=e.previewElement.querySelector(".expiry-date");s.dataset.timestamp=a.expirydate,s.innerHTML="EXP: "+page.getPrettyDate(new Date(1e3*a.expirydate)),s.classList.remove("is-hidden")}}},page.createAlbum=function(){var e=document.createElement("div");e.innerHTML='\n
    \n
    \n \n
    \n

    Max length is '+page.albumTitleMaxLength+' characters.

    \n
    \n
    \n
    \n \n
    \n

    Max length is '+page.albumDescMaxLength+' characters.

    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n ',swal({title:"Create new album",icon:"info",content:e,buttons:{cancel:!0,confirm:{closeModal:!1}}}).then((function(e){if(e){var a=document.querySelector("#swalName").value.trim();axios.post("api/albums",{name:a,description:document.querySelector("#swalDescription").value.trim(),download:document.querySelector("#swalDownload").checked,public:document.querySelector("#swalPublic").checked},{headers:{token:page.token}}).then((function(e){if(!1===e.data.success)return swal("An error occurred!",e.data.description,"error");var t=document.createElement("option");page.albumSelect.appendChild(t),t.value=e.data.id,t.innerHTML=a,t.selected=!0,page.albumSelectOnChange(),swal("Woohoo!","Album was created successfully.","success")})).catch(page.onError)}}))},page.prepareUploadConfig=function(){var e={chunkSize:page.chunkSizeConfig.default,parallelUploads:2},a=Array.isArray(page.temporaryUploadAges)&&page.temporaryUploadAges.length,t=page.fileIdentifierLength&&"number"==typeof page.fileIdentifierLength.min&&"number"==typeof page.fileIdentifierLength.max,n={siBytes:{label:"File size display",select:[{value:"default",text:"1000 B = 1 kB = 1 Kilobyte"},{value:"0",text:"1024 B = 1 KiB = 1 Kibibyte"}],help:"This will be used in our homepage, dashboard, and album public pages.",valueHandler:function(){}},ampmTime:{label:"Show AM/PM on date",select:[{value:"default",text:"No"},{value:"1",text:"Yes"}],help:"This will be used in our homepage and dashboard.",valueHandler:function(){}},fileLength:{display:t,label:"File identifier length",number:t?{min:page.fileIdentifierLength.min,max:page.fileIdentifierLength.max,default:page.fileIdentifierLength.default,round:!0}:void 0,help:!0,disabled:t&&page.fileIdentifierLength.force},uploadAge:{display:a,label:"Upload age",select:[],help:"Whether to automatically delete your uploads after a certain amount of time."},stripTags:{display:page.stripTagsConfig,label:"Strip tags",select:page.stripTagsConfig?[{value:page.stripTagsConfig.default?"default":"1",text:"Yes"},{value:page.stripTagsConfig.default?"0":"default",text:"No"}]:null,help:"Whether to strip tags (e.g. EXIF) from your uploads.
    \n This only applies to regular image"+(page.stripTagsConfig&&page.stripTagsConfig.video?" and video":"")+" uploads (i.e. not URL uploads).",disabled:page.stripTagsConfig&&page.stripTagsConfig.force},chunkSize:{display:Boolean(page.chunkSizeConfig.default),label:"Upload chunk size (MB)",number:{min:1,max:page.chunkSizeConfig.max,default:e.chunkSize,suffix:" MB",round:!0},help:!0},parallelUploads:{label:"Parallel uploads",number:{min:1,max:10,default:e.parallelUploads,round:!0},help:!0},uploadsHistoryOrder:{label:"Uploads history order",select:[{value:"default",text:"Older files on top"},{value:"0",text:"Newer files on top"}],help:'"Newer files on top" will use a CSS technique, which unfortunately come with some undesirable side effects.
    \n This also affects text selection, such as when trying to select text from top to bottom will result in them being selected from bottom to top instead, and vice versa.',valueHandler:function(e){if("0"===e)for(var a=document.querySelectorAll(".tab-content > .uploads"),t=0;t=page.fileIdentifierLength.min&&o<=page.fileIdentifierLength.max&&(n.fileLength.value=o)}var s=document.querySelector("#tab-config"),u=document.createElement("form");u.addEventListener("submit",(function(e){return e.preventDefault()}));for(var p=Object.keys(n),d=0;d=g.number.min&&(f=h)}else{var v=localStorage[lsKeys[c]];f=Array.isArray(g.select)?g.select.find((function(e){return e.value===v}))?v:void 0:v}"function"==typeof g.valueHandler?g.valueHandler(f):void 0!==f?page[c]=f:void 0!==e[c]&&(page[c]=e[c])}var b=void 0;if(Array.isArray(g.select)){(b=document.createElement("div")).className="select is-fullwidth";for(var y=[],S=0;S\n "+w.text+("default"===w.value?" (default)":"")+"\n \n ")}b.innerHTML='\n \n "}else g.number&&((b=document.createElement("input")).id=b.name=c,b.className="input is-fullwidth",b.type="number",void 0!==g.number.min&&(b.min=g.number.min),void 0!==g.number.max&&(b.max=g.number.max),"number"==typeof f?b.value=f:void 0!==g.number.default&&(b.value=g.number.default));var x=void 0;if(g.disabled)Array.isArray(g.select)?b.querySelector("select").disabled=g.disabled:b.disabled=g.disabled,x="This option is currently not configurable.";else if("string"==typeof g.help)x=g.help;else if(!0===g.help&&void 0!==g.number){var L=[];void 0!==g.number.default&&L.push("Default is "+g.number.default+(g.number.suffix||"")+"."),void 0!==g.number.min&&L.push("Min is "+g.number.min+(g.number.suffix||"")+"."),void 0!==g.number.max&&L.push("Max is "+g.number.max+(g.number.suffix||"")+"."),x=L.join(" ")}m.innerHTML='\n \n
    \n '+(x?'

    '+x+"

    ":"")+"\n ",m.querySelector("div.control").appendChild(b),u.appendChild(m)}}var T=document.createElement("div");T.className="field",T.innerHTML='\n

    \n \n

    \n

    \n This configuration will only be used in this browser.
    \n After reloading the page, some of them will also be applied to the ShareX config that you can download by clicking on the ShareX icon below.\n

    \n ',u.appendChild(T),u.querySelector("#saveConfig").addEventListener("click",(function(){if(u.checkValidity()){for(var e=Object.keys(n).filter((function(e){return!1!==n[e].display&&!0!==n[e].disabled})),a=0;a=24){var t=e/24;return t+" day"+(1===t?"":"s")}return e+" hour"+(1===e?"":"s")},window.addEventListener("paste",(function(e){for(var a=(e.clipboardData||e.originalEvent.clipboardData).items,t=Object.keys(a),n=0;n

    \n

    Please check your console for more information.

    \n ",swal({title:"An error occurred!",icon:"error",content:a})},onAxiosError:function(e,a){a||console.error(e);var t={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;if(a)return e.response.data&&e.response.data.description?e.response:{data:{success:!1,description:e.response?e.response.status+" "+t:e.toString()}};var n=e.response.data&&e.response.data.description?e.response.data.description:"There was an error with the request.\nPlease check the console for more information.";return swal(e.response.status+" "+t,n,"error")},checkClientVersion:function(e){var a=document.querySelector("#mainScript").src.match(/\?_=(\d+)$/);if(a&&a[1]&&a[1]!==e)return swal({title:"Update detected!",text:"Client assets have been updated. Reload to display the latest version?",icon:"info",buttons:{confirm:{text:"Reload",closeModal:!1}}}).then((function(){window.location.reload()}))},checkIfPublic:function(){return axios.get("api/check",{onDownloadProgress:function(){"undefined"==typeof render||render.done||render.do(),"undefined"==typeof newsfeed||newsfeed.done||newsfeed.do(),page.apiChecked||(page.apiChecked=!0)}}).then((function(e){return e.data.version&&page.checkClientVersion(e.data.version),page.private=e.data.private,page.enableUserAccounts=e.data.enableUserAccounts,page.maxSize=parseInt(e.data.maxSize),page.maxSizeBytes=1e6*page.maxSize,page.chunkSizeConfig={max:e.data.chunkSize&&parseInt(e.data.chunkSize.max)||95,default:e.data.chunkSize&&parseInt(e.data.chunkSize.default)},page.temporaryUploadAges=e.data.temporaryUploadAges,page.fileIdentifierLength=e.data.fileIdentifierLength,page.stripTagsConfig=e.data.stripTags,page.preparePage()})).catch(page.onInitError)},preparePage:function(){if(page.token)return page.verifyToken(page.token);if(!page.private)return page.prepareUpload();var e=document.querySelector("#loginToUpload");e.href="auth",e.classList.remove("is-loading"),page.enableUserAccounts?e.innerText="Anonymous upload is disabled.\nLog in or register to upload.":e.innerText="Running in private mode.\nLog in to upload."},verifyToken:function(e){return axios.post("api/tokens/verify",{token:e}).then((function(a){return localStorage[lsKeys.token]=e,page.token=e,page.prepareUpload()})).catch((function(e){return swal({title:"An error occurred!",text:e.response.data?e.response.data.description:e.toString(),icon:"error"}).then((function(){e.response.data&&10001===e.response.data.code?(localStorage.removeItem(lsKeys.token),window.location.reload()):page.onInitError()}))}))},prepareUpload:function(){if(page.token){var e=document.querySelector('#linksColumn a[href="auth"]');e&&e.setAttribute("href","dashboard"),document.querySelector("#albumDiv").classList.remove("is-hidden"),page.albumSelect=document.querySelector("#albumSelect"),page.albumSelectOnChange=function(){page.album=parseInt(page.albumSelect.value),"function"==typeof page.prepareShareX&&page.prepareShareX()},page.albumSelect.addEventListener("change",page.albumSelectOnChange),page.fetchAlbums()}else page.enableUserAccounts&&(document.querySelector("#loginLinkText").innerHTML="Create an account and keep track of your uploads");page.prepareUploadConfig(),document.querySelector("#maxSize > span").innerHTML=page.getPrettyBytes(page.maxSizeBytes),document.querySelector("#loginToUpload").classList.add("is-hidden"),page.prepareDropzone(),"function"==typeof page.prepareShareX&&page.prepareShareX();var a=document.querySelector("#urlMaxSize");a&&(page.urlMaxSize=parseInt(a.innerHTML),page.urlMaxSizeBytes=1e6*page.urlMaxSize,a.innerHTML=page.getPrettyBytes(page.urlMaxSizeBytes));var t=document.querySelector("#uploadUrls");t&&t.addEventListener("click",(function(e){page.addUrlsToQueue()}));for(var n=document.querySelector("#tabs"),r=n.querySelectorAll("li"),i=function(e){var a=r[e].dataset.id,t=document.querySelector("#"+a);t&&(r[e].addEventListener("click",(function(){page.setActiveTab(e)})),page.tabs.push({tab:r[e],content:t}))},l=0;l2){for(var f=0,h=0,v=!1,b=m-1;b--;)if(v)l._uplSpeedCalc.data.splice(b,1);else if((f=c-l._uplSpeedCalc.data[b].timestamp)>1e3){var y=f-1e3,S=f-(c-l._uplSpeedCalc.data[b+1].timestamp);h+=(S-y)/S*l._uplSpeedCalc.data[b+1].bytes,v=!0}else h+=l._uplSpeedCalc.data[b+1].bytes;v||(h*=1e3/f),t=page.getPrettyBytes(h)}}e.previewElement.querySelector(".descriptive-progress").innerHTML=o+" "+r+"%"+(t?" at "+t+"/s":"")})),this.on("success",(function(e,a){a&&(e.previewElement.querySelector(".descriptive-progress").classList.add("is-hidden"),!1===a.success&&(e.previewElement.querySelector(".error").innerHTML=a.description,e.previewElement.querySelector(".error").classList.remove("is-hidden")),Array.isArray(a.files)&&a.files[0]&&page.updateTemplate(e,a.files[0]))})),this.on("error",(function(e,a,t){var n=a;"object"==typeof a&&a.description?n=a.description:t?n=page.onAxiosError({response:{status:t.status,statusText:t.statusText}},!0).data.description:a instanceof Error&&(n=a.toString()),(/^File is too big/.test(n)||/File too large/.test(n))&&(n="File too large ("+page.getPrettyBytes(e.size)+")."),e.previewElement.querySelector(".descriptive-progress").classList.add("is-hidden"),e.previewElement.querySelector(".error").innerHTML=n,e.previewElement.querySelector(".error").classList.remove("is-hidden"),page.updateTemplateIcon(e.previewElement,"icon-block")}))},chunksUploaded:function(e,a){return e.previewElement.querySelector(".descriptive-progress").innerHTML="Rebuilding "+e.upload.totalChunkCount+" chunks…",axios.post("api/upload/finishchunks",{files:[{uuid:e.upload.uuid,original:e.name,type:e.type,albumid:page.album,filelength:page.fileLength,age:page.uploadAge}]},{headers:{token:page.token,striptags:page.stripTags}}).catch((function(e){return page.onAxiosError(e,!0)})).then((function(t){return e.previewElement.querySelector(".descriptive-progress").classList.add("is-hidden"),!1===t.data.success&&(e.previewElement.querySelector(".error").innerHTML=t.data.description,e.previewElement.querySelector(".error").classList.remove("is-hidden"),page.updateTemplateIcon(e.previewElement,"icon-block")),t.data.files&&t.data.files[0]&&page.updateTemplate(e,t.data.files[0]),a()}))}})},addUrlsToQueue:function(){var e=document.querySelector("#urls").value.split(/\r?\n/).filter((function(e){return e.trim().length}));if(!e.length)return swal("An error occurred!","You have not entered any URLs.","error");var a=document.querySelector("#tab-urls");a.querySelector(".uploads").classList.remove("is-hidden");for(var t=0;t .clipboard-js");n.href=n.innerHTML=r.dataset.clipboardText=a.url,t.classList.remove("is-hidden"),r.parentElement.classList.remove("is-hidden");var i=/.[\w]+$/.exec(a.url),l=i&&i[0]?i[0].toLowerCase():null;if(page.imageExts.includes(l))if(page.previewImages){var o=e.previewElement.querySelector("img");o.setAttribute("alt",a.name||""),o.dataset.src=a.url,o.classList.remove("is-hidden"),o.onerror=function(a){a.currentTarget.classList.add("is-hidden"),page.updateTemplateIcon(e.previewElement,"icon-picture")},page.lazyLoad.update(e.previewElement.querySelectorAll("img"))}else page.updateTemplateIcon(e.previewElement,"icon-picture");else page.videoExts.includes(l)?page.updateTemplateIcon(e.previewElement,"icon-video"):page.updateTemplateIcon(e.previewElement,"icon-doc-inv");if(a.expirydate){var s=e.previewElement.querySelector(".expiry-date");s.dataset.timestamp=a.expirydate,s.innerHTML="EXP: "+page.getPrettyDate(new Date(1e3*a.expirydate)),s.classList.remove("is-hidden")}}},page.createAlbum=function(){var e=document.createElement("div");e.innerHTML='\n
    \n
    \n \n
    \n

    Max length is '+page.albumTitleMaxLength+' characters.

    \n
    \n
    \n
    \n \n
    \n

    Max length is '+page.albumDescMaxLength+' characters.

    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n ',swal({title:"Create new album",icon:"info",content:e,buttons:{cancel:!0,confirm:{closeModal:!1}}}).then((function(e){if(e){var a=document.querySelector("#swalName").value.trim();axios.post("api/albums",{name:a,description:document.querySelector("#swalDescription").value.trim(),download:document.querySelector("#swalDownload").checked,public:document.querySelector("#swalPublic").checked},{headers:{token:page.token}}).then((function(e){if(!1===e.data.success)return swal("An error occurred!",e.data.description,"error");var t=document.createElement("option");page.albumSelect.appendChild(t),t.value=e.data.id,t.innerHTML=a,t.selected=!0,page.albumSelectOnChange(),swal("Woohoo!","Album was created successfully.","success")})).catch(page.onError)}}))},page.prepareUploadConfig=function(){var e={chunkSize:page.chunkSizeConfig.default,parallelUploads:2},a=Array.isArray(page.temporaryUploadAges)&&page.temporaryUploadAges.length,t=page.fileIdentifierLength&&"number"==typeof page.fileIdentifierLength.min&&"number"==typeof page.fileIdentifierLength.max,n={siBytes:{label:"File size display",select:[{value:"default",text:"1000 B = 1 kB = 1 Kilobyte"},{value:"0",text:"1024 B = 1 KiB = 1 Kibibyte"}],help:"This will be used in our homepage, dashboard, and album public pages.",valueHandler:function(){}},ampmTime:{label:"Show AM/PM on date",select:[{value:"default",text:"No"},{value:"1",text:"Yes"}],help:"This will be used in our homepage and dashboard.",valueHandler:function(){}},fileLength:{display:t,label:"File identifier length",number:t?{min:page.fileIdentifierLength.min,max:page.fileIdentifierLength.max,default:page.fileIdentifierLength.default,round:!0}:void 0,help:!0,disabled:t&&page.fileIdentifierLength.force},uploadAge:{display:a,label:"Upload age",select:[],help:"Whether to automatically delete your uploads after a certain amount of time."},stripTags:{display:page.stripTagsConfig,label:"Strip tags",select:page.stripTagsConfig?[{value:page.stripTagsConfig.default?"default":"1",text:"Yes"},{value:page.stripTagsConfig.default?"0":"default",text:"No"}]:null,help:"Whether to strip tags (e.g. EXIF) from your uploads.
    \n This only applies to regular image"+(page.stripTagsConfig&&page.stripTagsConfig.video?" and video":"")+" uploads (i.e. not URL uploads).",disabled:page.stripTagsConfig&&page.stripTagsConfig.force},chunkSize:{display:Boolean(page.chunkSizeConfig.default),label:"Upload chunk size (MB)",number:{min:1,max:page.chunkSizeConfig.max,default:e.chunkSize,suffix:" MB",round:!0},help:!0},parallelUploads:{label:"Parallel uploads",number:{min:1,max:10,default:e.parallelUploads,round:!0},help:!0},uploadsHistoryOrder:{label:"Uploads history order",select:[{value:"default",text:"Older files on top"},{value:"0",text:"Newer files on top"}],help:'"Newer files on top" will use a CSS technique, which unfortunately come with some undesirable side effects.
    \n This also affects text selection, such as when trying to select text from top to bottom will result in them being selected from bottom to top instead, and vice versa.',valueHandler:function(e){if("0"===e)for(var a=document.querySelectorAll(".tab-content > .uploads"),t=0;t=page.fileIdentifierLength.min&&o<=page.fileIdentifierLength.max&&(n.fileLength.value=o)}var s=document.querySelector("#tab-config"),p=document.createElement("form");p.addEventListener("submit",(function(e){return e.preventDefault()}));for(var u=Object.keys(n),d=0;d=g.number.min&&(f=h)}else{var v=localStorage[lsKeys[c]];f=Array.isArray(g.select)?g.select.find((function(e){return e.value===v}))?v:void 0:v}"function"==typeof g.valueHandler?g.valueHandler(f):void 0!==f?page[c]=f:void 0!==e[c]&&(page[c]=e[c])}var b=void 0;if(Array.isArray(g.select)){(b=document.createElement("div")).className="select is-fullwidth";for(var y=[],S=0;S\n "+w.text+("default"===w.value?" (default)":"")+"\n \n ")}b.innerHTML='\n \n "}else g.number&&((b=document.createElement("input")).id=b.name=c,b.className="input is-fullwidth",b.type="number",void 0!==g.number.min&&(b.min=g.number.min),void 0!==g.number.max&&(b.max=g.number.max),"number"==typeof f?b.value=f:void 0!==g.number.default&&(b.value=g.number.default));var x=void 0;if(g.disabled)Array.isArray(g.select)?b.querySelector("select").disabled=g.disabled:b.disabled=g.disabled,x="This option is currently not configurable.";else if("string"==typeof g.help)x=g.help;else if(!0===g.help&&void 0!==g.number){var L=[];void 0!==g.number.default&&L.push("Default is "+g.number.default+(g.number.suffix||"")+"."),void 0!==g.number.min&&L.push("Min is "+g.number.min+(g.number.suffix||"")+"."),void 0!==g.number.max&&L.push("Max is "+g.number.max+(g.number.suffix||"")+"."),x=L.join(" ")}m.innerHTML='\n \n
    \n '+(x?'

    '+x+"

    ":"")+"\n ",m.querySelector("div.control").appendChild(b),p.appendChild(m)}}var T=document.createElement("div");T.className="field",T.innerHTML='\n

    \n \n

    \n

    \n This configuration will only be used in this browser.
    \n After reloading the page, some of them will also be applied to the ShareX config that you can download by clicking on the ShareX icon below.\n

    \n ',p.appendChild(T),p.querySelector("#saveConfig").addEventListener("click",(function(){if(p.checkValidity()){for(var e=Object.keys(n).filter((function(e){return!1!==n[e].display&&!0!==n[e].disabled})),a=0;a=24){var t=e/24;return t+" day"+(1===t?"":"s")}return e+" hour"+(1===e?"":"s")},window.addEventListener("paste",(function(e){for(var a=(e.clipboardData||e.originalEvent.clipboardData).items,t=Object.keys(a),n=0;n {\n // Hide these elements\n document.querySelector('#albumDiv').classList.add('is-hidden')\n document.querySelector('#tabs').classList.add('is-hidden')\n document.querySelectorAll('.tab-content').forEach(element => {\n return element.classList.add('is-hidden')\n })\n\n // Update upload button\n const uploadButton = document.querySelector('#loginToUpload')\n uploadButton.innerText = 'An error occurred. Try to reload?'\n uploadButton.classList.remove('is-loading')\n uploadButton.classList.remove('is-hidden')\n\n uploadButton.addEventListener('click', () => {\n window.location.reload()\n })\n\n if (error.response) page.onAxiosError(error)\n else page.onError(error)\n}\n\n// Handler for regular JS errors\npage.onError = error => {\n console.error(error)\n\n const content = document.createElement('div')\n content.innerHTML = `\n

    ${error.toString()}

    \n

    Please check your console for more information.

    \n `\n return swal({\n title: 'An error occurred!',\n icon: 'error',\n content\n })\n}\n\n// Handler for Axios errors\npage.onAxiosError = (error, cont) => {\n if (!cont) console.error(error)\n\n // Better Cloudflare errors\n const cloudflareErrors = {\n 520: 'Unknown Error',\n 521: 'Web Server Is Down',\n 522: 'Connection Timed Out',\n 523: 'Origin Is Unreachable',\n 524: 'A Timeout Occurred',\n 525: 'SSL Handshake Failed',\n 526: 'Invalid SSL Certificate',\n 527: 'Railgun Error',\n 530: 'Origin DNS Error'\n }\n\n const statusText = cloudflareErrors[error.response.status] || error.response.statusText\n\n if (!cont) {\n const description = error.response.data && error.response.data.description\n ? error.response.data.description\n : 'There was an error with the request.\\nPlease check the console for more information.'\n return swal(`${error.response.status} ${statusText}`, description, 'error')\n } else if (error.response.data && error.response.data.description) {\n return error.response\n } else {\n const description = error.response\n ? `${error.response.status} ${statusText}`\n : error.toString()\n return { data: { success: false, description } }\n }\n}\n\npage.checkClientVersion = apiVersion => {\n const self = document.querySelector('#mainScript')\n const match = self.src.match(/\\?_=(\\d+)$/)\n if (match && match[1] && match[1] !== apiVersion) {\n return swal({\n title: 'Update detected!',\n text: 'Client assets have been updated. Reload to display the latest version?',\n icon: 'info',\n buttons: {\n confirm: {\n text: 'Reload',\n closeModal: false\n }\n }\n }).then(() => {\n window.location.reload()\n })\n }\n}\n\npage.checkIfPublic = () => {\n return axios.get('api/check', {\n onDownloadProgress: () => {\n // Only do render and/or newsfeed after this request has been initiated to avoid blocking\n /* global render */\n if (typeof render !== 'undefined' && !render.done) render.do()\n /* global newsfeed */\n if (typeof newsfeed !== 'undefined' && !newsfeed.done) newsfeed.do()\n if (!page.apiChecked) page.apiChecked = true\n }\n }).then(response => {\n if (response.data.version) {\n page.checkClientVersion(response.data.version)\n }\n\n page.private = response.data.private\n page.enableUserAccounts = response.data.enableUserAccounts\n\n page.maxSize = parseInt(response.data.maxSize)\n page.maxSizeBytes = page.maxSize * 1e6\n page.chunkSizeConfig = {\n max: (response.data.chunkSize && parseInt(response.data.chunkSize.max)) || 95,\n default: response.data.chunkSize && parseInt(response.data.chunkSize.default)\n }\n\n page.temporaryUploadAges = response.data.temporaryUploadAges\n page.fileIdentifierLength = response.data.fileIdentifierLength\n page.stripTagsConfig = response.data.stripTags\n\n return page.preparePage()\n }).catch(page.onInitError)\n}\n\npage.preparePage = () => {\n if (page.private) {\n if (page.token) {\n return page.verifyToken(page.token, true)\n } else {\n const button = document.querySelector('#loginToUpload')\n button.href = 'auth'\n button.classList.remove('is-loading')\n if (page.enableUserAccounts) {\n button.innerText = 'Anonymous upload is disabled.\\nLog in or register to upload.'\n } else {\n button.innerText = 'Running in private mode.\\nLog in to upload.'\n }\n }\n } else {\n return page.prepareUpload()\n }\n}\n\npage.verifyToken = (token, reloadOnError) => {\n return axios.post('api/tokens/verify', { token }).then(response => {\n if (response.data.success === false) {\n return swal({\n title: 'An error occurred!',\n text: response.data.description,\n icon: 'error'\n }).then(() => {\n if (!reloadOnError) return\n localStorage.removeItem('token')\n window.location.reload()\n })\n }\n\n localStorage[lsKeys.token] = token\n page.token = token\n return page.prepareUpload()\n }).catch(page.onInitError)\n}\n\npage.prepareUpload = () => {\n // I think this fits best here because we need to check for a valid token before we can get the albums\n if (page.token) {\n // Change /auth link to /dashboard\n const authLink = document.querySelector('#linksColumn a[href=\"auth\"]')\n if (authLink) authLink.setAttribute('href', 'dashboard')\n\n // Display the album selection\n document.querySelector('#albumDiv').classList.remove('is-hidden')\n\n page.albumSelect = document.querySelector('#albumSelect')\n page.albumSelectOnChange = () => {\n page.album = parseInt(page.albumSelect.value)\n // Re-generate ShareX config file\n if (typeof page.prepareShareX === 'function') page.prepareShareX()\n }\n page.albumSelect.addEventListener('change', page.albumSelectOnChange)\n\n // Fetch albums\n page.fetchAlbums()\n } else if (page.enableUserAccounts) {\n document.querySelector('#loginLinkText').innerHTML = 'Create an account and keep track of your uploads'\n }\n\n // Prepare & generate config tab\n page.prepareUploadConfig()\n\n // Update elements wherever applicable\n document.querySelector('#maxSize > span').innerHTML = page.getPrettyBytes(page.maxSizeBytes)\n document.querySelector('#loginToUpload').classList.add('is-hidden')\n\n // Prepare & generate files upload tab\n page.prepareDropzone()\n\n // Generate ShareX config file\n if (typeof page.prepareShareX === 'function') page.prepareShareX()\n\n // Prepare urls upload tab\n const urlMaxSize = document.querySelector('#urlMaxSize')\n if (urlMaxSize) {\n page.urlMaxSize = parseInt(urlMaxSize.innerHTML)\n page.urlMaxSizeBytes = page.urlMaxSize * 1e6\n urlMaxSize.innerHTML = page.getPrettyBytes(page.urlMaxSizeBytes)\n }\n\n const uploadUrls = document.querySelector('#uploadUrls')\n if (uploadUrls) {\n uploadUrls.addEventListener('click', event => {\n page.addUrlsToQueue()\n })\n }\n\n // Get all tabs\n const tabsContainer = document.querySelector('#tabs')\n const tabs = tabsContainer.querySelectorAll('li')\n for (let i = 0; i < tabs.length; i++) {\n const id = tabs[i].dataset.id\n const tabContent = document.querySelector(`#${id}`)\n if (!tabContent) continue\n\n tabs[i].addEventListener('click', () => {\n page.setActiveTab(i)\n })\n page.tabs.push({ tab: tabs[i], content: tabContent })\n }\n\n // Set first valid tab as the default active tab\n if (page.tabs.length) {\n page.setActiveTab(0)\n tabsContainer.classList.remove('is-hidden')\n }\n}\n\npage.setActiveTab = index => {\n for (let i = 0; i < page.tabs.length; i++) {\n if (i === index) {\n page.tabs[i].tab.classList.add('is-active')\n page.tabs[i].content.classList.remove('is-hidden')\n page.activeTab = index\n } else {\n page.tabs[i].tab.classList.remove('is-active')\n page.tabs[i].content.classList.add('is-hidden')\n }\n }\n}\n\npage.fetchAlbums = () => {\n return axios.get('api/albums', {\n headers: {\n simple: '1',\n token: page.token\n }\n }).then(response => {\n if (response.data.success === false) {\n return swal('An error occurred!', response.data.description, 'error')\n }\n\n // Create an option for each album\n if (Array.isArray(response.data.albums) && response.data.albums.length) {\n for (let i = 0; i < response.data.albums.length; i++) {\n const album = response.data.albums[i]\n const option = document.createElement('option')\n option.value = album.id\n option.innerHTML = album.name\n page.albumSelect.appendChild(option)\n }\n }\n }).catch(page.onInitError)\n}\n\npage.prepareDropzone = () => {\n // Parse template element\n const previewNode = document.querySelector('#tpl')\n page.previewTemplate = previewNode.innerHTML\n previewNode.parentNode.removeChild(previewNode)\n\n // Generate files upload tab\n const tabDiv = document.querySelector('#tab-files')\n const div = document.createElement('div')\n div.className = 'control is-expanded'\n div.innerHTML = `\n
    \n \n \n \n Click here or drag & drop files\n
    \n `\n tabDiv.querySelector('.dz-container').appendChild(div)\n\n const previewsContainer = tabDiv.querySelector('#tab-files .field.uploads')\n\n page.dropzone = new Dropzone(document.body, {\n url: 'api/upload',\n paramName: 'files[]',\n clickable: tabDiv.querySelector('#dropzone'),\n maxFilesize: page.maxSizeBytes / 1024 / 1024, // this option expects MiB\n parallelUploads: page.parallelUploads,\n uploadMultiple: false,\n previewsContainer,\n previewTemplate: page.previewTemplate,\n createImageThumbnails: false,\n autoProcessQueue: true,\n headers: { token: page.token },\n chunking: Boolean(page.chunkSize),\n chunkSize: page.chunkSize * 1e6, // this option expects Bytes\n parallelChunkUploads: false, // for now, enabling this breaks descriptive upload progress\n timeout: 0,\n\n init () {\n this.on('addedfile', file => {\n // Set active tab to file uploads, if necessary\n if (page.activeTab !== 0) page.setActiveTab(0)\n\n // Add file entry\n tabDiv.querySelector('.uploads').classList.remove('is-hidden')\n\n file.previewElement.querySelector('.name').innerHTML = file.name\n file.previewElement.querySelector('.descriptive-progress').innerHTML = 'Waiting in queue\\u2026'\n })\n\n this.on('sending', (file, xhr) => {\n // Add timeout listener (hacky method due to lack of built-in timeout handler)\n if (!xhr.ontimeout) {\n xhr.ontimeout = () => {\n const instances = page.dropzone.getUploadingFiles()\n .filter(instance => instance.xhr === xhr)\n page.dropzone._handleUploadError(instances, xhr, 'Connection timed out. Try to reduce upload chunk size.')\n }\n }\n\n // Attach necessary data for initial upload speed calculation\n if (typeof xhr._uplSpeedCalc === 'undefined') {\n xhr._uplSpeedCalc = {\n lastSent: 0,\n data: [{ timestamp: Date.now(), bytes: 0 }]\n }\n }\n\n // If not chunked uploads, add extra headers\n if (!file.upload.chunked) {\n if (page.album !== null) xhr.setRequestHeader('albumid', page.album)\n if (page.fileLength !== null) xhr.setRequestHeader('filelength', page.fileLength)\n if (page.uploadAge !== null) xhr.setRequestHeader('age', page.uploadAge)\n if (page.stripTags !== null) xhr.setRequestHeader('striptags', page.stripTags)\n }\n\n if (!file.upload.chunked) {\n file.previewElement.querySelector('.descriptive-progress').innerHTML = 'Uploading\\u2026'\n } else if (file.upload.chunks.length === 1) {\n file.previewElement.querySelector('.descriptive-progress').innerHTML = `Uploading chunk 1/${file.upload.totalChunkCount}\\u2026`\n }\n })\n\n // Update descriptive progress\n this.on('uploadprogress', (file, progress) => {\n // Total bytes will eventually be bigger than file size when chunked\n const total = Math.max(file.size, file.upload.total)\n const percentage = (file.upload.bytesSent / total * 100).toFixed(0)\n\n const upl = file.upload.chunked\n ? file.upload.chunks[file.upload.chunks.length - 1]\n : file.upload\n const xhr = upl.xhr || file.xhr\n\n let prefix = 'Uploading\\u2026'\n let skipProgress = false\n if (file.upload.chunked) {\n const done = upl.bytesSent === upl.total\n const last = file.upload.chunks.length === file.upload.totalChunkCount\n let chunkIndex = file.upload.chunks.length\n if (done && !last) {\n chunkIndex++\n skipProgress = true\n }\n prefix = `Uploading chunk ${chunkIndex}/${file.upload.totalChunkCount}\\u2026`\n }\n\n // Real-time upload speed calculation\n let prettyBytesPerSec\n if (!skipProgress) {\n const now = Date.now()\n const bytesSent = upl.bytesSent - xhr._uplSpeedCalc.lastSent\n\n // Push data of current iteration\n xhr._uplSpeedCalc.lastSent = upl.bytesSent\n xhr._uplSpeedCalc.data.push({ timestamp: now, bytes: bytesSent })\n\n // Wait till at least the 2nd iteration (3 data including initial data)\n const length = xhr._uplSpeedCalc.data.length\n if (length > 2) {\n // Calculate using data from all iterations\n let elapsed = 0\n let bytesPerSec = 0\n let fullSec = false\n let i = length - 1 // Always start with 2nd from last item\n while (i--) {\n // Splice data of unrequired iterations\n if (fullSec) {\n xhr._uplSpeedCalc.data.splice(i, 1)\n continue\n }\n // Sum data\n elapsed = now - xhr._uplSpeedCalc.data[i].timestamp\n if (elapsed > 1000) {\n const excessDuration = elapsed - 1000\n const newerIterationElapsed = now - xhr._uplSpeedCalc.data[i + 1].timestamp\n const duration = elapsed - newerIterationElapsed\n const fragment = (duration - excessDuration) / duration * xhr._uplSpeedCalc.data[i + 1].bytes\n bytesPerSec += fragment\n fullSec = true\n } else {\n bytesPerSec += xhr._uplSpeedCalc.data[i + 1].bytes\n }\n }\n\n // If not enough data\n if (!fullSec) bytesPerSec = 1000 / elapsed * bytesPerSec\n\n // Get pretty bytes\n prettyBytesPerSec = page.getPrettyBytes(bytesPerSec)\n }\n }\n\n file.previewElement.querySelector('.descriptive-progress').innerHTML =\n `${prefix} ${percentage}%${prettyBytesPerSec ? ` at ${prettyBytesPerSec}/s` : ''}`\n })\n\n this.on('success', (file, data) => {\n if (!data) return\n file.previewElement.querySelector('.descriptive-progress').classList.add('is-hidden')\n\n if (data.success === false) {\n file.previewElement.querySelector('.error').innerHTML = data.description\n file.previewElement.querySelector('.error').classList.remove('is-hidden')\n }\n\n if (Array.isArray(data.files) && data.files[0]) {\n page.updateTemplate(file, data.files[0])\n }\n })\n\n this.on('error', (file, error, xhr) => {\n let err = error\n if (typeof error === 'object' && error.description) {\n err = error.description\n } else if (xhr) {\n // Formatting the Object is necessary since the function expect Axios errors\n err = page.onAxiosError({\n response: {\n status: xhr.status,\n statusText: xhr.statusText\n }\n }, true).data.description\n } else if (error instanceof Error) {\n err = error.toString()\n }\n\n // Clean up file size errors\n if (/^File is too big/.test(err) || /File too large/.test(err)) {\n err = `File too large (${page.getPrettyBytes(file.size)}).`\n }\n\n file.previewElement.querySelector('.descriptive-progress').classList.add('is-hidden')\n\n file.previewElement.querySelector('.error').innerHTML = err\n file.previewElement.querySelector('.error').classList.remove('is-hidden')\n\n page.updateTemplateIcon(file.previewElement, 'icon-block')\n })\n },\n\n chunksUploaded (file, done) {\n file.previewElement.querySelector('.descriptive-progress').innerHTML =\n `Rebuilding ${file.upload.totalChunkCount} chunks\\u2026`\n\n return axios.post('api/upload/finishchunks', {\n // This API supports an array of multiple files\n files: [{\n uuid: file.upload.uuid,\n original: file.name,\n type: file.type,\n albumid: page.album,\n filelength: page.fileLength,\n age: page.uploadAge\n }]\n }, {\n headers: {\n token: page.token,\n // Unlike the options above (e.g. albumid, filelength, etc.),\n // strip tags cannot yet be configured per file with this API\n striptags: page.stripTags\n }\n }).catch(error => page.onAxiosError(error, true)).then(response => {\n file.previewElement.querySelector('.descriptive-progress').classList.add('is-hidden')\n\n if (response.data.success === false) {\n file.previewElement.querySelector('.error').innerHTML = response.data.description\n file.previewElement.querySelector('.error').classList.remove('is-hidden')\n\n page.updateTemplateIcon(file.previewElement, 'icon-block')\n }\n\n if (response.data.files && response.data.files[0]) {\n page.updateTemplate(file, response.data.files[0])\n }\n\n return done()\n })\n }\n })\n}\n\npage.addUrlsToQueue = () => {\n const urls = document.querySelector('#urls').value\n .split(/\\r?\\n/)\n .filter(url => {\n return url.trim().length\n })\n\n if (!urls.length) {\n return swal('An error occurred!', 'You have not entered any URLs.', 'error')\n }\n\n const tabDiv = document.querySelector('#tab-urls')\n tabDiv.querySelector('.uploads').classList.remove('is-hidden')\n\n for (let i = 0; i < urls.length; i++) {\n const previewTemplate = document.createElement('template')\n previewTemplate.innerHTML = page.previewTemplate.trim()\n\n const previewElement = previewTemplate.content.firstChild\n previewElement.querySelector('.name').innerHTML = urls[i]\n previewElement.querySelector('.descriptive-progress').innerHTML = 'Waiting in queue\\u2026'\n\n const previewsContainer = tabDiv.querySelector('.uploads')\n previewsContainer.appendChild(previewElement)\n\n page.urlsQueue.push({\n url: urls[i],\n previewElement\n })\n }\n\n page.processUrlsQueue()\n document.querySelector('#urls').value = ''\n}\n\npage.processUrlsQueue = () => {\n if (!page.urlsQueue.length) return\n\n function finishedUrlUpload (file, data) {\n file.previewElement.querySelector('.descriptive-progress').classList.add('is-hidden')\n\n if (data.success === false) {\n const match = data.description.match(/ over limit: (\\d+)$/)\n if (match && match[1]) {\n data.description = `File exceeded limit of ${page.getPrettyBytes(match[1])}.`\n }\n\n file.previewElement.querySelector('.error').innerHTML = data.description\n file.previewElement.querySelector('.error').classList.remove('is-hidden')\n\n page.updateTemplateIcon(file.previewElement, 'icon-block')\n }\n\n if (Array.isArray(data.files) && data.files[0]) {\n page.updateTemplate(file, data.files[0])\n }\n\n page.activeUrlsQueue--\n return shiftQueue()\n }\n\n function initUrlUpload (file) {\n file.previewElement.querySelector('.descriptive-progress').innerHTML =\n 'Waiting for server to fetch URL\\u2026'\n\n return axios.post('api/upload', {\n urls: [file.url]\n }, {\n headers: {\n token: page.token,\n albumid: page.album,\n age: page.uploadAge,\n filelength: page.fileLength\n }\n }).catch(error => page.onAxiosError(error, true)).then(response => {\n return finishedUrlUpload(file, response.data)\n })\n }\n\n function shiftQueue () {\n while (page.urlsQueue.length && (page.activeUrlsQueue < page.parallelUploads)) {\n page.activeUrlsQueue++\n initUrlUpload(page.urlsQueue.shift())\n }\n }\n\n return shiftQueue()\n}\n\npage.updateTemplateIcon = (templateElement, iconClass) => {\n const iconElement = templateElement.querySelector('.icon')\n if (!iconElement) return\n\n iconElement.classList.add(iconClass)\n iconElement.classList.remove('is-hidden')\n}\n\npage.updateTemplate = (file, response) => {\n if (!response.url) return\n\n const link = file.previewElement.querySelector('.link')\n const a = link.querySelector('a')\n const clipboard = file.previewElement.querySelector('.clipboard-mobile > .clipboard-js')\n a.href = a.innerHTML = clipboard.dataset.clipboardText = response.url\n\n link.classList.remove('is-hidden')\n clipboard.parentElement.classList.remove('is-hidden')\n\n const exec = /.[\\w]+$/.exec(response.url)\n const extname = exec && exec[0]\n ? exec[0].toLowerCase()\n : null\n\n if (page.imageExts.includes(extname)) {\n if (page.previewImages) {\n const img = file.previewElement.querySelector('img')\n img.setAttribute('alt', response.name || '')\n img.dataset.src = response.url\n img.classList.remove('is-hidden')\n img.onerror = event => {\n // Hide image elements that fail to load\n // Consequently include WEBP in browsers that do not have WEBP support (e.g. IE)\n event.currentTarget.classList.add('is-hidden')\n page.updateTemplateIcon(file.previewElement, 'icon-picture')\n }\n page.lazyLoad.update(file.previewElement.querySelectorAll('img'))\n } else {\n page.updateTemplateIcon(file.previewElement, 'icon-picture')\n }\n } else if (page.videoExts.includes(extname)) {\n page.updateTemplateIcon(file.previewElement, 'icon-video')\n } else {\n page.updateTemplateIcon(file.previewElement, 'icon-doc-inv')\n }\n\n if (response.expirydate) {\n const expiryDate = file.previewElement.querySelector('.expiry-date')\n expiryDate.dataset.timestamp = response.expirydate\n expiryDate.innerHTML = `EXP: ${page.getPrettyDate(new Date(response.expirydate * 1000))}`\n expiryDate.classList.remove('is-hidden')\n }\n}\n\npage.createAlbum = () => {\n const div = document.createElement('div')\n div.innerHTML = `\n
    \n
    \n \n
    \n

    Max length is ${page.albumTitleMaxLength} characters.

    \n
    \n
    \n
    \n \n
    \n

    Max length is ${page.albumDescMaxLength} characters.

    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n `\n\n swal({\n title: 'Create new album',\n icon: 'info',\n content: div,\n buttons: {\n cancel: true,\n confirm: {\n closeModal: false\n }\n }\n }).then(value => {\n if (!value) return\n\n const name = document.querySelector('#swalName').value.trim()\n axios.post('api/albums', {\n name,\n description: document.querySelector('#swalDescription').value.trim(),\n download: document.querySelector('#swalDownload').checked,\n public: document.querySelector('#swalPublic').checked\n }, {\n headers: {\n token: page.token\n }\n }).then(response => {\n if (response.data.success === false) {\n return swal('An error occurred!', response.data.description, 'error')\n }\n\n const option = document.createElement('option')\n page.albumSelect.appendChild(option)\n option.value = response.data.id\n option.innerHTML = name\n option.selected = true\n page.albumSelectOnChange()\n\n swal('Woohoo!', 'Album was created successfully.', 'success')\n }).catch(page.onError)\n })\n}\n\npage.prepareUploadConfig = () => {\n // This object should only be used to set fallback values for page[key]\n // (essentially for page[key] properties that explicitly need to be set as something)\n // As for default values in the Config tab (which will not set page[key]),\n // check out number.default property of each config\n const fallback = {\n chunkSize: page.chunkSizeConfig.default,\n parallelUploads: 2\n }\n\n const temporaryUploadAges = Array.isArray(page.temporaryUploadAges) &&\n page.temporaryUploadAges.length\n const fileIdentifierLength = page.fileIdentifierLength &&\n typeof page.fileIdentifierLength.min === 'number' &&\n typeof page.fileIdentifierLength.max === 'number'\n\n const config = {\n siBytes: {\n label: 'File size display',\n select: [\n { value: 'default', text: '1000 B = 1 kB = 1 Kilobyte' },\n { value: '0', text: '1024 B = 1 KiB = 1 Kibibyte' }\n ],\n help: 'This will be used in our homepage, dashboard, and album public pages.',\n valueHandler () {} // Do nothing\n },\n ampmTime: {\n label: 'Show AM/PM on date',\n select: [\n { value: 'default', text: 'No' },\n { value: '1', text: 'Yes' }\n ],\n help: 'This will be used in our homepage and dashboard.',\n valueHandler () {} // Do nothing\n },\n fileLength: {\n display: fileIdentifierLength,\n label: 'File identifier length',\n number: fileIdentifierLength\n ? {\n min: page.fileIdentifierLength.min,\n max: page.fileIdentifierLength.max,\n default: page.fileIdentifierLength.default,\n round: true\n }\n : undefined,\n help: true, // true means auto-generated, for number-based configs only\n disabled: fileIdentifierLength && page.fileIdentifierLength.force\n },\n uploadAge: {\n display: temporaryUploadAges,\n label: 'Upload age',\n select: [],\n help: 'Whether to automatically delete your uploads after a certain amount of time.'\n },\n stripTags: {\n display: page.stripTagsConfig,\n label: 'Strip tags',\n select: page.stripTagsConfig\n ? [\n { value: page.stripTagsConfig.default ? 'default' : '1', text: 'Yes' },\n { value: page.stripTagsConfig.default ? '0' : 'default', text: 'No' }\n ]\n : null,\n help: `Whether to strip tags (e.g. EXIF) from your uploads.
    \n This only applies to regular image${page.stripTagsConfig && page.stripTagsConfig.video ? ' and video' : ''} uploads (i.e. not URL uploads).`,\n disabled: page.stripTagsConfig && page.stripTagsConfig.force\n },\n chunkSize: {\n display: Boolean(page.chunkSizeConfig.default),\n label: 'Upload chunk size (MB)',\n number: {\n min: 1,\n max: page.chunkSizeConfig.max,\n default: fallback.chunkSize,\n suffix: ' MB',\n round: true\n },\n help: true\n },\n parallelUploads: {\n label: 'Parallel uploads',\n number: {\n min: 1,\n max: 10,\n default: fallback.parallelUploads,\n round: true\n },\n help: true\n },\n uploadsHistoryOrder: {\n label: 'Uploads history order',\n select: [\n { value: 'default', text: 'Older files on top' },\n { value: '0', text: 'Newer files on top' }\n ],\n help: `\"Newer files on top\" will use a CSS technique, which unfortunately come with some undesirable side effects.
    \n This also affects text selection, such as when trying to select text from top to bottom will result in them being selected from bottom to top instead, and vice versa.`,\n valueHandler (value) {\n if (value === '0') {\n const uploadFields = document.querySelectorAll('.tab-content > .uploads')\n for (let i = 0; i < uploadFields.length; i++) {\n uploadFields[i].classList.add('is-reversed')\n }\n }\n }\n },\n previewImages: {\n label: 'Load images for preview',\n select: [\n { value: 'default', text: 'Yes' },\n { value: '0', text: 'No' }\n ],\n help: 'By default, uploaded images will be loaded as their previews.',\n valueHandler (value) {\n page.previewImages = value !== '0'\n }\n }\n }\n\n if (temporaryUploadAges) {\n const stored = parseFloat(localStorage[lsKeys.uploadAge])\n for (let i = 0; i < page.temporaryUploadAges.length; i++) {\n const age = page.temporaryUploadAges[i]\n config.uploadAge.select.push({\n value: i === 0 ? 'default' : String(age),\n text: page.getPrettyUploadAge(age)\n })\n if (age === stored) {\n config.uploadAge.value = stored\n }\n }\n }\n\n if (fileIdentifierLength) {\n const stored = parseInt(localStorage[lsKeys.fileLength])\n if (!page.fileIdentifierLength.force &&\n !isNaN(stored) &&\n stored >= page.fileIdentifierLength.min &&\n stored <= page.fileIdentifierLength.max) {\n config.fileLength.value = stored\n }\n }\n\n const tabContent = document.querySelector('#tab-config')\n const form = document.createElement('form')\n form.addEventListener('submit', event => event.preventDefault())\n\n const configKeys = Object.keys(config)\n for (let i = 0; i < configKeys.length; i++) {\n const key = configKeys[i]\n const conf = config[key]\n\n // Skip only if display attribute is explicitly set to false\n if (conf.display === false) continue\n\n const field = document.createElement('div')\n field.className = 'field'\n\n let value\n if (!conf.disabled) {\n if (typeof conf.value !== 'undefined') {\n value = conf.value\n } else if (typeof conf.number !== 'undefined') {\n const parsed = parseInt(localStorage[lsKeys[key]])\n if (!isNaN(parsed) && parsed <= conf.number.max && parsed >= conf.number.min) {\n value = parsed\n }\n } else {\n const stored = localStorage[lsKeys[key]]\n if (Array.isArray(conf.select)) {\n value = conf.select.find(sel => sel.value === stored)\n ? stored\n : undefined\n } else {\n value = stored\n }\n }\n\n // If valueHandler function exists, defer to the function,\n // otherwise pass value to global page object\n if (typeof conf.valueHandler === 'function') {\n conf.valueHandler(value)\n } else if (typeof value !== 'undefined') {\n page[key] = value\n } else if (typeof fallback[key] !== 'undefined') {\n page[key] = fallback[key]\n }\n }\n\n let control\n if (Array.isArray(conf.select)) {\n control = document.createElement('div')\n control.className = 'select is-fullwidth'\n\n const opts = []\n for (let j = 0; j < conf.select.length; j++) {\n const opt = conf.select[j]\n const selected = (value && (opt.value === String(value))) ||\n (typeof value === 'undefined' && opt.value === 'default')\n opts.push(`\n \n `)\n }\n\n control.innerHTML = `\n \n `\n } else if (conf.number) {\n control = document.createElement('input')\n control.id = control.name = key\n control.className = 'input is-fullwidth'\n control.type = 'number'\n\n if (typeof conf.number.min !== 'undefined') control.min = conf.number.min\n if (typeof conf.number.max !== 'undefined') control.max = conf.number.max\n if (typeof value === 'number') control.value = value\n else if (typeof conf.number.default !== 'undefined') control.value = conf.number.default\n }\n\n let help\n if (conf.disabled) {\n if (Array.isArray(conf.select)) {\n control.querySelector('select').disabled = conf.disabled\n } else {\n control.disabled = conf.disabled\n }\n help = 'This option is currently not configurable.'\n } else if (typeof conf.help === 'string') {\n help = conf.help\n } else if (conf.help === true && typeof conf.number !== 'undefined') {\n const tmp = []\n\n if (typeof conf.number.default !== 'undefined') {\n tmp.push(`Default is ${conf.number.default}${conf.number.suffix || ''}.`)\n }\n if (typeof conf.number.min !== 'undefined') {\n tmp.push(`Min is ${conf.number.min}${conf.number.suffix || ''}.`)\n }\n if (typeof conf.number.max !== 'undefined') {\n tmp.push(`Max is ${conf.number.max}${conf.number.suffix || ''}.`)\n }\n\n help = tmp.join(' ')\n }\n\n field.innerHTML = `\n \n
    \n ${help ? `

    ${help}

    ` : ''}\n `\n field.querySelector('div.control').appendChild(control)\n\n form.appendChild(field)\n }\n\n const submit = document.createElement('div')\n submit.className = 'field'\n submit.innerHTML = `\n

    \n \n

    \n

    \n This configuration will only be used in this browser.
    \n After reloading the page, some of them will also be applied to the ShareX config that you can download by clicking on the ShareX icon below.\n

    \n `\n\n form.appendChild(submit)\n form.querySelector('#saveConfig').addEventListener('click', () => {\n if (!form.checkValidity()) return\n\n const keys = Object.keys(config)\n .filter(key => config[key].display !== false && config[key].disabled !== true)\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i]\n\n let value\n if (typeof config[key].select !== 'undefined') {\n if (form.elements[key].value !== 'default') {\n value = form.elements[key].value\n }\n } else if (typeof config[key].number !== 'undefined') {\n const parsed = parseInt(form.elements[key].value)\n if (!isNaN(parsed) && parsed !== config[key].number.default) {\n value = Math.min(Math.max(parsed, config[key].number.min), config[key].number.max)\n }\n }\n\n if (typeof value !== 'undefined') localStorage[lsKeys[key]] = value\n else localStorage.removeItem(lsKeys[key])\n }\n\n swal({\n title: 'Woohoo!',\n text: 'Configuration saved into this browser.',\n icon: 'success'\n }).then(() => {\n window.location.reload()\n })\n })\n\n tabContent.appendChild(form)\n}\n\npage.getPrettyUploadAge = hours => {\n if (hours === 0) {\n return 'Permanent'\n } else if (hours < 1) {\n const minutes = hours * 60\n return `${minutes} minute${minutes === 1 ? '' : 's'}`\n } else if (hours >= 24) {\n const days = hours / 24\n return `${days} day${days === 1 ? '' : 's'}`\n } else {\n return `${hours} hour${hours === 1 ? '' : 's'}`\n }\n}\n\n// Handle image paste event\nwindow.addEventListener('paste', event => {\n const items = (event.clipboardData || event.originalEvent.clipboardData).items\n const index = Object.keys(items)\n for (let i = 0; i < index.length; i++) {\n const item = items[index[i]]\n if (item.kind === 'file') {\n const blob = item.getAsFile()\n /* eslint-disable-next-line compat/compat */\n const file = new File([blob], `pasted-image.${blob.type.match(/(?:[^/]*\\/)([^;]*)/)[1]}`, {\n type: blob.type\n })\n page.dropzone.addFile(file)\n }\n }\n})\n\nwindow.addEventListener('DOMContentLoaded', () => {\n if (window.cookieconsent) {\n window.cookieconsent.initialise({\n cookie: {\n name: 'cookieconsent_status',\n path: window.location.pathname,\n expiryDays: 730,\n secure: window.location.protocol === 'https:'\n },\n palette: {\n popup: {\n background: '#282828',\n text: '#eff0f1'\n },\n button: {\n background: '#209cee',\n text: '#ffffff'\n }\n },\n theme: 'classic',\n position: 'bottom-left',\n content: {\n message: 'We use cookies to offer you a better browsing experience and to analyze our traffic. You consent to our cookies if you continue to use this website.',\n dismiss: 'Got it!',\n link: 'Details in our Cookie Policy',\n href: 'cookiepolicy'\n }\n })\n }\n\n page.checkIfPublic()\n\n page.clipboardJS = new ClipboardJS('.clipboard-js')\n\n page.clipboardJS.on('success', () => {\n return swal('', 'The link has been copied to clipboard.', 'success', {\n buttons: false,\n timer: 1500\n })\n })\n\n page.clipboardJS.on('error', page.onError)\n\n page.lazyLoad = new LazyLoad({\n elements_selector: '.field.uploads img'\n })\n\n document.querySelector('#createAlbum').addEventListener('click', () => {\n page.createAlbum()\n })\n})\n"]} \ No newline at end of file +{"version":3,"sources":["home.js"],"names":["const","lsKeys","token","chunkSize","parallelUploads","uploadsHistoryOrder","previewImages","fileLength","uploadAge","stripTags","page","localStorage","apiChecked","private","enableUserAccounts","maxSize","chunkSizeConfig","temporaryUploadAges","fileIdentifierLength","stripTagsConfig","album","maxSizeBytes","urlMaxSize","urlMaxSizeBytes","tabs","activeTab","albumSelect","albumSelectOnChange","previewTemplate","dropzone","clipboardJS","lazyLoad","urlsQueue","activeUrlsQueue","imageExts","videoExts","albumTitleMaxLength","albumDescMaxLength","error","document","querySelector","classList","add","querySelectorAll","forEach","element","uploadButton","innerText","remove","addEventListener","window","location","reload","response","onAxiosError","onError","console","content","createElement","innerHTML","toString","swal","title","icon","cont","statusText","status","data","description","success","apiVersion","match","src","text","buttons","confirm","closeModal","then","axios","get","onDownloadProgress","render","done","do","newsfeed","version","checkClientVersion","parseInt","max","default","preparePage","catch","onInitError","verifyToken","prepareUpload","button","href","post","code","removeItem","authLink","setAttribute","value","prepareShareX","fetchAlbums","prepareUploadConfig","getPrettyBytes","prepareDropzone","uploadUrls","event","addUrlsToQueue","tabsContainer","loop","i","id","dataset","tabContent","setActiveTab","push","tab","length","index","let","headers","simple","Array","isArray","albums","option","name","appendChild","previewNode","parentNode","removeChild","tabDiv","div","className","previewsContainer","Dropzone","body","url","paramName","clickable","maxFilesize","uploadMultiple","createImageThumbnails","autoProcessQueue","chunking","Boolean","parallelChunkUploads","timeout","init","this","on","file","previewElement","xhr","ontimeout","instances","getUploadingFiles","filter","instance","_handleUploadError","_uplSpeedCalc","lastSent","timestamp","Date","now","bytes","upload","chunked","setRequestHeader","chunks","progress","prettyBytesPerSec","total","Math","size","percentage","bytesSent","toFixed","upl","prefix","skipProgress","last","totalChunkCount","chunkIndex","elapsed","bytesPerSec","fullSec","splice","excessDuration","duration","files","updateTemplate","err","Error","test","updateTemplateIcon","chunksUploaded","uuid","original","type","albumid","filelength","age","striptags","urls","split","trim","firstChild","processUrlsQueue","shiftQueue","initUrlUpload","finishedUrlUpload","shift","templateElement","iconClass","iconElement","link","a","clipboard","clipboardText","parentElement","exec","extname","toLowerCase","includes","img","onerror","currentTarget","update","expirydate","expiryDate","getPrettyDate","createAlbum","cancel","download","checked","public","selected","fallback","min","config","siBytes","label","select","help","valueHandler","ampmTime","display","number","round","undefined","disabled","force","video","suffix","uploadFields","stored","parseFloat","String","getPrettyUploadAge","isNaN","form","preventDefault","configKeys","Object","keys","key","conf","field","parsed","find","sel","control","opts","j","opt","join","tmp","submit","checkValidity","elements","hours","minutes","days","items","clipboardData","originalEvent","item","kind","blob","getAsFile","File","addFile","cookieconsent","initialise","cookie","path","pathname","expiryDays","secure","protocol","palette","popup","background","theme","position","message","dismiss","checkIfPublic","ClipboardJS","timer","LazyLoad","elements_selector"],"mappings":"AAEAA,IAAMC,OAAS,CACbC,MAAO,QACPC,UAAW,YACXC,gBAAiB,kBACjBC,oBAAqB,sBACrBC,cAAe,gBACfC,WAAY,aACZC,UAAW,YACXC,UAAW,aAGPC,KAAO,CAEXR,MAAOS,aAAaV,OAAOC,OAG3BU,YAAY,EACZC,QAAS,KACTC,mBAAoB,KACpBC,QAAS,KACTC,gBAAiB,KACjBC,oBAAqB,KACrBC,qBAAsB,KACtBC,gBAAiB,KAGjBC,MAAO,KAEPhB,gBAAiB,KACjBE,cAAe,KACfC,WAAY,KACZC,UAAW,KACXC,UAAW,KAEXY,aAAc,KACdC,WAAY,KACZC,gBAAiB,KACjBpB,UAAW,KAEXqB,KAAM,GACNC,UAAW,KACXC,YAAa,KACbC,oBAAqB,KACrBC,gBAAiB,KAEjBC,SAAU,KACVC,YAAa,KACbC,SAAU,KAGVC,UAAW,GACXC,gBAAiB,EAIjBC,UAAW,C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YAAY2H,GAAG,WAAS,WAC3B,OAAO5F,KAAK,GAAI,yCAA0C,UAAW,CACnEa,SAAS,EACT+O,MAAO,UAIX/S,KAAKoB,YAAY2H,GAAG,QAAS/I,KAAK6C,SAElC7C,KAAKqB,SAAW,IAAI2R,SAAS,CAC3BC,kBAAmB,uBAGrBpR,SAASC,cAAc,gBAAgBS,iBAAiB,SAAO,WAC7DvC,KAAKiO","file":"home.js","sourcesContent":["/* global swal, axios, Dropzone, ClipboardJS, LazyLoad */\n\nconst lsKeys = {\n token: 'token',\n chunkSize: 'chunkSize',\n parallelUploads: 'parallelUploads',\n uploadsHistoryOrder: 'uploadsHistoryOrder',\n previewImages: 'previewImages',\n fileLength: 'fileLength',\n uploadAge: 'uploadAge',\n stripTags: 'stripTags'\n}\n\nconst page = {\n // user token\n token: localStorage[lsKeys.token],\n\n // configs from api/check\n apiChecked: false,\n private: null,\n enableUserAccounts: null,\n maxSize: null,\n chunkSizeConfig: null,\n temporaryUploadAges: null,\n fileIdentifierLength: null,\n stripTagsConfig: null,\n\n // store album id that will be used with upload requests\n album: null,\n\n parallelUploads: null,\n previewImages: null,\n fileLength: null,\n uploadAge: null,\n stripTags: null,\n\n maxSizeBytes: null,\n urlMaxSize: null,\n urlMaxSizeBytes: null,\n chunkSize: null,\n\n tabs: [],\n activeTab: null,\n albumSelect: null,\n albumSelectOnChange: null,\n previewTemplate: null,\n\n dropzone: null,\n clipboardJS: null,\n lazyLoad: null,\n\n // additional vars for url uploads\n urlsQueue: [],\n activeUrlsQueue: 0,\n\n // Include BMP for uploads preview only, cause the real images will be used\n // Sharp isn't capable of making their thumbnails for dashboard and album public pages\n imageExts: ['.gif', '.jpeg', '.jpg', '.png', '.svg', '.tif', '.tiff', '.webp', '.bmp'],\n videoExts: ['.avi', '.m2ts', '.m4v', '.mkv', '.mov', '.mp4', '.webm', '.wmv'],\n\n albumTitleMaxLength: 70,\n albumDescMaxLength: 4000\n}\n\n// Handler for errors during initialization\npage.onInitError = error => {\n // Hide these elements\n document.querySelector('#albumDiv').classList.add('is-hidden')\n document.querySelector('#tabs').classList.add('is-hidden')\n document.querySelectorAll('.tab-content').forEach(element => {\n return element.classList.add('is-hidden')\n })\n\n // Update upload button\n const uploadButton = document.querySelector('#loginToUpload')\n uploadButton.innerText = 'An error occurred. Try to reload?'\n uploadButton.classList.remove('is-loading')\n uploadButton.classList.remove('is-hidden')\n\n uploadButton.addEventListener('click', () => {\n window.location.reload()\n })\n\n if (!error) return\n if (error.response) page.onAxiosError(error)\n else page.onError(error)\n}\n\n// Handler for regular JS errors\npage.onError = error => {\n console.error(error)\n\n const content = document.createElement('div')\n content.innerHTML = `\n

    ${error.toString()}

    \n

    Please check your console for more information.

    \n `\n return swal({\n title: 'An error occurred!',\n icon: 'error',\n content\n })\n}\n\n// Handler for Axios errors\npage.onAxiosError = (error, cont) => {\n if (!cont) console.error(error)\n\n // Better Cloudflare errors\n const cloudflareErrors = {\n 520: 'Unknown Error',\n 521: 'Web Server Is Down',\n 522: 'Connection Timed Out',\n 523: 'Origin Is Unreachable',\n 524: 'A Timeout Occurred',\n 525: 'SSL Handshake Failed',\n 526: 'Invalid SSL Certificate',\n 527: 'Railgun Error',\n 530: 'Origin DNS Error'\n }\n\n const statusText = cloudflareErrors[error.response.status] || error.response.statusText\n\n if (!cont) {\n const description = error.response.data && error.response.data.description\n ? error.response.data.description\n : 'There was an error with the request.\\nPlease check the console for more information.'\n return swal(`${error.response.status} ${statusText}`, description, 'error')\n } else if (error.response.data && error.response.data.description) {\n return error.response\n } else {\n const description = error.response\n ? `${error.response.status} ${statusText}`\n : error.toString()\n return { data: { success: false, description } }\n }\n}\n\npage.checkClientVersion = apiVersion => {\n const self = document.querySelector('#mainScript')\n const match = self.src.match(/\\?_=(\\d+)$/)\n if (match && match[1] && match[1] !== apiVersion) {\n return swal({\n title: 'Update detected!',\n text: 'Client assets have been updated. Reload to display the latest version?',\n icon: 'info',\n buttons: {\n confirm: {\n text: 'Reload',\n closeModal: false\n }\n }\n }).then(() => {\n window.location.reload()\n })\n }\n}\n\npage.checkIfPublic = () => {\n return axios.get('api/check', {\n onDownloadProgress: () => {\n // Only do render and/or newsfeed after this request has been initiated to avoid blocking\n /* global render */\n if (typeof render !== 'undefined' && !render.done) render.do()\n /* global newsfeed */\n if (typeof newsfeed !== 'undefined' && !newsfeed.done) newsfeed.do()\n if (!page.apiChecked) page.apiChecked = true\n }\n }).then(response => {\n if (response.data.version) {\n page.checkClientVersion(response.data.version)\n }\n\n page.private = response.data.private\n page.enableUserAccounts = response.data.enableUserAccounts\n\n page.maxSize = parseInt(response.data.maxSize)\n page.maxSizeBytes = page.maxSize * 1e6\n page.chunkSizeConfig = {\n max: (response.data.chunkSize && parseInt(response.data.chunkSize.max)) || 95,\n default: response.data.chunkSize && parseInt(response.data.chunkSize.default)\n }\n\n page.temporaryUploadAges = response.data.temporaryUploadAges\n page.fileIdentifierLength = response.data.fileIdentifierLength\n page.stripTagsConfig = response.data.stripTags\n\n return page.preparePage()\n }).catch(page.onInitError)\n}\n\npage.preparePage = () => {\n if (page.token) {\n return page.verifyToken(page.token)\n } else if (page.private) {\n const button = document.querySelector('#loginToUpload')\n button.href = 'auth'\n button.classList.remove('is-loading')\n if (page.enableUserAccounts) {\n button.innerText = 'Anonymous upload is disabled.\\nLog in or register to upload.'\n } else {\n button.innerText = 'Running in private mode.\\nLog in to upload.'\n }\n } else {\n return page.prepareUpload()\n }\n}\n\npage.verifyToken = token => {\n return axios.post('api/tokens/verify', { token }).then(response => {\n localStorage[lsKeys.token] = token\n page.token = token\n return page.prepareUpload()\n }).catch(error => {\n return swal({\n title: 'An error occurred!',\n text: error.response.data ? error.response.data.description : error.toString(),\n icon: 'error'\n }).then(() => {\n if (error.response.data && error.response.data.code === 10001) {\n localStorage.removeItem(lsKeys.token)\n window.location.reload()\n } else {\n page.onInitError()\n }\n })\n })\n}\n\npage.prepareUpload = () => {\n // I think this fits best here because we need to check for a valid token before we can get the albums\n if (page.token) {\n // Change /auth link to /dashboard\n const authLink = document.querySelector('#linksColumn a[href=\"auth\"]')\n if (authLink) authLink.setAttribute('href', 'dashboard')\n\n // Display the album selection\n document.querySelector('#albumDiv').classList.remove('is-hidden')\n\n page.albumSelect = document.querySelector('#albumSelect')\n page.albumSelectOnChange = () => {\n page.album = parseInt(page.albumSelect.value)\n // Re-generate ShareX config file\n if (typeof page.prepareShareX === 'function') page.prepareShareX()\n }\n page.albumSelect.addEventListener('change', page.albumSelectOnChange)\n\n // Fetch albums\n page.fetchAlbums()\n } else if (page.enableUserAccounts) {\n document.querySelector('#loginLinkText').innerHTML = 'Create an account and keep track of your uploads'\n }\n\n // Prepare & generate config tab\n page.prepareUploadConfig()\n\n // Update elements wherever applicable\n document.querySelector('#maxSize > span').innerHTML = page.getPrettyBytes(page.maxSizeBytes)\n document.querySelector('#loginToUpload').classList.add('is-hidden')\n\n // Prepare & generate files upload tab\n page.prepareDropzone()\n\n // Generate ShareX config file\n if (typeof page.prepareShareX === 'function') page.prepareShareX()\n\n // Prepare urls upload tab\n const urlMaxSize = document.querySelector('#urlMaxSize')\n if (urlMaxSize) {\n page.urlMaxSize = parseInt(urlMaxSize.innerHTML)\n page.urlMaxSizeBytes = page.urlMaxSize * 1e6\n urlMaxSize.innerHTML = page.getPrettyBytes(page.urlMaxSizeBytes)\n }\n\n const uploadUrls = document.querySelector('#uploadUrls')\n if (uploadUrls) {\n uploadUrls.addEventListener('click', event => {\n page.addUrlsToQueue()\n })\n }\n\n // Get all tabs\n const tabsContainer = document.querySelector('#tabs')\n const tabs = tabsContainer.querySelectorAll('li')\n for (let i = 0; i < tabs.length; i++) {\n const id = tabs[i].dataset.id\n const tabContent = document.querySelector(`#${id}`)\n if (!tabContent) continue\n\n tabs[i].addEventListener('click', () => {\n page.setActiveTab(i)\n })\n page.tabs.push({ tab: tabs[i], content: tabContent })\n }\n\n // Set first valid tab as the default active tab\n if (page.tabs.length) {\n page.setActiveTab(0)\n tabsContainer.classList.remove('is-hidden')\n }\n}\n\npage.setActiveTab = index => {\n for (let i = 0; i < page.tabs.length; i++) {\n if (i === index) {\n page.tabs[i].tab.classList.add('is-active')\n page.tabs[i].content.classList.remove('is-hidden')\n page.activeTab = index\n } else {\n page.tabs[i].tab.classList.remove('is-active')\n page.tabs[i].content.classList.add('is-hidden')\n }\n }\n}\n\npage.fetchAlbums = () => {\n return axios.get('api/albums', {\n headers: {\n simple: '1',\n token: page.token\n }\n }).then(response => {\n if (response.data.success === false) {\n return swal('An error occurred!', response.data.description, 'error')\n }\n\n // Create an option for each album\n if (Array.isArray(response.data.albums) && response.data.albums.length) {\n for (let i = 0; i < response.data.albums.length; i++) {\n const album = response.data.albums[i]\n const option = document.createElement('option')\n option.value = album.id\n option.innerHTML = album.name\n page.albumSelect.appendChild(option)\n }\n }\n }).catch(page.onInitError)\n}\n\npage.prepareDropzone = () => {\n // Parse template element\n const previewNode = document.querySelector('#tpl')\n page.previewTemplate = previewNode.innerHTML\n previewNode.parentNode.removeChild(previewNode)\n\n // Generate files upload tab\n const tabDiv = document.querySelector('#tab-files')\n const div = document.createElement('div')\n div.className = 'control is-expanded'\n div.innerHTML = `\n
    \n \n \n \n Click here or drag & drop files\n
    \n `\n tabDiv.querySelector('.dz-container').appendChild(div)\n\n const previewsContainer = tabDiv.querySelector('#tab-files .field.uploads')\n\n page.dropzone = new Dropzone(document.body, {\n url: 'api/upload',\n paramName: 'files[]',\n clickable: tabDiv.querySelector('#dropzone'),\n maxFilesize: page.maxSizeBytes / 1024 / 1024, // this option expects MiB\n parallelUploads: page.parallelUploads,\n uploadMultiple: false,\n previewsContainer,\n previewTemplate: page.previewTemplate,\n createImageThumbnails: false,\n autoProcessQueue: true,\n headers: { token: page.token },\n chunking: Boolean(page.chunkSize),\n chunkSize: page.chunkSize * 1e6, // this option expects Bytes\n parallelChunkUploads: false, // for now, enabling this breaks descriptive upload progress\n timeout: 0,\n\n init () {\n this.on('addedfile', file => {\n // Set active tab to file uploads, if necessary\n if (page.activeTab !== 0) page.setActiveTab(0)\n\n // Add file entry\n tabDiv.querySelector('.uploads').classList.remove('is-hidden')\n\n file.previewElement.querySelector('.name').innerHTML = file.name\n file.previewElement.querySelector('.descriptive-progress').innerHTML = 'Waiting in queue\\u2026'\n })\n\n this.on('sending', (file, xhr) => {\n // Add timeout listener (hacky method due to lack of built-in timeout handler)\n if (!xhr.ontimeout) {\n xhr.ontimeout = () => {\n const instances = page.dropzone.getUploadingFiles()\n .filter(instance => instance.xhr === xhr)\n page.dropzone._handleUploadError(instances, xhr, 'Connection timed out. Try to reduce upload chunk size.')\n }\n }\n\n // Attach necessary data for initial upload speed calculation\n if (typeof xhr._uplSpeedCalc === 'undefined') {\n xhr._uplSpeedCalc = {\n lastSent: 0,\n data: [{ timestamp: Date.now(), bytes: 0 }]\n }\n }\n\n // If not chunked uploads, add extra headers\n if (!file.upload.chunked) {\n if (page.album !== null) xhr.setRequestHeader('albumid', page.album)\n if (page.fileLength !== null) xhr.setRequestHeader('filelength', page.fileLength)\n if (page.uploadAge !== null) xhr.setRequestHeader('age', page.uploadAge)\n if (page.stripTags !== null) xhr.setRequestHeader('striptags', page.stripTags)\n }\n\n if (!file.upload.chunked) {\n file.previewElement.querySelector('.descriptive-progress').innerHTML = 'Uploading\\u2026'\n } else if (file.upload.chunks.length === 1) {\n file.previewElement.querySelector('.descriptive-progress').innerHTML = `Uploading chunk 1/${file.upload.totalChunkCount}\\u2026`\n }\n })\n\n // Update descriptive progress\n this.on('uploadprogress', (file, progress) => {\n // Total bytes will eventually be bigger than file size when chunked\n const total = Math.max(file.size, file.upload.total)\n const percentage = (file.upload.bytesSent / total * 100).toFixed(0)\n\n const upl = file.upload.chunked\n ? file.upload.chunks[file.upload.chunks.length - 1]\n : file.upload\n const xhr = upl.xhr || file.xhr\n\n let prefix = 'Uploading\\u2026'\n let skipProgress = false\n if (file.upload.chunked) {\n const done = upl.bytesSent === upl.total\n const last = file.upload.chunks.length === file.upload.totalChunkCount\n let chunkIndex = file.upload.chunks.length\n if (done && !last) {\n chunkIndex++\n skipProgress = true\n }\n prefix = `Uploading chunk ${chunkIndex}/${file.upload.totalChunkCount}\\u2026`\n }\n\n // Real-time upload speed calculation\n let prettyBytesPerSec\n if (!skipProgress) {\n const now = Date.now()\n const bytesSent = upl.bytesSent - xhr._uplSpeedCalc.lastSent\n\n // Push data of current iteration\n xhr._uplSpeedCalc.lastSent = upl.bytesSent\n xhr._uplSpeedCalc.data.push({ timestamp: now, bytes: bytesSent })\n\n // Wait till at least the 2nd iteration (3 data including initial data)\n const length = xhr._uplSpeedCalc.data.length\n if (length > 2) {\n // Calculate using data from all iterations\n let elapsed = 0\n let bytesPerSec = 0\n let fullSec = false\n let i = length - 1 // Always start with 2nd from last item\n while (i--) {\n // Splice data of unrequired iterations\n if (fullSec) {\n xhr._uplSpeedCalc.data.splice(i, 1)\n continue\n }\n // Sum data\n elapsed = now - xhr._uplSpeedCalc.data[i].timestamp\n if (elapsed > 1000) {\n const excessDuration = elapsed - 1000\n const newerIterationElapsed = now - xhr._uplSpeedCalc.data[i + 1].timestamp\n const duration = elapsed - newerIterationElapsed\n const fragment = (duration - excessDuration) / duration * xhr._uplSpeedCalc.data[i + 1].bytes\n bytesPerSec += fragment\n fullSec = true\n } else {\n bytesPerSec += xhr._uplSpeedCalc.data[i + 1].bytes\n }\n }\n\n // If not enough data\n if (!fullSec) bytesPerSec = 1000 / elapsed * bytesPerSec\n\n // Get pretty bytes\n prettyBytesPerSec = page.getPrettyBytes(bytesPerSec)\n }\n }\n\n file.previewElement.querySelector('.descriptive-progress').innerHTML =\n `${prefix} ${percentage}%${prettyBytesPerSec ? ` at ${prettyBytesPerSec}/s` : ''}`\n })\n\n this.on('success', (file, data) => {\n if (!data) return\n file.previewElement.querySelector('.descriptive-progress').classList.add('is-hidden')\n\n if (data.success === false) {\n file.previewElement.querySelector('.error').innerHTML = data.description\n file.previewElement.querySelector('.error').classList.remove('is-hidden')\n }\n\n if (Array.isArray(data.files) && data.files[0]) {\n page.updateTemplate(file, data.files[0])\n }\n })\n\n this.on('error', (file, error, xhr) => {\n let err = error\n if (typeof error === 'object' && error.description) {\n err = error.description\n } else if (xhr) {\n // Formatting the Object is necessary since the function expect Axios errors\n err = page.onAxiosError({\n response: {\n status: xhr.status,\n statusText: xhr.statusText\n }\n }, true).data.description\n } else if (error instanceof Error) {\n err = error.toString()\n }\n\n // Clean up file size errors\n if (/^File is too big/.test(err) || /File too large/.test(err)) {\n err = `File too large (${page.getPrettyBytes(file.size)}).`\n }\n\n file.previewElement.querySelector('.descriptive-progress').classList.add('is-hidden')\n\n file.previewElement.querySelector('.error').innerHTML = err\n file.previewElement.querySelector('.error').classList.remove('is-hidden')\n\n page.updateTemplateIcon(file.previewElement, 'icon-block')\n })\n },\n\n chunksUploaded (file, done) {\n file.previewElement.querySelector('.descriptive-progress').innerHTML =\n `Rebuilding ${file.upload.totalChunkCount} chunks\\u2026`\n\n return axios.post('api/upload/finishchunks', {\n // This API supports an array of multiple files\n files: [{\n uuid: file.upload.uuid,\n original: file.name,\n type: file.type,\n albumid: page.album,\n filelength: page.fileLength,\n age: page.uploadAge\n }]\n }, {\n headers: {\n token: page.token,\n // Unlike the options above (e.g. albumid, filelength, etc.),\n // strip tags cannot yet be configured per file with this API\n striptags: page.stripTags\n }\n }).catch(error => page.onAxiosError(error, true)).then(response => {\n file.previewElement.querySelector('.descriptive-progress').classList.add('is-hidden')\n\n if (response.data.success === false) {\n file.previewElement.querySelector('.error').innerHTML = response.data.description\n file.previewElement.querySelector('.error').classList.remove('is-hidden')\n\n page.updateTemplateIcon(file.previewElement, 'icon-block')\n }\n\n if (response.data.files && response.data.files[0]) {\n page.updateTemplate(file, response.data.files[0])\n }\n\n return done()\n })\n }\n })\n}\n\npage.addUrlsToQueue = () => {\n const urls = document.querySelector('#urls').value\n .split(/\\r?\\n/)\n .filter(url => {\n return url.trim().length\n })\n\n if (!urls.length) {\n return swal('An error occurred!', 'You have not entered any URLs.', 'error')\n }\n\n const tabDiv = document.querySelector('#tab-urls')\n tabDiv.querySelector('.uploads').classList.remove('is-hidden')\n\n for (let i = 0; i < urls.length; i++) {\n const previewTemplate = document.createElement('template')\n previewTemplate.innerHTML = page.previewTemplate.trim()\n\n const previewElement = previewTemplate.content.firstChild\n previewElement.querySelector('.name').innerHTML = urls[i]\n previewElement.querySelector('.descriptive-progress').innerHTML = 'Waiting in queue\\u2026'\n\n const previewsContainer = tabDiv.querySelector('.uploads')\n previewsContainer.appendChild(previewElement)\n\n page.urlsQueue.push({\n url: urls[i],\n previewElement\n })\n }\n\n page.processUrlsQueue()\n document.querySelector('#urls').value = ''\n}\n\npage.processUrlsQueue = () => {\n if (!page.urlsQueue.length) return\n\n function finishedUrlUpload (file, data) {\n file.previewElement.querySelector('.descriptive-progress').classList.add('is-hidden')\n\n if (data.success === false) {\n const match = data.description.match(/ over limit: (\\d+)$/)\n if (match && match[1]) {\n data.description = `File exceeded limit of ${page.getPrettyBytes(match[1])}.`\n }\n\n file.previewElement.querySelector('.error').innerHTML = data.description\n file.previewElement.querySelector('.error').classList.remove('is-hidden')\n\n page.updateTemplateIcon(file.previewElement, 'icon-block')\n }\n\n if (Array.isArray(data.files) && data.files[0]) {\n page.updateTemplate(file, data.files[0])\n }\n\n page.activeUrlsQueue--\n return shiftQueue()\n }\n\n function initUrlUpload (file) {\n file.previewElement.querySelector('.descriptive-progress').innerHTML =\n 'Waiting for server to fetch URL\\u2026'\n\n return axios.post('api/upload', {\n urls: [file.url]\n }, {\n headers: {\n token: page.token,\n albumid: page.album,\n age: page.uploadAge,\n filelength: page.fileLength\n }\n }).catch(error => page.onAxiosError(error, true)).then(response => {\n return finishedUrlUpload(file, response.data)\n })\n }\n\n function shiftQueue () {\n while (page.urlsQueue.length && (page.activeUrlsQueue < page.parallelUploads)) {\n page.activeUrlsQueue++\n initUrlUpload(page.urlsQueue.shift())\n }\n }\n\n return shiftQueue()\n}\n\npage.updateTemplateIcon = (templateElement, iconClass) => {\n const iconElement = templateElement.querySelector('.icon')\n if (!iconElement) return\n\n iconElement.classList.add(iconClass)\n iconElement.classList.remove('is-hidden')\n}\n\npage.updateTemplate = (file, response) => {\n if (!response.url) return\n\n const link = file.previewElement.querySelector('.link')\n const a = link.querySelector('a')\n const clipboard = file.previewElement.querySelector('.clipboard-mobile > .clipboard-js')\n a.href = a.innerHTML = clipboard.dataset.clipboardText = response.url\n\n link.classList.remove('is-hidden')\n clipboard.parentElement.classList.remove('is-hidden')\n\n const exec = /.[\\w]+$/.exec(response.url)\n const extname = exec && exec[0]\n ? exec[0].toLowerCase()\n : null\n\n if (page.imageExts.includes(extname)) {\n if (page.previewImages) {\n const img = file.previewElement.querySelector('img')\n img.setAttribute('alt', response.name || '')\n img.dataset.src = response.url\n img.classList.remove('is-hidden')\n img.onerror = event => {\n // Hide image elements that fail to load\n // Consequently include WEBP in browsers that do not have WEBP support (e.g. IE)\n event.currentTarget.classList.add('is-hidden')\n page.updateTemplateIcon(file.previewElement, 'icon-picture')\n }\n page.lazyLoad.update(file.previewElement.querySelectorAll('img'))\n } else {\n page.updateTemplateIcon(file.previewElement, 'icon-picture')\n }\n } else if (page.videoExts.includes(extname)) {\n page.updateTemplateIcon(file.previewElement, 'icon-video')\n } else {\n page.updateTemplateIcon(file.previewElement, 'icon-doc-inv')\n }\n\n if (response.expirydate) {\n const expiryDate = file.previewElement.querySelector('.expiry-date')\n expiryDate.dataset.timestamp = response.expirydate\n expiryDate.innerHTML = `EXP: ${page.getPrettyDate(new Date(response.expirydate * 1000))}`\n expiryDate.classList.remove('is-hidden')\n }\n}\n\npage.createAlbum = () => {\n const div = document.createElement('div')\n div.innerHTML = `\n
    \n
    \n \n
    \n

    Max length is ${page.albumTitleMaxLength} characters.

    \n
    \n
    \n
    \n \n
    \n

    Max length is ${page.albumDescMaxLength} characters.

    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n `\n\n swal({\n title: 'Create new album',\n icon: 'info',\n content: div,\n buttons: {\n cancel: true,\n confirm: {\n closeModal: false\n }\n }\n }).then(value => {\n if (!value) return\n\n const name = document.querySelector('#swalName').value.trim()\n axios.post('api/albums', {\n name,\n description: document.querySelector('#swalDescription').value.trim(),\n download: document.querySelector('#swalDownload').checked,\n public: document.querySelector('#swalPublic').checked\n }, {\n headers: {\n token: page.token\n }\n }).then(response => {\n if (response.data.success === false) {\n return swal('An error occurred!', response.data.description, 'error')\n }\n\n const option = document.createElement('option')\n page.albumSelect.appendChild(option)\n option.value = response.data.id\n option.innerHTML = name\n option.selected = true\n page.albumSelectOnChange()\n\n swal('Woohoo!', 'Album was created successfully.', 'success')\n }).catch(page.onError)\n })\n}\n\npage.prepareUploadConfig = () => {\n // This object should only be used to set fallback values for page[key]\n // (essentially for page[key] properties that explicitly need to be set as something)\n // As for default values in the Config tab (which will not set page[key]),\n // check out number.default property of each config\n const fallback = {\n chunkSize: page.chunkSizeConfig.default,\n parallelUploads: 2\n }\n\n const temporaryUploadAges = Array.isArray(page.temporaryUploadAges) &&\n page.temporaryUploadAges.length\n const fileIdentifierLength = page.fileIdentifierLength &&\n typeof page.fileIdentifierLength.min === 'number' &&\n typeof page.fileIdentifierLength.max === 'number'\n\n const config = {\n siBytes: {\n label: 'File size display',\n select: [\n { value: 'default', text: '1000 B = 1 kB = 1 Kilobyte' },\n { value: '0', text: '1024 B = 1 KiB = 1 Kibibyte' }\n ],\n help: 'This will be used in our homepage, dashboard, and album public pages.',\n valueHandler () {} // Do nothing\n },\n ampmTime: {\n label: 'Show AM/PM on date',\n select: [\n { value: 'default', text: 'No' },\n { value: '1', text: 'Yes' }\n ],\n help: 'This will be used in our homepage and dashboard.',\n valueHandler () {} // Do nothing\n },\n fileLength: {\n display: fileIdentifierLength,\n label: 'File identifier length',\n number: fileIdentifierLength\n ? {\n min: page.fileIdentifierLength.min,\n max: page.fileIdentifierLength.max,\n default: page.fileIdentifierLength.default,\n round: true\n }\n : undefined,\n help: true, // true means auto-generated, for number-based configs only\n disabled: fileIdentifierLength && page.fileIdentifierLength.force\n },\n uploadAge: {\n display: temporaryUploadAges,\n label: 'Upload age',\n select: [],\n help: 'Whether to automatically delete your uploads after a certain amount of time.'\n },\n stripTags: {\n display: page.stripTagsConfig,\n label: 'Strip tags',\n select: page.stripTagsConfig\n ? [\n { value: page.stripTagsConfig.default ? 'default' : '1', text: 'Yes' },\n { value: page.stripTagsConfig.default ? '0' : 'default', text: 'No' }\n ]\n : null,\n help: `Whether to strip tags (e.g. EXIF) from your uploads.
    \n This only applies to regular image${page.stripTagsConfig && page.stripTagsConfig.video ? ' and video' : ''} uploads (i.e. not URL uploads).`,\n disabled: page.stripTagsConfig && page.stripTagsConfig.force\n },\n chunkSize: {\n display: Boolean(page.chunkSizeConfig.default),\n label: 'Upload chunk size (MB)',\n number: {\n min: 1,\n max: page.chunkSizeConfig.max,\n default: fallback.chunkSize,\n suffix: ' MB',\n round: true\n },\n help: true\n },\n parallelUploads: {\n label: 'Parallel uploads',\n number: {\n min: 1,\n max: 10,\n default: fallback.parallelUploads,\n round: true\n },\n help: true\n },\n uploadsHistoryOrder: {\n label: 'Uploads history order',\n select: [\n { value: 'default', text: 'Older files on top' },\n { value: '0', text: 'Newer files on top' }\n ],\n help: `\"Newer files on top\" will use a CSS technique, which unfortunately come with some undesirable side effects.
    \n This also affects text selection, such as when trying to select text from top to bottom will result in them being selected from bottom to top instead, and vice versa.`,\n valueHandler (value) {\n if (value === '0') {\n const uploadFields = document.querySelectorAll('.tab-content > .uploads')\n for (let i = 0; i < uploadFields.length; i++) {\n uploadFields[i].classList.add('is-reversed')\n }\n }\n }\n },\n previewImages: {\n label: 'Load images for preview',\n select: [\n { value: 'default', text: 'Yes' },\n { value: '0', text: 'No' }\n ],\n help: 'By default, uploaded images will be loaded as their previews.',\n valueHandler (value) {\n page.previewImages = value !== '0'\n }\n }\n }\n\n if (temporaryUploadAges) {\n const stored = parseFloat(localStorage[lsKeys.uploadAge])\n for (let i = 0; i < page.temporaryUploadAges.length; i++) {\n const age = page.temporaryUploadAges[i]\n config.uploadAge.select.push({\n value: i === 0 ? 'default' : String(age),\n text: page.getPrettyUploadAge(age)\n })\n if (age === stored) {\n config.uploadAge.value = stored\n }\n }\n }\n\n if (fileIdentifierLength) {\n const stored = parseInt(localStorage[lsKeys.fileLength])\n if (!page.fileIdentifierLength.force &&\n !isNaN(stored) &&\n stored >= page.fileIdentifierLength.min &&\n stored <= page.fileIdentifierLength.max) {\n config.fileLength.value = stored\n }\n }\n\n const tabContent = document.querySelector('#tab-config')\n const form = document.createElement('form')\n form.addEventListener('submit', event => event.preventDefault())\n\n const configKeys = Object.keys(config)\n for (let i = 0; i < configKeys.length; i++) {\n const key = configKeys[i]\n const conf = config[key]\n\n // Skip only if display attribute is explicitly set to false\n if (conf.display === false) continue\n\n const field = document.createElement('div')\n field.className = 'field'\n\n let value\n if (!conf.disabled) {\n if (typeof conf.value !== 'undefined') {\n value = conf.value\n } else if (typeof conf.number !== 'undefined') {\n const parsed = parseInt(localStorage[lsKeys[key]])\n if (!isNaN(parsed) && parsed <= conf.number.max && parsed >= conf.number.min) {\n value = parsed\n }\n } else {\n const stored = localStorage[lsKeys[key]]\n if (Array.isArray(conf.select)) {\n value = conf.select.find(sel => sel.value === stored)\n ? stored\n : undefined\n } else {\n value = stored\n }\n }\n\n // If valueHandler function exists, defer to the function,\n // otherwise pass value to global page object\n if (typeof conf.valueHandler === 'function') {\n conf.valueHandler(value)\n } else if (typeof value !== 'undefined') {\n page[key] = value\n } else if (typeof fallback[key] !== 'undefined') {\n page[key] = fallback[key]\n }\n }\n\n let control\n if (Array.isArray(conf.select)) {\n control = document.createElement('div')\n control.className = 'select is-fullwidth'\n\n const opts = []\n for (let j = 0; j < conf.select.length; j++) {\n const opt = conf.select[j]\n const selected = (value && (opt.value === String(value))) ||\n (typeof value === 'undefined' && opt.value === 'default')\n opts.push(`\n \n `)\n }\n\n control.innerHTML = `\n \n `\n } else if (conf.number) {\n control = document.createElement('input')\n control.id = control.name = key\n control.className = 'input is-fullwidth'\n control.type = 'number'\n\n if (typeof conf.number.min !== 'undefined') control.min = conf.number.min\n if (typeof conf.number.max !== 'undefined') control.max = conf.number.max\n if (typeof value === 'number') control.value = value\n else if (typeof conf.number.default !== 'undefined') control.value = conf.number.default\n }\n\n let help\n if (conf.disabled) {\n if (Array.isArray(conf.select)) {\n control.querySelector('select').disabled = conf.disabled\n } else {\n control.disabled = conf.disabled\n }\n help = 'This option is currently not configurable.'\n } else if (typeof conf.help === 'string') {\n help = conf.help\n } else if (conf.help === true && typeof conf.number !== 'undefined') {\n const tmp = []\n\n if (typeof conf.number.default !== 'undefined') {\n tmp.push(`Default is ${conf.number.default}${conf.number.suffix || ''}.`)\n }\n if (typeof conf.number.min !== 'undefined') {\n tmp.push(`Min is ${conf.number.min}${conf.number.suffix || ''}.`)\n }\n if (typeof conf.number.max !== 'undefined') {\n tmp.push(`Max is ${conf.number.max}${conf.number.suffix || ''}.`)\n }\n\n help = tmp.join(' ')\n }\n\n field.innerHTML = `\n \n
    \n ${help ? `

    ${help}

    ` : ''}\n `\n field.querySelector('div.control').appendChild(control)\n\n form.appendChild(field)\n }\n\n const submit = document.createElement('div')\n submit.className = 'field'\n submit.innerHTML = `\n

    \n \n

    \n

    \n This configuration will only be used in this browser.
    \n After reloading the page, some of them will also be applied to the ShareX config that you can download by clicking on the ShareX icon below.\n

    \n `\n\n form.appendChild(submit)\n form.querySelector('#saveConfig').addEventListener('click', () => {\n if (!form.checkValidity()) return\n\n const keys = Object.keys(config)\n .filter(key => config[key].display !== false && config[key].disabled !== true)\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i]\n\n let value\n if (typeof config[key].select !== 'undefined') {\n if (form.elements[key].value !== 'default') {\n value = form.elements[key].value\n }\n } else if (typeof config[key].number !== 'undefined') {\n const parsed = parseInt(form.elements[key].value)\n if (!isNaN(parsed) && parsed !== config[key].number.default) {\n value = Math.min(Math.max(parsed, config[key].number.min), config[key].number.max)\n }\n }\n\n if (typeof value !== 'undefined') localStorage[lsKeys[key]] = value\n else localStorage.removeItem(lsKeys[key])\n }\n\n swal({\n title: 'Woohoo!',\n text: 'Configuration saved into this browser.',\n icon: 'success'\n }).then(() => {\n window.location.reload()\n })\n })\n\n tabContent.appendChild(form)\n}\n\npage.getPrettyUploadAge = hours => {\n if (hours === 0) {\n return 'Permanent'\n } else if (hours < 1) {\n const minutes = hours * 60\n return `${minutes} minute${minutes === 1 ? '' : 's'}`\n } else if (hours >= 24) {\n const days = hours / 24\n return `${days} day${days === 1 ? '' : 's'}`\n } else {\n return `${hours} hour${hours === 1 ? '' : 's'}`\n }\n}\n\n// Handle image paste event\nwindow.addEventListener('paste', event => {\n const items = (event.clipboardData || event.originalEvent.clipboardData).items\n const index = Object.keys(items)\n for (let i = 0; i < index.length; i++) {\n const item = items[index[i]]\n if (item.kind === 'file') {\n const blob = item.getAsFile()\n /* eslint-disable-next-line compat/compat */\n const file = new File([blob], `pasted-image.${blob.type.match(/(?:[^/]*\\/)([^;]*)/)[1]}`, {\n type: blob.type\n })\n page.dropzone.addFile(file)\n }\n }\n})\n\nwindow.addEventListener('DOMContentLoaded', () => {\n if (window.cookieconsent) {\n window.cookieconsent.initialise({\n cookie: {\n name: 'cookieconsent_status',\n path: window.location.pathname,\n expiryDays: 730,\n secure: window.location.protocol === 'https:'\n },\n palette: {\n popup: {\n background: '#282828',\n text: '#eff0f1'\n },\n button: {\n background: '#209cee',\n text: '#ffffff'\n }\n },\n theme: 'classic',\n position: 'bottom-left',\n content: {\n message: 'We use cookies to offer you a better browsing experience and to analyze our traffic. You consent to our cookies if you continue to use this website.',\n dismiss: 'Got it!',\n link: 'Details in our Cookie Policy',\n href: 'cookiepolicy'\n }\n })\n }\n\n page.checkIfPublic()\n\n page.clipboardJS = new ClipboardJS('.clipboard-js')\n\n page.clipboardJS.on('success', () => {\n return swal('', 'The link has been copied to clipboard.', 'success', {\n buttons: false,\n timer: 1500\n })\n })\n\n page.clipboardJS.on('error', page.onError)\n\n page.lazyLoad = new LazyLoad({\n elements_selector: '.field.uploads img'\n })\n\n document.querySelector('#createAlbum').addEventListener('click', () => {\n page.createAlbum()\n })\n})\n"]} \ No newline at end of file diff --git a/src/versions.json b/src/versions.json index bd09e0597..b79287daf 100644 --- a/src/versions.json +++ b/src/versions.json @@ -1,5 +1,5 @@ { - "1": "1651844975", + "1": "1651849175", "2": "1602515119", "3": "1650485321", "4": "1602515119",