\n Time taken: '+a.data.hrtime[0]+"s "+Math.ceil(a.data.hrtime[1]/1e6)+"ms.\n
\n diff --git a/dist/js/auth.js b/dist/js/auth.js index c2ae32e..b867106 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,cloudflareErrors:{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"},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){var r=page.cloudflareErrors[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()})); +var lsKeys={token:"token"},page={token:localStorage[lsKeys.token],user:null,pass:null,cloudflareErrors:{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"},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")},onError:function(e){console.error(e);var r=document.createElement("div");return r.innerHTML="\n
"+e.toString()+"
Please check your console for more information.
\n ",swal({title:"An error occurred!",icon:"error",content:r})},onAxiosError:function(e){if(!e.response)return page.onError(e);var r=page.cloudflareErrors[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 eb96862..dc3f682 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","cloudflareErrors","loaderSection","document","querySelector","classList","add","loginSection","remove","floatingBtn","error","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,KAGNC,iBAAkB,CAChB,IAAK,gBACL,IAAK,qBACL,IAAK,uBACL,IAAK,wBACL,IAAK,qBACL,IAAK,uBACL,IAAK,0BACL,IAAK,gBACL,IAAK,oBAITJ,OAAW,WACTH,IAAMQ,EAAgBC,SAASC,cAAc,WACzCF,GAAeA,EAAcG,UAAUC,IAAI,aAE/CZ,IAAMa,EAAeJ,SAASC,cAAc,oBACxCG,GAAcA,EAAaF,UAAUG,OAAO,aAEhDd,IAAMe,EAAcN,SAASC,cAAc,mCACvCK,GAAaA,EAAYJ,UAAUG,OAAO,YAChD,EAGAX,aAAiB,SAAGa,GAClBhB,IAAMiB,EAAad,KAAKI,iBAAiBS,EAAME,SAASC,SAAWH,EAAME,SAASD,WAC5EG,EAAcJ,EAAME,SAASG,MAAQL,EAAME,SAASG,K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+B,EAAKD,iBAAiB,UAAQ,SAAEE,GAC9BA,EAAMC,gBACR,IAEA3C,IAAM4C,EAAWnC,SAASC,cAAc,aACpCkC,GACFA,EAASJ,iBAAiB,SAAO,SAAEE,GAC5BD,EAAKI,iBACV1C,KAAK2C,GAAG,QAASJ,EAAMK,cACzB,IAGF/C,IAAMgD,EAAcvC,SAASC,cAAc,gBACvCsC,GACFA,EAAYR,iBAAiB,SAAO,SAAEE,GACpC,IAAKD,EAAKI,gBAER,OAAOD,EAASK,QAElB9C,KAAK2C,GAAG,WAAYJ,EAAMK,cAC5B,IAGE5C,KAAKD,MAAOC,KAAK+C,SAChB/C,KAAKkC,QACZ","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 // Better Cloudflare errors\n 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\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 const statusText = page.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 +{"version":3,"sources":["auth.js"],"names":["const","lsKeys","token","page","localStorage","user","pass","cloudflareErrors","loaderSection","document","querySelector","classList","add","loginSection","remove","floatingBtn","error","console","content","createElement","innerHTML","toString","swal","title","icon","response","onError","statusText","status","description","data","dest","trigger","value","trim","axios","post","username","password","then","success","window","location","catch","onAxiosError","unhide","code","removeItem","addEventListener","form","event","preventDefault","lo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QAElBtD,KAAKmD,GAAG,WAAYJ,EAAMK,cAF5B,IAMEpD,KAAKD,MAAOC,KAAKuD,SAChBvD,KAAK0C,QAFZ","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 // Better Cloudflare errors\n 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\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 regular JS errors\npage.onError = error => {\n console.error(error)\n\n const content = document.createElement('div')\n content.innerHTML = `\n${error.toString()}
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 if (!error.response) {\n return page.onError(error)\n }\n\n const statusText = page.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 fc54297..c80a107 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,cloudflareErrors:{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"},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()+"
Please check your console for more information.
\n ",swal({title:"An error occurred!",icon:"error",content:a})},onAxiosError:function(e){var a=page.cloudflareErrors[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 page.onAxiosError(e).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'+y.name+"
\n "+(m?''+y.original+"
":"")+'\n'+(y.appendix?""+y.appendix+" – ":"")+y.prettyBytes+"
\n "+(b&&y.prettyExpiryDate?'EXP: "+y.prettyExpiryDate+"
":"")+"\n\n | File name | \n '+(m?'Original name | ':"")+"\n "+(void 0===e.album?'User':'albumid">Album')+" | ":"")+"\n "+(x?'Album | ':"")+'\nSize | \n '+(e.all?'IP | ':"")+'\nUpload date | \n '+(b?'Expiry date | ':"")+'\n('+a.data.count+' total) | \n
---|
\n
\n \n
':"")+"\n\"
).\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,"You won't be able to recover "+t.replace(/^(\d*)(.*)/,"$1$2")+"!
";e.all&&(n+="\nWarning: 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.lengthYou are about to add '+t+" upload"+(1===t?"":"s")+' to an album.
\nIf an upload is already in an album, it will be moved.
\n \n\n | ID | \nName | \n '+(e.all?"User | ":"")+'\nUploads | \nSize | \nCreated at | \nZIP size | \nZIP generated at | \nPublic link | \n('+a.data.count+' total) | \n
---|
Max length is '+page.albumTitleMaxLength+' characters.
\nMarkdown supported. Max length is '+page.albumDescMaxLength+" characters.
\nSave changes then re-open this Edit prompt to refresh this preview.
\nCurrent public link: '+t+"
\n\n | Username | \nUploads | \nUsage | \nGroup | \nRegistration date | \nLast token update | \n('+a.data.count+' total) | \n
---|
Username: "+e.data.username+"
\nPassword: "+e.data.password+"
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='\nUser ID: '+e+'
\n"+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+"
"+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="\nYou will be disabling a user named "+page.cache[e].username+".
\nTheir 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="\nYou 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[s]+" | \n\n |
---|
Please check your console for more information.
\n ",swal({title:"An error occurred!",icon:"error",content:a})},onAxiosError:function(e){if(!e.response)return page.onError(e);var a=page.cloudflareErrors[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 page.onAxiosError(e).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'+k.name+"
\n "+(h?''+k.original+"
":"")+'\n'+x+k.prettyBytes+"
\n "+(b&&k.prettyExpiryDate?'EXP: "+k.prettyExpiryDate+"
":"")+"\n\n | File name | \n '+(h?'Original name | ':"")+"\n "+(e.all?'User | ':"")+"\n "+(!e.all||m?'Album | ':"")+'\nSize | \n '+(e.all?'IP | ':"")+'\nUpload date | \n '+(b?'Expiry date | ':"")+'\n('+a.data.count+' total) | \n
---|
\n
\n \n
':"")+"\n\"
).\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,"You won't be able to recover "+t.replace(/^(\d*)(.*)/,"$1$2")+"!
";e.all&&(n+="\nWarning: 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.lengthYou are about to add '+t+" upload"+(1===t?"":"s")+' to an album.
\nIf an upload is already in an album, it will be moved.
\n \n\n | ID | \nName | \n '+(e.all?"User | ":"")+'\nUploads | \nSize | \nCreated at | \nZIP size | \nZIP generated at | \nPublic link | \n('+a.data.count+' total) | \n
---|
Max length is '+page.albumTitleMaxLength+' characters.
\nMarkdown supported. Max length is '+page.albumDescMaxLength+" characters.
\nSave changes then re-open this Edit prompt to refresh this preview.
\nCurrent public link: '+t+"
\n\n | Username | \nUploads | \nUsage | \nGroup | \nRegistration date | \nLast token update | \n('+a.data.count+' total) | \n
---|
Username: "+e.data.username+"
\nPassword: "+e.data.password+"
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='\nUser ID: '+e+'
\n"+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+"
"+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="\nYou will be disabling a user named "+page.cache[e].username+".
\nTheir 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="\nYou 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[s]+" | \n\n |
---|
${error.toString()}
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 const statusText = page.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 page.onAxiosError(error).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 assume 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 uploadsPerPage = response.data.uploadsPerPage || 25\n const pages = Math.ceil(response.data.count / uploadsPerPage)\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) {\n params.pageNum = Math.max(0, pages + params.pageNum)\n }\n const pagination = page.paginate(response.data.count, uploadsPerPage, params.pageNum)\n\n const filter = `\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 | File name | \n ${showOriginalNames ? 'Original name | ' : ''}\n ${typeof params.album === 'undefined' ? `User' : 'albumid\">Album'} | ` : ''}\n ${allAlbums ? 'Album | ' : ''}\nSize | \n ${params.all ? 'IP | ' : ''}\nUpload date | \n ${hasExpiryDateColumn ? 'Expiry date | ' : ''}\n(${response.data.count} total) | \n
---|
\n
\n \n
`\n : ''}\n\"
).\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, '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 += `\\nWarning: 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 = `\nYou are about to add ${count} upload${count === 1 ? '' : 's'} to an album.
\nIf an upload is already in an album, it will be moved.
\n\n | ID | \nName | \n ${params.all ? 'User | ' : ''}\nUploads | \nSize | \nCreated at | \nZIP size | \nZIP generated at | \nPublic link | \n(${response.data.count} total) | \n
---|
Max length is ${page.albumTitleMaxLength} characters.
\nMarkdown supported. Max length is ${page.albumDescMaxLength} characters.
\nSave changes then re-open this Edit prompt to refresh this preview.
\nCurrent public link: ${albumUrlText}
\n\n | Username | \nUploads | \nUsage | \nGroup | \nRegistration date | \nLast token update | \n(${response.data.count} total) | \n
---|
Username: ${response.data.username}
\nPassword: ${response.data.password}
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 = `\nUser ID: ${id}
\n${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}
${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 = `\nYou will be disabling a user named ${page.cache[id].username}.
\nTheir 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 = `\nYou 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/03cac0fb8af3a759bc1220bd3c011b67dbc5e909/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 += `${keys[i]} | \n\n |
---|
${error.toString()}
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 if (!error.response) {\n return page.onError(error)\n }\n\n const statusText = page.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 page.onAxiosError(error).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 assume 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 uploadsPerPage = response.data.uploadsPerPage || 25\n const pages = Math.ceil(response.data.count / uploadsPerPage)\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) {\n params.pageNum = Math.max(0, pages + params.pageNum)\n }\n const pagination = page.paginate(response.data.count, uploadsPerPage, params.pageNum)\n\n const filter = `\n${upload.name}
\n ${showOriginalNames ? `${upload.original}
` : ''}\n${appendix}${upload.prettyBytes}
\n ${hasExpiryDateColumn && upload.prettyExpiryDate\n ? `EXP: ${upload.prettyExpiryDate}
`\n : ''}\n\n | File name | \n ${showOriginalNames ? 'Original name | ' : ''}\n ${params.all ? 'User | ' : ''}\n ${!params.all || filterAllByAlbums ? 'Album | ' : ''}\nSize | \n ${params.all ? 'IP | ' : ''}\nUpload date | \n ${hasExpiryDateColumn ? 'Expiry date | ' : ''}\n(${response.data.count} total) | \n
---|
\n
\n \n
`\n : ''}\n\"
).\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, '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 += `\\nWarning: 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 = `\nYou are about to add ${count} upload${count === 1 ? '' : 's'} to an album.
\nIf an upload is already in an album, it will be moved.
\n\n | ID | \nName | \n ${params.all ? 'User | ' : ''}\nUploads | \nSize | \nCreated at | \nZIP size | \nZIP generated at | \nPublic link | \n(${response.data.count} total) | \n
---|
Max length is ${page.albumTitleMaxLength} characters.
\nMarkdown supported. Max length is ${page.albumDescMaxLength} characters.
\nSave changes then re-open this Edit prompt to refresh this preview.
\nCurrent public link: ${albumUrlText}
\n\n | Username | \nUploads | \nUsage | \nGroup | \nRegistration date | \nLast token update | \n(${response.data.count} total) | \n
---|
Username: ${response.data.username}
\nPassword: ${response.data.password}
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 = `\nUser ID: ${id}
\n${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}
${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 = `\nYou will be disabling a user named ${page.cache[id].username}.
\nTheir 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 = `\nYou 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/03cac0fb8af3a759bc1220bd3c011b67dbc5e909/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 += `${keys[i]} | \n\n |
---|
An error occurred!
\n"+e.toString()+"
Please check your console for more information.
\n ")},onAxiosError:function(e){var t=page.cloudflareErrors[e.response.status]||e.response.statusText,a=e.response.data&&e.response.data.description?e.response.data.description:"";page.updateMessageBody("\n"+e.response.status+" "+t+"
\n"+a+"
\n ")},deleteFile:function(){if(page.file){var e=document.createElement("div");e.innerHTML="You won't be able to recover this file!
",swal({title:"Are you sure?",content:e,icon:"warning",dangerMode:!0,buttons:{cancel:!0,confirm:{text:"Yes, nuke it!",closeModal:!1}}}).then((function(e){e&&axios.post("../api/upload/delete",{id:page.file.id}).then((function(e){if(e){if(!1===e.data.success)return swal("An error occurred!",e.data.description,"error");(Array.isArray(e.data.failed)?e.data.failed:[]).length?swal("An error occurred!","Unable to delete this file.","error"):swal("Deleted!","This file has been deleted.","success",{buttons:!1})}})).catch(page.onAxiosError)}))}},loadFileinfo:function(){page.urlIdentifier&&axios.get("../api/upload/get/"+page.urlIdentifier).then((function(e){if(![200,304].includes(e.status))return page.onAxiosError(e);page.file=e.data.file,page.titleFormat&&(document.title=page.titleFormat.replace(/%identifier%/g,page.file.name));for(var t="",a=Object.keys(page.file),n=0;nFields | \nValues | \n\n |
---|
Failed to parse upload identifier from URL.
");page.urlIdentifier=a[1],t+=window.location.pathname.substring(0,window.location.pathname.indexOf(a[1])),page.urlPrefix=t,page.urlParams=new URLSearchParams(window.location.search),page.clipboardJS=new ClipboardJS(".clipboard-js"),page.clipboardJS.on("success",(function(){return swal("","The link has been copied to clipboard.","success",{buttons:!1,timer:1500})})),page.clipboardJS.on("error",page.onError),page.deleteBtn.addEventListener("click",page.deleteFile),page.loadFileinfo()}})); +var lsKeys={token:"token"},page={token:localStorage[lsKeys.token],urlPrefix:null,urlIdentifier:null,messageElement:document.querySelector("#message"),fileinfoContainer:document.querySelector("#fileinfo"),clipboardBtn:document.querySelector("#clipboardBtn"),playerBtn:document.querySelector("#playerBtn"),downloadBtn:document.querySelector("#downloadBtn"),deleteBtn:document.querySelector("#deleteBtn"),uploadRoot:null,titleFormat:null,file:null,clipboardJS:null,cloudflareErrors:{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"},updateMessageBody:function(e){page.messageElement.querySelector(".message-body").innerHTML=e,page.messageElement.classList.remove("is-hidden")},onError:function(e){console.error(e),page.updateMessageBody("\nAn error occurred!
\n"+e.toString()+"
Please check your console for more information.
\n ")},onAxiosError:function(e){if(!e.response)return page.onError(e);var t=page.cloudflareErrors[e.response.status]||e.response.statusText,a=e.response.data&&e.response.data.description?e.response.data.description:"";page.updateMessageBody("\n"+e.response.status+" "+t+"
\n"+a+"
\n ")},deleteFile:function(){if(page.file){var e=document.createElement("div");e.innerHTML="You won't be able to recover this file!
",swal({title:"Are you sure?",content:e,icon:"warning",dangerMode:!0,buttons:{cancel:!0,confirm:{text:"Yes, nuke it!",closeModal:!1}}}).then((function(e){e&&axios.post("../api/upload/delete",{id:page.file.id}).then((function(e){if(e){if(!1===e.data.success)return swal("An error occurred!",e.data.description,"error");(Array.isArray(e.data.failed)?e.data.failed:[]).length?swal("An error occurred!","Unable to delete this file.","error"):swal("Deleted!","This file has been deleted.","success",{buttons:!1})}})).catch(page.onAxiosError)}))}},loadFileinfo:function(){page.urlIdentifier&&axios.get("../api/upload/get/"+page.urlIdentifier).then((function(e){if(![200,304].includes(e.status))return page.onAxiosError(e);page.file=e.data.file,page.titleFormat&&(document.title=page.titleFormat.replace(/%identifier%/g,page.file.name));for(var t="",a=Object.keys(page.file),n=0;nFields | \nValues | \n\n |
---|
Failed to parse upload identifier from URL.
");page.urlIdentifier=a[1],t+=window.location.pathname.substring(0,window.location.pathname.indexOf(a[1])),page.urlPrefix=t,page.urlParams=new URLSearchParams(window.location.search),page.clipboardJS=new ClipboardJS(".clipboard-js"),page.clipboardJS.on("success",(function(){return swal("","The link has been copied to clipboard.","success",{buttons:!1,timer:1500})})),page.clipboardJS.on("error",page.onError),page.deleteBtn.addEventListener("click",page.deleteFile),page.loadFileinfo()}})); //# sourceMappingURL=file.js.map diff --git a/dist/js/file.js.map b/dist/js/file.js.map index c7c9fc1..cdfaa5e 100644 --- a/dist/js/file.js.map +++ b/dist/js/file.js.map @@ -1 +1 @@ -{"version":3,"sources":["file.js"],"names":["const","lsKeys","token","page","localStorage","urlPrefix","urlIdentifier","messageElement","document","querySelector","fileinfoContainer","clipboardBtn","playerBtn","downloadBtn","deleteBtn","uploadRoot","titleFormat","file","clipboardJS","cloudflareErrors","content","innerHTML","classList","remove","error","console","updateMessageBody","toString","statusText","response","status","description","data","createElement","swal","title","icon","dangerMode","buttons","cancel","confirm","text","closeModal","then","proceed","axios","post","id","success","Array","isArray","failed","length","catch","onAxiosError","get","includes","replace","name","let","rows","keys","Object","i","value","prettyValue","getPrettyBytes","getPrettyDate","Date","innerText","fileUrl","setAttribute","dataset","clipboardText","img","src","parentNode","onerror","event","currentTarget","add","isvideo","type","startsWith","isaudio","urlParams","has","click","onError","window","addEventListener","URLSearchParams","searchString","self","this","RegExp","exec","defaults","headers","common","mainScript","location","protocol","host","match","pathname","substring","indexOf","search","ClipboardJS","on","timer","deleteFile","loadFileinfo"],"mappings":"AAEAA,IAAMC,OAAS,CACbC,MAAO,SAGHC,KAAO,CAEXD,MAAOE,aAAaH,OAAOC,OAE3BG,UAAW,KACXC,cAAe,KAEfC,eAAgBC,SAASC,cAAc,YACvCC,kBAAmBF,SAASC,cAAc,aAE1CE,aAAcH,SAASC,cAAc,iBACrCG,UAAWJ,SAASC,cAAc,cAClCI,YAAaL,SAASC,cAAc,gBACpCK,UAAWN,SAASC,cAAc,cAClCM,WAAY,KACZC,YAAa,KAEbC,KAAM,KACNC,YAAa,KAGbC,iBAAkB,CAChB,IAAK,gBACL,IAAK,qBACL,IAA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BAAgBF,OAAOY,SAASO,QAErDzG,KAAKe,YAAc,IAAI2F,YAAY,iBAEnC1G,KAAKe,YAAY4F,GAAG,WAAS,WAC3B,OAAO5E,KAAK,GAAI,yCAA0C,UAAW,CACnEI,SAAS,EACTyE,MAAO,MA1BX,IA8BA5G,KAAKe,YAAY4F,GAAG,QAAS3G,KAAKqF,SAElCrF,KAAKW,UAAU4E,iBAAiB,QAASvF,KAAK6G,YAE9C7G,KAAK8G,cA/BoE,CAI3E","file":"file.js","sourcesContent":["/* global swal, axios, ClipboardJS */\n\nconst lsKeys = {\n token: 'token'\n}\n\nconst page = {\n // user token\n token: localStorage[lsKeys.token],\n\n urlPrefix: null,\n urlIdentifier: null,\n\n messageElement: document.querySelector('#message'),\n fileinfoContainer: document.querySelector('#fileinfo'),\n\n clipboardBtn: document.querySelector('#clipboardBtn'),\n playerBtn: document.querySelector('#playerBtn'),\n downloadBtn: document.querySelector('#downloadBtn'),\n deleteBtn: document.querySelector('#deleteBtn'),\n uploadRoot: null,\n titleFormat: null,\n\n file: null,\n clipboardJS: null,\n\n // Better Cloudflare errors\n 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\npage.updateMessageBody = content => {\n page.messageElement.querySelector('.message-body').innerHTML = content\n page.messageElement.classList.remove('is-hidden')\n}\n\n// Handler for regular JS errors\npage.onError = error => {\n console.error(error)\n page.updateMessageBody(`\nAn error occurred!
\n${error.toString()}
Please check your console for more information.
\n `)\n}\n\n// Handler for Axios errors\npage.onAxiosError = error => {\n const statusText = page.cloudflareErrors[error.response.status] || error.response.statusText\n\n const description = error.response.data && error.response.data.description\n ? error.response.data.description\n : ''\n page.updateMessageBody(`\n${error.response.status} ${statusText}
\n${description}
\n `)\n}\n\npage.deleteFile = () => {\n if (!page.file) return\n\n const content = document.createElement('div')\n content.innerHTML = 'You won\\'t be able to recover this file!
'\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 it!',\n closeModal: false\n }\n }\n }).then(proceed => {\n if (!proceed) return\n\n axios.post('../api/upload/delete', {\n id: page.file.id\n }).then(response => {\n if (!response) return\n\n if (response.data.success === false) {\n return swal('An error occurred!', response.data.description, 'error')\n }\n\n const failed = Array.isArray(response.data.failed) ? response.data.failed : []\n if (failed.length) {\n swal('An error occurred!', 'Unable to delete this file.', 'error')\n } else {\n swal('Deleted!', 'This file has been deleted.', 'success', {\n buttons: false\n })\n }\n }).catch(page.onAxiosError)\n })\n}\n\npage.loadFileinfo = () => {\n if (!page.urlIdentifier) return\n\n axios.get(`../api/upload/get/${page.urlIdentifier}`).then(response => {\n if (![200, 304].includes(response.status)) {\n return page.onAxiosError(response)\n }\n\n page.file = response.data.file\n\n if (page.titleFormat) {\n document.title = page.titleFormat.replace(/%identifier%/g, page.file.name)\n }\n\n let rows = ''\n const keys = Object.keys(page.file)\n for (let i = 0; i < keys.length; i++) {\n const value = page.file[keys[i]]\n\n let prettyValue = ''\n if (value) {\n if (['size'].includes(keys[i])) {\n prettyValue = page.getPrettyBytes(value)\n } else if (['timestamp', 'expirydate'].includes(keys[i])) {\n prettyValue = page.getPrettyDate(new Date(value * 1000))\n }\n }\n\n rows += `\nFields | \nValues | \n\n |
---|
Failed to parse upload identifier from URL.
')\n }\n\n page.urlIdentifier = match[1]\n urlPrefix += window.location.pathname.substring(0, window.location.pathname.indexOf(match[1]))\n page.urlPrefix = urlPrefix\n\n // eslint-disable-next-line compat/compat\n page.urlParams = new URLSearchParams(window.location.search)\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.deleteBtn.addEventListener('click', page.deleteFile)\n\n page.loadFileinfo()\n})\n"]} \ No newline at end of file +{"version":3,"sources":["file.js"],"names":["const","lsKeys","token","page","localStorage","urlPrefix","urlIdentifier","messageElement","document","querySelector","fileinfoContainer","clipboardBtn","playerBtn","downloadBtn","deleteBtn","uploadRoot","titleFormat","file","clipboardJS","cloudflareErrors","content","innerHTML","classList","remove","error","console","updateMessageBody","toString","response","onError","statusText","status","description","data","createElement","swal","title","icon","dangerMode","buttons","cancel","confirm","text","closeModal","then","proceed","axios","post","id","success","Array","isArray","failed","length","catch","onAxiosError","get","includes","replace","name","let","rows","keys","Object","i","value","prettyValue","getPrettyBytes","getPrettyDate","Date","innerText","fileUrl","setAttribute","dataset","clipboardText","img","src","parentNode","onerror","event","currentTarget","add","isvideo","type","startsWith","isaudio","urlParams","has","click","window","addEventListener","URLSearchParams","searchString","self","this","RegExp","exec","defaults","headers","common","mainScript","location","protocol","host","match","pathname","substring","indexOf","search","ClipboardJS","on","timer","deleteFile","loadFileinfo"],"mappings":"AAEAA,IAAMC,OAAS,CACbC,MAAO,SAGHC,KAAO,CAEXD,MAAOE,aAAaH,OAAOC,OAE3BG,UAAW,KACXC,cAAe,KAEfC,eAAgBC,SAASC,cAAc,YACvCC,kBAAmBF,SAASC,cAAc,aAE1CE,aAAcH,SAASC,cAAc,iBACrCG,UAAWJ,SAASC,cAAc,cAClCI,YAAaL,SAASC,cAAc,gBACpCK,UAAWN,SAASC,cAAc,cAClCM,WAAY,KACZC,YAAa,KAEbC,KAAM,KACNC,YAAa,KAGbC,iBAAkB,CAChB,IAAK,gBACL,IAAK,qBACL,IAAK,uBACL,IAAK,wBACL,IAAK,qBACL,IAAK,uBACL,IAAK,0BACL,IAAK,gBACL,IAAK,oBAIThB,kBAAsB,SAAGiB,GACvBjB,KAAKI,eAAeE,cAAc,iBAAiBY,UAAYD,EAC/DjB,KAAKI,eAAee,UAAUC,OAAO,YACvC,E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C,UAAW,CACnEI,SAAS,EACTwE,MAAO,MA1BX,IA8BA5G,KAAKe,YAAY4F,GAAG,QAAS3G,KAAK0B,SAElC1B,KAAKW,UAAU4E,iBAAiB,QAASvF,KAAK6G,YAE9C7G,KAAK8G,cA/BoE,CAI3E","file":"file.js","sourcesContent":["/* global swal, axios, ClipboardJS */\n\nconst lsKeys = {\n token: 'token'\n}\n\nconst page = {\n // user token\n token: localStorage[lsKeys.token],\n\n urlPrefix: null,\n urlIdentifier: null,\n\n messageElement: document.querySelector('#message'),\n fileinfoContainer: document.querySelector('#fileinfo'),\n\n clipboardBtn: document.querySelector('#clipboardBtn'),\n playerBtn: document.querySelector('#playerBtn'),\n downloadBtn: document.querySelector('#downloadBtn'),\n deleteBtn: document.querySelector('#deleteBtn'),\n uploadRoot: null,\n titleFormat: null,\n\n file: null,\n clipboardJS: null,\n\n // Better Cloudflare errors\n 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\npage.updateMessageBody = content => {\n page.messageElement.querySelector('.message-body').innerHTML = content\n page.messageElement.classList.remove('is-hidden')\n}\n\n// Handler for regular JS errors\npage.onError = error => {\n console.error(error)\n page.updateMessageBody(`\nAn error occurred!
\n${error.toString()}
Please check your console for more information.
\n `)\n}\n\n// Handler for Axios errors\npage.onAxiosError = error => {\n if (!error.response) {\n return page.onError(error)\n }\n\n const statusText = page.cloudflareErrors[error.response.status] || error.response.statusText\n\n const description = error.response.data && error.response.data.description\n ? error.response.data.description\n : ''\n page.updateMessageBody(`\n${error.response.status} ${statusText}
\n${description}
\n `)\n}\n\npage.deleteFile = () => {\n if (!page.file) return\n\n const content = document.createElement('div')\n content.innerHTML = 'You won\\'t be able to recover this file!
'\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 it!',\n closeModal: false\n }\n }\n }).then(proceed => {\n if (!proceed) return\n\n axios.post('../api/upload/delete', {\n id: page.file.id\n }).then(response => {\n if (!response) return\n\n if (response.data.success === false) {\n return swal('An error occurred!', response.data.description, 'error')\n }\n\n const failed = Array.isArray(response.data.failed) ? response.data.failed : []\n if (failed.length) {\n swal('An error occurred!', 'Unable to delete this file.', 'error')\n } else {\n swal('Deleted!', 'This file has been deleted.', 'success', {\n buttons: false\n })\n }\n }).catch(page.onAxiosError)\n })\n}\n\npage.loadFileinfo = () => {\n if (!page.urlIdentifier) return\n\n axios.get(`../api/upload/get/${page.urlIdentifier}`).then(response => {\n if (![200, 304].includes(response.status)) {\n return page.onAxiosError(response)\n }\n\n page.file = response.data.file\n\n if (page.titleFormat) {\n document.title = page.titleFormat.replace(/%identifier%/g, page.file.name)\n }\n\n let rows = ''\n const keys = Object.keys(page.file)\n for (let i = 0; i < keys.length; i++) {\n const value = page.file[keys[i]]\n\n let prettyValue = ''\n if (value) {\n if (['size'].includes(keys[i])) {\n prettyValue = page.getPrettyBytes(value)\n } else if (['timestamp', 'expirydate'].includes(keys[i])) {\n prettyValue = page.getPrettyDate(new Date(value * 1000))\n }\n }\n\n rows += `\nFields | \nValues | \n\n |
---|
Failed to parse upload identifier from URL.
')\n }\n\n page.urlIdentifier = match[1]\n urlPrefix += window.location.pathname.substring(0, window.location.pathname.indexOf(match[1]))\n page.urlPrefix = urlPrefix\n\n // eslint-disable-next-line compat/compat\n page.urlParams = new URLSearchParams(window.location.search)\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.deleteBtn.addEventListener('click', page.deleteFile)\n\n page.loadFileinfo()\n})\n"]} \ No newline at end of file diff --git a/dist/js/home.js b/dist/js/home.js index 9de7478..ea18569 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,defaultTemporaryUploadAge: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,cloudflareErrors:{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"},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&&(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()+"
Please check your console for more information.
\n ",swal({title:"An error occurred!",icon:"error",content:a})},onAxiosError:function(e){var a=page.cloudflareErrors[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")},formatAxiosError:function(e){var a=page.cloudflareErrors[e.response.status]||e.response.statusText;return e.response.data&&e.response.data.description?e.response:{data:{success:!1,description:e.response?e.response.status+" "+a:e.toString()}}},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,document.querySelector("#maxSize > span").innerHTML=page.getPrettyBytes(page.maxSizeBytes),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.defaultTemporaryUploadAge=e.data.defaultTemporaryUploadAge||null,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,Array.isArray(a.data.retentionPeriods)&&(page.temporaryUploadAges=a.data.retentionPeriods,page.defaultTemporaryUploadAge=a.data.defaultRetentionPeriod),page.prepareUpload()})).catch((function(e){return page.onAxiosError(e).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("#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"),l=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}))},i=0;iMax length is '+page.albumTitleMaxLength+' characters.
\nMax length is '+page.albumDescMaxLength+' characters.
\n'+L+"
":"")+"\n ",f.querySelector("div.control").appendChild(y),d.appendChild(f)}}var E=document.createElement("div");E.className="field",E.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
Please check your console for more information.
\n ",swal({title:"An error occurred!",icon:"error",content:a})},onAxiosError:function(e){if(!e.response)return page.onError(e);var a=page.cloudflareErrors[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")},formatAxiosError:function(e){var a=page.cloudflareErrors[e.response.status]||e.response.statusText;return e.response.data&&e.response.data.description?e.response:{data:{success:!1,description:e.response?e.response.status+" "+a:e.toString()}}},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,document.querySelector("#maxSize > span").innerHTML=page.getPrettyBytes(page.maxSizeBytes),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.defaultTemporaryUploadAge=e.data.defaultTemporaryUploadAge||null,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,Array.isArray(a.data.retentionPeriods)&&(page.temporaryUploadAges=a.data.retentionPeriods,page.defaultTemporaryUploadAge=a.data.defaultRetentionPeriod),page.prepareUpload()})).catch((function(e){return page.onAxiosError(e).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("#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"),l=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}))},i=0;iMax length is '+page.albumTitleMaxLength+' characters.
\nMax length is '+page.albumDescMaxLength+' characters.
\n'+L+"
":"")+"\n ",f.querySelector("div.control").appendChild(y),d.appendChild(f)}}var E=document.createElement("div");E.className="field",E.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
${error.toString()}
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 const statusText = page.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.formatAxiosError = error => {\n const statusText = page.cloudflareErrors[error.response.status] || error.response.statusText\n\n 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 document.querySelector('#maxSize > span').innerHTML = page.getPrettyBytes(page.maxSizeBytes)\n\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.defaultTemporaryUploadAge = response.data.defaultTemporaryUploadAge || null\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\n // If user has its own retention periods array, override defaults\n if (Array.isArray(response.data.retentionPeriods)) {\n page.temporaryUploadAges = response.data.retentionPeriods\n page.defaultTemporaryUploadAge = response.data.defaultRetentionPeriod\n }\n\n return page.prepareUpload()\n }).catch(error => {\n return page.onAxiosError(error).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 // Hide login button\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 = `\nMax length is ${page.albumTitleMaxLength} characters.
\nMax length is ${page.albumDescMaxLength} characters.
\n${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
${error.toString()}
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 if (!error.response) {\n return page.onError(error)\n }\n\n const statusText = page.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.formatAxiosError = error => {\n const statusText = page.cloudflareErrors[error.response.status] || error.response.statusText\n\n 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 document.querySelector('#maxSize > span').innerHTML = page.getPrettyBytes(page.maxSizeBytes)\n\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.defaultTemporaryUploadAge = response.data.defaultTemporaryUploadAge || null\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\n // If user has its own retention periods array, override defaults\n if (Array.isArray(response.data.retentionPeriods)) {\n page.temporaryUploadAges = response.data.retentionPeriods\n page.defaultTemporaryUploadAge = response.data.defaultRetentionPeriod\n }\n\n return page.prepareUpload()\n }).catch(error => {\n return page.onAxiosError(error).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 // Hide login button\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 = `\nMax length is ${page.albumTitleMaxLength} characters.
\nMax length is ${page.albumDescMaxLength} characters.
\n${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
"+e.toString()+"
Please check your console for more information.
\n ",swal({title:"An error occurred!",icon:"error",content:o})},page.onAxiosError=function(e){var o=page.cloudflareErrors[e.response.status]||e.response.statusText,t=e.response.data&&e.response.data.description?e.response.data.description:"";return swal(e.response.status+" "+o,t,"error")},page.toggleReloadBtn=function(e){e?(page.reloadBtn.classList.remove("is-loading"),page.reloadBtn.removeAttribute("disabled")):(page.reloadBtn.classList.add("is-loading"),page.reloadBtn.setAttribute("disabled","disabled"))},page.reloadVideo=function(){if(page.urlInput.value){page.toggleReloadBtn(!1);var e=page.uploadRoot+"/"+page.urlInput.value;axios.head(e).then((function(o){if(![200,304].includes(o.status))return page.toggleReloadBtn(!0),page.onAxiosError(o);var t=o.headers["content-type"]||"",r=t.startsWith("video/"),a=t.startsWith("audio/");if(!r&&!a)return page.toggleReloadBtn(!0),swal("An error occurred!","The requested upload does not appear to be a media file.","error");page.urlIdentifier=page.urlInput.value,page.player&&(page.player.dispose(),page.videoContainer.innerHTML="");var n=document.createElement("video-js");n.id="video-js",n.className="video-js vjs-default-skin vjs-fluid vjs-big-play-centered",n.setAttribute("controls",!0),n.setAttribute("preload","auto"),page.videoContainer.appendChild(n);var i={language:"en",playbackRates:[.25,.5,.75,1,1.25,1.5,1.75,2],responsive:!0,plugins:{}};a&&(i.plugins.wavesurfer={responsive:!0}),page.player=videojs("video-js",i,(function(){var o="Using video.js "+videojs.VERSION;a&&(o+=" with videojs-wavesurfer "+videojs.getPluginVersion("wavesurfer")+" and wavesurfer.js "+WaveSurfer.VERSION),videojs.log(o),page.player.src({src:e,type:t})})),page.player.seekButtons({forward:10,back:10});var l=videojs.getComponent("Button"),d=function(){return page.player.loop()?"Disable loop":"Enable loop"},s=videojs.extend(l,{constructor:function(){l.apply(this,arguments),this.addClass("vjs-loop-button"),this.controlText(d())},handleClick:function(){page.player.loop(!page.player.loop()),this.toggleClass("vjs-loop-enabled",page.player.loop()),this.controlText(d())}});videojs.registerComponent("loopButton",s),page.player.getChild("controlBar").addChild("loopButton"),page.titleFormat&&(document.title=page.titleFormat.replace(/%identifier%/g,page.urlIdentifier)),page.downloadBtn&&page.downloadBtn.setAttribute("href",e),window.history.pushState(null,null,page.urlPrefix+page.urlIdentifier),page.toggleReloadBtn(!0)})).catch((function(e){page.toggleReloadBtn(!0),void 0!==e.response?page.onAxiosError(e):page.onError(e)}))}},window.addEventListener("DOMContentLoaded",(function(){var e=document.querySelector("#mainScript");if(e&&void 0!==e.dataset.uploadRoot){page.uploadRoot=e.dataset.uploadRoot,page.titleFormat=e.dataset.titleFormat;var o=window.location.protocol+"//"+window.location.host,t=window.location.pathname.match(/.*\/(.*)$/);if(!t||!t[1])return swal("An error occurred!","Failed to parse upload identifier from URL.","error");if(page.urlIdentifier=t[1],o+=window.location.pathname.substring(0,window.location.pathname.indexOf(t[1])),page.urlPrefix=o,page.urlInput){page.urlInput.value=page.urlIdentifier;var r=document.querySelector("#inputForm");r.addEventListener("submit",(function(e){e.preventDefault()})),page.videoContainer&&(page.reloadBtn=document.querySelector("#reloadBtn"),page.reloadBtn&&page.reloadBtn.addEventListener("click",(function(e){r.checkValidity()&&page.reloadVideo()})),page.reloadVideo())}}})); +var lsKeys={},page={urlPrefix:null,urlIdentifier:null,urlInput:document.querySelector("#identifier"),reloadBtn:document.querySelector("#reloadBtn"),downloadBtn:document.querySelector("#downloadBtn"),uploadRoot:null,titleFormat:null,videoContainer:document.querySelector("#playerContainer"),player:null,cloudflareErrors:{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"}};window.HELP_IMPROVE_VIDEOJS=!1,page.onError=function(e){console.error(e);var o=document.createElement("div");return o.innerHTML="\n"+e.toString()+"
Please check your console for more information.
\n ",swal({title:"An error occurred!",icon:"error",content:o})},page.onAxiosError=function(e){if(!e.response)return page.onError(e);var o=page.cloudflareErrors[e.response.status]||e.response.statusText,r=e.response.data&&e.response.data.description?e.response.data.description:"";return swal(e.response.status+" "+o,r,"error")},page.toggleReloadBtn=function(e){e?(page.reloadBtn.classList.remove("is-loading"),page.reloadBtn.removeAttribute("disabled")):(page.reloadBtn.classList.add("is-loading"),page.reloadBtn.setAttribute("disabled","disabled"))},page.reloadVideo=function(){if(page.urlInput.value){page.toggleReloadBtn(!1);var e=page.uploadRoot+"/"+page.urlInput.value;axios.head(e).then((function(o){if(![200,304].includes(o.status))return page.toggleReloadBtn(!0),page.onAxiosError(o);var r=o.headers["content-type"]||"",t=r.startsWith("video/"),a=r.startsWith("audio/");if(!t&&!a)return page.toggleReloadBtn(!0),swal("An error occurred!","The requested upload does not appear to be a media file.","error");page.urlIdentifier=page.urlInput.value,page.player&&(page.player.dispose(),page.videoContainer.innerHTML="");var n=document.createElement("video-js");n.id="video-js",n.className="video-js vjs-default-skin vjs-fluid vjs-big-play-centered",n.setAttribute("controls",!0),n.setAttribute("preload","auto"),page.videoContainer.appendChild(n);var i={language:"en",playbackRates:[.25,.5,.75,1,1.25,1.5,1.75,2],responsive:!0,plugins:{}};a&&(i.plugins.wavesurfer={responsive:!0}),page.player=videojs("video-js",i,(function(){var o="Using video.js "+videojs.VERSION;a&&(o+=" with videojs-wavesurfer "+videojs.getPluginVersion("wavesurfer")+" and wavesurfer.js "+WaveSurfer.VERSION),videojs.log(o),page.player.src({src:e,type:r})})),page.player.seekButtons({forward:10,back:10});var l=videojs.getComponent("Button"),d=function(){return page.player.loop()?"Disable loop":"Enable loop"},s=videojs.extend(l,{constructor:function(){l.apply(this,arguments),this.addClass("vjs-loop-button"),this.controlText(d())},handleClick:function(){page.player.loop(!page.player.loop()),this.toggleClass("vjs-loop-enabled",page.player.loop()),this.controlText(d())}});videojs.registerComponent("loopButton",s),page.player.getChild("controlBar").addChild("loopButton"),page.titleFormat&&(document.title=page.titleFormat.replace(/%identifier%/g,page.urlIdentifier)),page.downloadBtn&&page.downloadBtn.setAttribute("href",e),window.history.pushState(null,null,page.urlPrefix+page.urlIdentifier),page.toggleReloadBtn(!0)})).catch((function(e){page.toggleReloadBtn(!0),void 0!==e.response?page.onAxiosError(e):page.onError(e)}))}},window.addEventListener("DOMContentLoaded",(function(){var e=document.querySelector("#mainScript");if(e&&void 0!==e.dataset.uploadRoot){page.uploadRoot=e.dataset.uploadRoot,page.titleFormat=e.dataset.titleFormat;var o=window.location.protocol+"//"+window.location.host,r=window.location.pathname.match(/.*\/(.*)$/);if(!r||!r[1])return swal("An error occurred!","Failed to parse upload identifier from URL.","error");if(page.urlIdentifier=r[1],o+=window.location.pathname.substring(0,window.location.pathname.indexOf(r[1])),page.urlPrefix=o,page.urlInput){page.urlInput.value=page.urlIdentifier;var t=document.querySelector("#inputForm");t.addEventListener("submit",(function(e){e.preventDefault()})),page.videoContainer&&(page.reloadBtn=document.querySelector("#reloadBtn"),page.reloadBtn&&page.reloadBtn.addEventListener("click",(function(e){t.checkValidity()&&page.reloadVideo()})),page.reloadVideo())}}})); //# sourceMappingURL=player.js.map diff --git a/dist/js/player.js.map b/dist/js/player.js.map index b5cc464..37ac256 100644 --- a/dist/js/player.js.map +++ b/dist/js/player.js.map @@ -1 +1 @@ -{"version":3,"sources":["player.js"],"names":["const","lsKeys","page","urlPrefix","urlIdentifier","urlInput","document","querySelector","reloadBtn","downloadBtn","uploadRoot","titleFormat","videoContainer","player","cloudflareErrors","window","HELP_IMPROVE_VIDEOJS","onError","error","console","content","createElement","innerHTML","toString","swal","title","icon","onAxiosError","statusText","response","status","description","data","toggleReloadBtn","enabled","classList","remove","removeAttribute","add","setAttribute","reloadVideo","value","src","axios","head","then","includes","type","headers","isvideo","startsWith","isaudio","dispose","videoElement","id","className","appendChild","options","language","playbackRates","responsive","plugins","wavesurfer","videojs","let","message","getPluginVersion","WaveSurfer","log","seekButtons","forward","back","videoJSButton","getComponent","loopButtonText","loop","loopButton","extend","constructor","apply","this","arguments","addClass","controlText","handleClick","toggleClass","registerComponent","getChild","addChild","replace","history","pushState","catch","addEventListener","mainScript","dataset","location","protocol","host","match","pathname","substring","indexOf","form","event","preventDefault","checkValidity"],"mappings":"AAGAA,IAAMC,OAAS,CAAA,EAETC,KAAO,CACXC,UAAW,KACXC,cAAe,KAEfC,SAAUC,SAASC,cAAc,eACjCC,UAAWF,SAASC,cAAc,cAClCE,YAAaH,SAASC,cAAc,gBACpCG,WAAY,KACZC,YAAa,KAEbC,eAAgBN,SAASC,cAAc,oBACvCM,OAAQ,KAGRC,iBAAkB,CAChB,IAAK,gBACL,IAAK,qBACL,IAAK,u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unused-vars\nconst lsKeys = {}\n\nconst page = {\n urlPrefix: null,\n urlIdentifier: null,\n\n urlInput: document.querySelector('#identifier'),\n reloadBtn: document.querySelector('#reloadBtn'),\n downloadBtn: document.querySelector('#downloadBtn'),\n uploadRoot: null,\n titleFormat: null,\n\n videoContainer: document.querySelector('#playerContainer'),\n player: null,\n\n // Better Cloudflare errors\n 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\n// Disable video.js telemetry (should already be disabled by default since v7 though)\nwindow.HELP_IMPROVE_VIDEOJS = false\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()}
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 const statusText = page.cloudflareErrors[error.response.status] || error.response.statusText\n\n const description = error.response.data && error.response.data.description\n ? error.response.data.description\n : ''\n return swal(`${error.response.status} ${statusText}`, description, 'error')\n}\n\npage.toggleReloadBtn = enabled => {\n if (enabled) {\n page.reloadBtn.classList.remove('is-loading')\n page.reloadBtn.removeAttribute('disabled')\n } else {\n page.reloadBtn.classList.add('is-loading')\n page.reloadBtn.setAttribute('disabled', 'disabled')\n }\n}\n\npage.reloadVideo = () => {\n if (!page.urlInput.value) return\n\n page.toggleReloadBtn(false)\n const src = `${page.uploadRoot}/${page.urlInput.value}`\n\n axios.head(src).then(response => {\n if (![200, 304].includes(response.status)) {\n page.toggleReloadBtn(true)\n return page.onAxiosError(response)\n }\n\n const type = response.headers['content-type'] || ''\n const isvideo = type.startsWith('video/')\n const isaudio = type.startsWith('audio/')\n if (!isvideo && !isaudio) {\n page.toggleReloadBtn(true)\n return swal('An error occurred!', 'The requested upload does not appear to be a media file.', 'error')\n }\n\n page.urlIdentifier = page.urlInput.value\n\n if (page.player) {\n page.player.dispose()\n page.videoContainer.innerHTML = ''\n }\n\n const videoElement = document.createElement('video-js')\n videoElement.id = 'video-js'\n videoElement.className = 'video-js vjs-default-skin vjs-fluid vjs-big-play-centered'\n videoElement.setAttribute('controls', true)\n videoElement.setAttribute('preload', 'auto')\n\n page.videoContainer.appendChild(videoElement)\n\n const options = {\n language: 'en',\n playbackRates: [0.25, 0.5, 0.75, 1, 1.25, 1.5, 1.75, 2],\n responsive: true,\n plugins: {}\n }\n\n if (isaudio) {\n options.plugins.wavesurfer = {\n responsive: true\n }\n }\n\n page.player = videojs('video-js', options, () => {\n let message = `Using video.js ${videojs.VERSION}`\n if (isaudio) {\n message += ` with videojs-wavesurfer ${videojs.getPluginVersion('wavesurfer')} and wavesurfer.js ${WaveSurfer.VERSION}`\n }\n videojs.log(message)\n page.player.src({ src, type })\n })\n page.player.seekButtons({ forward: 10, back: 10 })\n\n const videoJSButton = videojs.getComponent('Button')\n const loopButtonText = () => page.player.loop()\n ? 'Disable loop'\n : 'Enable loop'\n const loopButton = videojs.extend(videoJSButton, {\n constructor () {\n videoJSButton.apply(this, arguments)\n this.addClass('vjs-loop-button')\n this.controlText(loopButtonText())\n },\n handleClick () {\n page.player.loop(!page.player.loop())\n this.toggleClass('vjs-loop-enabled', page.player.loop())\n this.controlText(loopButtonText())\n }\n })\n videojs.registerComponent('loopButton', loopButton)\n page.player.getChild('controlBar').addChild('loopButton')\n\n if (page.titleFormat) {\n document.title = page.titleFormat.replace(/%identifier%/g, page.urlIdentifier)\n }\n\n if (page.downloadBtn) {\n page.downloadBtn.setAttribute('href', src)\n }\n\n window.history.pushState(null, null, page.urlPrefix + page.urlIdentifier)\n page.toggleReloadBtn(true)\n }).catch(error => {\n page.toggleReloadBtn(true)\n if (typeof error.response !== 'undefined') page.onAxiosError(error)\n else page.onError(error)\n })\n}\n\nwindow.addEventListener('DOMContentLoaded', () => {\n const mainScript = document.querySelector('#mainScript')\n if (!mainScript || typeof mainScript.dataset.uploadRoot === 'undefined') return\n\n page.uploadRoot = mainScript.dataset.uploadRoot\n page.titleFormat = mainScript.dataset.titleFormat\n\n let urlPrefix = window.location.protocol + '//' + window.location.host\n const match = window.location.pathname.match(/.*\\/(.*)$/)\n if (!match || !match[1]) {\n return swal('An error occurred!', 'Failed to parse upload identifier from URL.', 'error')\n }\n\n page.urlIdentifier = match[1]\n urlPrefix += window.location.pathname.substring(0, window.location.pathname.indexOf(match[1]))\n page.urlPrefix = urlPrefix\n\n if (!page.urlInput) return\n page.urlInput.value = page.urlIdentifier\n\n // Prevent default form's submit actio\n const form = document.querySelector('#inputForm')\n form.addEventListener('submit', event => {\n event.preventDefault()\n })\n\n if (!page.videoContainer) return\n\n page.reloadBtn = document.querySelector('#reloadBtn')\n if (page.reloadBtn) {\n page.reloadBtn.addEventListener('click', event => {\n if (!form.checkValidity()) return\n page.reloadVideo()\n })\n }\n\n page.reloadVideo()\n})\n"]} \ No newline at end of file +{"version":3,"sources":["player.js"],"names":["const","lsKeys","page","urlPrefix","urlIdentifier","urlInput","document","querySelector","reloadBtn","downloadBtn","uploadRoot","titleFormat","videoContainer","player","cloudflareErrors","window","HELP_IMPROVE_VIDEOJS","onError","error","console","content","createElement","innerHTML","toString","swal","title","icon","onAxiosError","response","statusText","status","description","data","toggleReloadBtn","enabled","classList","remove","removeAttribute","add","setAttribute","reloadVideo","value","src","axios","head","then","includes","type","headers","isvideo","startsWith","isaudio","dispose","videoElement","id","className","appendChild","options","language","playbackRates","responsive","plugins","wavesurfer","videojs","let","message","getPluginVersion","WaveSurfer","log","seekButtons","forward","back","videoJSButton","getComponent","loopButtonText","loop","loopButton","extend","constructor","apply","this","arguments","addClass","controlText","handleClick","toggleClass","registerComponent","getChild","addChild","replace","history","pushState","catch","addEventListener","mainScript","dataset","location","protocol","host","match","pathname","substring","indexOf","form","event","preventDefault","checkValidity"],"mapp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C,cAAc,cACpCgG,EAAKV,iBAAiB,UAAQ,SAAEW,GAC9BA,EAAMC,gBAFR,IAKKvG,KAAKU,iBAEVV,KAAKM,UAAYF,SAASC,cAAc,cACpCL,KAAKM,WACPN,KAAKM,UAAUqF,iBAAiB,SAAO,SAAEW,GAClCD,EAAKG,iBACVxG,KAAKsC,aAFP,IAMFtC,KAAKsC,cAnBe,CAfqD,CAgC3E","file":"player.js","sourcesContent":["/* global swal, axios, videojs, WaveSurfer */\n\n// eslint-disable-next-line no-unused-vars\nconst lsKeys = {}\n\nconst page = {\n urlPrefix: null,\n urlIdentifier: null,\n\n urlInput: document.querySelector('#identifier'),\n reloadBtn: document.querySelector('#reloadBtn'),\n downloadBtn: document.querySelector('#downloadBtn'),\n uploadRoot: null,\n titleFormat: null,\n\n videoContainer: document.querySelector('#playerContainer'),\n player: null,\n\n // Better Cloudflare errors\n 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\n// Disable video.js telemetry (should already be disabled by default since v7 though)\nwindow.HELP_IMPROVE_VIDEOJS = false\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()}
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 if (!error.response) {\n return page.onError(error)\n }\n\n const statusText = page.cloudflareErrors[error.response.status] || error.response.statusText\n\n const description = error.response.data && error.response.data.description\n ? error.response.data.description\n : ''\n return swal(`${error.response.status} ${statusText}`, description, 'error')\n}\n\npage.toggleReloadBtn = enabled => {\n if (enabled) {\n page.reloadBtn.classList.remove('is-loading')\n page.reloadBtn.removeAttribute('disabled')\n } else {\n page.reloadBtn.classList.add('is-loading')\n page.reloadBtn.setAttribute('disabled', 'disabled')\n }\n}\n\npage.reloadVideo = () => {\n if (!page.urlInput.value) return\n\n page.toggleReloadBtn(false)\n const src = `${page.uploadRoot}/${page.urlInput.value}`\n\n axios.head(src).then(response => {\n if (![200, 304].includes(response.status)) {\n page.toggleReloadBtn(true)\n return page.onAxiosError(response)\n }\n\n const type = response.headers['content-type'] || ''\n const isvideo = type.startsWith('video/')\n const isaudio = type.startsWith('audio/')\n if (!isvideo && !isaudio) {\n page.toggleReloadBtn(true)\n return swal('An error occurred!', 'The requested upload does not appear to be a media file.', 'error')\n }\n\n page.urlIdentifier = page.urlInput.value\n\n if (page.player) {\n page.player.dispose()\n page.videoContainer.innerHTML = ''\n }\n\n const videoElement = document.createElement('video-js')\n videoElement.id = 'video-js'\n videoElement.className = 'video-js vjs-default-skin vjs-fluid vjs-big-play-centered'\n videoElement.setAttribute('controls', true)\n videoElement.setAttribute('preload', 'auto')\n\n page.videoContainer.appendChild(videoElement)\n\n const options = {\n language: 'en',\n playbackRates: [0.25, 0.5, 0.75, 1, 1.25, 1.5, 1.75, 2],\n responsive: true,\n plugins: {}\n }\n\n if (isaudio) {\n options.plugins.wavesurfer = {\n responsive: true\n }\n }\n\n page.player = videojs('video-js', options, () => {\n let message = `Using video.js ${videojs.VERSION}`\n if (isaudio) {\n message += ` with videojs-wavesurfer ${videojs.getPluginVersion('wavesurfer')} and wavesurfer.js ${WaveSurfer.VERSION}`\n }\n videojs.log(message)\n page.player.src({ src, type })\n })\n page.player.seekButtons({ forward: 10, back: 10 })\n\n const videoJSButton = videojs.getComponent('Button')\n const loopButtonText = () => page.player.loop()\n ? 'Disable loop'\n : 'Enable loop'\n const loopButton = videojs.extend(videoJSButton, {\n constructor () {\n videoJSButton.apply(this, arguments)\n this.addClass('vjs-loop-button')\n this.controlText(loopButtonText())\n },\n handleClick () {\n page.player.loop(!page.player.loop())\n this.toggleClass('vjs-loop-enabled', page.player.loop())\n this.controlText(loopButtonText())\n }\n })\n videojs.registerComponent('loopButton', loopButton)\n page.player.getChild('controlBar').addChild('loopButton')\n\n if (page.titleFormat) {\n document.title = page.titleFormat.replace(/%identifier%/g, page.urlIdentifier)\n }\n\n if (page.downloadBtn) {\n page.downloadBtn.setAttribute('href', src)\n }\n\n window.history.pushState(null, null, page.urlPrefix + page.urlIdentifier)\n page.toggleReloadBtn(true)\n }).catch(error => {\n page.toggleReloadBtn(true)\n if (typeof error.response !== 'undefined') page.onAxiosError(error)\n else page.onError(error)\n })\n}\n\nwindow.addEventListener('DOMContentLoaded', () => {\n const mainScript = document.querySelector('#mainScript')\n if (!mainScript || typeof mainScript.dataset.uploadRoot === 'undefined') return\n\n page.uploadRoot = mainScript.dataset.uploadRoot\n page.titleFormat = mainScript.dataset.titleFormat\n\n let urlPrefix = window.location.protocol + '//' + window.location.host\n const match = window.location.pathname.match(/.*\\/(.*)$/)\n if (!match || !match[1]) {\n return swal('An error occurred!', 'Failed to parse upload identifier from URL.', 'error')\n }\n\n page.urlIdentifier = match[1]\n urlPrefix += window.location.pathname.substring(0, window.location.pathname.indexOf(match[1]))\n page.urlPrefix = urlPrefix\n\n if (!page.urlInput) return\n page.urlInput.value = page.urlIdentifier\n\n // Prevent default form's submit actio\n const form = document.querySelector('#inputForm')\n form.addEventListener('submit', event => {\n event.preventDefault()\n })\n\n if (!page.videoContainer) return\n\n page.reloadBtn = document.querySelector('#reloadBtn')\n if (page.reloadBtn) {\n page.reloadBtn.addEventListener('click', event => {\n if (!form.checkValidity()) return\n page.reloadVideo()\n })\n }\n\n page.reloadVideo()\n})\n"]} \ No newline at end of file diff --git a/src/versions.json b/src/versions.json index c2bf4be..1e3134d 100644 --- a/src/versions.json +++ b/src/versions.json @@ -1,5 +1,5 @@ { - "1": "1659883842", + "1": "1659913785", "2": "1602515119", "3": "1650485321", "4": "1602515119",