From 1980d536dbe3734a752bc8c28a729b6402b969a5 Mon Sep 17 00:00:00 2001 From: Bobby Wibowo Date: Sun, 3 May 2020 02:39:24 +0700 Subject: [PATCH] Initialize upload filters for regular users (WIP) Updated ESLint's ECMA version to 9 (2018). I'll need to use some lookbehind regex directives from now on. It's supported since Node 10, which is the oldest version I'll support. Refactored "can not" -> "cannot". Filtering for regular users is still work in progress. Some features aren't working as expected yet. --- .eslintrc.json | 2 +- controllers/uploadController.js | 310 ++++++++++++++++++++++---------- dist/js/dashboard.js | 2 +- dist/js/dashboard.js.map | 2 +- dist/js/home.js.map | 2 +- src/js/dashboard.js | 120 +++++++------ src/js/home.js | 2 +- src/versions.json | 2 +- 8 files changed, 288 insertions(+), 154 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 54f42d8..489c11f 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,7 +1,7 @@ { "root": true, "parserOptions": { - "ecmaVersion": 8 + "ecmaVersion": 9 }, "env": { "node": true diff --git a/controllers/uploadController.js b/controllers/uploadController.js index 8c50843..6a3bd0b 100644 --- a/controllers/uploadController.js +++ b/controllers/uploadController.js @@ -761,11 +761,16 @@ self.list = async (req, res) => { const filters = req.headers.filters const minoffset = req.headers.minoffset const ismoderator = perms.is(user, 'moderator') - if ((all || filters) && !ismoderator) + if (all && !ismoderator) return res.status(403).end() const basedomain = config.domain + // Thresholds for regular users + const MAX_WILDCARDS_IN_KEY = 2 + const MAX_TEXT_QUERIES = 3 // non-keyed keywords + const MAX_SORT_KEYS = 1 + const filterObj = { uploaders: [], excludeUploaders: [], @@ -794,15 +799,47 @@ self.list = async (req, res) => { parsed: [] } + // Parse glob wildcards into SQL wildcards + function sqlLikeParser (pattern) { + // Escape SQL operators + const escaped = pattern + .replace(/(? { offsets: false }) + // For some reason, single value won't be in Array even with 'alwaysArray' option + if (typeof filterObj.queries.exclude.text === 'string') + filterObj.queries.exclude.text = [filterObj.queries.exclude.text] + + let textQueries = 0 + if (filterObj.queries.text) textQueries += filterObj.queries.text.length + if (filterObj.queries.exclude.text) textQueries += filterObj.queries.exclude.text.length + + // Regular user threshold check + if (!ismoderator && textQueries > MAX_TEXT_QUERIES) + return res.json({ + success: false, + description: `Users are only allowed to use ${MAX_TEXT_QUERIES} non-keyed keyword${MAX_TEXT_QUERIES === 1 ? '' : 's'} at a time.` + }) + + if (filterObj.queries.text) + for (let i = 0; i < filterObj.queries.text.length; i++) { + const result = sqlLikeParser(filterObj.queries.text[i]) + if (result.count > MAX_WILDCARDS_IN_KEY) + return res.json({ + success: false, + description: `Users are only allowed to use ${MAX_WILDCARDS_IN_KEY} wildcard${MAX_WILDCARDS_IN_KEY === 1 ? '' : 's'} per key.` + }) + filterObj.queries.text[i] = result.escaped + } + + if (filterObj.queries.exclude.text) { + textQueries += filterObj.queries.exclude.text.length + for (let i = 0; i < filterObj.queries.exclude.text.length; i++) { + const result = sqlLikeParser(filterObj.queries.exclude.text[i]) + if (result.count > MAX_WILDCARDS_IN_KEY) + return res.json({ + success: false, + description: `Users are only allowed to use ${MAX_WILDCARDS_IN_KEY} wildcard${MAX_WILDCARDS_IN_KEY === 1 ? '' : 's'} per key.` + }) + filterObj.queries.exclude.text[i] = result.escaped + } + } + for (const key of keywords) { let queryIndex = -1 let excludeIndex = -1 @@ -833,8 +909,18 @@ self.list = async (req, res) => { if (inQuery || inExclude) { // Prioritize exclude keys when both types found filterObj.flags[`${key}Null`] = inExclude ? false : inQuery - if (inQuery) filterObj.queries[key].splice(queryIndex, 1) - if (inExclude) filterObj.queries.exclude[key].splice(excludeIndex, 1) + if (inQuery) + if (filterObj.queries[key].length === 1) + // Delete key to avoid unexpected behavior + delete filterObj.queries[key] + else + filterObj.queries[key].splice(queryIndex, 1) + if (inExclude) + if (filterObj.queries.exclude[key].length === 1) + // Delete key to avoid unexpected behavior + delete filterObj.queries.exclude[key] + else + filterObj.queries.exclude[key].splice(excludeIndex, 1) } } @@ -909,107 +995,137 @@ self.list = async (req, res) => { else filterObj.excludeUploaders.push(uploader) + // Delete keys to avoid unexpected behavior delete filterObj.queries.user delete filterObj.queries.exclude.user } // Parse sort keys if (filterObj.queries.sort) { + let allowed = [ + 'albumid', + 'expirydate', + 'id', + 'name', + 'size', + 'timestamp' + ] + // Only allow sorting by 'ip' and 'userid' columns when listing all uploads + if (all) + allowed = allowed.concat([ + 'ip', + 'userid' + ]) + for (const obQuery of filterObj.queries.sort) { const tmp = obQuery.toLowerCase().split(':') + const column = sortObj.maps[tmp[0]] || tmp[0] - let column = sortObj.maps[tmp[0]] || tmp[0] - let direction = 'asc' + if (!allowed.includes(column)) + // Alert users if using disallowed/missing columns + return res.json({ success: false, description: `Column \`${column}\` cannot be used for sorting.\n\nTry the following instead:\n${allowed.join(', ')}` }) - if (sortObj.casts[column]) - column = `cast (\`${column}\` as ${sortObj.casts[column]})` - if (tmp[1] && /^d/.test(tmp[1])) - direction = 'desc' - - const suffix = sortObj.nullsLast.includes(column) ? ' nulls last' : '' - sortObj.parsed.push(`${column} ${direction}${suffix}`) + sortObj.parsed.push({ + column, + order: (tmp[1] && /^d/.test(tmp[1])) ? 'desc' : 'asc', + clause: sortObj.nullsLast.includes(column) ? 'nulls last' : '', + cast: sortObj.casts[column] || null + }) } + // Regular user threshold check + if (!ismoderator && sortObj.parsed.length > MAX_SORT_KEYS) + return res.json({ + success: false, + description: `Users are only allowed to use ${MAX_SORT_KEYS} sort key${MAX_SORT_KEYS === 1 ? '' : 's'} at a time.` + }) + + // Delete key to avoid unexpected behavior delete filterObj.queries.sort } - - // For some reason, single value won't be in Array even with 'alwaysArray' option - if (typeof filterObj.queries.exclude.text === 'string') - filterObj.queries.exclude.text = [filterObj.queries.exclude.text] } function filter () { - if (req.params.id !== undefined) + if (req.params.id !== undefined) { this.where('albumid', req.params.id) - else if (!all) - this.where('userid', user.id) - else - // Sheesh, these look too overbearing... - this.where(function () { - // Filter uploads matching any of the supplied 'user' keys and/or NULL flag - // Prioritze exclude keys when both types found - if (filterObj.excludeUploaders.length) - this.orWhereNotIn('userid', filterObj.excludeUploaders.map(v => v.id)) - else if (filterObj.uploaders.length) - this.orWhereIn('userid', filterObj.uploaders.map(v => v.id)) - // Such overbearing logic for NULL values, smh... - if ((filterObj.excludeUploaders.length && filterObj.flags.userNull !== false) || - (filterObj.uploaders.length && filterObj.flags.userNull) || - (!filterObj.excludeUploaders.length && !filterObj.uploaders.length && filterObj.flags.userNull)) - this.orWhereNull('userid') - else if (filterObj.flags.userNull === false) - this.orWhereNotNull('userid') - }).orWhere(function () { - // Filter uploads matching any of the supplied 'ip' keys and/or NULL flag - // Same prioritization logics as above - if (filterObj.queries.exclude.ip) - this.orWhereNotIn('ip', filterObj.queries.exclude.ip) - else if (filterObj.queries.ip) - this.orWhereIn('ip', filterObj.queries.ip) - // ... - if ((filterObj.queries.exclude.ip && filterObj.flags.ipNull !== false) || - (filterObj.queries.ip && filterObj.flags.ipNull) || - (!filterObj.queries.exclude.ip && !filterObj.queries.ip && filterObj.flags.ipNull)) - this.orWhereNull('ip') - else if (filterObj.flags.ipNull === false) - this.orWhereNotNull('ip') - }).andWhere(function () { - // Then, refine using the supplied 'date' and/or 'expiry' ranges - if (filterObj.queries.date) - if (typeof filterObj.queries.date.from === 'number') - if (typeof filterObj.queries.date.to === 'number') - this.andWhereBetween('timestamp', [filterObj.queries.date.from, filterObj.queries.date.to]) - else - this.andWhere('timestamp', '>=', filterObj.queries.date.from) + } else { + // Sheesh, these look so overbearing... + if (!all) + // If not listing all uploads, list user's uploads + this.where('userid', user.id) + else + this.where(function () { + // Filter uploads matching any of the supplied 'user' keys and/or NULL flag + // Prioritze exclude keys when both types found + this.orWhere(function () { + if (filterObj.excludeUploaders.length) + this.orWhereNotIn('userid', filterObj.excludeUploaders.map(v => v.id)) + else if (filterObj.uploaders.length) + this.orWhereIn('userid', filterObj.uploaders.map(v => v.id)) + // Such overbearing logic for NULL values, smh... + if ((filterObj.excludeUploaders.length && filterObj.flags.userNull !== false) || + (filterObj.uploaders.length && filterObj.flags.userNull) || + (!filterObj.excludeUploaders.length && !filterObj.uploaders.length && filterObj.flags.userNull)) + this.orWhereNull('userid') + else if (filterObj.flags.userNull === false) + this.orWhereNotNull('userid') + }) + + // Filter uploads matching any of the supplied 'ip' keys and/or NULL flag + // Same prioritization logic as above + this.orWhere(function () { + if (filterObj.queries.exclude.ip) + this.orWhereNotIn('ip', filterObj.queries.exclude.ip) + else if (filterObj.queries.ip) + this.orWhereIn('ip', filterObj.queries.ip) + // ... + if ((filterObj.queries.exclude.ip && filterObj.flags.ipNull !== false) || + (filterObj.queries.ip && filterObj.flags.ipNull) || + (!filterObj.queries.exclude.ip && !filterObj.queries.ip && filterObj.flags.ipNull)) + this.orWhereNull('ip') + else if (filterObj.flags.ipNull === false) + this.orWhereNotNull('ip') + }) + }) + + // Then, refine using the supplied 'date' ranges + this.andWhere(function () { + if (!filterObj.queries.date) return + if (typeof filterObj.queries.date.from === 'number') + if (typeof filterObj.queries.date.to === 'number') + this.andWhereBetween('timestamp', [filterObj.queries.date.from, filterObj.queries.date.to]) else - this.andWhere('timestamp', '<=', filterObj.queries.date.to) - if (filterObj.queries.expiry) - if (typeof filterObj.queries.expiry.from === 'number') - if (typeof filterObj.queries.expiry.to === 'number') - this.andWhereBetween('expirydate', [filterObj.queries.expiry.from, filterObj.queries.expiry.to]) - else - this.andWhere('expirydate', '>=', filterObj.queries.date.from) - else - this.andWhere('expirydate', '<=', filterObj.queries.date.to) - }).andWhere(function () { - // Then, refine using the supplied keywords against their file names - if (!filterObj.queries.text) return - for (const name of filterObj.queries.text) - if (name.includes('*')) - this.orWhere('name', 'like', name.replace(/\*/g, '%')) - else - // If no asterisks, assume partial - this.orWhere('name', 'like', `%${name}%`) - }).andWhere(function () { - // Finally, refine using the supplied exclusions against their file names - if (!filterObj.queries.exclude.text) return - for (const exclude of filterObj.queries.exclude.text) - if (exclude.includes('*')) - this.andWhere('name', 'not like', exclude.replace(/\*/g, '%')) - else - // If no asterisks, assume partial - this.andWhere('name', 'not like', `%${exclude}%`) + this.andWhere('timestamp', '>=', filterObj.queries.date.from) + else + this.andWhere('timestamp', '<=', filterObj.queries.date.to) }) + + // Then, refine using the supplied 'expiry' ranges + this.andWhere(function () { + if (!filterObj.queries.expiry) return + if (typeof filterObj.queries.expiry.from === 'number') + if (typeof filterObj.queries.expiry.to === 'number') + this.andWhereBetween('expirydate', [filterObj.queries.expiry.from, filterObj.queries.expiry.to]) + else + this.andWhere('expirydate', '>=', filterObj.queries.date.from) + else + this.andWhere('expirydate', '<=', filterObj.queries.date.to) + }) + + // Then, refine using the supplied keywords against their file names + this.andWhere(function () { + if (!filterObj.queries.text) return + for (const pattern of filterObj.queries.text) + this.orWhere('name', 'like', pattern) + }) + + // Finally, refine using the supplied exclusions against their file names + this.andWhere(function () { + if (!filterObj.queries.exclude.text) return + for (const pattern of filterObj.queries.exclude.text) + this.orWhere('name', 'not like', pattern) + }) + } } try { @@ -1032,12 +1148,22 @@ self.list = async (req, res) => { // Only select IPs if we are listing all uploads columns.push(all ? 'ip' : 'albumid') - const sortRaw = sortObj.parsed.length - ? sortObj.parsed.join(', ') - : '`id` desc' + // Build raw query for order by (sorting) operation + let orderByRaw + if (sortObj.parsed.length) + orderByRaw = sortObj.parsed.map(sort => { + // Use Knex.raw() to sanitize user inputs + if (sort.cast) + return db.raw(`cast (?? as ${sort.cast}) ${sort.order} ${sort.clause}`.trim(), sort.column) + else + return db.raw(`?? ${sort.order} ${sort.clause}`.trim(), sort.column) + }).join(', ') + else + orderByRaw = '`id` desc' + const files = await db.table('files') .where(filter) - .orderByRaw(sortRaw) + .orderByRaw(orderByRaw) .limit(25) .offset(25 * offset) .select(columns) diff --git a/dist/js/dashboard.js b/dist/js/dashboard.js index ee03d93..01aedac 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",users:"selectedUsers"}},page={dom:null,token:localStorage[lsKeys.token],username:null,permissions:null,menusContainer:null,menus:[],currentView:null,views:{uploads:{type:localStorage[lsKeys.viewType.uploads],album:null,pageNum:null},uploadsAll:{type:localStorage[lsKeys.viewType.uploadsAll],filters:null,pageNum:null,all:!0},users:{filters:null,pageNum:null}},selected:{uploads:[],uploadsAll:[],users:[]},checkboxes:{uploads:[],uploadsAll:[],users:[]},lastSelected:{upload:null,uploadsAll:null,user:null},selectAlbumContainer:null,cache:{uploads:{},albums:{},users:{}},clipboardJS:null,lazyLoad:null,imageExts:[".webp",".jpg",".jpeg",".gif",".png",".tiff",".tif",".svg"],videoExts:[".webm",".mp4",".wmv",".avi",".mov",".mkv",".m4v",".m2ts"],isTriggerLoading:null,fadingIn:null,albumTitleMaxLength:70,albumDescMaxLength:4e3,unhide:function(){document.querySelector("#loader").classList.add("is-hidden"),document.querySelector("#dashboard").classList.remove("is-hidden")},onError:function(e){console.error(e);var a=document.createElement("div");return a.innerHTML=""+e.toString()+"",swal({title:"An error occurred!",icon:"error",content:a})},onAxiosError:function(e){console.error(e);var a={520:"Unknown Error",521:"Web Server Is Down",522:"Connection Timed Out",523:"Origin Is Unreachable",524:"A Timeout Occurred",525:"SSL Handshake Failed",526:"Invalid SSL Certificate",527:"Railgun Error",530:"Origin DNS Error"}[e.response.status]||e.response.statusText,n=e.response.data&&e.response.data.description?e.response.data.description:"There was an error with the request, please check the console for more information.";return swal(e.response.status+" "+a,n,"error")},preparePage:function(){page.token?page.verifyToken(page.token,!0):window.location="auth"},checkClientVersion:function(e){var a=document.querySelector("#mainScript").src.match(/\?_=(\d+)$/);if(a&&a[1]&&a[1]!==e)return swal({title:"Updated detected!",text:"Client assets have been updated. Reload to display the latest version?",icon:"info",buttons:{confirm:{text:"Reload",closeModal:!1}}}).then((function(){location.reload()}))},verifyToken:function(e,a){axios.post("api/tokens/verify",{token:e}).then((function(n){if(!1===n.data.success)return swal({title:"An error occurred!",text:n.data.description,icon:"error"}).then((function(){a&&(localStorage.removeItem(lsKeys.token),window.location="auth")}));axios.defaults.headers.common.token=e,localStorage[lsKeys.token]=e,n.data.version&&page.checkClientVersion(n.data.version),page.token=e,page.username=n.data.username,page.permissions=n.data.permissions,page.prepareDashboard()})).catch(page.onAxiosError)},prepareDashboard:function(){page.dom=document.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:"#itemManageAlbums",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:"#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 n=document.querySelector(e[a].selector);n.addEventListener("click",(function(n){page.menusContainer.classList.contains("is-loading")||e[a].onclick.call(null,Object.assign({trigger:n.currentTarget},e[a].params||{}))})),n.classList.remove("is-hidden"),page.menus.push(n)}},n=0;n';e.all&&(o='\n
\n
\n
\n
\n \n
\n
\n \n
\n
\n \n
\n
\n
\n
\n ');for(var c='\n
\n '+o+'\n
\n
\n
\n
\n \n
\n
\n \n
\n
\n
\n
\n
\n ',d='\n
\n
\n \n \n
\n ',u=c.replace(/id="filters"/,'id="bFilters"').replace(/(data-action="filter-uploads")/,'$1 data-filtersid="bFilters"').replace(/id="jumpToPage"/,'id="bJumpToPage"').replace(/(data-action="jump-to-page")/g,'$1 data-jumpid="bJumpToPage"'),p=r.replace(/(data-action="page-ellipsis")/g,'$1 data-jumpid="bJumpToPage"'),g=!1,m=t.some((function(e){return void 0!==e.expirydate})),b=0;b\n \n '+d+"\n "+u+"\n "+p+"\n ";for(var f=document.querySelector("#table"),w=0;w'+y.name+'':k.innerHTML='

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

",k.innerHTML+='\n \n
\n '+(y.thumb?'\n \n \n \n \n ':"")+'\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n
\n

'+y.name+"

\n

"+(y.appendix?""+y.appendix+" – ":"")+y.prettyBytes+"

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

EXP: '+y.prettyExpiryDate+"

":"")+"\n
\n ",f.appendChild(k),page.checkboxes[page.currentView]=f.querySelectorAll('.checkbox[data-action="select"]')}}else{page.dom.innerHTML="\n "+r+"\n "+c+"\n "+d+'\n
\n \n \n \n \n \n '+(void 0===e.album?"":"")+"\n \n "+(e.all?"":"")+"\n \n "+(m?"":"")+'\n \n \n \n \n \n
File name"+(e.all?"User":"Album")+"SizeIPDateExpiry date
\n
\n '+d+"\n "+u+"\n "+p+"\n ";for(var x=document.querySelector("#table"),T=0;T\n '+A.name+"\n "+(void 0===e.album?""+A.appendix+"":"")+"\n "+A.prettyBytes+"\n "+(e.all?""+(A.ip||"")+"":"")+"\n "+A.prettyDate+"\n "+(m?""+(A.prettyExpiryDate||"-")+"":"")+'\n \n \n \n \n \n \n \n \n \n \n \n '+(e.all?"":'\n \n \n \n \n ')+'\n \n \n \n \n \n \n ',x.appendChild(S),page.checkboxes[page.currentView]=x.querySelectorAll('.checkbox[data-action="select"]')}}var N=document.querySelector("#selectAll");N&&!g&&t.length&&(N.checked=!0,N.title="Unselect all"),"thumbs"===page.views[page.currentView].type?(page.fadeAndScroll(!0),page.lazyLoad.update()):page.fadeAndScroll(),page.updateTrigger(e.trigger,"active"),"uploads"===page.currentView&&(page.views.uploads.album=e.album),"uploadsAll"===page.currentView&&(page.views.uploadsAll.filters=e.filters),page.views[page.currentView].pageNum=t.length?e.pageNum:0})).catch((function(a){page.updateTrigger(e.trigger),page.onAxiosError(a)}))},setUploadsView:function(e,a){localStorage[lsKeys.viewType[page.currentView]]=e,page.views[page.currentView].type=e,page.getUploads(Object.assign({trigger:a},page.views[page.currentView]))},displayPreview:function(e){var a=page.cache.uploads[e];if(a.thumb){var n=document.createElement("div");if(n.innerHTML='\n
\n \n
\n \n
\n
\n ',a.original){var t=/.[\w]+(\?|$)/.exec(a.original),s=t&&t[0]?t[0].toLowerCase():null,i=page.imageExts.includes(s),l=!i&&page.videoExts.includes(s);(i||l)&&(n.innerHTML+='\n \n ',n.querySelector("#swalOriginal").addEventListener("click",(function(e){var t=e.currentTarget;if(!t.classList.contains("is-danger")){t.classList.add("is-loading");var s=n.querySelector("#swalThumb");if(i)s.src=a.original,s.onload=function(){t.classList.add("is-hidden"),document.body.querySelector(".swal-overlay .swal-modal:not(.is-expanded)").classList.add("is-expanded")},s.onerror=function(e){e.currentTarget.classList.add("is-hidden"),t.className="button is-danger is-fullwidth",t.innerHTML='\n \n \n \n Unable to load original\n '};else if(l){s.classList.add("is-hidden");var r=document.createElement("video");r.id="swalVideo",r.controls=!0,r.autoplay=!0,r.src=a.original,s.insertAdjacentElement("afterend",r),t.classList.add("is-hidden"),document.body.querySelector(".swal-overlay .swal-modal:not(.is-expanded)").classList.add("is-expanded")}}})))}return swal({content:n,buttons:!1}).then((function(){var e=n.querySelector("#swalVideo");e&&e.remove(),document.body.querySelector(".swal-overlay .swal-modal").classList.remove("is-expanded")}))}},selectAll:function(e){for(var a=0;at&&s>t&&sn&&sdate: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? Don\'t fret, 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 Its format is: 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, userid, 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 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 Internals:\n First, query uploads passing ALL exclusion filter keys OR matching ANY filter keys, if any.\n Second, refine matches using range keys, if any.\n Third, refine matches using ANY non-keyed keywords, if any.\n Fourth, filter matches using ALL exclusion non-keyed keywords, if any.\n Fifth, sort matches using sorting keys, if any.\n\n Examples:\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 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 user:"John Doe" sort:size\n *.mp4 user:- sort:size:d\n\n Friendly reminder: This window can be scrolled up!\n '.trim().replace(/^ {6}/gm,"").replace(/\n/g,"
"),swal({content:a}).then((function(){document.body.querySelector(".swal-overlay .swal-modal").classList.remove("is-expanded")})),document.body.querySelector(".swal-overlay .swal-modal:not(.is-expanded)").classList.add("is-expanded")},filterUploads:function(e){var a=document.querySelector("#"+(e.dataset.filtersid||"filters")).value.trim();page.getUploads({all:!0,filters:a},e)},viewUserUploads:function(e,a){var n=page.cache.users[e];if(n){a.classList.add("is-loading");var t=n.username.includes(" ")?'"'+n.username+'"':n.username;page.getUploads({all:!0,filters:"user:"+t,trigger:document.querySelector("#itemManageUploads")})}},deleteUpload:function(e){page.postBulkDeleteUploads({all:"uploadsAll"===page.currentView,field:"id",values:[e],cb:function(a){!a.length&&page.selected[page.currentView].includes(e)&&page.selected[page.currentView].splice(page.selected[page.currentView].indexOf(e),1),page.selected[page.currentView].length?localStorage[lsKeys.selected[page.currentView]]=JSON.stringify(page.selected[page.currentView]):delete localStorage[lsKeys.selected[page.currentView]],page.getUploads(Object.assign(page.views[page.currentView],{autoPage:!0}))}})},bulkDeleteUploads:function(){if(!page.selected[page.currentView].length)return swal("An error occurred!","You have not selected any uploads.","error");page.postBulkDeleteUploads({all:"uploadsAll"===page.currentView,field:"id",values:page.selected[page.currentView],cb:function(e){e.length?page.selected[page.currentView]=page.selected[page.currentView].filter((function(a){return e.includes(a)})):page.selected[page.currentView]=[],page.selected[page.currentView].length?localStorage[lsKeys.selected[page.currentView]]=JSON.stringify(page.selected[page.currentView]):delete localStorage[lsKeys.selected[page.currentView]],page.getUploads(Object.assign(page.views[page.currentView],{autoPage:!0}))}})},deleteUploadsByNames:function(e){void 0===e&&(e={});var a="";page.permissions.moderator&&(a="
Hint: You can use this feature to delete uploads by other users."),page.dom.innerHTML='\n
\n
\n \n
\n \n
\n

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

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

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

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

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

");var s=document.createElement("div");s.innerHTML=t,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(t){t&&axios.post("api/upload/bulkdelete",{field:e.fields,values:e.values}).then((function(t){if(t){if(!1===t.data.success)return"No token provided"===t.data.description?page.verifyToken(page.token):swal("An error occurred!",t.data.description,"error");var s=Array.isArray(t.data.failed)?t.data.failed:[];s.length===e.values.length?swal("An error occurred!","Unable to delete any of the "+n+".","error"):s.length&&s.length\n

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

\n

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

\n \n
\n
\n
\n \n
\n
\n
\n ',swal({icon:"warning",content:t,buttons:{cancel:!0,confirm:{text:"OK",closeModal:!1}}}).then((function(n){if(n){var t=parseInt(document.querySelector("#swalAlbum").value);if(isNaN(t))return swal("An error occurred!","You did not choose an album.","error");axios.post("api/albums/addfiles",{ids:e,albumid:t}).then((function(n){if(n)if(!1!==n.data.success){var s=e.length;n.data.failed&&n.data.failed.length&&(s-=n.data.failed.length);var i="upload"+(1===e.length?"":"s");if(!s)return swal("An error occurred!","Could not add the "+i+" to the album.","error");swal("Woohoo!","Successfully "+(t<0?"removed":"added")+" "+s+" "+i+" "+(t<0?"from":"to")+" the album.","success",{buttons:!1,timer:1500}),a(n.data.failed)}else"No token provided"===n.data.description?page.verifyToken(page.token):swal("An error occurred!",n.data.description,"error")})).catch(page.onAxiosError)}})),axios.get("api/albums").then((function(e){if(!1!==e.data.success){var a=document.querySelector("#swalAlbum");a&&(a.innerHTML+=e.data.albums.map((function(e){return'"})).join("\n"),a.getElementsByTagName("option")[1].innerHTML="Choose an album",a.removeAttribute("disabled"))}else"No token provided"===e.data.description?page.verifyToken(page.token):swal("An error occurred!",e.data.description,"error")})).catch(page.onAxiosError)},getAlbums:function(e){void 0===e&&(e={}),page.updateTrigger(e.trigger,"loading"),axios.get("api/albums").then((function(a){if(a){if(!1===a.data.success)return"No token provided"===a.data.description?page.verifyToken(page.token):(page.updateTrigger(e.trigger),swal("An error occurred!",a.data.description,"error"));page.cache.albums={},page.dom.innerHTML='\n

Create new album

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

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

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

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

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

List of albums

\n
\n \n \n \n \n \n \n \n \n \n \n \n \n \n
IDNameFilesCreated atPublic link
\n
\n ';for(var n=a.data.homeDomain,t=document.querySelector("#table"),s=0;s"+i.id+"\n "+i.name+"\n "+i.files+"\n "+i.prettyDate+"\n '+l+'\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n ',t.appendChild(r)}page.fadeAndScroll(),page.updateTrigger(e.trigger,"active")}})).catch((function(a){page.updateTrigger(e.trigger),page.onAxiosError(a)}))},editAlbum:function(e){var a=page.cache.albums[e];if(a){var n=document.createElement("div");n.innerHTML='\n
\n
\n \n
\n

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

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

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

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

Username: "+e.data.username+"

\n

Password: "+e.data.password+"

\n

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

\n ",swal({title:"Created a new user!",icon:"success",content:a}),page.getUsers(Object.assign(page.views.users,{pageNum:-1}))}})).catch(page.onAxiosError)}))},editUser:function(e){var a=page.cache.users[e];if(a){var n=Object.keys(page.permissions).map((function(e,n,t){return'"})).join("\n"),t=document.createElement("div");t.innerHTML='\n
\n \n
\n \n
\n
\n
\n \n
\n
\n \n
\n
\n
\n
\n
\n \n
\n
\n
\n
\n \n
\n
\n ',swal({title:"Edit user",icon:"info",content:t,buttons:{cancel:!0,confirm:{closeModal:!1}}}).then((function(n){n&&axios.post("api/users/edit",{id:e,username:document.querySelector("#swalUsername").value,group:document.querySelector("#swalGroup").value,enabled:document.querySelector("#swalEnabled").checked,resetPassword:document.querySelector("#swalResetPassword").checked}).then((function(e){if(e){if(!1===e.data.success)return"No token provided"===e.data.description?page.verifyToken(page.token):swal("An error occurred!",e.data.description,"error");var n=!0,t=document.createElement("div"),s=a.username;e.data.update.username!==a.username&&(t.innerHTML+="

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

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

"+s+"'s new password is:

\n

"+e.data.update.password+"

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

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

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

"+s+" was edited!

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

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

\n

Their files will remain.

\n ",swal({title:"Are you sure?",icon:"warning",content:n,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.users[e].username+" has been disabled.","success",{buttons:!1,timer:1500}),page.getUsers(page.views.users)}})).catch(page.onAxiosError)}))}},deleteUser:function(e){if(page.cache.users[e]){var a=document.createElement("div");a.innerHTML="\n

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

\n

Their files will remain, unless you choose otherwise.

\n ",swal({title:"Are you sure?",icon:"warning",content:a,dangerMode:!0,buttons:{cancel:!0,confirm:{text:"Yes, delete it!",closeModal:!1},purge:{text:"Yes, and the 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 n=Array.isArray(a.data.failed)?a.data.failed:[];return"No token provided"===a.data.description?page.verifyToken(page.token):n.length?swal("An error occurred!","Unable to delete "+n.length+" of the user's upload"+(1===n.length?"":"s")+".","error"):swal("An error occurred!",a.data.description,"error")}swal("Success!",page.cache.users[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,n){n+=1;var t=Math.ceil(e/a),s="",i=function(e,a){for(var t=e;t<=a;++t)s+='
  • '+t+"
  • "},l=function(){s+='\n
  • 1
  • \n
  • \n '},r=function(){s+='\n
  • \n
  • '+t+"
  • \n "};return 7>=t?i(1,t):n<6?(i(1,6),r()):n>t-6+1?(l(),i(t-6+1,t)):(l(),i(n-3+1,n+3-1),r()),'\n \n "},getStatistics:function(e){if(void 0===e&&(e={}),!page.permissions.admin)return swal("An error occurred!","You can not do this!","error");page.updateTrigger(e.trigger,"loading");axios.get("api/stats").then((function(a){if(!1===a.data.success)return"No token provided"===a.data.description?page.verifyToken(page.token):(page.updateTrigger(e.trigger),swal("An error occurred!",a.data.description,"error"));for(var n="",t=Object.keys(a.data.stats),s=0;s\n "+d+"\n \n "}}catch(e){i="\n \n Error parsing response. Try again?\n \n \n ",page.onError(e)}else i+="\n \n Generating, please try again later…\n \n \n ";n+='\n
    \n \n \n \n \n \n \n \n \n "+i+"\n \n
    '+t[s].toUpperCase()+"
    \n
    \n "}page.dom.innerHTML=n,page.fadeAndScroll(),page.updateTrigger(e.trigger,"active")})).catch((function(a){page.updateTrigger(e.trigger),page.onAxiosError(a)}))}};window.onload=function(){"function"!=typeof Object.assign&&Object.defineProperty(Object,"assign",{value:function(e,a){"use strict";var n=arguments;if(null==e)throw new TypeError("Cannot convert undefined or null to object");for(var t=Object(e),s=1;s",swal({title:"An error occurred!",icon:"error",content:a})},onAxiosError:function(e){console.error(e);var a={520:"Unknown Error",521:"Web Server Is Down",522:"Connection Timed Out",523:"Origin Is Unreachable",524:"A Timeout Occurred",525:"SSL Handshake Failed",526:"Invalid SSL Certificate",527:"Railgun Error",530:"Origin DNS Error"}[e.response.status]||e.response.statusText,t=e.response.data&&e.response.data.description?e.response.data.description:"There was an error with the request, please check the console for more information.";return swal(e.response.status+" "+a,t,"error")},preparePage:function(){page.token?page.verifyToken(page.token,!0):window.location="auth"},checkClientVersion:function(e){var a=document.querySelector("#mainScript").src.match(/\?_=(\d+)$/);if(a&&a[1]&&a[1]!==e)return swal({title:"Updated detected!",text:"Client assets have been updated. Reload to display the latest version?",icon:"info",buttons:{confirm:{text:"Reload",closeModal:!1}}}).then((function(){location.reload()}))},verifyToken:function(e,a){axios.post("api/tokens/verify",{token:e}).then((function(t){if(!1===t.data.success)return swal({title:"An error occurred!",text:t.data.description,icon:"error"}).then((function(){a&&(localStorage.removeItem(lsKeys.token),window.location="auth")}));axios.defaults.headers.common.token=e,localStorage[lsKeys.token]=e,t.data.version&&page.checkClientVersion(t.data.version),page.token=e,page.username=t.data.username,page.permissions=t.data.permissions,page.prepareDashboard()})).catch(page.onAxiosError)},prepareDashboard:function(){page.dom=document.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:"#itemManageAlbums",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:"#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){page.menusContainer.classList.contains("is-loading")||e[a].onclick.call(null,Object.assign({trigger:t.currentTarget},e[a].params||{}))})),t.classList.remove("is-hidden"),page.menus.push(t)}},t=0;t\n '+('\n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n ')+'\n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n ',c='\n
    \n
    \n \n \n
    \n ',d=o.replace(/id="filters"/,'id="bFilters"').replace(/(data-action="filter-uploads")/,'$1 data-filtersid="bFilters"').replace(/id="jumpToPage"/,'id="bJumpToPage"').replace(/(data-action="jump-to-page")/g,'$1 data-jumpid="bJumpToPage"'),u=r.replace(/(data-action="page-ellipsis")/g,'$1 data-jumpid="bJumpToPage"'),p=!1,g=n.some((function(e){return void 0!==e.expirydate})),m=0;m\n \n '+c+"\n "+d+"\n "+u+"\n ";for(var v=document.querySelector("#table"),f=0;f'+w.name+'':y.innerHTML='

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

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

    '+w.name+"

    \n

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

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

    EXP: '+w.prettyExpiryDate+"

    ":"")+"\n
    \n ",v.appendChild(y),page.checkboxes[page.currentView]=v.querySelectorAll('.checkbox[data-action="select"]')}}else{page.dom.innerHTML="\n "+r+"\n "+o+"\n "+c+'\n
    \n \n \n \n \n \n '+(void 0===e.album?"":"")+"\n \n "+(e.all?"":"")+"\n \n "+(g?"":"")+'\n \n \n \n \n \n
    File name"+(e.all?"User":"Album")+"SizeIPDateExpiry date
    \n
    \n '+c+"\n "+d+"\n "+u+"\n ";for(var k=document.querySelector("#table"),x=0;x\n '+T.name+"\n "+(void 0===e.album?""+T.appendix+"":"")+"\n "+T.prettyBytes+"\n "+(e.all?""+(T.ip||"")+"":"")+"\n "+T.prettyDate+"\n "+(g?""+(T.prettyExpiryDate||"-")+"":"")+'\n \n \n \n \n \n \n \n \n \n \n \n '+(e.all?"":'\n \n \n \n \n ')+'\n \n \n \n \n \n \n ',k.appendChild(A),page.checkboxes[page.currentView]=k.querySelectorAll('.checkbox[data-action="select"]')}}var S=document.querySelector("#selectAll");S&&!p&&n.length&&(S.checked=!0,S.title="Unselect all"),"thumbs"===page.views[page.currentView].type?(page.fadeAndScroll(!0),page.lazyLoad.update()):page.fadeAndScroll(),page.updateTrigger(e.trigger,"active"),"uploads"===page.currentView&&(page.views.uploads.album=e.album),"uploadsAll"===page.currentView&&(page.views.uploadsAll.filters=e.filters),page.views[page.currentView].pageNum=n.length?e.pageNum:0})).catch((function(a){page.updateTrigger(e.trigger),page.onAxiosError(a)}))},setUploadsView:function(e,a){localStorage[lsKeys.viewType[page.currentView]]=e,page.views[page.currentView].type=e,page.getUploads(Object.assign({trigger:a},page.views[page.currentView]))},displayPreview:function(e){var a=page.cache.uploads[e];if(a.thumb){var t=document.createElement("div");if(t.innerHTML='\n
    \n \n
    \n \n
    \n
    \n ',a.original){var n=/.[\w]+(\?|$)/.exec(a.original),s=n&&n[0]?n[0].toLowerCase():null,i=page.imageExts.includes(s),l=!i&&page.videoExts.includes(s);(i||l)&&(t.innerHTML+='\n \n ',t.querySelector("#swalOriginal").addEventListener("click",(function(e){var n=e.currentTarget;if(!n.classList.contains("is-danger")){n.classList.add("is-loading");var s=t.querySelector("#swalThumb");if(i)s.src=a.original,s.onload=function(){n.classList.add("is-hidden"),document.body.querySelector(".swal-overlay .swal-modal:not(.is-expanded)").classList.add("is-expanded")},s.onerror=function(e){e.currentTarget.classList.add("is-hidden"),n.className="button is-danger is-fullwidth",n.innerHTML='\n \n \n \n Unable to load original\n '};else if(l){s.classList.add("is-hidden");var r=document.createElement("video");r.id="swalVideo",r.controls=!0,r.autoplay=!0,r.src=a.original,s.insertAdjacentElement("afterend",r),n.classList.add("is-hidden"),document.body.querySelector(".swal-overlay .swal-modal:not(.is-expanded)").classList.add("is-expanded")}}})))}return swal({content:t,buttons:!1}).then((function(){var e=t.querySelector("#swalVideo");e&&e.remove(),document.body.querySelector(".swal-overlay .swal-modal").classList.remove("is-expanded")}))}},selectAll:function(e){for(var a=0;an&&s>n&&st&&suser (username) and ip.\n These keys can be specified more than once.\n For usernames with whitespaces, wrap them with double quotes (").\n Special cases such as uploads by non-registered users or have no IPs respectively, use user:- or ip:-.\n\n To exclude certain users/ips while still listing every other uploads, add negation sign (-) before the keys.\n Negation sign can also be used to exclude the special cases mentioned above (i.e. -user:- or -ip:-).\n ':"")+'\n 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.\n 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 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? Don\'t fret, 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 Its format is: 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 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 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 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?"":"\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,"
    "),swal({content:t}).then((function(){document.body.querySelector(".swal-overlay .swal-modal").classList.remove("is-expanded")})),document.body.querySelector(".swal-overlay .swal-modal:not(.is-expanded)").classList.add("is-expanded")},filterUploads:function(e){var a=document.querySelector("#"+(e.dataset.filtersid||"filters")).value.trim();page.getUploads(Object.assign(page.views[page.currentView],{filters:a,pageNum:0}),e)},viewUserUploads:function(e,a){var t=page.cache.users[e];if(t){a.classList.add("is-loading");var n=t.username.includes(" ")?'"'+t.username+'"':t.username;page.getUploads({all:!0,filters:"user:"+n,trigger:document.querySelector("#itemManageUploads")})}},deleteUpload:function(e){page.postBulkDeleteUploads({all:"uploadsAll"===page.currentView,field:"id",values:[e],cb:function(a){!a.length&&page.selected[page.currentView].includes(e)&&page.selected[page.currentView].splice(page.selected[page.currentView].indexOf(e),1),page.selected[page.currentView].length?localStorage[lsKeys.selected[page.currentView]]=JSON.stringify(page.selected[page.currentView]):delete localStorage[lsKeys.selected[page.currentView]],page.getUploads(Object.assign(page.views[page.currentView],{autoPage:!0}))}})},bulkDeleteUploads:function(){if(!page.selected[page.currentView].length)return swal("An error occurred!","You have not selected any uploads.","error");page.postBulkDeleteUploads({all:"uploadsAll"===page.currentView,field:"id",values:page.selected[page.currentView],cb:function(e){e.length?page.selected[page.currentView]=page.selected[page.currentView].filter((function(a){return e.includes(a)})):page.selected[page.currentView]=[],page.selected[page.currentView].length?localStorage[lsKeys.selected[page.currentView]]=JSON.stringify(page.selected[page.currentView]):delete localStorage[lsKeys.selected[page.currentView]],page.getUploads(Object.assign(page.views[page.currentView],{autoPage:!0}))}})},deleteUploadsByNames:function(e){void 0===e&&(e={});var a="";page.permissions.moderator&&(a="
    Hint: You can use this feature to delete uploads by other users."),page.dom.innerHTML='\n
    \n
    \n \n
    \n \n
    \n

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

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

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

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

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

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

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

    \n

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

    \n \n
    \n
    \n
    \n \n
    \n
    \n
    \n ',swal({icon:"warning",content:n,buttons:{cancel:!0,confirm:{text:"OK",closeModal:!1}}}).then((function(t){if(t){var n=parseInt(document.querySelector("#swalAlbum").value);if(isNaN(n))return swal("An error occurred!","You did not choose an album.","error");axios.post("api/albums/addfiles",{ids:e,albumid:n}).then((function(t){if(t)if(!1!==t.data.success){var s=e.length;t.data.failed&&t.data.failed.length&&(s-=t.data.failed.length);var i="upload"+(1===e.length?"":"s");if(!s)return swal("An error occurred!","Could not add the "+i+" to the album.","error");swal("Woohoo!","Successfully "+(n<0?"removed":"added")+" "+s+" "+i+" "+(n<0?"from":"to")+" the album.","success",{buttons:!1,timer:1500}),a(t.data.failed)}else"No token provided"===t.data.description?page.verifyToken(page.token):swal("An error occurred!",t.data.description,"error")})).catch(page.onAxiosError)}})),axios.get("api/albums").then((function(e){if(!1!==e.data.success){var a=document.querySelector("#swalAlbum");a&&(a.innerHTML+=e.data.albums.map((function(e){return'"})).join("\n"),a.getElementsByTagName("option")[1].innerHTML="Choose an album",a.removeAttribute("disabled"))}else"No token provided"===e.data.description?page.verifyToken(page.token):swal("An error occurred!",e.data.description,"error")})).catch(page.onAxiosError)},getAlbums:function(e){void 0===e&&(e={}),page.updateTrigger(e.trigger,"loading"),axios.get("api/albums").then((function(a){if(a){if(!1===a.data.success)return"No token provided"===a.data.description?page.verifyToken(page.token):(page.updateTrigger(e.trigger),swal("An error occurred!",a.data.description,"error"));page.cache.albums={},page.dom.innerHTML='\n

    Create new album

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

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

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

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

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

    List of albums

    \n
    \n \n \n \n \n \n \n \n \n \n \n \n \n \n
    IDNameFilesCreated atPublic link
    \n
    \n ';for(var t=a.data.homeDomain,n=document.querySelector("#table"),s=0;s"+i.id+"\n "+i.name+"\n "+i.files+"\n "+i.prettyDate+"\n '+l+'\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n ',n.appendChild(r)}page.fadeAndScroll(),page.updateTrigger(e.trigger,"active")}})).catch((function(a){page.updateTrigger(e.trigger),page.onAxiosError(a)}))},editAlbum:function(e){var a=page.cache.albums[e];if(a){var t=document.createElement("div");t.innerHTML='\n
    \n
    \n \n
    \n

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

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

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

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

    Username: "+e.data.username+"

    \n

    Password: "+e.data.password+"

    \n

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

    \n ",swal({title:"Created a new user!",icon:"success",content:a}),page.getUsers(Object.assign(page.views.users,{pageNum:-1}))}})).catch(page.onAxiosError)}))},editUser:function(e){var a=page.cache.users[e];if(a){var t=Object.keys(page.permissions).map((function(e,t,n){return'"})).join("\n"),n=document.createElement("div");n.innerHTML='\n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n ',swal({title:"Edit user",icon:"info",content:n,buttons:{cancel:!0,confirm:{closeModal:!1}}}).then((function(t){t&&axios.post("api/users/edit",{id:e,username:document.querySelector("#swalUsername").value,group:document.querySelector("#swalGroup").value,enabled:document.querySelector("#swalEnabled").checked,resetPassword:document.querySelector("#swalResetPassword").checked}).then((function(e){if(e){if(!1===e.data.success)return"No token provided"===e.data.description?page.verifyToken(page.token):swal("An error occurred!",e.data.description,"error");var t=!0,n=document.createElement("div"),s=a.username;e.data.update.username!==a.username&&(n.innerHTML+="

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

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

    "+s+"'s new password is:

    \n

    "+e.data.update.password+"

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

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

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

    "+s+" was edited!

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

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

    \n

    Their files will remain.

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

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

    \n

    Their files will remain, unless you choose otherwise.

    \n ",swal({title:"Are you sure?",icon:"warning",content:a,dangerMode:!0,buttons:{cancel:!0,confirm:{text:"Yes, delete it!",closeModal:!1},purge:{text:"Yes, and the 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.users[e].username+" has been deleted.","success",{buttons:!1,timer:1500}),page.getUsers(Object.assign(page.views.users,{autoPage:!0}))}})).catch(page.onAxiosError)}))}},paginate:function(e,a,t){t+=1;var n=Math.ceil(e/a),s="",i=function(e,a){for(var n=e;n<=a;++n)s+='
  • '+n+"
  • "},l=function(){s+='\n
  • 1
  • \n
  • \n '},r=function(){s+='\n
  • \n
  • '+n+"
  • \n "};return 7>=n?i(1,n):t<6?(i(1,6),r()):t>n-6+1?(l(),i(n-6+1,n)):(l(),i(t-3+1,t+3-1),r()),'\n \n "},getStatistics:function(e){if(void 0===e&&(e={}),!page.permissions.admin)return swal("An error occurred!","You cannot do this!","error");page.updateTrigger(e.trigger,"loading");axios.get("api/stats").then((function(a){if(!1===a.data.success)return"No token provided"===a.data.description?page.verifyToken(page.token):(page.updateTrigger(e.trigger),swal("An error occurred!",a.data.description,"error"));for(var t="",n=Object.keys(a.data.stats),s=0;s\n "+d+"\n \n "}}catch(e){i="\n \n Error parsing response. Try again?\n \n \n ",page.onError(e)}else i+="\n \n Generating, please try again later…\n \n \n ";t+='\n
    \n \n \n \n \n \n \n \n \n "+i+"\n \n
    '+n[s].toUpperCase()+"
    \n
    \n "}page.dom.innerHTML=t,page.fadeAndScroll(),page.updateTrigger(e.trigger,"active")})).catch((function(a){page.updateTrigger(e.trigger),page.onAxiosError(a)}))}};window.onload=function(){"function"!=typeof Object.assign&&Object.defineProperty(Object,"assign",{value:function(e,a){"use strict";var t=arguments;if(null==e)throw new TypeError("Cannot convert undefined or null to object");for(var n=Object(e),s=1;s {\n document.querySelector('#loader').classList.add('is-hidden')\n document.querySelector('#dashboard').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 = `${error.toString()}`\n return swal({\n title: 'An error occurred!',\n icon: 'error',\n content\n })\n}\n\n// Handler for Axios errors\npage.onAxiosError = error => {\n console.error(error)\n\n // Better Cloudflare errors\n const cloudflareErrors = {\n 520: 'Unknown Error',\n 521: 'Web Server Is Down',\n 522: 'Connection Timed Out',\n 523: 'Origin Is Unreachable',\n 524: 'A Timeout Occurred',\n 525: 'SSL Handshake Failed',\n 526: 'Invalid SSL Certificate',\n 527: 'Railgun Error',\n 530: 'Origin DNS Error'\n }\n\n const statusText = cloudflareErrors[error.response.status] || error.response.statusText\n const description = error.response.data && error.response.data.description\n ? error.response.data.description\n : 'There was an error with the request, please check the console for more information.'\n\n return swal(`${error.response.status} ${statusText}`, description, 'error')\n}\n\npage.preparePage = () => {\n if (page.token)\n page.verifyToken(page.token, true)\n else\n 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: 'Updated 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 location.reload()\n })\n}\n\npage.verifyToken = (token, reloadOnError) => {\n axios.post('api/tokens/verify', { token }).then(response => {\n if (response.data.success === false)\n return swal({\n title: 'An error occurred!',\n text: response.data.description,\n icon: 'error'\n }).then(() => {\n if (!reloadOnError) return\n localStorage.removeItem(lsKeys.token)\n window.location = 'auth'\n })\n\n 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 page.token = token\n page.username = response.data.username\n page.permissions = response.data.permissions\n page.prepareDashboard()\n }).catch(page.onAxiosError)\n}\n\npage.prepareDashboard = () => {\n page.dom = document.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 }, 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: '#itemManageAlbums', 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: '#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])\n continue\n\n // Add onclick event listener\n const item = document.querySelector(itemMenus[i].selector)\n item.addEventListener('click', event => {\n // TODO: This class name isn't actually being applied fast enough\n if (page.menusContainer.classList.contains('is-loading'))\n return\n\n // eslint-disable-next-line compat/compat\n itemMenus[i].onclick.call(null, Object.assign({\n trigger: event.currentTarget\n }, itemMenus[i].params || {}))\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')\n 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.updateTrigger = (trigger, newState) => {\n if (!trigger) return\n\n // Disable menus container and pagination when loading\n if (newState === 'loading') {\n page.menusContainer.classList.add('is-loading')\n const paginations = page.dom.querySelectorAll('.pagination')\n for (let i = 0; i < paginations.length; i++)\n paginations[i].classList.add('is-loading')\n } else {\n page.menusContainer.classList.remove('is-loading')\n const paginations = page.dom.querySelectorAll('.pagination.is-loading')\n for (let i = 0; i < paginations.length; i++)\n paginations[i].classList.remove('is-loading')\n }\n\n if (newState === 'loading') {\n trigger.classList.add('is-loading')\n } else if (newState === 'active') {\n if (trigger.parentNode.tagName !== 'LI')\n return\n for (let i = 0; i < page.menus.length; i++)\n page.menus[i].classList.remove('is-active')\n trigger.classList.remove('is-loading')\n trigger.classList.add('is-active')\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 if (['SPAN'].includes(element.tagName) && ['A', 'BUTTON'].includes(element.parentNode.tagName))\n element = element.parentNode\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 '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 'delete-album':\n return page.deleteAlbum(id)\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 /* // WIP\n case 'user-filters-help':\n return page.userFiltersHelp(element)\n case 'filter-users':\n return page.filterUsers(element)\n */\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.fadeAndScroll = 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 page.dom.scrollIntoView({\n behavior: disableFading ? 'auto' : 'smooth',\n block: 'start',\n inline: 'nearest'\n })\n}\n\npage.switchPage = (action, element) => {\n // Skip if other pagination buttons are still loading\n const isLoading = page.dom.querySelectorAll('.pagination.is-loading')\n if (isLoading.length) return\n\n // eslint-disable-next-line compat/compat\n const params = Object.assign({\n trigger: element\n }, page.views[page.currentView])\n\n const func = page.currentView === 'users' ? page.getUsers : page.getUploads\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 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 === undefined)\n params = {}\n\n if ((params.all || params.filters) && !page.permissions.moderator)\n return swal('An error occurred!', 'You can not do this!', 'error')\n\n page.updateTrigger(params.trigger, 'loading')\n\n if (typeof params.pageNum !== 'number' || params.pageNum < 0)\n params.pageNum = 0\n\n const url = params.album !== undefined\n ? `api/album/${params.album}/${params.pageNum}`\n : `api/uploads/${params.pageNum}`\n\n const headers = {\n all: params.all ? '1' : '',\n filters: params.filters || ''\n }\n\n // Send client timezone offset if using date filter\n // Server will pretend client is on UTC if missing\n if (headers.filters.includes('date:') || headers.filters.includes('expiry:'))\n headers.minOffset = new Date().getTimezoneOffset()\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 const pages = Math.ceil(response.data.count / 25)\n const files = response.data.files\n if (params.pageNum && (files.length === 0))\n if (params.autoPage) {\n params.pageNum = pages - 1\n return page.getUploads(params)\n } else {\n page.updateTrigger(params.trigger)\n return swal('An error occurred!', `There are no more uploads to populate page ${params.pageNum + 1}.`, 'error')\n }\n\n page.currentView = params.all ? 'uploadsAll' : 'uploads'\n page.cache.uploads = {}\n\n const albums = response.data.albums\n const users = response.data.users\n const basedomain = response.data.basedomain\n const pagination = page.paginate(response.data.count, 25, params.pageNum)\n\n let filter = '
    '\n if (params.all)\n filter = `\n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n `\n const extraControls = `\n
    \n ${filter}\n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n `\n\n const controls = `\n
    \n
    \n \n
    \n \n \n \n \n \n ${params.all ? '' : `\n \n \n \n \n `}\n \n \n \n \n Bulk delete\n \n
    \n
    \n `\n\n // Do some string replacements for bottom controls\n const bottomFiltersId = 'bFilters'\n const bottomJumpId = 'bJumpToPage'\n const bottomExtraControls = extraControls\n .replace(/id=\"filters\"/, `id=\"${bottomFiltersId}\"`)\n .replace(/(data-action=\"filter-uploads\")/, `$1 data-filtersid=\"${bottomFiltersId}\"`)\n .replace(/id=\"jumpToPage\"/, `id=\"${bottomJumpId}\"`)\n .replace(/(data-action=\"jump-to-page\")/g, `$1 data-jumpid=\"${bottomJumpId}\"`)\n const bottomPagination = pagination\n .replace(/(data-action=\"page-ellipsis\")/g, `$1 data-jumpid=\"${bottomJumpId}\"`)\n\n // Whether there are any unselected items\n let unselected = false\n\n const hasExpiryDateColumn = files.some(file => {\n return file.expirydate !== undefined\n })\n\n for (let i = 0; i < files.length; i++) {\n // Build full URLs\n files[i].file = `${basedomain}/${files[i].name}`\n if (files[i].thumb)\n files[i].thumb = `${basedomain}/${files[i].thumb}`\n\n // Determine types\n files[i].type = 'other'\n const exec = /.[\\w]+(\\?|$)/.exec(files[i].file)\n const extname = exec && exec[0] ? exec[0].toLowerCase() : null\n if (page.imageExts.includes(extname))\n files[i].type = 'picture'\n else if (page.videoExts.includes(extname))\n files[i].type = 'video'\n\n // Cache bare minimum data for thumbnails viewer\n page.cache.uploads[files[i].id] = {\n name: files[i].name,\n thumb: files[i].thumb,\n original: files[i].file,\n type: files[i].type\n }\n\n // Prettify\n files[i].prettyBytes = page.getPrettyBytes(parseInt(files[i].size))\n files[i].prettyDate = page.getPrettyDate(new Date(files[i].timestamp * 1000))\n\n if (hasExpiryDateColumn)\n files[i].prettyExpiryDate = files[i].expirydate\n ? page.getPrettyDate(new Date(files[i].expirydate * 1000))\n : null\n\n // Update selected status\n files[i].selected = page.selected[page.currentView].includes(files[i].id)\n if (!files[i].selected) unselected = true\n\n // Appendix (display album or user)\n if (params.all)\n files[i].appendix = files[i].userid\n ? users[files[i].userid] || ''\n : ''\n else if (params.album === undefined)\n files[i].appendix = files[i].albumid\n ? albums[files[i].albumid] || ''\n : ''\n }\n\n if (page.views[page.currentView].type === 'thumbs') {\n page.dom.innerHTML = `\n ${pagination}\n ${extraControls}\n ${controls}\n
    \n
    \n ${controls}\n ${bottomExtraControls}\n ${bottomPagination}\n `\n\n const table = document.querySelector('#table')\n\n for (let i = 0; i < files.length; i++) {\n const upload = files[i]\n const div = document.createElement('div')\n div.className = 'image-container column'\n div.dataset.id = upload.id\n\n if (upload.thumb !== undefined)\n div.innerHTML = `\"${upload.name}\"`\n else\n div.innerHTML = `

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

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

    ${upload.name}

    \n

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

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

    EXP: ${upload.prettyExpiryDate}

    ` : ''}\n
    \n `\n\n table.appendChild(div)\n page.checkboxes[page.currentView] = table.querySelectorAll('.checkbox[data-action=\"select\"]')\n }\n } else {\n page.dom.innerHTML = `\n ${pagination}\n ${extraControls}\n ${controls}\n
    \n \n \n \n \n \n ${params.album === undefined ? `` : ''}\n \n ${params.all ? '' : ''}\n \n ${hasExpiryDateColumn ? '' : ''}\n \n \n \n \n \n
    File name${params.all ? 'User' : 'Album'}SizeIPDateExpiry date
    \n
    \n ${controls}\n ${bottomExtraControls}\n ${bottomPagination}\n `\n\n const table = document.querySelector('#table')\n\n for (let i = 0; i < files.length; i++) {\n const upload = files[i]\n const tr = document.createElement('tr')\n tr.dataset.id = upload.id\n tr.innerHTML = `\n \n ${upload.name}\n ${params.album === undefined ? `${upload.appendix}` : ''}\n ${upload.prettyBytes}\n ${params.all ? `${upload.ip || ''}` : ''}\n ${upload.prettyDate}\n ${hasExpiryDateColumn ? `${upload.prettyExpiryDate || '-'}` : ''}\n \n \n \n \n \n \n \n \n \n \n \n ${params.all ? '' : `\n \n \n \n \n `}\n \n \n \n \n \n \n `\n\n table.appendChild(tr)\n page.checkboxes[page.currentView] = table.querySelectorAll('.checkbox[data-action=\"select\"]')\n }\n }\n\n const selectAll = document.querySelector('#selectAll')\n if (selectAll && !unselected && files.length) {\n selectAll.checked = true\n selectAll.title = 'Unselect all'\n }\n\n if (page.views[page.currentView].type === 'thumbs') {\n page.fadeAndScroll(true)\n page.lazyLoad.update()\n } else {\n page.fadeAndScroll()\n }\n\n page.updateTrigger(params.trigger, 'active')\n\n if (page.currentView === 'uploads')\n page.views.uploads.album = params.album\n if (page.currentView === 'uploadsAll')\n page.views.uploadsAll.filters = params.filters\n page.views[page.currentView].pageNum = files.length ? params.pageNum : 0\n }).catch(error => {\n page.updateTrigger(params.trigger)\n page.onAxiosError(error)\n })\n}\n\npage.setUploadsView = (view, element) => {\n localStorage[lsKeys.viewType[page.currentView]] = view\n page.views[page.currentView].type = view\n\n // eslint-disable-next-line compat/compat\n page.getUploads(Object.assign({\n trigger: element\n }, page.views[page.currentView]))\n}\n\npage.displayPreview = id => {\n const file = page.cache.uploads[id]\n if (!file.thumb) return\n\n const div = document.createElement('div')\n div.innerHTML = `\n
    \n \n
    \n \n
    \n
    \n `\n\n if (file.original) {\n const exec = /.[\\w]+(\\?|$)/.exec(file.original)\n const extname = exec && exec[0] ? exec[0].toLowerCase() : null\n const isimage = page.imageExts.includes(extname)\n const isvideo = !isimage && page.videoExts.includes(extname)\n\n if (isimage || isvideo) {\n div.innerHTML += `\n \n `\n\n div.querySelector('#swalOriginal').addEventListener('click', event => {\n const trigger = event.currentTarget\n if (trigger.classList.contains('is-danger'))\n return\n\n trigger.classList.add('is-loading')\n const thumb = div.querySelector('#swalThumb')\n\n if (isimage) {\n thumb.src = file.original\n thumb.onload = () => {\n trigger.classList.add('is-hidden')\n document.body.querySelector('.swal-overlay .swal-modal:not(.is-expanded)').classList.add('is-expanded')\n }\n thumb.onerror = event => {\n event.currentTarget.classList.add('is-hidden')\n trigger.className = 'button is-danger is-fullwidth'\n trigger.innerHTML = `\n \n \n \n Unable to load original\n `\n }\n } else if (isvideo) {\n thumb.classList.add('is-hidden')\n const video = document.createElement('video')\n video.id = 'swalVideo'\n video.controls = true\n video.autoplay = true\n video.src = file.original\n thumb.insertAdjacentElement('afterend', video)\n\n trigger.classList.add('is-hidden')\n document.body.querySelector('.swal-overlay .swal-modal:not(.is-expanded)').classList.add('is-expanded')\n }\n })\n }\n }\n\n return swal({\n content: div,\n buttons: false\n }).then(() => {\n // Destroy video, if necessary\n const video = div.querySelector('#swalVideo')\n if (video) video.remove()\n\n // Restore modal size\n document.body.querySelector('.swal-overlay .swal-modal').classList.remove('is-expanded')\n })\n}\n\npage.selectAll = element => {\n for (let i = 0; i < page.checkboxes[page.currentView].length; i++) {\n const id = page.getItemID(page.checkboxes[page.currentView][i])\n if (isNaN(id)) continue\n if (page.checkboxes[page.currentView][i].checked !== element.checked) {\n page.checkboxes[page.currentView][i].checked = element.checked\n if (page.checkboxes[page.currentView][i].checked)\n page.selected[page.currentView].push(id)\n else\n page.selected[page.currentView].splice(page.selected[page.currentView].indexOf(id), 1)\n }\n }\n\n if (page.selected[page.currentView].length)\n localStorage[lsKeys.selected[page.currentView]] = JSON.stringify(page.selected[page.currentView])\n else\n delete localStorage[lsKeys.selected[page.currentView]]\n\n element.title = element.checked ? 'Unselect all' : 'Select all'\n}\n\npage.selectInBetween = (element, lastElement) => {\n const thisIndex = parseInt(element.dataset.index)\n const lastIndex = parseInt(lastElement.dataset.index)\n\n const distance = Math.abs(thisIndex - lastIndex)\n if (distance < 2)\n return\n\n for (let i = 0; i < page.checkboxes[page.currentView].length; i++)\n if ((thisIndex > lastIndex && i > lastIndex && i < thisIndex) ||\n (thisIndex < lastIndex && i > thisIndex && i < lastIndex)) {\n // Check or uncheck depending on the state of the initial checkbox\n const checked = page.checkboxes[page.currentView][i].checked = lastElement.checked\n const id = page.getItemID(page.checkboxes[page.currentView][i])\n if (!page.selected[page.currentView].includes(id) && checked)\n page.selected[page.currentView].push(id)\n else if (page.selected[page.currentView].includes(id) && !checked)\n page.selected[page.currentView].splice(page.selected[page.currentView].indexOf(id), 1)\n }\n}\n\npage.select = (element, event) => {\n const id = page.getItemID(element)\n if (isNaN(id)) return\n\n const lastSelected = page.lastSelected[page.currentView]\n if (event.shiftKey && lastSelected) {\n page.selectInBetween(element, lastSelected)\n // Check or uncheck depending on the state of the initial checkbox\n element.checked = lastSelected.checked\n } else {\n page.lastSelected[page.currentView] = element\n }\n\n if (!page.selected[page.currentView].includes(id) && element.checked)\n page.selected[page.currentView].push(id)\n else if (page.selected[page.currentView].includes(id) && !element.checked)\n page.selected[page.currentView].splice(page.selected[page.currentView].indexOf(id), 1)\n\n // Update local storage\n if (page.selected[page.currentView].length)\n localStorage[lsKeys.selected[page.currentView]] = JSON.stringify(page.selected[page.currentView])\n else\n delete localStorage[lsKeys.selected[page.currentView]]\n}\n\npage.clearSelection = () => {\n const selected = page.selected[page.currentView]\n const type = page.currentView === 'users' ? 'users' : 'uploads'\n const count = selected.length\n if (!count)\n return swal('An error occurred!', `You have not selected any ${type}.`, 'error')\n\n const suffix = count === 1 ? type.substring(0, type.length - 1) : type\n return swal({\n title: 'Are you sure?',\n text: `You are going to unselect ${count} ${suffix}.`,\n buttons: true\n }).then(proceed => {\n if (!proceed) return\n\n const checkboxes = page.checkboxes[page.currentView]\n for (let i = 0; i < checkboxes.length; i++)\n if (checkboxes[i].checked)\n checkboxes[i].checked = false\n\n page.selected[page.currentView] = []\n delete localStorage[lsKeys.selected[page.currentView]]\n\n const selectAll = document.querySelector('#selectAll')\n if (selectAll) selectAll.checked = false\n\n return swal('Cleared selection!', `Unselected ${count} ${suffix}.`, 'success')\n })\n}\n\npage.uploadFiltersHelp = element => {\n const content = document.createElement('div')\n content.style = 'text-align: left'\n content.innerHTML = `\n There are 2 filter keys, namely user (username) and ip.\n These keys can be specified more than once.\n For usernames with whitespaces, wrap them with double quotes (\").\n Special cases such as uploads by non-registered users or have no IPs respectively, use user:- or ip:-.\n\n To exclude certain users/ips while still listing every other uploads, add negation sign (-) before the keys.\n Negation sign can also be used to exclude the special cases mentioned above (i.e. -user:- or -ip:-).\n\n 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 can specify only one date. 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 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? Don't fret, 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 Its format is: 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, userid, 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 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 Internals:\n First, query uploads passing ALL exclusion filter keys OR matching ANY filter keys, if any.\n Second, refine matches using range keys, if any.\n Third, refine matches using ANY non-keyed keywords, if any.\n Fourth, filter matches using ALL exclusion non-keyed keywords, if any.\n Fifth, sort matches using sorting keys, if any.\n\n Examples:\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 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 user:\"John Doe\" sort:size\n *.mp4 user:- sort:size:d\n\n Friendly reminder: This window can be scrolled up!\n `.trim().replace(/^ {6}/gm, '').replace(/\\n/g, '
    ')\n\n swal({ content }).then(() => {\n // Restore modal size\n document.body.querySelector('.swal-overlay .swal-modal').classList.remove('is-expanded')\n })\n\n // Expand modal size\n document.body.querySelector('.swal-overlay .swal-modal:not(.is-expanded)').classList.add('is-expanded')\n}\n\npage.filterUploads = element => {\n const filters = document.querySelector(`#${element.dataset.filtersid || 'filters'}`).value.trim()\n page.getUploads({ all: true, filters }, element)\n}\n\npage.viewUserUploads = (id, element) => {\n const user = page.cache.users[id]\n if (!user) return\n element.classList.add('is-loading')\n // Wrap username in quotes if it contains whitespaces\n const username = user.username.includes(' ')\n ? `\"${user.username}\"`\n : user.username\n page.getUploads({\n all: true,\n filters: `user:${username}`,\n trigger: document.querySelector('#itemManageUploads')\n })\n}\n\npage.deleteUpload = id => {\n page.postBulkDeleteUploads({\n all: page.currentView === 'uploadsAll',\n field: 'id',\n values: [id],\n cb (failed) {\n // Remove from remembered checkboxes if necessary\n if (!failed.length && page.selected[page.currentView].includes(id))\n page.selected[page.currentView].splice(page.selected[page.currentView].indexOf(id), 1)\n\n // Update local storage\n if (page.selected[page.currentView].length)\n localStorage[lsKeys.selected[page.currentView]] = JSON.stringify(page.selected[page.currentView])\n else\n delete localStorage[lsKeys.selected[page.currentView]]\n\n // Reload upload list\n // eslint-disable-next-line compat/compat\n page.getUploads(Object.assign(page.views[page.currentView], {\n autoPage: true\n }))\n }\n })\n}\n\npage.bulkDeleteUploads = () => {\n const count = page.selected[page.currentView].length\n if (!count)\n return swal('An error occurred!', 'You have not selected any uploads.', 'error')\n\n page.postBulkDeleteUploads({\n all: page.currentView === 'uploadsAll',\n field: 'id',\n values: page.selected[page.currentView],\n cb (failed) {\n // Update state of checkboxes\n if (failed.length)\n page.selected[page.currentView] = page.selected[page.currentView]\n .filter(id => {\n return failed.includes(id)\n })\n else\n page.selected[page.currentView] = []\n\n // Update local storage\n if (page.selected[page.currentView].length)\n localStorage[lsKeys.selected[page.currentView]] = JSON.stringify(page.selected[page.currentView])\n else\n delete localStorage[lsKeys.selected[page.currentView]]\n\n // Reload uploads list\n // eslint-disable-next-line compat/compat\n page.getUploads(Object.assign(page.views[page.currentView], {\n autoPage: true\n }))\n }\n })\n}\n\npage.deleteUploadsByNames = (params = {}) => {\n let appendix = ''\n if (page.permissions.moderator)\n appendix = '
    Hint: You can use this feature to delete uploads by other users.'\n\n page.dom.innerHTML = `\n
    \n
    \n \n
    \n \n
    \n

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

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

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

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

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

    `\n }\n\n const content = document.createElement('div')\n content.innerHTML = text\n\n swal({\n title: 'Are you sure?',\n content,\n icon: 'warning',\n dangerMode: true,\n buttons: {\n cancel: true,\n confirm: {\n text: `Yes, nuke ${params.values.length === 1 ? 'it' : 'them'}!`,\n closeModal: false\n }\n }\n }).then(proceed => {\n if (!proceed) return\n\n axios.post('api/upload/bulkdelete', {\n field: params.fields,\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 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 if (typeof params.cb === 'function')\n params.cb(failed)\n }).catch(page.onAxiosError)\n })\n}\n\npage.addSelectedUploadsToAlbum = () => {\n if (page.currentView !== 'uploads')\n return\n\n const count = page.selected[page.currentView].length\n if (!count)\n 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].filter(id => {\n return failed.includes(id)\n })\n else\n page.selected[page.currentView] = []\n\n localStorage[lsKeys.selected[page.currentView]] = JSON.stringify(page.selected[page.currentView])\n page.getUploads(page.views[page.currentView])\n })\n}\n\npage.addToAlbum = id => {\n page.addUploadsToAlbum([id], failed => {\n if (!failed) return\n page.getUploads(page.views[page.currentView])\n })\n}\n\npage.addUploadsToAlbum = (ids, callback) => {\n const count = ids.length\n\n const content = document.createElement('div')\n content.innerHTML = `\n
    \n

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

    \n

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

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n `\n\n swal({\n icon: 'warning',\n content,\n buttons: {\n cancel: true,\n confirm: {\n text: 'OK',\n closeModal: false\n }\n }\n }).then(choose => {\n if (!choose) return\n\n const albumid = parseInt(document.querySelector('#swalAlbum').value)\n if (isNaN(albumid))\n return swal('An error occurred!', 'You did not choose an album.', 'error')\n\n axios.post('api/albums/addfiles', {\n ids,\n albumid\n }).then(add => {\n if (!add) return\n\n if (add.data.success === false) {\n if (add.data.description === 'No token provided')\n page.verifyToken(page.token)\n else\n swal('An error occurred!', add.data.description, 'error')\n\n return\n }\n\n let added = ids.length\n if (add.data.failed && add.data.failed.length)\n added -= add.data.failed.length\n\n const suffix = `upload${ids.length === 1 ? '' : 's'}`\n if (!added)\n return swal('An error occurred!', `Could not add the ${suffix} to the album.`, 'error')\n\n swal('Woohoo!', `Successfully ${albumid < 0 ? 'removed' : 'added'} ${added} ${suffix} ${albumid < 0 ? 'from' : 'to'} the album.`, 'success', {\n buttons: false,\n timer: 1500\n })\n callback(add.data.failed)\n }).catch(page.onAxiosError)\n })\n\n // Get albums list then update content of swal\n axios.get('api/albums').then(list => {\n if (list.data.success === false) {\n if (list.data.description === 'No token provided')\n page.verifyToken(page.token)\n else\n swal('An error occurred!', list.data.description, 'error')\n\n return\n }\n\n // If the prompt was replaced, the container would be missing\n const select = document.querySelector('#swalAlbum')\n if (!select) return\n\n select.innerHTML += list.data.albums\n .map(album => {\n return ``\n })\n .join('\\n')\n\n select.getElementsByTagName('option')[1].innerHTML = 'Choose an album'\n select.removeAttribute('disabled')\n }).catch(page.onAxiosError)\n}\n\npage.getAlbums = (params = {}) => {\n page.updateTrigger(params.trigger, 'loading')\n\n axios.get('api/albums').then(response => {\n if (!response) return\n\n if (response.data.success === false)\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n page.updateTrigger(params.trigger)\n return swal('An error occurred!', response.data.description, 'error')\n }\n\n page.cache.albums = {}\n\n page.dom.innerHTML = `\n

    Create new album

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

    Max length is ${page.albumTitleMaxLength} characters.

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

    Max length is ${page.albumDescMaxLength} characters.

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

    List of albums

    \n
    \n \n \n \n \n \n \n \n \n \n \n \n \n \n
    IDNameFilesCreated atPublic link
    \n
    \n `\n\n const homeDomain = response.data.homeDomain\n const table = document.querySelector('#table')\n\n for (let i = 0; i < response.data.albums.length; i++) {\n const album = response.data.albums[i]\n const albumUrl = `${homeDomain}/a/${album.identifier}`\n\n // Prettify\n album.prettyDate = page.getPrettyDate(new Date(album.timestamp * 1000))\n\n page.cache.albums[album.id] = {\n name: album.name,\n download: album.download,\n public: album.public,\n description: album.description\n }\n\n const tr = document.createElement('tr')\n tr.innerHTML = `\n ${album.id}\n ${album.name}\n ${album.files}\n ${album.prettyDate}\n ${albumUrl}\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n `\n\n table.appendChild(tr)\n }\n page.fadeAndScroll()\n page.updateTrigger(params.trigger, 'active')\n }).catch(error => {\n page.updateTrigger(params.trigger)\n page.onAxiosError(error)\n })\n}\n\npage.editAlbum = id => {\n const album = page.cache.albums[id]\n if (!album) return\n\n const div = document.createElement('div')\n div.innerHTML = `\n
    \n
    \n \n
    \n

    Max length is ${page.albumTitleMaxLength} characters.

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

    Max length is ${page.albumDescMaxLength} characters.

    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n `\n\n swal({\n title: 'Edit album',\n icon: 'info',\n content: div,\n buttons: {\n cancel: true,\n confirm: {\n closeModal: false\n }\n }\n }).then(value => {\n if (!value) return\n\n axios.post('api/albums/edit', {\n id,\n name: document.querySelector('#swalName').value.trim(),\n description: document.querySelector('#swalDescription').value.trim(),\n download: document.querySelector('#swalDownload').checked,\n public: document.querySelector('#swalPublic').checked,\n requestLink: document.querySelector('#swalRequestLink').checked\n }).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 if (response.data.identifier)\n swal('Success!', `Your album's new identifier is: ${response.data.identifier}.`, 'success')\n else if (response.data.name !== album.name)\n swal('Success!', `Your album was renamed to: ${response.data.name}.`, 'success')\n else\n swal('Success!', 'Your album was edited!', 'success', {\n buttons: false,\n timer: 1500\n })\n\n page.getAlbumsSidebar()\n page.getAlbums()\n }).catch(page.onAxiosError)\n })\n}\n\npage.deleteAlbum = id => {\n swal({\n title: 'Are you sure?',\n text: 'This won\\'t delete your uploads, only the album!',\n icon: 'warning',\n dangerMode: true,\n buttons: {\n cancel: true,\n confirm: {\n text: 'Yes, delete it!',\n closeModal: false\n },\n purge: {\n text: 'Umm, delete the uploads too please?',\n value: 'purge',\n className: 'swal-button--danger',\n closeModal: false\n }\n }\n }).then(proceed => {\n if (!proceed) return\n\n axios.post('api/albums/delete', {\n id,\n purge: proceed === 'purge'\n }).then(response => {\n if (response.data.success === false) {\n const failed = Array.isArray(response.data.failed)\n ? response.data.failed\n : []\n\n if (response.data.description === 'No token provided')\n return page.verifyToken(page.token)\n else if (failed.length)\n return swal('An error occurred!', `Unable to delete ${failed.length} of the album's upload${failed.length === 1 ? '' : 's'}.`, 'error')\n else\n return swal('An error occurred!', response.data.description, 'error')\n }\n\n swal('Deleted!', 'Your album has been deleted.', 'success', {\n buttons: false,\n timer: 1500\n })\n page.getAlbumsSidebar()\n page.getAlbums()\n }).catch(page.onAxiosError)\n })\n}\n\npage.submitAlbum = element => {\n page.updateTrigger(element, 'loading')\n\n axios.post('api/albums', {\n name: document.querySelector('#albumName').value.trim(),\n description: document.querySelector('#albumDescription').value.trim()\n }).then(response => {\n if (!response) return\n\n page.updateTrigger(element)\n if (response.data.success === false)\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n return swal('An error occurred!', response.data.description, 'error')\n }\n\n swal('Woohoo!', 'Album was created successfully.', 'success', {\n buttons: false,\n timer: 1500\n })\n page.getAlbumsSidebar()\n page.getAlbums()\n }).catch(error => {\n page.updateTrigger(element)\n page.onAxiosError(error)\n })\n}\n\npage.getAlbumsSidebar = () => {\n axios.get('api/albums/sidebar').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 const albumsContainer = document.querySelector('#albumsContainer')\n\n // Clear albums sidebar if necessary\n const oldAlbums = albumsContainer.querySelectorAll('li > a')\n if (oldAlbums.length) {\n for (let i = 0; i < oldAlbums.length; i++)\n page.menus.splice(page.menus.indexOf(oldAlbums[i]), 1)\n albumsContainer.innerHTML = ''\n }\n\n if (response.data.albums === undefined)\n return\n\n for (let i = 0; i < response.data.albums.length; i++) {\n const album = response.data.albums[i]\n const li = document.createElement('li')\n const a = document.createElement('a')\n a.id = album.id\n a.innerHTML = album.name\n a.className = 'is-relative'\n\n a.addEventListener('click', event => {\n page.getUploads({\n album: parseInt(event.currentTarget.id),\n trigger: event.currentTarget\n })\n })\n page.menus.push(a)\n\n li.appendChild(a)\n albumsContainer.appendChild(li)\n }\n }).catch(page.onAxiosError)\n}\n\npage.changeToken = (params = {}) => {\n page.dom.innerHTML = `\n
    \n \n
    \n
    \n \n
    \n
    \n
    \n \n `\n page.fadeAndScroll()\n page.updateTrigger(params.trigger, 'active')\n\n document.querySelector('#getNewToken').addEventListener('click', event => {\n const trigger = event.currentTarget\n page.updateTrigger(trigger, 'loading')\n axios.post('api/tokens/change').then(response => {\n if (response.data.success === false)\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n page.updateTrigger(trigger)\n return swal('An error occurred!', response.data.description, 'error')\n }\n\n page.updateTrigger(trigger)\n swal({\n title: 'Woohoo!',\n text: 'Your token was successfully changed.',\n icon: 'success',\n buttons: false,\n timer: 1500\n }).then(() => {\n axios.defaults.headers.common.token = response.data.token\n localStorage[lsKeys.token] = response.data.token\n page.token = response.data.token\n page.changeToken()\n })\n }).catch(error => {\n page.updateTrigger(trigger)\n page.onAxiosError(error)\n })\n })\n}\n\npage.changePassword = (params = {}) => {\n page.dom.innerHTML = `\n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n `\n page.fadeAndScroll()\n page.updateTrigger(params.trigger, 'active')\n\n document.querySelector('#sendChangePassword').addEventListener('click', event => {\n if (!page.dom.querySelector('form').checkValidity()) return\n if (document.querySelector('#password').value === document.querySelector('#passwordConfirm').value)\n page.sendNewPassword(document.querySelector('#password').value, event.currentTarget)\n else\n swal({\n title: 'Password mismatch!',\n text: 'Your passwords do not match, please try again.',\n icon: 'error'\n })\n })\n}\n\npage.sendNewPassword = (pass, element) => {\n page.updateTrigger(element, 'loading')\n\n axios.post('api/password/change', { password: pass }).then(response => {\n if (response.data.success === false)\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n page.updateTrigger(element)\n return swal('An error occurred!', response.data.description, 'error')\n }\n\n page.updateTrigger(element)\n swal({\n title: 'Woohoo!',\n text: 'Your password was successfully changed.',\n icon: 'success',\n buttons: false,\n timer: 1500\n }).then(() => {\n page.changePassword()\n })\n }).catch(error => {\n page.updateTrigger(element)\n page.onAxiosError(error)\n })\n}\n\npage.getUsers = (params = {}) => {\n page.updateTrigger(params.trigger, 'loading')\n\n if (params.pageNum === undefined)\n params.pageNum = 0\n\n if (!page.permissions.admin)\n return swal('An error occurred!', 'You can not do this!', 'error')\n\n const url = `api/users/${params.pageNum}`\n axios.get(url).then(response => {\n if (response.data.success === false)\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n page.updateTrigger(params.trigger)\n return swal('An error occurred!', response.data.description, 'error')\n }\n\n const pages = Math.ceil(response.data.count / 25)\n if (params.pageNum && (response.data.users.length === 0))\n if (params.autoPage) {\n params.pageNum = pages - 1\n return page.getUsers(params)\n } else {\n page.updateTrigger(params.trigger)\n return swal('An error occurred!', `There are no more users to populate page ${params.pageNum + 1}.`, 'error')\n }\n\n page.currentView = 'users'\n page.cache.users = {}\n\n if (params.pageNum < 0) params.pageNum = Math.max(0, pages + params.pageNum)\n const pagination = page.paginate(response.data.count, 25, params.pageNum)\n\n const filter = `\n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n `\n const extraControls = `\n
    \n ${filter}\n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n `\n\n const controls = `\n \n `\n\n // Do some string replacements for bottom controls\n const bottomFiltersId = 'bFilters'\n const bottomJumpId = 'bJumpToPage'\n const bottomExtraControls = extraControls\n .replace(/id=\"filters\"/, `id=\"${bottomFiltersId}\"`)\n .replace(/(data-action=\"filter-uploads\")/, `$1 data-filtersid=\"${bottomFiltersId}\"`)\n .replace(/id=\"jumpToPage\"/, `id=\"${bottomJumpId}\"`)\n .replace(/(data-action=\"jump-to-page\")/g, `$1 data-jumpid=\"${bottomJumpId}\"`)\n const bottomPagination = pagination\n .replace(/(data-action=\"page-ellipsis\")/g, `$1 data-jumpid=\"${bottomJumpId}\"`)\n\n // Whether there are any unselected items\n let unselected = false\n\n page.dom.innerHTML = `\n ${pagination}\n ${extraControls}\n ${controls}\n
    \n \n \n \n \n \n \n \n \n \n \n \n \n \n
    UsernameUploadsUsageGroup
    \n
    \n ${controls}\n ${bottomExtraControls}\n ${bottomPagination}\n `\n\n const table = document.querySelector('#table')\n\n for (let i = 0; i < response.data.users.length; i++) {\n const user = response.data.users[i]\n const selected = page.selected.users.includes(user.id)\n if (!selected) unselected = true\n\n let displayGroup = null\n const groups = Object.keys(user.groups)\n for (let i = 0; i < groups.length; i++) {\n if (!user.groups[groups[i]]) break\n displayGroup = groups[i]\n }\n\n // Server-side explicitly expects either of these two values to consider a user as disabled\n const enabled = user.enabled !== false && user.enabled !== 0\n page.cache.users[user.id] = {\n username: user.username,\n groups: user.groups,\n enabled,\n displayGroup\n }\n\n const tr = document.createElement('tr')\n tr.dataset.id = user.id\n tr.innerHTML = `\n \n ${user.username}\n ${user.uploads}\n ${page.getPrettyBytes(user.usage)}\n ${displayGroup}\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n `\n\n table.appendChild(tr)\n page.checkboxes.users = table.querySelectorAll('.checkbox[data-action=\"select\"]')\n }\n\n const selectAll = document.querySelector('#selectAll')\n if (selectAll && !unselected) {\n selectAll.checked = true\n selectAll.title = 'Unselect all'\n }\n\n page.fadeAndScroll()\n page.updateTrigger(params.trigger, 'active')\n\n page.views.users.pageNum = response.data.users.length ? params.pageNum : 0\n }).catch(error => {\n page.updateTrigger(params.trigger)\n page.onAxiosError(error)\n })\n}\n\npage.createUser = () => {\n const groupOptions = Object.keys(page.permissions).map((g, i, a) => {\n const disabled = !(a[i + 1] && page.permissions[a[i + 1]])\n return ``\n }).join('\\n')\n\n const div = document.createElement('div')\n div.innerHTML = `\n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n `\n\n swal({\n title: 'Create new user',\n icon: 'info',\n content: div,\n buttons: {\n cancel: true,\n confirm: {\n closeModal: false\n }\n }\n }).then(proceed => {\n if (!proceed) return\n\n axios.post('api/users/create', {\n username: document.querySelector('#swalUsername').value,\n password: document.querySelector('#swalPassword').value,\n group: document.querySelector('#swalGroup').value\n }).then(response => {\n if (!response) return\n\n if (response.data.success === false)\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n return swal('An error occurred!', response.data.description, 'error')\n }\n\n const div = document.createElement('div')\n div.innerHTML = `\n

    Username: ${response.data.username}

    \n

    Password: ${response.data.password}

    \n

    User group: ${response.data.group}

    \n `\n swal({\n title: 'Created a new user!',\n icon: 'success',\n content: div\n })\n\n // Reload 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.users[id]\n if (!user) return\n\n const groupOptions = Object.keys(page.permissions).map((g, i, a) => {\n const selected = g === user.displayGroup\n const disabled = !(a[i + 1] && page.permissions[a[i + 1]])\n return ``\n }).join('\\n')\n\n const div = document.createElement('div')\n div.innerHTML = `\n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n `\n\n swal({\n title: 'Edit user',\n icon: 'info',\n content: div,\n buttons: {\n cancel: true,\n confirm: {\n closeModal: false\n }\n }\n }).then(proceed => {\n if (!proceed) return\n\n axios.post('api/users/edit', {\n id,\n username: document.querySelector('#swalUsername').value,\n group: document.querySelector('#swalGroup').value,\n enabled: document.querySelector('#swalEnabled').checked,\n resetPassword: document.querySelector('#swalResetPassword').checked\n }).then(response => {\n if (!response) return\n\n if (response.data.success === false)\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n return swal('An error occurred!', response.data.description, 'error')\n }\n\n let autoClose = true\n const div = document.createElement('div')\n\n let displayName = user.username\n if (response.data.update.username !== user.username) {\n div.innerHTML += `

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

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

    ${displayName}'s new password is:

    \n

    ${response.data.update.password}

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

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

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

    ${displayName} was edited!

    `\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.users[id]\n if (!user || !user.enabled) return\n\n const content = document.createElement('div')\n content.innerHTML = `\n

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

    \n

    Their files will remain.

    \n `\n\n swal({\n title: 'Are you sure?',\n icon: 'warning',\n content,\n dangerMode: true,\n buttons: {\n cancel: true,\n confirm: {\n text: 'Yes, disable them!',\n closeModal: false\n }\n }\n }).then(proceed => {\n if (!proceed) return\n\n axios.post('api/users/disable', { id }).then(response => {\n if (!response) return\n\n if (response.data.success === false)\n if (response.data.description === 'No token provided')\n return page.verifyToken(page.token)\n else\n return swal('An error occurred!', response.data.description, 'error')\n\n swal('Success!', `${page.cache.users[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.users[id]\n if (!user) return\n\n const content = document.createElement('div')\n content.innerHTML = `\n

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

    \n

    Their files will 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, delete it!',\n closeModal: false\n },\n purge: {\n text: 'Yes, and the 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 swal('Success!', `${page.cache.users[id].username} has been deleted.`, 'success', {\n buttons: false,\n timer: 1500\n })\n\n // Reload users list\n // eslint-disable-next-line compat/compat\n page.getUsers(Object.assign(page.views.users, {\n autoPage: true\n }))\n }).catch(page.onAxiosError)\n })\n}\n\n// Roughly based on https://github.com/mayuska/pagination/blob/master/index.js\npage.paginate = (totalItems, itemsPerPage, currentPage) => {\n currentPage = currentPage + 1\n const step = 3\n const numPages = Math.ceil(totalItems / itemsPerPage)\n\n let template = ''\n const elementsToShow = step * 2\n const add = {\n pageNum (start, end) {\n for (let i = start; i <= end; ++i)\n template += `
  • ${i}
  • `\n },\n startDots () {\n template += `\n
  • 1
  • \n
  • \n `\n },\n endDots () {\n template += `\n
  • \n
  • ${numPages}
  • \n `\n }\n }\n\n if (elementsToShow + 1 >= numPages) {\n add.pageNum(1, numPages)\n } else if (currentPage < elementsToShow) {\n add.pageNum(1, elementsToShow)\n add.endDots()\n } else if (currentPage > numPages - elementsToShow + 1) {\n add.startDots()\n add.pageNum(numPages - elementsToShow + 1, numPages)\n } else {\n add.startDots()\n add.pageNum(currentPage - step + 1, currentPage + step - 1)\n add.endDots()\n }\n\n return `\n \n `\n}\n\npage.getStatistics = (params = {}) => {\n if (!page.permissions.admin)\n return swal('An error occurred!', 'You can not do this!', 'error')\n\n page.updateTrigger(params.trigger, 'loading')\n\n const url = 'api/stats'\n axios.get(url).then(response => {\n if (response.data.success === false)\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n page.updateTrigger(params.trigger)\n return swal('An error occurred!', response.data.description, 'error')\n }\n\n let content = ''\n const keys = Object.keys(response.data.stats)\n for (let i = 0; i < keys.length; i++) {\n let rows = ''\n if (!response.data.stats[keys[i]])\n rows += `\n \n Generating, please try again later\\u2026\n \n \n `\n else\n try {\n const types = response.data.stats[keys[i]]._types || {}\n const valKeys = Object.keys(response.data.stats[keys[i]])\n for (let j = 0; j < valKeys.length; j++) {\n // Skip keys that starts with an underscore\n if (/^_/.test(valKeys[j]))\n continue\n\n const value = response.data.stats[keys[i]][valKeys[j]]\n let parsed = value\n\n // Parse values with some preset formatting\n if ((types.number || []).includes(valKeys[j]))\n parsed = value.toLocaleString()\n if ((types.byte || []).includes(valKeys[j]))\n parsed = page.getPrettyBytes(value)\n if ((types.byteUsage || []).includes(valKeys[j]))\n parsed = `${page.getPrettyBytes(value.used)} / ${page.getPrettyBytes(value.total)} (${Math.round(value.used / value.total * 100)}%)`\n\n const string = valKeys[j]\n .replace(/([A-Z])/g, ' $1')\n .toUpperCase()\n rows += `\n \n ${string}\n ${parsed}\n \n `\n }\n } catch (error) {\n rows = `\n \n Error parsing response. Try again?\n \n \n `\n page.onError(error)\n }\n\n content += `\n
    \n \n \n \n \n \n \n \n \n ${rows}\n \n
    ${keys[i].toUpperCase()}
    \n
    \n `\n }\n\n page.dom.innerHTML = content\n page.fadeAndScroll()\n page.updateTrigger(params.trigger, 'active')\n }).catch(error => {\n page.updateTrigger(params.trigger)\n page.onAxiosError(error)\n })\n}\n\nwindow.onload = () => {\n // Polyfill Object.assign()\n // eslint-disable-next-line compat/compat\n if (typeof Object.assign !== 'function')\n // Must be writable: true, enumerable: false, configurable: true\n Object.defineProperty(Object, 'assign', {\n value: function assign (target, varArgs) { // .length of function is 2\n 'use strict'\n if (target === null || target === undefined)\n throw new TypeError('Cannot convert undefined or null to object')\n const to = Object(target)\n for (let i = 1; i < arguments.length; i++) {\n const nextSource = arguments[i]\n if (nextSource !== null && nextSource !== undefined)\n for (const nextKey in nextSource)\n // Avoid bugs when hasOwnProperty is shadowed\n if (Object.prototype.hasOwnProperty.call(nextSource, nextKey))\n to[nextKey] = nextSource[nextKey]\n }\n return to\n },\n writable: true,\n configurable: true\n })\n\n // Add 'no-touch' class to non-touch devices\n if (!('ontouchstart' in document.documentElement))\n document.documentElement.classList.add('no-touch')\n\n const selectedKeys = ['uploads', 'uploadsAll', 'users']\n for (let i = 0; i < selectedKeys.length; i++) {\n const ls = localStorage[lsKeys.selected[selectedKeys[i]]]\n if (ls) page.selected[selectedKeys[i]] = JSON.parse(ls)\n }\n\n page.preparePage()\n\n page.clipboardJS = new ClipboardJS('.clipboard-js')\n\n page.clipboardJS.on('success', () => {\n return swal('', 'The link has been copied to clipboard.', 'success', {\n buttons: false,\n timer: 1500\n })\n })\n\n page.clipboardJS.on('error', page.onError)\n\n page.lazyLoad = new LazyLoad()\n}\n"]} \ No newline at end of file +{"version":3,"sources":["dashboard.js"],"names":["const","lsKeys","token","viewType","uploads","uploadsAll","selected","users","page","dom","localStorage","username","permissions","menusContainer","menus","currentView","views","type","album","pageNum","filters","all","checkboxes","lastSelected","upload","user","selectAlbumContainer","cache","albums","clipboardJS","lazyLoad","imageExts","videoExts","isTriggerLoading","fadingIn","albumTitleMaxLength","albumDescMaxLength","unhide","document","querySelector","classList","add","remove","onError","error","console","content","createElement","innerHTML","toString","swal","title","icon","onAxiosError","statusText","520","521","522","523","524","525","526","527","530","response","status","description","data","preparePage","verifyToken","window","location","checkClientVersion","apiVersion","match","src","text","buttons","confirm","closeModal","then","reload","reloadOnError","axios","post","success","removeItem","defaults","headers","common","version","prepareDashboard","catch","addEventListener","domClick","event","target","contains","preventDefault","itemMenus","selector","onclick","getUploads","deleteUploadsByNames","getAlbums","changeToken","changePassword","logout","params","group","getStatistics","getUsers","loop","i","item","call","Object","assign","trigger","currentTarget","push","length","moderator","getAlbumsSidebar","prepareShareX","updateTrigger","newState","paginations","querySelectorAll","parentNode","tagName","let","getItemID","element","parent","parseInt","dataset","id","includes","action","hasAttribute","stopPropagation","setUploadsView","addToAlbum","deleteUpload","addSelectedUploadsToAlbum","bulkDeleteUploads","displayPreview","uploadFiltersHelp","filterUploads","submitAlbum","editAlbum","deleteAlbum","createUser","editUser","disableUser","deleteUser","viewUserUploads","getNewToken","clearSelection","select","selectAll","focusJumpToPage","switchPage","fadeAndScroll","disableFading","clearTimeout","setTimeout","scrollIntoView","behavior","block","inline","func","goto","jumpToPage","jumpid","checkValidity","parsed","value","isNaN","focus","undefined","url","minOffset","Date","getTimezoneOffset","get","pages","Math","ceil","count","files","autoPage","basedomain","pagination","paginate","extraControls","escape","controls","bottomExtraControls","replace","bottomPagination","unselected","hasExpiryDateColumn","some","file","expirydate","thumb","exec","extname","toLowerCase","name","original","prettyBytes","getPrettyBytes","size","prettyDate","getPrettyDate","timestamp","prettyExpiryDate","appendix","userid","albumid","table","div","className","appendChild","tr","ip","checked","update","view","isimage","isvideo","onload","body","onerror","video","autoplay","insertAdjacentElement","splice","indexOf","JSON","stringify","selectInBetween","lastElement","thisIndex","index","lastIndex","abs","shiftKey","suffix","substring","proceed","Boolean","style","trim","filtersid","postBulkDeleteUploads","field","values","cb","failed","filter","textArea","seen","names","split","map","trimmed","test","prototype","hasOwnProperty","join","objective","dangerMode","cancel","fields","Array","isArray","timer","addUploadsToAlbum","ids","callback","choose","added","list","getElementsByTagName","removeAttribute","homeDomain","albumUrl","download","public","requestLink","identifier","purge","albumsContainer","oldAlbums","li","a","sendNewPassword","pass","password","admin","max","displayGroup","groups","keys","enabled","usage","groupOptions","g","resetPassword","autoClose","displayName","totalItems","itemsPerPage","currentPage","numPages","template","start","end","elementsToShow","step","stats","rows","types","_types","valKeys","j","number","toLocaleString","byte","byteUsage","used","total","round","toUpperCase","defineProperty","varArgs","arguments$1","arguments","TypeError","to","nextSource","nextKey","writable","configurable","documentElement","selectedKeys","ls","parse","ClipboardJS","on","LazyLoad"],"mappings":"AAEAA,IAAMC,OAAS,CACbC,MAAO,QACPC,SAAU,CACRC,QAAS,kBACTC,WAAY,sBAEdC,SAAU,CACRF,QAAS,kBACTC,WAAY,qBACZE,MAAO,kBAILC,KAAO,CAEXC,IAAK,KAGLP,MAAOQ,aAAaT,OAAOC,OAG3BS,SAAU,KACVC,YAAa,KAGbC,eAAgB,KAChBC,MAAO,GAEPC,YAAa,KACbC,MAAO,CAELZ,QAAS,CACPa,KAAMP,aAAaT,OAAOE,SAASC,SACnCc,MAAO,KACPC,QAAS,MAGXd,WAAY,CACVY,KAAMP,aAAaT,OAAOE,SAASE,YACnCe,QAAS,KACTD,QAAS,KACTE,KAAK,GAGPd,MAAO,CACLa,QAAS,KACTD,QAAS,OAKbb,SAAU,CACRF,QAAS,GACTC,WAAY,GACZE,MAAO,IAETe,WAAY,CACVlB,QAAS,GACTC,WAAY,GACZE,MAAO,IAETgB,aAAc,CACZC,OAAQ,KACRnB,WAAY,KACZoB,KAAM,MAIRC,qBAAsB,KAGtBC,MAAO,CACLvB,QAAS,GACTwB,OAAQ,GACRrB,MAAO,IAGTsB,YAAa,KACbC,SAAU,KAEVC,UAAW,CAAC,QAAS,OAAQ,QAAS,OAAQ,OAAQ,QAAS,OAAQ,QAEvEC,UAAW,CAAC,QAAS,OAAQ,OAAQ,OAAQ,OAAQ,OAAQ,OAAQ,SAErEC,iBAAkB,KAClBC,SAAU,KAEVC,oBAAqB,GACrBC,mBAAoB,IAGtBC,OAAW,WACTC,SAASC,cAAc,WAAWC,UAAUC,IAAI,aAChDH,SAASC,cAAc,cAAcC,UAAUE,OAAO,cAIxDC,QAAY,SAAGC,GACbC,QAAQD,MAAMA,GAEd5C,IAAM8C,EAAUR,SAASS,cAAc,OAEvC,OADAD,EAAQE,UAAY,SAASJ,EAAMK,WAAU,UACtCC,KAAK,CACV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U,SAC1B9G,KAAK6C,aAAaT,QAItB0B,OAAOoK,OAAM,WAGkB,mBAAlBtH,OAAOC,QAEhBD,OAAO8N,eAAe9N,OAAQ,SAAU,CACtC8D,MAAO,SAAiBlF,EAAQmP,GAC9B,aAtpBA,IAAIC,EAAcC,UAupBlB,GAAIrP,MAAAA,EACF,MAAM,IAAIsP,UAAU,8CAEtB,IADAtV,IAAMuV,EAAKnO,OAAOpB,GACTiB,EAAI,EAAGA,EAAIoO,UAAU5N,OAAQR,IAAK,CACzCjH,IAAMwV,EAAaH,EAAUpO,GAC7B,GAAIuO,MAAAA,EACF,IAAKxV,IAAMyV,KAAWD,EAEhBpO,OAAO2J,UAAUC,eAAe7J,KAAKqO,EAAYC,KACnDF,EAAGE,GAAWD,EAAWC,IAEjC,OAAOF,GAETG,UAAU,EACVC,cAAc,IAIZ,iBAAkBrT,SAASsT,iBAC/BtT,SAASsT,gBAAgBpT,UAAUC,IAAI,YAGzC,IADAzC,IAAM6V,EAAe,CAAC,UAAW,aAAc,SACtC5O,EAAI,EAAGA,EAAI4O,EAAapO,OAAQR,IAAK,CAC5CjH,IAAM8V,EAAKpV,aAAaT,OAAOK,SAASuV,EAAa5O,KACjD6O,IAAItV,KAAKF,SAASuV,EAAa5O,IAAMiI,KAAK6G,MAAMD,IAGtDtV,KAAK4D,cAEL5D,KAAKqB,YAAc,IAAImU,YAAY,iBAEnCxV,KAAKqB,YAAYoU,GAAG,WAAS,WAC3B,OAAO/S,KAAK,GAAI,yCAA0C,UAAW,CACnE2B,SAAS,EACT2M,MAAO,UAIXhR,KAAKqB,YAAYoU,GAAG,QAASzV,KAAKmC,SAElCnC,KAAKsB,SAAW,IAAIoU","file":"dashboard.js","sourcesContent":["/* global swal, axios, ClipboardJS, LazyLoad */\n\nconst lsKeys = {\n token: 'token',\n viewType: {\n uploads: 'viewTypeUploads',\n uploadsAll: 'viewTypeUploadsAll'\n },\n selected: {\n uploads: 'selectedUploads',\n uploadsAll: 'selectedUploadsAll',\n users: 'selectedUsers'\n }\n}\n\nconst page = {\n // #page\n dom: null,\n\n // user token\n token: localStorage[lsKeys.token],\n\n // from api/tokens/verify\n username: null,\n permissions: null,\n\n // sidebar menus\n menusContainer: null,\n menus: [],\n\n currentView: null,\n views: {\n // config of uploads view\n uploads: {\n type: localStorage[lsKeys.viewType.uploads],\n album: null, // album's id\n pageNum: null // page num\n },\n // config of uploads view (all)\n uploadsAll: {\n type: localStorage[lsKeys.viewType.uploadsAll],\n filters: null, // uploads' filters\n pageNum: null, // page num\n all: true\n },\n // config of users view\n users: {\n filters: null, // users' filters\n pageNum: null\n }\n },\n\n // id of selected items (shared across pages and will be synced with localStorage)\n selected: {\n uploads: [],\n uploadsAll: [],\n users: []\n },\n checkboxes: {\n uploads: [],\n uploadsAll: [],\n users: []\n },\n lastSelected: {\n upload: null,\n uploadsAll: null,\n user: null\n },\n\n // select album dom for dialogs/modals\n selectAlbumContainer: null,\n\n // cache for dialogs/modals\n cache: {\n uploads: {},\n albums: {},\n users: {}\n },\n\n clipboardJS: null,\n lazyLoad: null,\n\n imageExts: ['.webp', '.jpg', '.jpeg', '.gif', '.png', '.tiff', '.tif', '.svg'],\n // TODO: Disable \"Load original\" button with non-streamable extensions\n videoExts: ['.webm', '.mp4', '.wmv', '.avi', '.mov', '.mkv', '.m4v', '.m2ts'],\n\n isTriggerLoading: null,\n fadingIn: null,\n\n albumTitleMaxLength: 70,\n albumDescMaxLength: 4000\n}\n\npage.unhide = () => {\n document.querySelector('#loader').classList.add('is-hidden')\n document.querySelector('#dashboard').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 = `${error.toString()}`\n return swal({\n title: 'An error occurred!',\n icon: 'error',\n content\n })\n}\n\n// Handler for Axios errors\npage.onAxiosError = error => {\n console.error(error)\n\n // Better Cloudflare errors\n const cloudflareErrors = {\n 520: 'Unknown Error',\n 521: 'Web Server Is Down',\n 522: 'Connection Timed Out',\n 523: 'Origin Is Unreachable',\n 524: 'A Timeout Occurred',\n 525: 'SSL Handshake Failed',\n 526: 'Invalid SSL Certificate',\n 527: 'Railgun Error',\n 530: 'Origin DNS Error'\n }\n\n const statusText = cloudflareErrors[error.response.status] || error.response.statusText\n const description = error.response.data && error.response.data.description\n ? error.response.data.description\n : 'There was an error with the request, please check the console for more information.'\n\n return swal(`${error.response.status} ${statusText}`, description, 'error')\n}\n\npage.preparePage = () => {\n if (page.token)\n page.verifyToken(page.token, true)\n else\n 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: 'Updated 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 location.reload()\n })\n}\n\npage.verifyToken = (token, reloadOnError) => {\n axios.post('api/tokens/verify', { token }).then(response => {\n if (response.data.success === false)\n return swal({\n title: 'An error occurred!',\n text: response.data.description,\n icon: 'error'\n }).then(() => {\n if (!reloadOnError) return\n localStorage.removeItem(lsKeys.token)\n window.location = 'auth'\n })\n\n 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 page.token = token\n page.username = response.data.username\n page.permissions = response.data.permissions\n page.prepareDashboard()\n }).catch(page.onAxiosError)\n}\n\npage.prepareDashboard = () => {\n page.dom = document.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 }, 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: '#itemManageAlbums', 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: '#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])\n continue\n\n // Add onclick event listener\n const item = document.querySelector(itemMenus[i].selector)\n item.addEventListener('click', event => {\n // TODO: This class name isn't actually being applied fast enough\n if (page.menusContainer.classList.contains('is-loading'))\n return\n\n // eslint-disable-next-line compat/compat\n itemMenus[i].onclick.call(null, Object.assign({\n trigger: event.currentTarget\n }, itemMenus[i].params || {}))\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')\n 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.updateTrigger = (trigger, newState) => {\n if (!trigger) return\n\n // Disable menus container and pagination when loading\n if (newState === 'loading') {\n page.menusContainer.classList.add('is-loading')\n const paginations = page.dom.querySelectorAll('.pagination')\n for (let i = 0; i < paginations.length; i++)\n paginations[i].classList.add('is-loading')\n } else {\n page.menusContainer.classList.remove('is-loading')\n const paginations = page.dom.querySelectorAll('.pagination.is-loading')\n for (let i = 0; i < paginations.length; i++)\n paginations[i].classList.remove('is-loading')\n }\n\n if (newState === 'loading') {\n trigger.classList.add('is-loading')\n } else if (newState === 'active') {\n if (trigger.parentNode.tagName !== 'LI')\n return\n for (let i = 0; i < page.menus.length; i++)\n page.menus[i].classList.remove('is-active')\n trigger.classList.remove('is-loading')\n trigger.classList.add('is-active')\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 if (['SPAN'].includes(element.tagName) && ['A', 'BUTTON'].includes(element.parentNode.tagName))\n element = element.parentNode\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 '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 'delete-album':\n return page.deleteAlbum(id)\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 /* // WIP\n case 'user-filters-help':\n return page.userFiltersHelp(element)\n case 'filter-users':\n return page.filterUsers(element)\n */\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.fadeAndScroll = 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 page.dom.scrollIntoView({\n behavior: disableFading ? 'auto' : 'smooth',\n block: 'start',\n inline: 'nearest'\n })\n}\n\npage.switchPage = (action, element) => {\n // Skip if other pagination buttons are still loading\n const isLoading = page.dom.querySelectorAll('.pagination.is-loading')\n if (isLoading.length) return\n\n // eslint-disable-next-line compat/compat\n const params = Object.assign({\n trigger: element\n }, page.views[page.currentView])\n\n const func = page.currentView === 'users' ? page.getUsers : page.getUploads\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 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 === undefined)\n params = {}\n\n if (params.all && !page.permissions.moderator)\n return swal('An error occurred!', 'You cannot do this!', 'error')\n\n page.updateTrigger(params.trigger, 'loading')\n\n if (typeof params.pageNum !== 'number' || params.pageNum < 0)\n params.pageNum = 0\n\n const url = params.album !== undefined\n ? `api/album/${params.album}/${params.pageNum}`\n : `api/uploads/${params.pageNum}`\n\n const headers = {\n all: params.all ? '1' : '',\n filters: params.filters || ''\n }\n\n // Send client timezone offset if using filters\n // Server will pretend client is on UTC if missing\n if (headers.filters)\n headers.minOffset = new Date().getTimezoneOffset()\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 const pages = Math.ceil(response.data.count / 25)\n const files = response.data.files\n if (params.pageNum && (files.length === 0))\n if (params.autoPage) {\n params.pageNum = pages - 1\n return page.getUploads(params)\n } else {\n page.updateTrigger(params.trigger)\n return swal('An error occurred!', `There are no more uploads to populate page ${params.pageNum + 1}.`, 'error')\n }\n\n page.currentView = params.all ? 'uploadsAll' : 'uploads'\n page.cache.uploads = {}\n\n const albums = response.data.albums\n const users = response.data.users\n const basedomain = response.data.basedomain\n const pagination = page.paginate(response.data.count, 25, params.pageNum)\n\n const filter = `\n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n `\n const extraControls = `\n
    \n ${filter}\n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n `\n\n const controls = `\n
    \n
    \n \n
    \n \n \n \n \n \n ${params.all ? '' : `\n \n \n \n \n `}\n \n \n \n \n Bulk delete\n \n
    \n
    \n `\n\n // Do some string replacements for bottom controls\n const bottomFiltersId = 'bFilters'\n const bottomJumpId = 'bJumpToPage'\n const bottomExtraControls = extraControls\n .replace(/id=\"filters\"/, `id=\"${bottomFiltersId}\"`)\n .replace(/(data-action=\"filter-uploads\")/, `$1 data-filtersid=\"${bottomFiltersId}\"`)\n .replace(/id=\"jumpToPage\"/, `id=\"${bottomJumpId}\"`)\n .replace(/(data-action=\"jump-to-page\")/g, `$1 data-jumpid=\"${bottomJumpId}\"`)\n const bottomPagination = pagination\n .replace(/(data-action=\"page-ellipsis\")/g, `$1 data-jumpid=\"${bottomJumpId}\"`)\n\n // Whether there are any unselected items\n let unselected = false\n\n const hasExpiryDateColumn = files.some(file => {\n return file.expirydate !== undefined\n })\n\n for (let i = 0; i < files.length; i++) {\n // Build full URLs\n files[i].file = `${basedomain}/${files[i].name}`\n if (files[i].thumb)\n files[i].thumb = `${basedomain}/${files[i].thumb}`\n\n // Determine types\n files[i].type = 'other'\n const exec = /.[\\w]+(\\?|$)/.exec(files[i].file)\n const extname = exec && exec[0] ? exec[0].toLowerCase() : null\n if (page.imageExts.includes(extname))\n files[i].type = 'picture'\n else if (page.videoExts.includes(extname))\n files[i].type = 'video'\n\n // Cache bare minimum data for thumbnails viewer\n page.cache.uploads[files[i].id] = {\n name: files[i].name,\n thumb: files[i].thumb,\n original: files[i].file,\n type: files[i].type\n }\n\n // Prettify\n files[i].prettyBytes = page.getPrettyBytes(parseInt(files[i].size))\n files[i].prettyDate = page.getPrettyDate(new Date(files[i].timestamp * 1000))\n\n if (hasExpiryDateColumn)\n files[i].prettyExpiryDate = files[i].expirydate\n ? page.getPrettyDate(new Date(files[i].expirydate * 1000))\n : null\n\n // Update selected status\n files[i].selected = page.selected[page.currentView].includes(files[i].id)\n if (!files[i].selected) unselected = true\n\n // Appendix (display album or user)\n if (params.all)\n files[i].appendix = files[i].userid\n ? users[files[i].userid] || ''\n : ''\n else if (params.album === undefined)\n files[i].appendix = files[i].albumid\n ? albums[files[i].albumid] || ''\n : ''\n }\n\n if (page.views[page.currentView].type === 'thumbs') {\n page.dom.innerHTML = `\n ${pagination}\n ${extraControls}\n ${controls}\n
    \n
    \n ${controls}\n ${bottomExtraControls}\n ${bottomPagination}\n `\n\n const table = document.querySelector('#table')\n\n for (let i = 0; i < files.length; i++) {\n const upload = files[i]\n const div = document.createElement('div')\n div.className = 'image-container column'\n div.dataset.id = upload.id\n\n if (upload.thumb !== undefined)\n div.innerHTML = `\"${upload.name}\"`\n else\n div.innerHTML = `

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

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

    ${upload.name}

    \n

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

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

    EXP: ${upload.prettyExpiryDate}

    ` : ''}\n
    \n `\n\n table.appendChild(div)\n page.checkboxes[page.currentView] = table.querySelectorAll('.checkbox[data-action=\"select\"]')\n }\n } else {\n page.dom.innerHTML = `\n ${pagination}\n ${extraControls}\n ${controls}\n
    \n \n \n \n \n \n ${params.album === undefined ? `` : ''}\n \n ${params.all ? '' : ''}\n \n ${hasExpiryDateColumn ? '' : ''}\n \n \n \n \n \n
    File name${params.all ? 'User' : 'Album'}SizeIPDateExpiry date
    \n
    \n ${controls}\n ${bottomExtraControls}\n ${bottomPagination}\n `\n\n const table = document.querySelector('#table')\n\n for (let i = 0; i < files.length; i++) {\n const upload = files[i]\n const tr = document.createElement('tr')\n tr.dataset.id = upload.id\n tr.innerHTML = `\n \n ${upload.name}\n ${params.album === undefined ? `${upload.appendix}` : ''}\n ${upload.prettyBytes}\n ${params.all ? `${upload.ip || ''}` : ''}\n ${upload.prettyDate}\n ${hasExpiryDateColumn ? `${upload.prettyExpiryDate || '-'}` : ''}\n \n \n \n \n \n \n \n \n \n \n \n ${params.all ? '' : `\n \n \n \n \n `}\n \n \n \n \n \n \n `\n\n table.appendChild(tr)\n page.checkboxes[page.currentView] = table.querySelectorAll('.checkbox[data-action=\"select\"]')\n }\n }\n\n const selectAll = document.querySelector('#selectAll')\n if (selectAll && !unselected && files.length) {\n selectAll.checked = true\n selectAll.title = 'Unselect all'\n }\n\n if (page.views[page.currentView].type === 'thumbs') {\n page.fadeAndScroll(true)\n page.lazyLoad.update()\n } else {\n page.fadeAndScroll()\n }\n\n page.updateTrigger(params.trigger, 'active')\n\n if (page.currentView === 'uploads')\n page.views.uploads.album = params.album\n if (page.currentView === 'uploadsAll')\n page.views.uploadsAll.filters = params.filters\n page.views[page.currentView].pageNum = files.length ? params.pageNum : 0\n }).catch(error => {\n page.updateTrigger(params.trigger)\n page.onAxiosError(error)\n })\n}\n\npage.setUploadsView = (view, element) => {\n localStorage[lsKeys.viewType[page.currentView]] = view\n page.views[page.currentView].type = view\n\n // eslint-disable-next-line compat/compat\n page.getUploads(Object.assign({\n trigger: element\n }, page.views[page.currentView]))\n}\n\npage.displayPreview = id => {\n const file = page.cache.uploads[id]\n if (!file.thumb) return\n\n const div = document.createElement('div')\n div.innerHTML = `\n
    \n \n
    \n \n
    \n
    \n `\n\n if (file.original) {\n const exec = /.[\\w]+(\\?|$)/.exec(file.original)\n const extname = exec && exec[0] ? exec[0].toLowerCase() : null\n const isimage = page.imageExts.includes(extname)\n const isvideo = !isimage && page.videoExts.includes(extname)\n\n if (isimage || isvideo) {\n div.innerHTML += `\n \n `\n\n div.querySelector('#swalOriginal').addEventListener('click', event => {\n const trigger = event.currentTarget\n if (trigger.classList.contains('is-danger'))\n return\n\n trigger.classList.add('is-loading')\n const thumb = div.querySelector('#swalThumb')\n\n if (isimage) {\n thumb.src = file.original\n thumb.onload = () => {\n trigger.classList.add('is-hidden')\n document.body.querySelector('.swal-overlay .swal-modal:not(.is-expanded)').classList.add('is-expanded')\n }\n thumb.onerror = event => {\n event.currentTarget.classList.add('is-hidden')\n trigger.className = 'button is-danger is-fullwidth'\n trigger.innerHTML = `\n \n \n \n Unable to load original\n `\n }\n } else if (isvideo) {\n thumb.classList.add('is-hidden')\n const video = document.createElement('video')\n video.id = 'swalVideo'\n video.controls = true\n video.autoplay = true\n video.src = file.original\n thumb.insertAdjacentElement('afterend', video)\n\n trigger.classList.add('is-hidden')\n document.body.querySelector('.swal-overlay .swal-modal:not(.is-expanded)').classList.add('is-expanded')\n }\n })\n }\n }\n\n return swal({\n content: div,\n buttons: false\n }).then(() => {\n // Destroy video, if necessary\n const video = div.querySelector('#swalVideo')\n if (video) video.remove()\n\n // Restore modal size\n document.body.querySelector('.swal-overlay .swal-modal').classList.remove('is-expanded')\n })\n}\n\npage.selectAll = element => {\n for (let i = 0; i < page.checkboxes[page.currentView].length; i++) {\n const id = page.getItemID(page.checkboxes[page.currentView][i])\n if (isNaN(id)) continue\n if (page.checkboxes[page.currentView][i].checked !== element.checked) {\n page.checkboxes[page.currentView][i].checked = element.checked\n if (page.checkboxes[page.currentView][i].checked)\n page.selected[page.currentView].push(id)\n else\n page.selected[page.currentView].splice(page.selected[page.currentView].indexOf(id), 1)\n }\n }\n\n if (page.selected[page.currentView].length)\n localStorage[lsKeys.selected[page.currentView]] = JSON.stringify(page.selected[page.currentView])\n else\n delete localStorage[lsKeys.selected[page.currentView]]\n\n element.title = element.checked ? 'Unselect all' : 'Select all'\n}\n\npage.selectInBetween = (element, lastElement) => {\n const thisIndex = parseInt(element.dataset.index)\n const lastIndex = parseInt(lastElement.dataset.index)\n\n const distance = Math.abs(thisIndex - lastIndex)\n if (distance < 2)\n return\n\n for (let i = 0; i < page.checkboxes[page.currentView].length; i++)\n if ((thisIndex > lastIndex && i > lastIndex && i < thisIndex) ||\n (thisIndex < lastIndex && i > thisIndex && i < lastIndex)) {\n // Check or uncheck depending on the state of the initial checkbox\n const checked = page.checkboxes[page.currentView][i].checked = lastElement.checked\n const id = page.getItemID(page.checkboxes[page.currentView][i])\n if (!page.selected[page.currentView].includes(id) && checked)\n page.selected[page.currentView].push(id)\n else if (page.selected[page.currentView].includes(id) && !checked)\n page.selected[page.currentView].splice(page.selected[page.currentView].indexOf(id), 1)\n }\n}\n\npage.select = (element, event) => {\n const id = page.getItemID(element)\n if (isNaN(id)) return\n\n const lastSelected = page.lastSelected[page.currentView]\n if (event.shiftKey && lastSelected) {\n page.selectInBetween(element, lastSelected)\n // Check or uncheck depending on the state of the initial checkbox\n element.checked = lastSelected.checked\n } else {\n page.lastSelected[page.currentView] = element\n }\n\n if (!page.selected[page.currentView].includes(id) && element.checked)\n page.selected[page.currentView].push(id)\n else if (page.selected[page.currentView].includes(id) && !element.checked)\n page.selected[page.currentView].splice(page.selected[page.currentView].indexOf(id), 1)\n\n // Update local storage\n if (page.selected[page.currentView].length)\n localStorage[lsKeys.selected[page.currentView]] = JSON.stringify(page.selected[page.currentView])\n else\n delete localStorage[lsKeys.selected[page.currentView]]\n}\n\npage.clearSelection = () => {\n const selected = page.selected[page.currentView]\n const type = page.currentView === 'users' ? 'users' : 'uploads'\n const count = selected.length\n if (!count)\n return swal('An error occurred!', `You have not selected any ${type}.`, 'error')\n\n const suffix = count === 1 ? type.substring(0, type.length - 1) : type\n return swal({\n title: 'Are you sure?',\n text: `You are going to unselect ${count} ${suffix}.`,\n buttons: true\n }).then(proceed => {\n if (!proceed) return\n\n const checkboxes = page.checkboxes[page.currentView]\n for (let i = 0; i < checkboxes.length; i++)\n if (checkboxes[i].checked)\n checkboxes[i].checked = false\n\n page.selected[page.currentView] = []\n delete localStorage[lsKeys.selected[page.currentView]]\n\n const selectAll = document.querySelector('#selectAll')\n if (selectAll) selectAll.checked = false\n\n return swal('Cleared selection!', `Unselected ${count} ${suffix}.`, 'success')\n })\n}\n\npage.uploadFiltersHelp = element => {\n const all = Boolean(element.dataset.all)\n const content = document.createElement('div')\n content.style = 'text-align: left'\n content.innerHTML = `${all ? `\n There are 2 filter keys, namely user (username) and ip.\n These keys can be specified more than once.\n For usernames with whitespaces, wrap them with double quotes (\").\n Special cases such as uploads by non-registered users or have no IPs respectively, use user:- or ip:-.\n\n To exclude certain users/ips while still listing every other uploads, add negation sign (-) before the keys.\n Negation sign can also be used to exclude the special cases mentioned above (i.e. -user:- or -ip:-).\n ` : ''}\n 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.\n 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 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? Don't fret, 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 Its format is: 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 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 ? `- 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 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 ? `- 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 uploaded since \"1 June 2019 00:00:00\":\n date:2019/06\n - Uploads uploaded between \"7 April 2020 12:00:00\" and \"7 April 2020 23:59:59\":\n date:2020/04/07 12-2020/04/07 23:59:59\n - Uploads uploaded before \"5 February 2020 00:00:00\":\n date:-2020/02/05\n - Uploads which file names match \"*.gz\" but NOT \"*.tar.gz\":\n *.gz -*.tar.gz\n - Sort matches by \"size\" column in ascending and descending order respectively:\n ${all ? 'user:\"John Doe\"' : '*.txt'} sort:size\n *.mp4 ${all ? 'user:- ' : ''}sort:size:d\n ${!page.permissions.moderator ? `\n Notice: Regular users may face some limitations in the amount of keys that can be used at a time.\n ` : ''}\n Friendly reminder: This window can be scrolled up!\n `.trim().replace(/^\\s*/g, '').replace(/\\n/g, '
    ')\n\n swal({ content }).then(() => {\n // Restore modal size\n document.body.querySelector('.swal-overlay .swal-modal').classList.remove('is-expanded')\n })\n\n // Expand modal size\n document.body.querySelector('.swal-overlay .swal-modal:not(.is-expanded)').classList.add('is-expanded')\n}\n\npage.filterUploads = element => {\n const filters = document.querySelector(`#${element.dataset.filtersid || 'filters'}`).value.trim()\n // eslint-disable-next-line compat/compat\n page.getUploads(Object.assign(page.views[page.currentView], {\n filters,\n pageNum: 0\n }), element)\n}\n\npage.viewUserUploads = (id, element) => {\n const user = page.cache.users[id]\n if (!user) return\n element.classList.add('is-loading')\n // Wrap username in quotes if it contains whitespaces\n const username = user.username.includes(' ')\n ? `\"${user.username}\"`\n : user.username\n page.getUploads({\n all: true,\n filters: `user:${username}`,\n trigger: document.querySelector('#itemManageUploads')\n })\n}\n\npage.deleteUpload = id => {\n page.postBulkDeleteUploads({\n all: page.currentView === 'uploadsAll',\n field: 'id',\n values: [id],\n cb (failed) {\n // Remove from remembered checkboxes if necessary\n if (!failed.length && page.selected[page.currentView].includes(id))\n page.selected[page.currentView].splice(page.selected[page.currentView].indexOf(id), 1)\n\n // Update local storage\n if (page.selected[page.currentView].length)\n localStorage[lsKeys.selected[page.currentView]] = JSON.stringify(page.selected[page.currentView])\n else\n delete localStorage[lsKeys.selected[page.currentView]]\n\n // Reload upload list\n // eslint-disable-next-line compat/compat\n page.getUploads(Object.assign(page.views[page.currentView], {\n autoPage: true\n }))\n }\n })\n}\n\npage.bulkDeleteUploads = () => {\n const count = page.selected[page.currentView].length\n if (!count)\n return swal('An error occurred!', 'You have not selected any uploads.', 'error')\n\n page.postBulkDeleteUploads({\n all: page.currentView === 'uploadsAll',\n field: 'id',\n values: page.selected[page.currentView],\n cb (failed) {\n // Update state of checkboxes\n if (failed.length)\n page.selected[page.currentView] = page.selected[page.currentView]\n .filter(id => {\n return failed.includes(id)\n })\n else\n page.selected[page.currentView] = []\n\n // Update local storage\n if (page.selected[page.currentView].length)\n localStorage[lsKeys.selected[page.currentView]] = JSON.stringify(page.selected[page.currentView])\n else\n delete localStorage[lsKeys.selected[page.currentView]]\n\n // Reload uploads list\n // eslint-disable-next-line compat/compat\n page.getUploads(Object.assign(page.views[page.currentView], {\n autoPage: true\n }))\n }\n })\n}\n\npage.deleteUploadsByNames = (params = {}) => {\n let appendix = ''\n if (page.permissions.moderator)\n appendix = '
    Hint: You can use this feature to delete uploads by other users.'\n\n page.dom.innerHTML = `\n
    \n
    \n \n
    \n \n
    \n

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

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

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

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

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

    `\n }\n\n const content = document.createElement('div')\n content.innerHTML = text\n\n swal({\n title: 'Are you sure?',\n content,\n icon: 'warning',\n dangerMode: true,\n buttons: {\n cancel: true,\n confirm: {\n text: `Yes, nuke ${params.values.length === 1 ? 'it' : 'them'}!`,\n closeModal: false\n }\n }\n }).then(proceed => {\n if (!proceed) return\n\n axios.post('api/upload/bulkdelete', {\n field: params.fields,\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 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 if (typeof params.cb === 'function')\n params.cb(failed)\n }).catch(page.onAxiosError)\n })\n}\n\npage.addSelectedUploadsToAlbum = () => {\n if (page.currentView !== 'uploads')\n return\n\n const count = page.selected[page.currentView].length\n if (!count)\n 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].filter(id => {\n return failed.includes(id)\n })\n else\n page.selected[page.currentView] = []\n\n localStorage[lsKeys.selected[page.currentView]] = JSON.stringify(page.selected[page.currentView])\n page.getUploads(page.views[page.currentView])\n })\n}\n\npage.addToAlbum = id => {\n page.addUploadsToAlbum([id], failed => {\n if (!failed) return\n page.getUploads(page.views[page.currentView])\n })\n}\n\npage.addUploadsToAlbum = (ids, callback) => {\n const count = ids.length\n\n const content = document.createElement('div')\n content.innerHTML = `\n
    \n

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

    \n

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

    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n `\n\n swal({\n icon: 'warning',\n content,\n buttons: {\n cancel: true,\n confirm: {\n text: 'OK',\n closeModal: false\n }\n }\n }).then(choose => {\n if (!choose) return\n\n const albumid = parseInt(document.querySelector('#swalAlbum').value)\n if (isNaN(albumid))\n return swal('An error occurred!', 'You did not choose an album.', 'error')\n\n axios.post('api/albums/addfiles', {\n ids,\n albumid\n }).then(add => {\n if (!add) return\n\n if (add.data.success === false) {\n if (add.data.description === 'No token provided')\n page.verifyToken(page.token)\n else\n swal('An error occurred!', add.data.description, 'error')\n\n return\n }\n\n let added = ids.length\n if (add.data.failed && add.data.failed.length)\n added -= add.data.failed.length\n\n const suffix = `upload${ids.length === 1 ? '' : 's'}`\n if (!added)\n return swal('An error occurred!', `Could not add the ${suffix} to the album.`, 'error')\n\n swal('Woohoo!', `Successfully ${albumid < 0 ? 'removed' : 'added'} ${added} ${suffix} ${albumid < 0 ? 'from' : 'to'} the album.`, 'success', {\n buttons: false,\n timer: 1500\n })\n callback(add.data.failed)\n }).catch(page.onAxiosError)\n })\n\n // Get albums list then update content of swal\n axios.get('api/albums').then(list => {\n if (list.data.success === false) {\n if (list.data.description === 'No token provided')\n page.verifyToken(page.token)\n else\n swal('An error occurred!', list.data.description, 'error')\n\n return\n }\n\n // If the prompt was replaced, the container would be missing\n const select = document.querySelector('#swalAlbum')\n if (!select) return\n\n select.innerHTML += list.data.albums\n .map(album => {\n return ``\n })\n .join('\\n')\n\n select.getElementsByTagName('option')[1].innerHTML = 'Choose an album'\n select.removeAttribute('disabled')\n }).catch(page.onAxiosError)\n}\n\npage.getAlbums = (params = {}) => {\n page.updateTrigger(params.trigger, 'loading')\n\n axios.get('api/albums').then(response => {\n if (!response) return\n\n if (response.data.success === false)\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n page.updateTrigger(params.trigger)\n return swal('An error occurred!', response.data.description, 'error')\n }\n\n page.cache.albums = {}\n\n page.dom.innerHTML = `\n

    Create new album

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

    Max length is ${page.albumTitleMaxLength} characters.

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

    Max length is ${page.albumDescMaxLength} characters.

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

    List of albums

    \n
    \n \n \n \n \n \n \n \n \n \n \n \n \n \n
    IDNameFilesCreated atPublic link
    \n
    \n `\n\n const homeDomain = response.data.homeDomain\n const table = document.querySelector('#table')\n\n for (let i = 0; i < response.data.albums.length; i++) {\n const album = response.data.albums[i]\n const albumUrl = `${homeDomain}/a/${album.identifier}`\n\n // Prettify\n album.prettyDate = page.getPrettyDate(new Date(album.timestamp * 1000))\n\n page.cache.albums[album.id] = {\n name: album.name,\n download: album.download,\n public: album.public,\n description: album.description\n }\n\n const tr = document.createElement('tr')\n tr.innerHTML = `\n ${album.id}\n ${album.name}\n ${album.files}\n ${album.prettyDate}\n ${albumUrl}\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n `\n\n table.appendChild(tr)\n }\n page.fadeAndScroll()\n page.updateTrigger(params.trigger, 'active')\n }).catch(error => {\n page.updateTrigger(params.trigger)\n page.onAxiosError(error)\n })\n}\n\npage.editAlbum = id => {\n const album = page.cache.albums[id]\n if (!album) return\n\n const div = document.createElement('div')\n div.innerHTML = `\n
    \n
    \n \n
    \n

    Max length is ${page.albumTitleMaxLength} characters.

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

    Max length is ${page.albumDescMaxLength} characters.

    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n `\n\n swal({\n title: 'Edit album',\n icon: 'info',\n content: div,\n buttons: {\n cancel: true,\n confirm: {\n closeModal: false\n }\n }\n }).then(value => {\n if (!value) return\n\n axios.post('api/albums/edit', {\n id,\n name: document.querySelector('#swalName').value.trim(),\n description: document.querySelector('#swalDescription').value.trim(),\n download: document.querySelector('#swalDownload').checked,\n public: document.querySelector('#swalPublic').checked,\n requestLink: document.querySelector('#swalRequestLink').checked\n }).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 if (response.data.identifier)\n swal('Success!', `Your album's new identifier is: ${response.data.identifier}.`, 'success')\n else if (response.data.name !== album.name)\n swal('Success!', `Your album was renamed to: ${response.data.name}.`, 'success')\n else\n swal('Success!', 'Your album was edited!', 'success', {\n buttons: false,\n timer: 1500\n })\n\n page.getAlbumsSidebar()\n page.getAlbums()\n }).catch(page.onAxiosError)\n })\n}\n\npage.deleteAlbum = id => {\n swal({\n title: 'Are you sure?',\n text: 'This won\\'t delete your uploads, only the album!',\n icon: 'warning',\n dangerMode: true,\n buttons: {\n cancel: true,\n confirm: {\n text: 'Yes, delete it!',\n closeModal: false\n },\n purge: {\n text: 'Umm, delete the uploads too please?',\n value: 'purge',\n className: 'swal-button--danger',\n closeModal: false\n }\n }\n }).then(proceed => {\n if (!proceed) return\n\n axios.post('api/albums/delete', {\n id,\n purge: proceed === 'purge'\n }).then(response => {\n if (response.data.success === false) {\n const failed = Array.isArray(response.data.failed)\n ? response.data.failed\n : []\n\n if (response.data.description === 'No token provided')\n return page.verifyToken(page.token)\n else if (failed.length)\n return swal('An error occurred!', `Unable to delete ${failed.length} of the album's upload${failed.length === 1 ? '' : 's'}.`, 'error')\n else\n return swal('An error occurred!', response.data.description, 'error')\n }\n\n swal('Deleted!', 'Your album has been deleted.', 'success', {\n buttons: false,\n timer: 1500\n })\n page.getAlbumsSidebar()\n page.getAlbums()\n }).catch(page.onAxiosError)\n })\n}\n\npage.submitAlbum = element => {\n page.updateTrigger(element, 'loading')\n\n axios.post('api/albums', {\n name: document.querySelector('#albumName').value.trim(),\n description: document.querySelector('#albumDescription').value.trim()\n }).then(response => {\n if (!response) return\n\n page.updateTrigger(element)\n if (response.data.success === false)\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n return swal('An error occurred!', response.data.description, 'error')\n }\n\n swal('Woohoo!', 'Album was created successfully.', 'success', {\n buttons: false,\n timer: 1500\n })\n page.getAlbumsSidebar()\n page.getAlbums()\n }).catch(error => {\n page.updateTrigger(element)\n page.onAxiosError(error)\n })\n}\n\npage.getAlbumsSidebar = () => {\n axios.get('api/albums/sidebar').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 const albumsContainer = document.querySelector('#albumsContainer')\n\n // Clear albums sidebar if necessary\n const oldAlbums = albumsContainer.querySelectorAll('li > a')\n if (oldAlbums.length) {\n for (let i = 0; i < oldAlbums.length; i++)\n page.menus.splice(page.menus.indexOf(oldAlbums[i]), 1)\n albumsContainer.innerHTML = ''\n }\n\n if (response.data.albums === undefined)\n return\n\n for (let i = 0; i < response.data.albums.length; i++) {\n const album = response.data.albums[i]\n const li = document.createElement('li')\n const a = document.createElement('a')\n a.id = album.id\n a.innerHTML = album.name\n a.className = 'is-relative'\n\n a.addEventListener('click', event => {\n page.getUploads({\n album: parseInt(event.currentTarget.id),\n trigger: event.currentTarget\n })\n })\n page.menus.push(a)\n\n li.appendChild(a)\n albumsContainer.appendChild(li)\n }\n }).catch(page.onAxiosError)\n}\n\npage.changeToken = (params = {}) => {\n page.dom.innerHTML = `\n
    \n \n
    \n
    \n \n
    \n
    \n
    \n \n `\n page.fadeAndScroll()\n page.updateTrigger(params.trigger, 'active')\n\n document.querySelector('#getNewToken').addEventListener('click', event => {\n const trigger = event.currentTarget\n page.updateTrigger(trigger, 'loading')\n axios.post('api/tokens/change').then(response => {\n if (response.data.success === false)\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n page.updateTrigger(trigger)\n return swal('An error occurred!', response.data.description, 'error')\n }\n\n page.updateTrigger(trigger)\n swal({\n title: 'Woohoo!',\n text: 'Your token was successfully changed.',\n icon: 'success',\n buttons: false,\n timer: 1500\n }).then(() => {\n axios.defaults.headers.common.token = response.data.token\n localStorage[lsKeys.token] = response.data.token\n page.token = response.data.token\n page.changeToken()\n })\n }).catch(error => {\n page.updateTrigger(trigger)\n page.onAxiosError(error)\n })\n })\n}\n\npage.changePassword = (params = {}) => {\n page.dom.innerHTML = `\n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n `\n page.fadeAndScroll()\n page.updateTrigger(params.trigger, 'active')\n\n document.querySelector('#sendChangePassword').addEventListener('click', event => {\n if (!page.dom.querySelector('form').checkValidity()) return\n if (document.querySelector('#password').value === document.querySelector('#passwordConfirm').value)\n page.sendNewPassword(document.querySelector('#password').value, event.currentTarget)\n else\n swal({\n title: 'Password mismatch!',\n text: 'Your passwords do not match, please try again.',\n icon: 'error'\n })\n })\n}\n\npage.sendNewPassword = (pass, element) => {\n page.updateTrigger(element, 'loading')\n\n axios.post('api/password/change', { password: pass }).then(response => {\n if (response.data.success === false)\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n page.updateTrigger(element)\n return swal('An error occurred!', response.data.description, 'error')\n }\n\n page.updateTrigger(element)\n swal({\n title: 'Woohoo!',\n text: 'Your password was successfully changed.',\n icon: 'success',\n buttons: false,\n timer: 1500\n }).then(() => {\n page.changePassword()\n })\n }).catch(error => {\n page.updateTrigger(element)\n page.onAxiosError(error)\n })\n}\n\npage.getUsers = (params = {}) => {\n page.updateTrigger(params.trigger, 'loading')\n\n if (params.pageNum === undefined)\n params.pageNum = 0\n\n if (!page.permissions.admin)\n return swal('An error occurred!', 'You cannot do this!', 'error')\n\n const url = `api/users/${params.pageNum}`\n axios.get(url).then(response => {\n if (response.data.success === false)\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n page.updateTrigger(params.trigger)\n return swal('An error occurred!', response.data.description, 'error')\n }\n\n const pages = Math.ceil(response.data.count / 25)\n if (params.pageNum && (response.data.users.length === 0))\n if (params.autoPage) {\n params.pageNum = pages - 1\n return page.getUsers(params)\n } else {\n page.updateTrigger(params.trigger)\n return swal('An error occurred!', `There are no more users to populate page ${params.pageNum + 1}.`, 'error')\n }\n\n page.currentView = 'users'\n page.cache.users = {}\n\n if (params.pageNum < 0) params.pageNum = Math.max(0, pages + params.pageNum)\n const pagination = page.paginate(response.data.count, 25, params.pageNum)\n\n const filter = `\n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n `\n const extraControls = `\n
    \n ${filter}\n
    \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n `\n\n const controls = `\n \n `\n\n // Do some string replacements for bottom controls\n const bottomFiltersId = 'bFilters'\n const bottomJumpId = 'bJumpToPage'\n const bottomExtraControls = extraControls\n .replace(/id=\"filters\"/, `id=\"${bottomFiltersId}\"`)\n .replace(/(data-action=\"filter-uploads\")/, `$1 data-filtersid=\"${bottomFiltersId}\"`)\n .replace(/id=\"jumpToPage\"/, `id=\"${bottomJumpId}\"`)\n .replace(/(data-action=\"jump-to-page\")/g, `$1 data-jumpid=\"${bottomJumpId}\"`)\n const bottomPagination = pagination\n .replace(/(data-action=\"page-ellipsis\")/g, `$1 data-jumpid=\"${bottomJumpId}\"`)\n\n // Whether there are any unselected items\n let unselected = false\n\n page.dom.innerHTML = `\n ${pagination}\n ${extraControls}\n ${controls}\n
    \n \n \n \n \n \n \n \n \n \n \n \n \n \n
    UsernameUploadsUsageGroup
    \n
    \n ${controls}\n ${bottomExtraControls}\n ${bottomPagination}\n `\n\n const table = document.querySelector('#table')\n\n for (let i = 0; i < response.data.users.length; i++) {\n const user = response.data.users[i]\n const selected = page.selected.users.includes(user.id)\n if (!selected) unselected = true\n\n let displayGroup = null\n const groups = Object.keys(user.groups)\n for (let i = 0; i < groups.length; i++) {\n if (!user.groups[groups[i]]) break\n displayGroup = groups[i]\n }\n\n // Server-side explicitly expects either of these two values to consider a user as disabled\n const enabled = user.enabled !== false && user.enabled !== 0\n page.cache.users[user.id] = {\n username: user.username,\n groups: user.groups,\n enabled,\n displayGroup\n }\n\n const tr = document.createElement('tr')\n tr.dataset.id = user.id\n tr.innerHTML = `\n \n ${user.username}\n ${user.uploads}\n ${page.getPrettyBytes(user.usage)}\n ${displayGroup}\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n `\n\n table.appendChild(tr)\n page.checkboxes.users = table.querySelectorAll('.checkbox[data-action=\"select\"]')\n }\n\n const selectAll = document.querySelector('#selectAll')\n if (selectAll && !unselected) {\n selectAll.checked = true\n selectAll.title = 'Unselect all'\n }\n\n page.fadeAndScroll()\n page.updateTrigger(params.trigger, 'active')\n\n page.views.users.pageNum = response.data.users.length ? params.pageNum : 0\n }).catch(error => {\n page.updateTrigger(params.trigger)\n page.onAxiosError(error)\n })\n}\n\npage.createUser = () => {\n const groupOptions = Object.keys(page.permissions).map((g, i, a) => {\n const disabled = !(a[i + 1] && page.permissions[a[i + 1]])\n return ``\n }).join('\\n')\n\n const div = document.createElement('div')\n div.innerHTML = `\n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n `\n\n swal({\n title: 'Create new user',\n icon: 'info',\n content: div,\n buttons: {\n cancel: true,\n confirm: {\n closeModal: false\n }\n }\n }).then(proceed => {\n if (!proceed) return\n\n axios.post('api/users/create', {\n username: document.querySelector('#swalUsername').value,\n password: document.querySelector('#swalPassword').value,\n group: document.querySelector('#swalGroup').value\n }).then(response => {\n if (!response) return\n\n if (response.data.success === false)\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n return swal('An error occurred!', response.data.description, 'error')\n }\n\n const div = document.createElement('div')\n div.innerHTML = `\n

    Username: ${response.data.username}

    \n

    Password: ${response.data.password}

    \n

    User group: ${response.data.group}

    \n `\n swal({\n title: 'Created a new user!',\n icon: 'success',\n content: div\n })\n\n // Load last page of users list\n // eslint-disable-next-line compat/compat\n page.getUsers(Object.assign(page.views.users, {\n pageNum: -1\n }))\n }).catch(page.onAxiosError)\n })\n}\n\npage.editUser = id => {\n const user = page.cache.users[id]\n if (!user) return\n\n const groupOptions = Object.keys(page.permissions).map((g, i, a) => {\n const selected = g === user.displayGroup\n const disabled = !(a[i + 1] && page.permissions[a[i + 1]])\n return ``\n }).join('\\n')\n\n const div = document.createElement('div')\n div.innerHTML = `\n
    \n \n
    \n \n
    \n
    \n
    \n \n
    \n
    \n \n
    \n
    \n
    \n
    \n
    \n \n
    \n
    \n
    \n
    \n \n
    \n
    \n `\n\n swal({\n title: 'Edit user',\n icon: 'info',\n content: div,\n buttons: {\n cancel: true,\n confirm: {\n closeModal: false\n }\n }\n }).then(proceed => {\n if (!proceed) return\n\n axios.post('api/users/edit', {\n id,\n username: document.querySelector('#swalUsername').value,\n group: document.querySelector('#swalGroup').value,\n enabled: document.querySelector('#swalEnabled').checked,\n resetPassword: document.querySelector('#swalResetPassword').checked\n }).then(response => {\n if (!response) return\n\n if (response.data.success === false)\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n return swal('An error occurred!', response.data.description, 'error')\n }\n\n let autoClose = true\n const div = document.createElement('div')\n\n let displayName = user.username\n if (response.data.update.username !== user.username) {\n div.innerHTML += `

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

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

    ${displayName}'s new password is:

    \n

    ${response.data.update.password}

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

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

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

    ${displayName} was edited!

    `\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.users[id]\n if (!user || !user.enabled) return\n\n const content = document.createElement('div')\n content.innerHTML = `\n

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

    \n

    Their files will remain.

    \n `\n\n swal({\n title: 'Are you sure?',\n icon: 'warning',\n content,\n dangerMode: true,\n buttons: {\n cancel: true,\n confirm: {\n text: 'Yes, disable them!',\n closeModal: false\n }\n }\n }).then(proceed => {\n if (!proceed) return\n\n axios.post('api/users/disable', { id }).then(response => {\n if (!response) return\n\n if (response.data.success === false)\n if (response.data.description === 'No token provided')\n return page.verifyToken(page.token)\n else\n return swal('An error occurred!', response.data.description, 'error')\n\n swal('Success!', `${page.cache.users[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.users[id]\n if (!user) return\n\n const content = document.createElement('div')\n content.innerHTML = `\n

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

    \n

    Their files will 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, delete it!',\n closeModal: false\n },\n purge: {\n text: 'Yes, and the 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 swal('Success!', `${page.cache.users[id].username} has been deleted.`, 'success', {\n buttons: false,\n timer: 1500\n })\n\n // Reload users list\n // eslint-disable-next-line compat/compat\n page.getUsers(Object.assign(page.views.users, {\n autoPage: true\n }))\n }).catch(page.onAxiosError)\n })\n}\n\n// Roughly based on https://github.com/mayuska/pagination/blob/master/index.js\npage.paginate = (totalItems, itemsPerPage, currentPage) => {\n currentPage = currentPage + 1\n const step = 3\n const numPages = Math.ceil(totalItems / itemsPerPage)\n\n let template = ''\n const elementsToShow = step * 2\n const add = {\n pageNum (start, end) {\n for (let i = start; i <= end; ++i)\n template += `
  • ${i}
  • `\n },\n startDots () {\n template += `\n
  • 1
  • \n
  • \n `\n },\n endDots () {\n template += `\n
  • \n
  • ${numPages}
  • \n `\n }\n }\n\n if (elementsToShow + 1 >= numPages) {\n add.pageNum(1, numPages)\n } else if (currentPage < elementsToShow) {\n add.pageNum(1, elementsToShow)\n add.endDots()\n } else if (currentPage > numPages - elementsToShow + 1) {\n add.startDots()\n add.pageNum(numPages - elementsToShow + 1, numPages)\n } else {\n add.startDots()\n add.pageNum(currentPage - step + 1, currentPage + step - 1)\n add.endDots()\n }\n\n return `\n \n `\n}\n\npage.getStatistics = (params = {}) => {\n if (!page.permissions.admin)\n return swal('An error occurred!', 'You cannot do this!', 'error')\n\n page.updateTrigger(params.trigger, 'loading')\n\n const url = 'api/stats'\n axios.get(url).then(response => {\n if (response.data.success === false)\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n page.updateTrigger(params.trigger)\n return swal('An error occurred!', response.data.description, 'error')\n }\n\n let content = ''\n const keys = Object.keys(response.data.stats)\n for (let i = 0; i < keys.length; i++) {\n let rows = ''\n if (!response.data.stats[keys[i]])\n rows += `\n \n Generating, please try again later\\u2026\n \n \n `\n else\n try {\n const types = response.data.stats[keys[i]]._types || {}\n const valKeys = Object.keys(response.data.stats[keys[i]])\n for (let j = 0; j < valKeys.length; j++) {\n // Skip keys that starts with an underscore\n if (/^_/.test(valKeys[j]))\n continue\n\n const value = response.data.stats[keys[i]][valKeys[j]]\n let parsed = value\n\n // Parse values with some preset formatting\n if ((types.number || []).includes(valKeys[j]))\n parsed = value.toLocaleString()\n if ((types.byte || []).includes(valKeys[j]))\n parsed = page.getPrettyBytes(value)\n if ((types.byteUsage || []).includes(valKeys[j]))\n parsed = `${page.getPrettyBytes(value.used)} / ${page.getPrettyBytes(value.total)} (${Math.round(value.used / value.total * 100)}%)`\n\n const string = valKeys[j]\n .replace(/([A-Z])/g, ' $1')\n .toUpperCase()\n rows += `\n \n ${string}\n ${parsed}\n \n `\n }\n } catch (error) {\n rows = `\n \n Error parsing response. Try again?\n \n \n `\n page.onError(error)\n }\n\n content += `\n
    \n \n \n \n \n \n \n \n \n ${rows}\n \n
    ${keys[i].toUpperCase()}
    \n
    \n `\n }\n\n page.dom.innerHTML = content\n page.fadeAndScroll()\n page.updateTrigger(params.trigger, 'active')\n }).catch(error => {\n page.updateTrigger(params.trigger)\n page.onAxiosError(error)\n })\n}\n\nwindow.onload = () => {\n // Polyfill Object.assign()\n // eslint-disable-next-line compat/compat\n if (typeof Object.assign !== 'function')\n // Must be writable: true, enumerable: false, configurable: true\n Object.defineProperty(Object, 'assign', {\n value: function assign (target, varArgs) { // .length of function is 2\n 'use strict'\n if (target === null || target === undefined)\n throw new TypeError('Cannot convert undefined or null to object')\n const to = Object(target)\n for (let i = 1; i < arguments.length; i++) {\n const nextSource = arguments[i]\n if (nextSource !== null && nextSource !== undefined)\n for (const nextKey in nextSource)\n // Avoid bugs when hasOwnProperty is shadowed\n if (Object.prototype.hasOwnProperty.call(nextSource, nextKey))\n to[nextKey] = nextSource[nextKey]\n }\n return to\n },\n writable: true,\n configurable: true\n })\n\n // Add 'no-touch' class to non-touch devices\n if (!('ontouchstart' in document.documentElement))\n document.documentElement.classList.add('no-touch')\n\n const selectedKeys = ['uploads', 'uploadsAll', 'users']\n for (let i = 0; i < selectedKeys.length; i++) {\n const ls = localStorage[lsKeys.selected[selectedKeys[i]]]\n if (ls) page.selected[selectedKeys[i]] = JSON.parse(ls)\n }\n\n page.preparePage()\n\n page.clipboardJS = new ClipboardJS('.clipboard-js')\n\n page.clipboardJS.on('success', () => {\n return swal('', 'The link has been copied to clipboard.', 'success', {\n buttons: false,\n timer: 1500\n })\n })\n\n page.clipboardJS.on('error', page.onError)\n\n page.lazyLoad = new LazyLoad()\n}\n"]} \ No newline at end of file diff --git a/dist/js/home.js.map b/dist/js/home.js.map index fa6d52c..cc65d13 100644 --- a/dist/js/home.js.map +++ b/dist/js/home.js.map @@ -1 +1 @@ -{"version":3,"sources":["home.js"],"names":["const","lsKeys","token","chunkSize","parallelUploads","uploadsHistoryOrder","previewImages","fileLength","uploadAge","stripTags","page","localStorage","private","enableUserAccounts","maxSize","temporaryUploadAges","fileIdentifierLength","stripTagsConfig","album","maxSizeBytes","urlMaxSize","urlMaxSizeBytes","tabs","activeTab","albumSelect","albumSelectOnChange","previewTemplate","dropzone","clipboardJS","lazyLoad","urlsQueue","activeUrlsQueue","imageExts","videoExts","albumTitleMaxLength","albumDescMaxLength","onInitError","error","document","querySelector","classList","add","querySelectorAll","forEach","element","uploadButton","innerText","remove","addEventListener","location","reload","response","onAxiosError","onError","console","content","createElement","innerHTML","toString","swal","title","icon","statusText","520","521","522","523","524","525","526","527","530","status","description","data","checkClientVersion","apiVersion","match","src","text","buttons","confirm","closeModal","then","checkIfPublic","let","renderShown","axios","get","onDownloadProgress","doRender","version","parseInt","preparePage","catch","prepareUpload","verifyToken","button","href","reloadOnError","post","success","removeItem","value","prepareShareX","fetchAlbums","prepareUploadConfig","getPrettyBytes","prepareDropzone","event","addUrlsToQueue","tabsContainer","loop","i","id","dataset","tabContent","setActiveTab","push","tab","length","index","headers","Array","isArray","albums","option","name","appendChild","previewNode","parentNode","removeChild","tabDiv","div","className","previewsContainer","Dropzone","body","url","paramName","clickable","maxFilesize","uploadMultiple","createImageThumbnails","autoProcessQueue","chunking","Boolean","parallelChunkUploads","timeout","init","this","on","file","previewElement","xhr","ontimeout","instances","getUploadingFiles","filter","instance","_handleUploadError","undefined","_uplSpeedCalc","lastSent","timestamp","Date","now","bytes","upload","chunked","setRequestHeader","chunks","progress","prettyBytesPerSec","total","Math","max","size","percentage","bytesSent","toFixed","upl","prefix","skipProgress","done","last","totalChunkCount","chunkIndex","elapsed","bytesPerSec","fullSec","splice","excessDuration","duration","files","updateTemplate","test","updateTemplateIcon","chunksUploaded","uuid","original","type","albumid","filelength","age","striptags","urls","split","trim","firstChild","processUrlsQueue","shiftQueue","initUrlUpload","finishedUrlUpload","shift","templateElement","iconClass","iconElement","link","a","clipboard","clipboardText","parentElement","exec","extname","toLowerCase","includes","img","setAttribute","onerror","currentTarget","update","expirydate","expiryDate","getPrettyDate","createAlbum","cancel","download","checked","public","selected","fallback","min","config","siBytes","label","select","help","valueHandler","display","number","round","disabled","force","default","video","isNaN","suffix","uploadFields","stored","parseFloat","String","getPrettyUploadAge","form","preventDefault","configKeys","Object","keys","key","conf","field","parsed","find","sel","control","opts","j","opt","join","tmp","submit","checkValidity","elements","hours","minutes","days","window","items","clipboardData","originalEvent","item","kind","blob","getAsFile","File","addFile","onload","ClipboardJS","timer","LazyLoad","elements_selector"],"mappings":"AAEAA,IAAMC,OAAS,CACbC,MAAO,QACPC,UAAW,YACXC,gBAAiB,kBACjBC,oBAAqB,sBACrBC,cAAe,gBACfC,WAAY,aACZC,UAAW,YACXC,UAAW,aAGPC,KAAO,CAEXR,MAAOS,aAAaV,OAAOC,OAG3BU,QAAS,KACTC,mBAAoB,KACpBC,QAAS,KACTX,UAAW,KACXY,oBAAqB,KACrBC,qBAAsB,KACtBC,gBAAiB,KAGjBC,MAAO,KAEPd,gBAAiB,EACjBE,cAAe,KACfC,WAAY,KACZC,UAAW,KAEXW,aAAc,KACdC,WAAY,KACZC,gBAAiB,KAEjBC,KAAM,GACNC,UAAW,KACXC,YAAa,KACbC,oBAAqB,KACrBC,gBAAiB,KAEjBC,SAAU,KACVC,YAAa,KACbC,SAAU,KAGVC,UAAW,GACXC,gBAAiB,EAIjBC,UAAW,CAAC,QAAS,OAAQ,QAAS,OAAQ,OAAQ,OAAQ,QAAS,OAAQ,QAC/EC,UAAW,CAAC,QAAS,OAAQ,OAAQ,OAAQ,OAAQ,OAAQ,OAAQ,SAErEC,oBAAqB,GACrBC,mBAAoB,IAItBC,YAAgB,SAAGC,GAEjBC,SAASC,cAAc,aAAaC,UAAUC,IAAI,aAClDH,SAASC,cAAc,SAASC,UAAUC,IAAI,aAC9CH,SAASI,iBAAiB,gBAAgBC,SAAO,SAACC,GAChD,OAAOA,EAAQJ,UAAUC,IAAI,gBAI/BzC,IAAM6C,EAAeP,SAASC,cAAc,kBAC5CM,EAAaC,UAAY,oCACzBD,EAAaL,UAAUO,OAAO,cAC9BF,EAAaL,UAAUO,OAAO,aAE9BF,EAAaG,iBAAiB,SAAO,WACnCC,SAASC,YAGPb,EAAMc,SACRzC,KAAK0C,aAAaf,GAElB3B,KAAK2C,QAAQhB,IAIjBgB,Q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eAAeD,MACnEtK,EAAQiJ,OAAOC,KAAKoB,GACjB9K,EAAI,EAAGA,EAAIQ,EAAMD,OAAQP,IAAK,CACrCjH,IAAMkS,EAAOH,EAAMtK,EAAMR,IACzB,GAAkB,SAAdiL,EAAKC,KAAiB,CACxBnS,IAAMoS,EAAOF,EAAKG,YAEZ7I,EAAO,IAAI8I,KAAK,CAACF,GAAO,gBAAgBA,EAAK3F,KAAK5H,MAAM,sBAAsB,GAAM,CACxF4H,KAAM2F,EAAK3F,OAEb/L,KAAKiB,SAAS4Q,QAAQ/I,QAK5BsI,OAAOU,OAAM,WACX9R,KAAK0E,gBAEL1E,KAAKkB,YAAc,IAAI6Q,YAAY,iBAEnC/R,KAAKkB,YAAY2H,GAAG,WAAS,WAC3B,OAAO5F,KAAK,GAAI,yCAA0C,UAAW,CACnEqB,SAAS,EACT0N,MAAO,UAIXhS,KAAKkB,YAAY2H,GAAG,QAAS7I,KAAK2C,SAElC3C,KAAKmB,SAAW,IAAI8Q,SAAS,CAC3BC,kBAAmB,uBAGrBtQ,SAASC,cAAc,gBAAgBS,iBAAiB,SAAO,WAC7DtC,KAAKiO","file":"home.js","sourcesContent":["/* global swal, axios, Dropzone, ClipboardJS, LazyLoad */\n\nconst lsKeys = {\n token: 'token',\n chunkSize: 'chunkSize',\n parallelUploads: 'parallelUploads',\n uploadsHistoryOrder: 'uploadsHistoryOrder',\n previewImages: 'previewImages',\n fileLength: 'fileLength',\n uploadAge: 'uploadAge',\n stripTags: 'stripTags'\n}\n\nconst page = {\n // user token\n token: localStorage[lsKeys.token],\n\n // configs from api/check\n private: null,\n enableUserAccounts: null,\n maxSize: null,\n chunkSize: null,\n temporaryUploadAges: null,\n fileIdentifierLength: null,\n stripTagsConfig: null,\n\n // store album id that will be used with upload requests\n album: null,\n\n parallelUploads: 2,\n previewImages: null,\n fileLength: null,\n uploadAge: null,\n\n maxSizeBytes: null,\n urlMaxSize: null,\n urlMaxSizeBytes: null,\n\n tabs: [],\n activeTab: null,\n albumSelect: null,\n albumSelectOnChange: null,\n previewTemplate: null,\n\n dropzone: null,\n clipboardJS: null,\n lazyLoad: null,\n\n // additional vars for url uploads\n urlsQueue: [],\n activeUrlsQueue: 0,\n\n // Include BMP for uploads preview only, cause the real images will be used\n // Sharp isn't capable of making their thumbnails for dashboard and album public pages\n imageExts: ['.webp', '.jpg', '.jpeg', '.bmp', '.gif', '.png', '.tiff', '.tif', '.svg'],\n videoExts: ['.webm', '.mp4', '.wmv', '.avi', '.mov', '.mkv', '.m4v', '.m2ts'],\n\n albumTitleMaxLength: 70,\n albumDescMaxLength: 4000\n}\n\n// Handler for errors during initialization\npage.onInitError = error => {\n // Hide these elements\n document.querySelector('#albumDiv').classList.add('is-hidden')\n document.querySelector('#tabs').classList.add('is-hidden')\n document.querySelectorAll('.tab-content').forEach(element => {\n return element.classList.add('is-hidden')\n })\n\n // Update upload button\n const uploadButton = document.querySelector('#loginToUpload')\n uploadButton.innerText = 'An error occurred. Try to reload?'\n uploadButton.classList.remove('is-loading')\n uploadButton.classList.remove('is-hidden')\n\n uploadButton.addEventListener('click', () => {\n location.reload()\n })\n\n if (error.response)\n page.onAxiosError(error)\n else\n page.onError(error)\n}\n\n// Handler for regular JS errors\npage.onError = error => {\n console.error(error)\n\n const content = document.createElement('div')\n content.innerHTML = `${error.toString()}`\n return swal({\n title: 'An error occurred!',\n icon: 'error',\n content\n })\n}\n\n// Handler for Axios errors\npage.onAxiosError = error => {\n console.error(error)\n\n // Better Cloudflare errors\n const cloudflareErrors = {\n 520: 'Unknown Error',\n 521: 'Web Server Is Down',\n 522: 'Connection Timed Out',\n 523: 'Origin Is Unreachable',\n 524: 'A Timeout Occurred',\n 525: 'SSL Handshake Failed',\n 526: 'Invalid SSL Certificate',\n 527: 'Railgun Error',\n 530: 'Origin DNS Error'\n }\n\n const statusText = cloudflareErrors[error.response.status] || error.response.statusText\n const description = error.response.data && error.response.data.description\n ? error.response.data.description\n : 'There was an error with the request, please check the console for more information.'\n\n return swal(`${error.response.status} ${statusText}`, description, 'error')\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: 'Updated 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 location.reload()\n })\n}\n\npage.checkIfPublic = () => {\n let renderShown = false\n return axios.get('api/check', {\n onDownloadProgress: () => {\n // Only show render after this request has been initiated to avoid blocking\n if (!renderShown && typeof page.doRender === 'function') {\n page.doRender()\n renderShown = true\n }\n }\n }).then(response => {\n if (response.data.version)\n page.checkClientVersion(response.data.version)\n\n page.private = response.data.private\n page.enableUserAccounts = response.data.enableUserAccounts\n page.maxSize = parseInt(response.data.maxSize)\n page.maxSizeBytes = page.maxSize * 1e6\n page.chunkSize = parseInt(response.data.chunkSize)\n page.temporaryUploadAges = response.data.temporaryUploadAges\n page.fileIdentifierLength = response.data.fileIdentifierLength\n page.stripTagsConfig = response.data.stripTags\n\n return page.preparePage()\n }).catch(page.onInitError)\n}\n\npage.preparePage = () => {\n if (page.private)\n if (page.token) {\n return page.verifyToken(page.token, true)\n } else {\n const button = document.querySelector('#loginToUpload')\n button.href = 'auth'\n button.classList.remove('is-loading')\n if (page.enableUserAccounts)\n button.innerText = 'Anonymous upload is disabled. Log in to upload.'\n else\n button.innerText = 'Running in private mode. Log in to upload.'\n }\n else\n return page.prepareUpload()\n}\n\npage.verifyToken = (token, reloadOnError) => {\n return axios.post('api/tokens/verify', { token }).then(response => {\n if (response.data.success === false)\n return swal({\n title: 'An error occurred!',\n text: response.data.description,\n icon: 'error'\n }).then(() => {\n if (!reloadOnError) return\n localStorage.removeItem('token')\n location.reload()\n })\n\n localStorage[lsKeys.token] = token\n page.token = token\n return page.prepareUpload()\n }).catch(page.onInitError)\n}\n\npage.prepareUpload = () => {\n // I think this fits best here because we need to check for a valid token before we can get the albums\n if (page.token) {\n // 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')\n page.prepareShareX()\n }\n page.albumSelect.addEventListener('change', page.albumSelectOnChange)\n\n // Fetch albums\n page.fetchAlbums()\n }\n\n // Prepare & generate config tab\n page.prepareUploadConfig()\n\n // Update elements wherever applicable\n document.querySelector('#maxSize > span').innerHTML = page.getPrettyBytes(page.maxSizeBytes)\n document.querySelector('#loginToUpload').classList.add('is-hidden')\n\n if (!page.token && page.enableUserAccounts)\n document.querySelector('#loginLinkText').innerHTML = 'Create an account and keep track of your uploads'\n\n // Prepare & generate files upload tab\n page.prepareDropzone()\n\n // Generate ShareX config file\n if (typeof page.prepareShareX === 'function')\n 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 document.querySelector('#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\npage.fetchAlbums = () => {\n return axios.get('api/albums', { headers: { token: page.token } }).then(response => {\n if (response.data.success === false)\n return swal('An error occurred!', response.data.description, 'error')\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 }).catch(page.onInitError)\n}\n\npage.prepareDropzone = () => {\n // Parse template element\n const previewNode = document.querySelector('#tpl')\n page.previewTemplate = previewNode.innerHTML\n previewNode.parentNode.removeChild(previewNode)\n\n // Generate files upload tab\n const tabDiv = document.querySelector('#tab-files')\n const div = document.createElement('div')\n div.className = 'control is-expanded'\n div.innerHTML = `\n
    \n \n \n \n Click here or drag & drop files\n
    \n `\n tabDiv.querySelector('.dz-container').appendChild(div)\n\n const previewsContainer = tabDiv.querySelector('#tab-files .field.uploads')\n\n page.dropzone = new Dropzone(document.body, {\n url: 'api/upload',\n paramName: 'files[]',\n clickable: tabDiv.querySelector('#dropzone'),\n maxFilesize: page.maxSizeBytes / 1024 / 1024, // this option expects MiB\n parallelUploads: page.parallelUploads,\n uploadMultiple: false,\n previewsContainer,\n previewTemplate: page.previewTemplate,\n createImageThumbnails: false,\n autoProcessQueue: true,\n headers: { token: page.token },\n chunking: Boolean(page.chunkSize),\n chunkSize: page.chunkSize * 1e6, // this option expects Bytes\n parallelChunkUploads: false, // for now, enabling this breaks descriptive upload progress\n timeout: 0,\n\n init () {\n this.on('addedfile', file => {\n // Set active tab to file uploads, if necessary\n if (page.activeTab !== 0)\n page.setActiveTab(0)\n\n // Add file entry\n tabDiv.querySelector('.uploads').classList.remove('is-hidden')\n\n file.previewElement.querySelector('.name').innerHTML = file.name\n file.previewElement.querySelector('.descriptive-progress').innerHTML = 'Waiting in queue\\u2026'\n })\n\n this.on('sending', (file, xhr) => {\n // Add timeout listener (hacky method due to lack of built-in timeout handler)\n if (!xhr.ontimeout)\n xhr.ontimeout = () => {\n const instances = page.dropzone.getUploadingFiles()\n .filter(instance => instance.xhr === xhr)\n page.dropzone._handleUploadError(instances, xhr, 'Connection timed out. Try to reduce upload chunk size.')\n }\n\n // Attach necessary data for initial upload speed calculation\n if (xhr._uplSpeedCalc === undefined)\n xhr._uplSpeedCalc = {\n lastSent: 0,\n data: [{ timestamp: Date.now(), bytes: 0 }]\n }\n\n // If not chunked uploads, add extra headers\n if (!file.upload.chunked) {\n if (page.album !== null) xhr.setRequestHeader('albumid', page.album)\n if (page.fileLength !== null) xhr.setRequestHeader('filelength', page.fileLength)\n if (page.uploadAge !== null) xhr.setRequestHeader('age', page.uploadAge)\n if (page.stripTags !== null) xhr.setRequestHeader('striptags', page.stripTags)\n }\n\n if (!file.upload.chunked)\n file.previewElement.querySelector('.descriptive-progress').innerHTML = 'Uploading\\u2026'\n else if (file.upload.chunks.length === 1)\n file.previewElement.querySelector('.descriptive-progress').innerHTML = `Uploading chunk 1/${file.upload.totalChunkCount}\\u2026`\n })\n\n // Update descriptive progress\n this.on('uploadprogress', (file, progress) => {\n // Total bytes will eventually be bigger than file size when chunked\n const total = Math.max(file.size, file.upload.total)\n const percentage = (file.upload.bytesSent / total * 100).toFixed(0)\n\n const upl = file.upload.chunked\n ? file.upload.chunks[file.upload.chunks.length - 1]\n : file.upload\n const xhr = upl.xhr || file.xhr\n\n let prefix = 'Uploading\\u2026'\n let skipProgress = false\n if (file.upload.chunked) {\n const done = upl.bytesSent === upl.total\n const last = file.upload.chunks.length === file.upload.totalChunkCount\n let chunkIndex = file.upload.chunks.length\n if (done && !last) {\n chunkIndex++\n skipProgress = true\n }\n prefix = `Uploading chunk ${chunkIndex}/${file.upload.totalChunkCount}\\u2026`\n }\n\n // Real-time upload speed calculation\n let prettyBytesPerSec\n if (!skipProgress) {\n const now = Date.now()\n const bytesSent = upl.bytesSent - xhr._uplSpeedCalc.lastSent\n\n // Push data of current iteration\n xhr._uplSpeedCalc.lastSent = upl.bytesSent\n xhr._uplSpeedCalc.data.push({ timestamp: now, bytes: bytesSent })\n\n // Wait till at least the 2nd iteration (3 data including initial data)\n const length = xhr._uplSpeedCalc.data.length\n if (length > 2) {\n // Calculate using data from all iterations\n let elapsed = 0\n let bytesPerSec = 0\n let fullSec = false\n let i = length - 1 // Always start with 2nd from last item\n while (i--) {\n // Splice data of unrequired iterations\n if (fullSec) {\n xhr._uplSpeedCalc.data.splice(i, 1)\n continue\n }\n // Sum data\n elapsed = now - xhr._uplSpeedCalc.data[i].timestamp\n if (elapsed > 1000) {\n const excessDuration = elapsed - 1000\n const newerIterationElapsed = now - xhr._uplSpeedCalc.data[i + 1].timestamp\n const duration = elapsed - newerIterationElapsed\n const fragment = (duration - excessDuration) / duration * xhr._uplSpeedCalc.data[i + 1].bytes\n bytesPerSec += fragment\n fullSec = true\n } else {\n bytesPerSec += xhr._uplSpeedCalc.data[i + 1].bytes\n }\n }\n\n // If not enough data\n if (!fullSec)\n bytesPerSec = 1000 / elapsed * bytesPerSec\n\n // Get pretty bytes\n prettyBytesPerSec = page.getPrettyBytes(bytesPerSec)\n }\n }\n\n file.previewElement.querySelector('.descriptive-progress').innerHTML =\n `${prefix} ${percentage}%${prettyBytesPerSec ? ` at ${prettyBytesPerSec}/s` : ''}`\n })\n\n this.on('success', (file, data) => {\n if (!data) return\n file.previewElement.querySelector('.descriptive-progress').classList.add('is-hidden')\n\n if (data.success === false) {\n file.previewElement.querySelector('.error').innerHTML = data.description\n file.previewElement.querySelector('.error').classList.remove('is-hidden')\n }\n\n if (Array.isArray(data.files) && data.files[0])\n page.updateTemplate(file, data.files[0])\n })\n\n this.on('error', (file, error) => {\n // Clean up file size errors\n if ((typeof error === 'string' && /^File is too big/.test(error)) ||\n (typeof error === 'object' && /File too large/.test(error.description)))\n error = `File too large (${page.getPrettyBytes(file.size)}).`\n\n page.updateTemplateIcon(file.previewElement, 'icon-block')\n\n file.previewElement.querySelector('.descriptive-progress').classList.add('is-hidden')\n\n file.previewElement.querySelector('.error').innerHTML = error.description || error\n file.previewElement.querySelector('.error').classList.remove('is-hidden')\n })\n },\n\n chunksUploaded (file, done) {\n file.previewElement.querySelector('.descriptive-progress').innerHTML =\n `Rebuilding ${file.upload.totalChunkCount} chunks\\u2026`\n\n return axios.post('api/upload/finishchunks', {\n // This API supports an array of multiple files\n files: [{\n uuid: file.upload.uuid,\n original: file.name,\n type: file.type,\n albumid: page.album,\n filelength: page.fileLength,\n age: page.uploadAge\n }]\n }, {\n headers: {\n token: page.token,\n // Unlike the options above (e.g. albumid, filelength, etc.),\n // strip tags can not yet be configured per file with this API\n striptags: page.stripTags\n }\n }).catch(error => {\n // Format error for display purpose\n return error.response.data ? error.response : {\n data: {\n success: false,\n description: error.toString()\n }\n }\n }).then(response => {\n file.previewElement.querySelector('.descriptive-progress').classList.add('is-hidden')\n\n if (response.data.success === false) {\n file.previewElement.querySelector('.error').innerHTML = response.data.description\n file.previewElement.querySelector('.error').classList.remove('is-hidden')\n }\n\n if (response.data.files && response.data.files[0])\n page.updateTemplate(file, response.data.files[0])\n\n return done()\n })\n }\n })\n}\n\npage.addUrlsToQueue = () => {\n const urls = document.querySelector('#urls').value\n .split(/\\r?\\n/)\n .filter(url => {\n return url.trim().length\n })\n\n if (!urls.length)\n return swal('An error occurred!', 'You have not entered any URLs.', 'error')\n\n const tabDiv = document.querySelector('#tab-urls')\n tabDiv.querySelector('.uploads').classList.remove('is-hidden')\n\n for (let i = 0; i < urls.length; i++) {\n const previewTemplate = document.createElement('template')\n previewTemplate.innerHTML = page.previewTemplate.trim()\n\n const previewElement = previewTemplate.content.firstChild\n previewElement.querySelector('.name').innerHTML = urls[i]\n previewElement.querySelector('.descriptive-progress').innerHTML = 'Waiting in queue\\u2026'\n\n const previewsContainer = tabDiv.querySelector('.uploads')\n previewsContainer.appendChild(previewElement)\n\n page.urlsQueue.push({\n url: urls[i],\n previewElement\n })\n }\n\n page.processUrlsQueue()\n document.querySelector('#urls').value = ''\n}\n\npage.processUrlsQueue = () => {\n if (!page.urlsQueue.length) return\n\n function finishedUrlUpload (file, data) {\n file.previewElement.querySelector('.descriptive-progress').classList.add('is-hidden')\n\n if (data.success === false) {\n const match = data.description.match(/ over limit: (\\d+)$/)\n if (match && match[1])\n data.description = `File exceeded limit of ${page.getPrettyBytes(match[1])}.`\n\n file.previewElement.querySelector('.error').innerHTML = data.description\n file.previewElement.querySelector('.error').classList.remove('is-hidden')\n }\n\n if (Array.isArray(data.files) && data.files[0])\n page.updateTemplate(file, data.files[0])\n\n page.activeUrlsQueue--\n return shiftQueue()\n }\n\n function initUrlUpload (file) {\n file.previewElement.querySelector('.descriptive-progress').innerHTML =\n 'Waiting for server to fetch URL\\u2026'\n\n return axios.post('api/upload', {\n urls: [file.url]\n }, {\n headers: {\n token: page.token,\n albumid: page.album,\n age: page.uploadAge,\n filelength: page.fileLength\n }\n }).catch(error => {\n // Format error for display purpose\n return error.response.data ? error.response : {\n data: {\n success: false,\n description: error.toString()\n }\n }\n }).then(response => {\n return finishedUrlUpload(file, response.data)\n })\n }\n\n function shiftQueue () {\n while (page.urlsQueue.length && (page.activeUrlsQueue < page.parallelUploads)) {\n page.activeUrlsQueue++\n initUrlUpload(page.urlsQueue.shift())\n }\n }\n\n return shiftQueue()\n}\n\npage.updateTemplateIcon = (templateElement, iconClass) => {\n const iconElement = templateElement.querySelector('.icon')\n if (!iconElement) return\n\n iconElement.classList.add(iconClass)\n iconElement.classList.remove('is-hidden')\n}\n\npage.updateTemplate = (file, response) => {\n if (!response.url) return\n\n const link = file.previewElement.querySelector('.link')\n const a = link.querySelector('a')\n const clipboard = file.previewElement.querySelector('.clipboard-mobile > .clipboard-js')\n a.href = a.innerHTML = clipboard.dataset.clipboardText = response.url\n\n link.classList.remove('is-hidden')\n clipboard.parentElement.classList.remove('is-hidden')\n\n const exec = /.[\\w]+(\\?|$)/.exec(response.url)\n const extname = exec && exec[0]\n ? exec[0].toLowerCase()\n : null\n\n if (page.imageExts.includes(extname))\n if (page.previewImages) {\n const img = file.previewElement.querySelector('img')\n img.setAttribute('alt', response.name || '')\n img.dataset.src = response.url\n img.classList.remove('is-hidden')\n img.onerror = event => {\n // Hide image elements that fail to load\n // Consequently include WEBP in browsers that do not have WEBP support (e.g. IE)\n event.currentTarget.classList.add('is-hidden')\n page.updateTemplateIcon(file.previewElement, 'icon-picture')\n }\n page.lazyLoad.update(file.previewElement.querySelectorAll('img'))\n } else {\n page.updateTemplateIcon(file.previewElement, 'icon-picture')\n }\n else if (page.videoExts.includes(extname))\n page.updateTemplateIcon(file.previewElement, 'icon-video')\n else\n page.updateTemplateIcon(file.previewElement, 'icon-doc-inv')\n\n if (response.expirydate) {\n const expiryDate = file.previewElement.querySelector('.expiry-date')\n expiryDate.innerHTML = `EXP: ${page.getPrettyDate(new Date(response.expirydate * 1000))}`\n expiryDate.classList.remove('is-hidden')\n }\n}\n\npage.createAlbum = () => {\n const div = document.createElement('div')\n div.innerHTML = `\n
    \n
    \n \n
    \n

    Max length is ${page.albumTitleMaxLength} characters.

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

    Max length is ${page.albumDescMaxLength} characters.

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

    ${help}

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

    \n \n

    \n

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

    \n `\n\n form.appendChild(submit)\n form.querySelector('#saveConfig').addEventListener('click', () => {\n if (!form.checkValidity())\n return\n\n const keys = Object.keys(config)\n .filter(key => config[key].display !== false && config[key].disabled !== true)\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i]\n\n let value\n if (config[key].select !== undefined) {\n if (form.elements[key].value !== 'default')\n value = form.elements[key].value\n } else if (config[key].number !== undefined) {\n const parsed = parseInt(form.elements[key].value)\n if (!isNaN(parsed))\n value = Math.min(Math.max(parsed, config[key].number.min), config[key].number.max)\n }\n\n if (value !== undefined && value !== fallback[key])\n localStorage[lsKeys[key]] = value\n else\n localStorage.removeItem(lsKeys[key])\n }\n\n swal({\n title: 'Woohoo!',\n text: 'Configuration saved into this browser.',\n icon: 'success'\n }).then(() => {\n location.reload()\n })\n })\n\n tabContent.appendChild(form)\n}\n\npage.getPrettyUploadAge = hours => {\n if (hours === 0) {\n return 'Permanent'\n } else if (hours < 1) {\n const minutes = hours * 60\n return `${minutes} minute${minutes === 1 ? '' : 's'}`\n } else if (hours >= 24) {\n const days = hours / 24\n return `${days} day${days === 1 ? '' : 's'}`\n } else {\n return `${hours} hour${hours === 1 ? '' : 's'}`\n }\n}\n\n// Handle image paste event\nwindow.addEventListener('paste', event => {\n const items = (event.clipboardData || event.originalEvent.clipboardData).items\n const index = Object.keys(items)\n for (let i = 0; i < index.length; i++) {\n const item = items[index[i]]\n if (item.kind === 'file') {\n const blob = item.getAsFile()\n /* eslint-disable-next-line compat/compat */\n const file = new File([blob], `pasted-image.${blob.type.match(/(?:[^/]*\\/)([^;]*)/)[1]}`, {\n type: blob.type\n })\n page.dropzone.addFile(file)\n }\n }\n})\n\nwindow.onload = () => {\n page.checkIfPublic()\n\n page.clipboardJS = new ClipboardJS('.clipboard-js')\n\n page.clipboardJS.on('success', () => {\n return swal('', 'The link has been copied to clipboard.', 'success', {\n buttons: false,\n timer: 1500\n })\n })\n\n page.clipboardJS.on('error', page.onError)\n\n page.lazyLoad = new LazyLoad({\n elements_selector: '.field.uploads img'\n })\n\n document.querySelector('#createAlbum').addEventListener('click', () => {\n page.createAlbum()\n })\n}\n"]} \ No newline at end of file +{"version":3,"sources":["home.js"],"names":["const","lsKeys","token","chunkSize","parallelUploads","uploadsHistoryOrder","previewImages","fileLength","uploadAge","stripTags","page","localStorage","private","enableUserAccounts","maxSize","temporaryUploadAges","fileIdentifierLength","stripTagsConfig","album","maxSizeBytes","urlMaxSize","urlMaxSizeBytes","tabs","activeTab","albumSelect","albumSelectOnChange","previewTemplate","dropzone","clipboardJS","lazyLoad","urlsQueue","activeUrlsQueue","imageExts","videoExts","albumTitleMaxLength","albumDescMaxLength","onInitError","error","document","querySelector","classList","add","querySelectorAll","forEach","element","uploadButton","innerText","remove","addEventListener","location","reload","response","onAxiosError","onError","console","content","createElement","innerHTML","toString","swal","title","icon","statusText","520","521","522","523","524","525","526","527","530","status","description","data","checkClientVersion","apiVersion","match","src","text","buttons","confirm","closeModal","then","checkIfPublic","let","renderShown","axios","get","onDownloadProgress","doRender","version","parseInt","preparePage","catch","prepareUpload","verifyToken","button","href","reloadOnError","post","success","removeItem","value","prepareShareX","fetchAlbums","prepareUploadConfig","getPrettyBytes","prepareDropzone","event","addUrlsToQueue","tabsContainer","loop","i","id","dataset","tabContent","setActiveTab","push","tab","length","index","headers","Array","isArray","albums","option","name","appendChild","previewNode","parentNode","removeChild","tabDiv","div","className","previewsContainer","Dropzone","body","url","paramName","clickable","maxFilesize","uploadMultiple","createImageThumbnails","autoProcessQueue","chunking","Boolean","parallelChunkUploads","timeout","init","this","on","file","previewElement","xhr","ontimeout","instances","getUploadingFiles","filter","instance","_handleUploadError","undefined","_uplSpeedCalc","lastSent","timestamp","Date","now","bytes","upload","chunked","setRequestHeader","chunks","progress","prettyBytesPerSec","total","Math","max","size","percentage","bytesSent","toFixed","upl","prefix","skipProgress","done","last","totalChunkCount","chunkIndex","elapsed","bytesPerSec","fullSec","splice","excessDuration","duration","files","updateTemplate","test","updateTemplateIcon","chunksUploaded","uuid","original","type","albumid","filelength","age","striptags","urls","split","trim","firstChild","processUrlsQueue","shiftQueue","initUrlUpload","finishedUrlUpload","shift","templateElement","iconClass","iconElement","link","a","clipboard","clipboardText","parentElement","exec","extname","toLowerCase","includes","img","setAttribute","onerror","currentTarget","update","expirydate","expiryDate","getPrettyDate","createAlbum","cancel","download","checked","public","selected","fallback","min","config","siBytes","label","select","help","valueHandler","display","number","round","disabled","force","default","video","isNaN","suffix","uploadFields","stored","parseFloat","String","getPrettyUploadAge","form","preventDefault","configKeys","Object","keys","key","conf","field","parsed","find","sel","control","opts","j","opt","join","tmp","submit","checkValidity","elements","hours","minutes","days","window","items","clipboardData","originalEvent","item","kind","blob","getAsFile","File","addFile","onload","ClipboardJS","timer","LazyLoad","elements_selector"],"mappings":"AAEAA,IAAMC,OAAS,CACbC,MAAO,QACPC,UAAW,YACXC,gBAAiB,kBACjBC,oBAAqB,sBACrBC,cAAe,gBACfC,WAAY,aACZC,UAAW,YACXC,UAAW,aAGPC,KAAO,CAEXR,MAAOS,aAAaV,OAAOC,OAG3BU,QAAS,KACTC,mBAAoB,KACpBC,QAAS,KACTX,UAAW,KACXY,oBAAqB,KACrBC,qBAAsB,KACtBC,gBAAiB,KAGjBC,MAAO,KAEPd,gBAAiB,EACjBE,cAAe,KACfC,WAAY,KACZC,UAAW,KAEXW,aAAc,KACdC,WAAY,KACZC,gBAAiB,KAEjBC,KAAM,GACNC,UAAW,KACXC,YAAa,KACbC,oBAAqB,KACrBC,gBAAiB,KAEjBC,SAAU,KACVC,YAAa,KACbC,SAAU,KAGVC,UAAW,GACXC,gBAAiB,EAIjBC,UAAW,CAAC,QAAS,OAAQ,QAAS,OAAQ,OAAQ,OAAQ,QAAS,OAAQ,QAC/EC,UAAW,CAAC,QAAS,OAAQ,OAAQ,OAAQ,OAAQ,OAAQ,OAAQ,SAErEC,oBAAqB,GACrBC,mBAAoB,IAItBC,YAAgB,SAAGC,GAEjBC,SAASC,c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GAAc,IAAVA,EACF,MAAO,YACF,GAAIA,EAAQ,EAAG,CACpB3R,IAAM4R,EAAkB,GAARD,EAChB,OAAUC,EAAO,WAAsB,IAAZA,EAAgB,GAAK,KAC3C,GAAID,GAAS,GAAI,CACtB3R,IAAM6R,EAAOF,EAAQ,GACrB,OAAUE,EAAI,QAAgB,IAATA,EAAa,GAAK,KAEvC,OAAUF,EAAK,SAAkB,IAAVA,EAAc,GAAK,MAK9CG,OAAO9O,iBAAiB,SAAO,SAAE6D,GAG/B,IAFA7G,IAAM+R,GAASlL,EAAMmL,eAAiBnL,EAAMoL,cAAcD,eAAeD,MACnEtK,EAAQiJ,OAAOC,KAAKoB,GACjB9K,EAAI,EAAGA,EAAIQ,EAAMD,OAAQP,IAAK,CACrCjH,IAAMkS,EAAOH,EAAMtK,EAAMR,IACzB,GAAkB,SAAdiL,EAAKC,KAAiB,CACxBnS,IAAMoS,EAAOF,EAAKG,YAEZ7I,EAAO,IAAI8I,KAAK,CAACF,GAAO,gBAAgBA,EAAK3F,KAAK5H,MAAM,sBAAsB,GAAM,CACxF4H,KAAM2F,EAAK3F,OAEb/L,KAAKiB,SAAS4Q,QAAQ/I,QAK5BsI,OAAOU,OAAM,WACX9R,KAAK0E,gBAEL1E,KAAKkB,YAAc,IAAI6Q,YAAY,iBAEnC/R,KAAKkB,YAAY2H,GAAG,WAAS,WAC3B,OAAO5F,KAAK,GAAI,yCAA0C,UAAW,CACnEqB,SAAS,EACT0N,MAAO,UAIXhS,KAAKkB,YAAY2H,GAAG,QAAS7I,KAAK2C,SAElC3C,KAAKmB,SAAW,IAAI8Q,SAAS,CAC3BC,kBAAmB,uBAGrBtQ,SAASC,cAAc,gBAAgBS,iBAAiB,SAAO,WAC7DtC,KAAKiO","file":"home.js","sourcesContent":["/* global swal, axios, Dropzone, ClipboardJS, LazyLoad */\n\nconst lsKeys = {\n token: 'token',\n chunkSize: 'chunkSize',\n parallelUploads: 'parallelUploads',\n uploadsHistoryOrder: 'uploadsHistoryOrder',\n previewImages: 'previewImages',\n fileLength: 'fileLength',\n uploadAge: 'uploadAge',\n stripTags: 'stripTags'\n}\n\nconst page = {\n // user token\n token: localStorage[lsKeys.token],\n\n // configs from api/check\n private: null,\n enableUserAccounts: null,\n maxSize: null,\n chunkSize: null,\n temporaryUploadAges: null,\n fileIdentifierLength: null,\n stripTagsConfig: null,\n\n // store album id that will be used with upload requests\n album: null,\n\n parallelUploads: 2,\n previewImages: null,\n fileLength: null,\n uploadAge: null,\n\n maxSizeBytes: null,\n urlMaxSize: null,\n urlMaxSizeBytes: null,\n\n tabs: [],\n activeTab: null,\n albumSelect: null,\n albumSelectOnChange: null,\n previewTemplate: null,\n\n dropzone: null,\n clipboardJS: null,\n lazyLoad: null,\n\n // additional vars for url uploads\n urlsQueue: [],\n activeUrlsQueue: 0,\n\n // Include BMP for uploads preview only, cause the real images will be used\n // Sharp isn't capable of making their thumbnails for dashboard and album public pages\n imageExts: ['.webp', '.jpg', '.jpeg', '.bmp', '.gif', '.png', '.tiff', '.tif', '.svg'],\n videoExts: ['.webm', '.mp4', '.wmv', '.avi', '.mov', '.mkv', '.m4v', '.m2ts'],\n\n albumTitleMaxLength: 70,\n albumDescMaxLength: 4000\n}\n\n// Handler for errors during initialization\npage.onInitError = error => {\n // Hide these elements\n document.querySelector('#albumDiv').classList.add('is-hidden')\n document.querySelector('#tabs').classList.add('is-hidden')\n document.querySelectorAll('.tab-content').forEach(element => {\n return element.classList.add('is-hidden')\n })\n\n // Update upload button\n const uploadButton = document.querySelector('#loginToUpload')\n uploadButton.innerText = 'An error occurred. Try to reload?'\n uploadButton.classList.remove('is-loading')\n uploadButton.classList.remove('is-hidden')\n\n uploadButton.addEventListener('click', () => {\n location.reload()\n })\n\n if (error.response)\n page.onAxiosError(error)\n else\n page.onError(error)\n}\n\n// Handler for regular JS errors\npage.onError = error => {\n console.error(error)\n\n const content = document.createElement('div')\n content.innerHTML = `${error.toString()}`\n return swal({\n title: 'An error occurred!',\n icon: 'error',\n content\n })\n}\n\n// Handler for Axios errors\npage.onAxiosError = error => {\n console.error(error)\n\n // Better Cloudflare errors\n const cloudflareErrors = {\n 520: 'Unknown Error',\n 521: 'Web Server Is Down',\n 522: 'Connection Timed Out',\n 523: 'Origin Is Unreachable',\n 524: 'A Timeout Occurred',\n 525: 'SSL Handshake Failed',\n 526: 'Invalid SSL Certificate',\n 527: 'Railgun Error',\n 530: 'Origin DNS Error'\n }\n\n const statusText = cloudflareErrors[error.response.status] || error.response.statusText\n const description = error.response.data && error.response.data.description\n ? error.response.data.description\n : 'There was an error with the request, please check the console for more information.'\n\n return swal(`${error.response.status} ${statusText}`, description, 'error')\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: 'Updated 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 location.reload()\n })\n}\n\npage.checkIfPublic = () => {\n let renderShown = false\n return axios.get('api/check', {\n onDownloadProgress: () => {\n // Only show render after this request has been initiated to avoid blocking\n if (!renderShown && typeof page.doRender === 'function') {\n page.doRender()\n renderShown = true\n }\n }\n }).then(response => {\n if (response.data.version)\n page.checkClientVersion(response.data.version)\n\n page.private = response.data.private\n page.enableUserAccounts = response.data.enableUserAccounts\n page.maxSize = parseInt(response.data.maxSize)\n page.maxSizeBytes = page.maxSize * 1e6\n page.chunkSize = parseInt(response.data.chunkSize)\n page.temporaryUploadAges = response.data.temporaryUploadAges\n page.fileIdentifierLength = response.data.fileIdentifierLength\n page.stripTagsConfig = response.data.stripTags\n\n return page.preparePage()\n }).catch(page.onInitError)\n}\n\npage.preparePage = () => {\n if (page.private)\n if (page.token) {\n return page.verifyToken(page.token, true)\n } else {\n const button = document.querySelector('#loginToUpload')\n button.href = 'auth'\n button.classList.remove('is-loading')\n if (page.enableUserAccounts)\n button.innerText = 'Anonymous upload is disabled. Log in to upload.'\n else\n button.innerText = 'Running in private mode. Log in to upload.'\n }\n else\n return page.prepareUpload()\n}\n\npage.verifyToken = (token, reloadOnError) => {\n return axios.post('api/tokens/verify', { token }).then(response => {\n if (response.data.success === false)\n return swal({\n title: 'An error occurred!',\n text: response.data.description,\n icon: 'error'\n }).then(() => {\n if (!reloadOnError) return\n localStorage.removeItem('token')\n location.reload()\n })\n\n localStorage[lsKeys.token] = token\n page.token = token\n return page.prepareUpload()\n }).catch(page.onInitError)\n}\n\npage.prepareUpload = () => {\n // I think this fits best here because we need to check for a valid token before we can get the albums\n if (page.token) {\n // 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')\n page.prepareShareX()\n }\n page.albumSelect.addEventListener('change', page.albumSelectOnChange)\n\n // Fetch albums\n page.fetchAlbums()\n }\n\n // Prepare & generate config tab\n page.prepareUploadConfig()\n\n // Update elements wherever applicable\n document.querySelector('#maxSize > span').innerHTML = page.getPrettyBytes(page.maxSizeBytes)\n document.querySelector('#loginToUpload').classList.add('is-hidden')\n\n if (!page.token && page.enableUserAccounts)\n document.querySelector('#loginLinkText').innerHTML = 'Create an account and keep track of your uploads'\n\n // Prepare & generate files upload tab\n page.prepareDropzone()\n\n // Generate ShareX config file\n if (typeof page.prepareShareX === 'function')\n 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 document.querySelector('#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\npage.fetchAlbums = () => {\n return axios.get('api/albums', { headers: { token: page.token } }).then(response => {\n if (response.data.success === false)\n return swal('An error occurred!', response.data.description, 'error')\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 }).catch(page.onInitError)\n}\n\npage.prepareDropzone = () => {\n // Parse template element\n const previewNode = document.querySelector('#tpl')\n page.previewTemplate = previewNode.innerHTML\n previewNode.parentNode.removeChild(previewNode)\n\n // Generate files upload tab\n const tabDiv = document.querySelector('#tab-files')\n const div = document.createElement('div')\n div.className = 'control is-expanded'\n div.innerHTML = `\n
    \n \n \n \n Click here or drag & drop files\n
    \n `\n tabDiv.querySelector('.dz-container').appendChild(div)\n\n const previewsContainer = tabDiv.querySelector('#tab-files .field.uploads')\n\n page.dropzone = new Dropzone(document.body, {\n url: 'api/upload',\n paramName: 'files[]',\n clickable: tabDiv.querySelector('#dropzone'),\n maxFilesize: page.maxSizeBytes / 1024 / 1024, // this option expects MiB\n parallelUploads: page.parallelUploads,\n uploadMultiple: false,\n previewsContainer,\n previewTemplate: page.previewTemplate,\n createImageThumbnails: false,\n autoProcessQueue: true,\n headers: { token: page.token },\n chunking: Boolean(page.chunkSize),\n chunkSize: page.chunkSize * 1e6, // this option expects Bytes\n parallelChunkUploads: false, // for now, enabling this breaks descriptive upload progress\n timeout: 0,\n\n init () {\n this.on('addedfile', file => {\n // Set active tab to file uploads, if necessary\n if (page.activeTab !== 0)\n page.setActiveTab(0)\n\n // Add file entry\n tabDiv.querySelector('.uploads').classList.remove('is-hidden')\n\n file.previewElement.querySelector('.name').innerHTML = file.name\n file.previewElement.querySelector('.descriptive-progress').innerHTML = 'Waiting in queue\\u2026'\n })\n\n this.on('sending', (file, xhr) => {\n // Add timeout listener (hacky method due to lack of built-in timeout handler)\n if (!xhr.ontimeout)\n xhr.ontimeout = () => {\n const instances = page.dropzone.getUploadingFiles()\n .filter(instance => instance.xhr === xhr)\n page.dropzone._handleUploadError(instances, xhr, 'Connection timed out. Try to reduce upload chunk size.')\n }\n\n // Attach necessary data for initial upload speed calculation\n if (xhr._uplSpeedCalc === undefined)\n xhr._uplSpeedCalc = {\n lastSent: 0,\n data: [{ timestamp: Date.now(), bytes: 0 }]\n }\n\n // If not chunked uploads, add extra headers\n if (!file.upload.chunked) {\n if (page.album !== null) xhr.setRequestHeader('albumid', page.album)\n if (page.fileLength !== null) xhr.setRequestHeader('filelength', page.fileLength)\n if (page.uploadAge !== null) xhr.setRequestHeader('age', page.uploadAge)\n if (page.stripTags !== null) xhr.setRequestHeader('striptags', page.stripTags)\n }\n\n if (!file.upload.chunked)\n file.previewElement.querySelector('.descriptive-progress').innerHTML = 'Uploading\\u2026'\n else if (file.upload.chunks.length === 1)\n file.previewElement.querySelector('.descriptive-progress').innerHTML = `Uploading chunk 1/${file.upload.totalChunkCount}\\u2026`\n })\n\n // Update descriptive progress\n this.on('uploadprogress', (file, progress) => {\n // Total bytes will eventually be bigger than file size when chunked\n const total = Math.max(file.size, file.upload.total)\n const percentage = (file.upload.bytesSent / total * 100).toFixed(0)\n\n const upl = file.upload.chunked\n ? file.upload.chunks[file.upload.chunks.length - 1]\n : file.upload\n const xhr = upl.xhr || file.xhr\n\n let prefix = 'Uploading\\u2026'\n let skipProgress = false\n if (file.upload.chunked) {\n const done = upl.bytesSent === upl.total\n const last = file.upload.chunks.length === file.upload.totalChunkCount\n let chunkIndex = file.upload.chunks.length\n if (done && !last) {\n chunkIndex++\n skipProgress = true\n }\n prefix = `Uploading chunk ${chunkIndex}/${file.upload.totalChunkCount}\\u2026`\n }\n\n // Real-time upload speed calculation\n let prettyBytesPerSec\n if (!skipProgress) {\n const now = Date.now()\n const bytesSent = upl.bytesSent - xhr._uplSpeedCalc.lastSent\n\n // Push data of current iteration\n xhr._uplSpeedCalc.lastSent = upl.bytesSent\n xhr._uplSpeedCalc.data.push({ timestamp: now, bytes: bytesSent })\n\n // Wait till at least the 2nd iteration (3 data including initial data)\n const length = xhr._uplSpeedCalc.data.length\n if (length > 2) {\n // Calculate using data from all iterations\n let elapsed = 0\n let bytesPerSec = 0\n let fullSec = false\n let i = length - 1 // Always start with 2nd from last item\n while (i--) {\n // Splice data of unrequired iterations\n if (fullSec) {\n xhr._uplSpeedCalc.data.splice(i, 1)\n continue\n }\n // Sum data\n elapsed = now - xhr._uplSpeedCalc.data[i].timestamp\n if (elapsed > 1000) {\n const excessDuration = elapsed - 1000\n const newerIterationElapsed = now - xhr._uplSpeedCalc.data[i + 1].timestamp\n const duration = elapsed - newerIterationElapsed\n const fragment = (duration - excessDuration) / duration * xhr._uplSpeedCalc.data[i + 1].bytes\n bytesPerSec += fragment\n fullSec = true\n } else {\n bytesPerSec += xhr._uplSpeedCalc.data[i + 1].bytes\n }\n }\n\n // If not enough data\n if (!fullSec)\n bytesPerSec = 1000 / elapsed * bytesPerSec\n\n // Get pretty bytes\n prettyBytesPerSec = page.getPrettyBytes(bytesPerSec)\n }\n }\n\n file.previewElement.querySelector('.descriptive-progress').innerHTML =\n `${prefix} ${percentage}%${prettyBytesPerSec ? ` at ${prettyBytesPerSec}/s` : ''}`\n })\n\n this.on('success', (file, data) => {\n if (!data) return\n file.previewElement.querySelector('.descriptive-progress').classList.add('is-hidden')\n\n if (data.success === false) {\n file.previewElement.querySelector('.error').innerHTML = data.description\n file.previewElement.querySelector('.error').classList.remove('is-hidden')\n }\n\n if (Array.isArray(data.files) && data.files[0])\n page.updateTemplate(file, data.files[0])\n })\n\n this.on('error', (file, error) => {\n // Clean up file size errors\n if ((typeof error === 'string' && /^File is too big/.test(error)) ||\n (typeof error === 'object' && /File too large/.test(error.description)))\n error = `File too large (${page.getPrettyBytes(file.size)}).`\n\n page.updateTemplateIcon(file.previewElement, 'icon-block')\n\n file.previewElement.querySelector('.descriptive-progress').classList.add('is-hidden')\n\n file.previewElement.querySelector('.error').innerHTML = error.description || error\n file.previewElement.querySelector('.error').classList.remove('is-hidden')\n })\n },\n\n chunksUploaded (file, done) {\n file.previewElement.querySelector('.descriptive-progress').innerHTML =\n `Rebuilding ${file.upload.totalChunkCount} chunks\\u2026`\n\n return axios.post('api/upload/finishchunks', {\n // This API supports an array of multiple files\n files: [{\n uuid: file.upload.uuid,\n original: file.name,\n type: file.type,\n albumid: page.album,\n filelength: page.fileLength,\n age: page.uploadAge\n }]\n }, {\n headers: {\n token: page.token,\n // Unlike the options above (e.g. albumid, filelength, etc.),\n // strip tags cannot yet be configured per file with this API\n striptags: page.stripTags\n }\n }).catch(error => {\n // Format error for display purpose\n return error.response.data ? error.response : {\n data: {\n success: false,\n description: error.toString()\n }\n }\n }).then(response => {\n file.previewElement.querySelector('.descriptive-progress').classList.add('is-hidden')\n\n if (response.data.success === false) {\n file.previewElement.querySelector('.error').innerHTML = response.data.description\n file.previewElement.querySelector('.error').classList.remove('is-hidden')\n }\n\n if (response.data.files && response.data.files[0])\n page.updateTemplate(file, response.data.files[0])\n\n return done()\n })\n }\n })\n}\n\npage.addUrlsToQueue = () => {\n const urls = document.querySelector('#urls').value\n .split(/\\r?\\n/)\n .filter(url => {\n return url.trim().length\n })\n\n if (!urls.length)\n return swal('An error occurred!', 'You have not entered any URLs.', 'error')\n\n const tabDiv = document.querySelector('#tab-urls')\n tabDiv.querySelector('.uploads').classList.remove('is-hidden')\n\n for (let i = 0; i < urls.length; i++) {\n const previewTemplate = document.createElement('template')\n previewTemplate.innerHTML = page.previewTemplate.trim()\n\n const previewElement = previewTemplate.content.firstChild\n previewElement.querySelector('.name').innerHTML = urls[i]\n previewElement.querySelector('.descriptive-progress').innerHTML = 'Waiting in queue\\u2026'\n\n const previewsContainer = tabDiv.querySelector('.uploads')\n previewsContainer.appendChild(previewElement)\n\n page.urlsQueue.push({\n url: urls[i],\n previewElement\n })\n }\n\n page.processUrlsQueue()\n document.querySelector('#urls').value = ''\n}\n\npage.processUrlsQueue = () => {\n if (!page.urlsQueue.length) return\n\n function finishedUrlUpload (file, data) {\n file.previewElement.querySelector('.descriptive-progress').classList.add('is-hidden')\n\n if (data.success === false) {\n const match = data.description.match(/ over limit: (\\d+)$/)\n if (match && match[1])\n data.description = `File exceeded limit of ${page.getPrettyBytes(match[1])}.`\n\n file.previewElement.querySelector('.error').innerHTML = data.description\n file.previewElement.querySelector('.error').classList.remove('is-hidden')\n }\n\n if (Array.isArray(data.files) && data.files[0])\n page.updateTemplate(file, data.files[0])\n\n page.activeUrlsQueue--\n return shiftQueue()\n }\n\n function initUrlUpload (file) {\n file.previewElement.querySelector('.descriptive-progress').innerHTML =\n 'Waiting for server to fetch URL\\u2026'\n\n return axios.post('api/upload', {\n urls: [file.url]\n }, {\n headers: {\n token: page.token,\n albumid: page.album,\n age: page.uploadAge,\n filelength: page.fileLength\n }\n }).catch(error => {\n // Format error for display purpose\n return error.response.data ? error.response : {\n data: {\n success: false,\n description: error.toString()\n }\n }\n }).then(response => {\n return finishedUrlUpload(file, response.data)\n })\n }\n\n function shiftQueue () {\n while (page.urlsQueue.length && (page.activeUrlsQueue < page.parallelUploads)) {\n page.activeUrlsQueue++\n initUrlUpload(page.urlsQueue.shift())\n }\n }\n\n return shiftQueue()\n}\n\npage.updateTemplateIcon = (templateElement, iconClass) => {\n const iconElement = templateElement.querySelector('.icon')\n if (!iconElement) return\n\n iconElement.classList.add(iconClass)\n iconElement.classList.remove('is-hidden')\n}\n\npage.updateTemplate = (file, response) => {\n if (!response.url) return\n\n const link = file.previewElement.querySelector('.link')\n const a = link.querySelector('a')\n const clipboard = file.previewElement.querySelector('.clipboard-mobile > .clipboard-js')\n a.href = a.innerHTML = clipboard.dataset.clipboardText = response.url\n\n link.classList.remove('is-hidden')\n clipboard.parentElement.classList.remove('is-hidden')\n\n const exec = /.[\\w]+(\\?|$)/.exec(response.url)\n const extname = exec && exec[0]\n ? exec[0].toLowerCase()\n : null\n\n if (page.imageExts.includes(extname))\n if (page.previewImages) {\n const img = file.previewElement.querySelector('img')\n img.setAttribute('alt', response.name || '')\n img.dataset.src = response.url\n img.classList.remove('is-hidden')\n img.onerror = event => {\n // Hide image elements that fail to load\n // Consequently include WEBP in browsers that do not have WEBP support (e.g. IE)\n event.currentTarget.classList.add('is-hidden')\n page.updateTemplateIcon(file.previewElement, 'icon-picture')\n }\n page.lazyLoad.update(file.previewElement.querySelectorAll('img'))\n } else {\n page.updateTemplateIcon(file.previewElement, 'icon-picture')\n }\n else if (page.videoExts.includes(extname))\n page.updateTemplateIcon(file.previewElement, 'icon-video')\n else\n page.updateTemplateIcon(file.previewElement, 'icon-doc-inv')\n\n if (response.expirydate) {\n const expiryDate = file.previewElement.querySelector('.expiry-date')\n expiryDate.innerHTML = `EXP: ${page.getPrettyDate(new Date(response.expirydate * 1000))}`\n expiryDate.classList.remove('is-hidden')\n }\n}\n\npage.createAlbum = () => {\n const div = document.createElement('div')\n div.innerHTML = `\n
    \n
    \n \n
    \n

    Max length is ${page.albumTitleMaxLength} characters.

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

    Max length is ${page.albumDescMaxLength} characters.

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

    ${help}

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

    \n \n

    \n

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

    \n `\n\n form.appendChild(submit)\n form.querySelector('#saveConfig').addEventListener('click', () => {\n if (!form.checkValidity())\n return\n\n const keys = Object.keys(config)\n .filter(key => config[key].display !== false && config[key].disabled !== true)\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i]\n\n let value\n if (config[key].select !== undefined) {\n if (form.elements[key].value !== 'default')\n value = form.elements[key].value\n } else if (config[key].number !== undefined) {\n const parsed = parseInt(form.elements[key].value)\n if (!isNaN(parsed))\n value = Math.min(Math.max(parsed, config[key].number.min), config[key].number.max)\n }\n\n if (value !== undefined && value !== fallback[key])\n localStorage[lsKeys[key]] = value\n else\n localStorage.removeItem(lsKeys[key])\n }\n\n swal({\n title: 'Woohoo!',\n text: 'Configuration saved into this browser.',\n icon: 'success'\n }).then(() => {\n location.reload()\n })\n })\n\n tabContent.appendChild(form)\n}\n\npage.getPrettyUploadAge = hours => {\n if (hours === 0) {\n return 'Permanent'\n } else if (hours < 1) {\n const minutes = hours * 60\n return `${minutes} minute${minutes === 1 ? '' : 's'}`\n } else if (hours >= 24) {\n const days = hours / 24\n return `${days} day${days === 1 ? '' : 's'}`\n } else {\n return `${hours} hour${hours === 1 ? '' : 's'}`\n }\n}\n\n// Handle image paste event\nwindow.addEventListener('paste', event => {\n const items = (event.clipboardData || event.originalEvent.clipboardData).items\n const index = Object.keys(items)\n for (let i = 0; i < index.length; i++) {\n const item = items[index[i]]\n if (item.kind === 'file') {\n const blob = item.getAsFile()\n /* eslint-disable-next-line compat/compat */\n const file = new File([blob], `pasted-image.${blob.type.match(/(?:[^/]*\\/)([^;]*)/)[1]}`, {\n type: blob.type\n })\n page.dropzone.addFile(file)\n }\n }\n})\n\nwindow.onload = () => {\n page.checkIfPublic()\n\n page.clipboardJS = new ClipboardJS('.clipboard-js')\n\n page.clipboardJS.on('success', () => {\n return swal('', 'The link has been copied to clipboard.', 'success', {\n buttons: false,\n timer: 1500\n })\n })\n\n page.clipboardJS.on('error', page.onError)\n\n page.lazyLoad = new LazyLoad({\n elements_selector: '.field.uploads img'\n })\n\n document.querySelector('#createAlbum').addEventListener('click', () => {\n page.createAlbum()\n })\n}\n"]} \ No newline at end of file diff --git a/src/js/dashboard.js b/src/js/dashboard.js index 248c77d..68b7fee 100644 --- a/src/js/dashboard.js +++ b/src/js/dashboard.js @@ -457,8 +457,8 @@ page.getUploads = (params = {}) => { if (params === undefined) params = {} - if ((params.all || params.filters) && !page.permissions.moderator) - return swal('An error occurred!', 'You can not do this!', 'error') + if (params.all && !page.permissions.moderator) + return swal('An error occurred!', 'You cannot do this!', 'error') page.updateTrigger(params.trigger, 'loading') @@ -474,9 +474,9 @@ page.getUploads = (params = {}) => { filters: params.filters || '' } - // Send client timezone offset if using date filter + // Send client timezone offset if using filters // Server will pretend client is on UTC if missing - if (headers.filters.includes('date:') || headers.filters.includes('expiry:')) + if (headers.filters) headers.minOffset = new Date().getTimezoneOffset() axios.get(url, { headers }).then(response => { @@ -507,33 +507,31 @@ page.getUploads = (params = {}) => { const basedomain = response.data.basedomain const pagination = page.paginate(response.data.count, 25, params.pageNum) - let filter = '
    ' - if (params.all) - filter = ` -
    -
    -
    -
    - -
    -
    - -
    -
    - -
    + const filter = ` +
    + +
    +
    +
    - -
    - ` +
    + +
    +
    + +
    +
    + +
    + ` const extraControls = `
    ${filter} @@ -1012,9 +1010,10 @@ page.clearSelection = () => { } page.uploadFiltersHelp = element => { + const all = Boolean(element.dataset.all) const content = document.createElement('div') content.style = 'text-align: left' - content.innerHTML = ` + content.innerHTML = `${all ? ` There are 2 filter keys, namely user (username) and ip. These keys can be specified more than once. For usernames with whitespaces, wrap them with double quotes ("). @@ -1022,10 +1021,12 @@ page.uploadFiltersHelp = element => { To exclude certain users/ips while still listing every other uploads, add negation sign (-) before the keys. Negation sign can also be used to exclude the special cases mentioned above (i.e. -user:- or -ip:-). - + ` : ''} There are 2 range keys: date (upload date) and expiry (expiry date). Their format is: YYYY/MM/DD HH:MM:SS-YYYY/MM/DD HH:MM:SS ("from" date and "to" date respectively). - You can specify only one date. If "to" date is missing, 'now' will be used. If "from" date is missing, 'beginning of time' will be used. + You may specify only one of the dates. + If "to" date is missing, 'now' will be used. + If "from" date is missing, 'beginning of time' will be used. 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). If only time is specified, today's date will be used. 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. @@ -1036,41 +1037,44 @@ page.uploadFiltersHelp = element => { Matches can also be sorted with sort keys. Its format is: sort:columnName[:d[escending]], where :d[escending] is an optional tag to set the direction to descending. - This key must be used with internal column names used in the database (id, userid, and so on), + This key must be used with internal column names used in the database (id, ${all ? 'userid' : 'albumid'}, and so on), but there are 2 shortcuts available: date for timestamp column and expiry for expirydate column. This key can also be specified more than once, where their order will decide the sorting steps. Any leftover keywords which do not use keys (non-keyed keywords) will be matched against the matches' file names. Excluding certain keywords is also supported by adding negation sign (-) before the keywords. - Internals: - First, query uploads passing ALL exclusion filter keys OR matching ANY filter keys, if any. - Second, refine matches using range keys, if any. - Third, refine matches using ANY non-keyed keywords, if any. - Fourth, filter matches using ALL exclusion non-keyed keywords, if any. - Fifth, sort matches using sorting keys, if any. + Internal steps: + ${all ? `- Query uploads passing ALL exclusion filter keys OR matching ANY filter keys, if any. + - Refine matches` : '- Filter uploads'} using date key, if any. + - Refine matches using expiry key, if any. + - Refine matches using ANY non-keyed keywords, if any. + - Filter matches using ALL exclusion non-keyed keywords, if any. + - Sort matches using sorting keys, if any. Examples: - Uploads from users named "demo" AND/OR "John Doe" AND/OR non-registered users: + ${all ? `- Uploads from users named "demo" AND/OR "John Doe" AND/OR non-registered users: user:demo user:"John Doe" user:- - ALL uploads, but NOT the ones from user named "demo" AND "John Doe": + - ALL uploads, but NOT the ones from user named "demo" AND "John Doe": -user:demo -user:"John Doe" - Uploads from IP "127.0.0.1" AND which file names match "*.rar" OR "*.zip": + - Uploads from IP "127.0.0.1" AND which file names match "*.rar" OR "*.zip": ip:127.0.0.1 *.rar *.zip - Uploads uploaded since "1 June 2019 00:00:00": + ` : ''}- Uploads uploaded since "1 June 2019 00:00:00": date:2019/06 - Uploads uploaded between "7 April 2020 12:00:00" and "7 April 2020 23:59:59": + - Uploads uploaded between "7 April 2020 12:00:00" and "7 April 2020 23:59:59": date:2020/04/07 12-2020/04/07 23:59:59 - Uploads uploaded before "5 February 2020 00:00:00": + - Uploads uploaded before "5 February 2020 00:00:00": date:-2020/02/05 - Uploads which file names match "*.gz" but NOT "*.tar.gz": + - Uploads which file names match "*.gz" but NOT "*.tar.gz": *.gz -*.tar.gz - Sort matches by "size" column in ascending and descending order respectively: - user:"John Doe" sort:size - *.mp4 user:- sort:size:d - + - Sort matches by "size" column in ascending and descending order respectively: + ${all ? 'user:"John Doe"' : '*.txt'} sort:size + *.mp4 ${all ? 'user:- ' : ''}sort:size:d + ${!page.permissions.moderator ? ` + Notice: Regular users may face some limitations in the amount of keys that can be used at a time. + ` : ''} Friendly reminder: This window can be scrolled up! - `.trim().replace(/^ {6}/gm, '').replace(/\n/g, '
    ') + `.trim().replace(/^\s*/g, '').replace(/\n/g, '
    ') swal({ content }).then(() => { // Restore modal size @@ -1083,7 +1087,11 @@ page.uploadFiltersHelp = element => { page.filterUploads = element => { const filters = document.querySelector(`#${element.dataset.filtersid || 'filters'}`).value.trim() - page.getUploads({ all: true, filters }, element) + // eslint-disable-next-line compat/compat + page.getUploads(Object.assign(page.views[page.currentView], { + filters, + pageNum: 0 + }), element) } page.viewUserUploads = (id, element) => { @@ -1879,7 +1887,7 @@ page.getUsers = (params = {}) => { params.pageNum = 0 if (!page.permissions.admin) - return swal('An error occurred!', 'You can not do this!', 'error') + return swal('An error occurred!', 'You cannot do this!', 'error') const url = `api/users/${params.pageNum}` axios.get(url).then(response => { @@ -2170,7 +2178,7 @@ page.createUser = () => { content: div }) - // Reload users list + // Load last page of users list // eslint-disable-next-line compat/compat page.getUsers(Object.assign(page.views.users, { pageNum: -1 @@ -2449,7 +2457,7 @@ page.paginate = (totalItems, itemsPerPage, currentPage) => { page.getStatistics = (params = {}) => { if (!page.permissions.admin) - return swal('An error occurred!', 'You can not do this!', 'error') + return swal('An error occurred!', 'You cannot do this!', 'error') page.updateTrigger(params.trigger, 'loading') diff --git a/src/js/home.js b/src/js/home.js index 216af7b..efd00a7 100644 --- a/src/js/home.js +++ b/src/js/home.js @@ -504,7 +504,7 @@ page.prepareDropzone = () => { headers: { token: page.token, // Unlike the options above (e.g. albumid, filelength, etc.), - // strip tags can not yet be configured per file with this API + // strip tags cannot yet be configured per file with this API striptags: page.stripTags } }).catch(error => { diff --git a/src/versions.json b/src/versions.json index b8349a9..210e94e 100644 --- a/src/versions.json +++ b/src/versions.json @@ -1,5 +1,5 @@ { - "1": "1588434390", + "1": "1588448172", "2": "1581416390", "3": "1581416390", "4": "1581416390",