filesafe/dist/js/dashboard.js
Bobby Wibowo 24ed7c48bb
Updated dashboard.js
Bumped v1 version string
2020-07-19 18:26:44 +07:00

3 lines
74 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

var lsKeys={token:"token",viewType:{uploads:"viewTypeUploads",uploadsAll:"viewTypeUploadsAll"},selected:{uploads:"selectedUploads",uploadsAll:"selectedUploadsAll",albums:"selectedAlbums",albumsAll:"selectedAlbumsAll",users:"selectedUsers"},originalNames:{uploads:"originalNames",uploadsAll:"originalNamesAll"}},page={section:null,dom:null,token:localStorage[lsKeys.token],username:null,permissions:null,menusContainer:null,menus:[],currentView:null,views:{uploads:{type:localStorage[lsKeys.viewType.uploads],originalNames:"1"===localStorage[lsKeys.originalNames.uploads],album:null,pageNum:null},uploadsAll:{type:localStorage[lsKeys.viewType.uploadsAll],originalNames:"1"===localStorage[lsKeys.originalNames.uploadsAll],filters:null,pageNum:null,all:!0},albums:{filters:null,pageNum:null},albumsAll:{filters:null,pageNum:null,all:!0},users:{filters:null,pageNum:null}},selected:{uploads:[],uploadsAll:[],albums:[],albumsAll:[],users:[]},checkboxes:[],lastSelected:[],selectAlbumContainer:null,cache:{},clipboardJS:null,lazyLoad:null,imageExts:[".webp",".jpg",".jpeg",".gif",".png",".tiff",".tif",".svg"],videoExts:[".webm",".mp4",".wmv",".avi",".mov",".mkv",".m4v",".m2ts"],isSomethingLoading:!1,fadingIn:null,albumTitleMaxLength:70,albumDescMaxLength:4e3,unhide:function(){document.querySelector("#loader").classList.add("is-hidden"),page.section.classList.remove("is-hidden")},onError:function(e){console.error(e);var a=document.createElement("div");return a.innerHTML="<code>"+e.toString()+"</code>",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(){window.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.section=document.querySelector("#dashboard"),page.dom=page.section.querySelector("#page"),page.dom.addEventListener("click",page.domClick,!0),page.dom.addEventListener("submit",(function(e){if(e.target&&e.target.classList.contains("prevent-default"))return e.preventDefault()}),!0),page.menusContainer=document.querySelector("#menu");for(var e=[{selector:"#itemUploads",onclick:page.getUploads},{selector:"#itemDeleteUploadsByNames",onclick:page.deleteUploadsByNames},{selector:"#itemManageYourAlbums",onclick:page.getAlbums},{selector:"#itemManageToken",onclick:page.changeToken},{selector:"#itemChangePassword",onclick:page.changePassword},{selector:"#itemLogout",onclick:page.logout},{selector:"#itemManageUploads",onclick:page.getUploads,params:{all:!0},group:"moderator"},{selector:"#itemManageAlbums",onclick:page.getAlbums,params:{all:!0},group:"moderator"},{selector:"#itemStatistics",onclick:page.getStatistics,group:"admin"},{selector:"#itemManageUsers",onclick:page.getUsers,group:"admin"}],a=function(a){if(!e[a].group||page.permissions[e[a].group]){var n=document.querySelector(e[a].selector);n.addEventListener("click",(function(n){if(page.isSomethingLoading)return page.warnSomethingLoading();e[a].onclick.call(null,Object.assign(e[a].params||{},{trigger:n.currentTarget}))})),n.classList.remove("is-hidden"),page.menus.push(n)}},n=0;n<e.length;n++)a(n);page.permissions.moderator&&(document.querySelector("#itemLabelAdmin").classList.remove("is-hidden"),document.querySelector("#itemListAdmin").classList.remove("is-hidden")),document.querySelector("#itemLogout").innerHTML="Logout ( "+page.username+" )",page.unhide(),page.getAlbumsSidebar(),"function"==typeof page.prepareShareX&&page.prepareShareX()},logout:function(e){page.updateTrigger(e.trigger,"active"),localStorage.removeItem(lsKeys.token),window.location="auth"},warnSomethingLoading:function(){swal("Please wait!","Something else is still loading…","warning",{buttons:!1,timer:3e3})},updateTrigger:function(e,a){if(e)if("loading"===a?(page.isSomethingLoading=!0,page.section.classList.add("is-loading")):(page.section.classList.remove("is-loading"),page.isSomethingLoading=!1),"loading"===a)e.classList.add("is-loading");else if("active"===a){if("LI"!==e.parentNode.tagName)return;for(var n=0;n<page.menus.length;n++)page.menus[n].classList.remove("is-active");e.classList.remove("is-loading"),e.classList.add("is-active")}else e.classList.remove("is-loading"),e.classList.remove("is-active")},getItemID:function(e){var a=e.parentNode;return e.parentNode.classList.contains("controls")&&(a=a.parentNode),parseInt(a.dataset.id)},domClick:function(e){var a=e.target;if(a&&(["I"].includes(a.tagName)&&["SPAN"].includes(a.parentNode.tagName)&&(a=a.parentNode),["SPAN"].includes(a.tagName)&&["A","BUTTON"].includes(a.parentNode.tagName)&&(a=a.parentNode),a.dataset&&a.dataset.action&&!a.hasAttribute("disabled"))){e.stopPropagation();var n=page.getItemID(a),t=a.dataset.action;switch(t){case"view-list":return page.setUploadsView("list",a);case"view-thumbs":return page.setUploadsView("thumbs",a);case"toggle-original-names":return page.toggleOriginalNames(a);case"add-to-album":return page.addToAlbum(n);case"delete-upload":return page.deleteUpload(n);case"add-selected-uploads-to-album":return page.addSelectedUploadsToAlbum();case"bulk-delete-uploads":return page.bulkDeleteUploads();case"display-preview":return page.displayPreview(n);case"upload-filters-help":return page.uploadFiltersHelp(a);case"filter-uploads":return page.filterUploads(a);case"submit-album":return page.submitAlbum(a);case"edit-album":return page.editAlbum(n);case"disable-album":return page.disableAlbum(n);case"view-album-uploads":return page.viewAlbumUploads(n,a);case"create-user":return page.createUser();case"edit-user":return page.editUser(n);case"disable-user":return page.disableUser(n);case"delete-user":return page.deleteUser(n);case"view-user-uploads":return page.viewUserUploads(n,a);case"get-new-token":return page.getNewToken(a);case"clear-selection":return page.clearSelection();case"select":return page.select(a,e);case"select-all":return page.selectAll(a);case"page-ellipsis":return page.focusJumpToPage(a);case"page-prev":case"page-next":case"page-goto":case"jump-to-page":return page.switchPage(t,a)}}},fadeAndScroll:function(e){page.fadingIn&&(clearTimeout(page.fadingIn),page.dom.classList.remove("fade-in")),e||(page.dom.classList.add("fade-in"),page.fadingIn=setTimeout((function(){page.dom.classList.remove("fade-in")}),500)),page.dom.scrollIntoView({behavior:e?"auto":"smooth",block:"start",inline:"nearest"})},getByView:function(e,a){switch(e){case"uploads":case"uploadsAll":return{type:"uploads",func:page.getUploads}[a];case"albums":case"albumsAll":return{type:"albums",func:page.getAlbums}[a];case"users":return{type:"users",func:page.getUsers}[a];default:return null}},switchPage:function(e,a){if(page.isSomethingLoading)return page.warnSomethingLoading();var n=Object.assign(page.views[page.currentView],{trigger:a}),t=page.getByView(page.currentView,"func");switch(e){case"page-prev":return n.pageNum=page.views[page.currentView].pageNum-1,n.pageNum<0?swal("An error occurred!","This is already the first page.","error"):t(n);case"page-next":return n.pageNum=page.views[page.currentView].pageNum+1,t(n);case"page-goto":return n.pageNum=parseInt(a.dataset.goto),t(n);case"jump-to-page":var s=document.querySelector("#"+(a.dataset.jumpid||"jumpToPage"));if(!s.checkValidity())return;var i=parseInt(s.value);return n.pageNum=isNaN(i)?0:i-1,n.pageNum<0&&(n.pageNum=0),t(n)}},focusJumpToPage:function(e){var a=document.querySelector("#"+(e.dataset.jumpid||"jumpToPage"));a&&(a.focus(),a.select())},getUploads:function(e){if(void 0===e&&(e={}),e&&e.all&&!page.permissions.moderator)return swal("An error occurred!","You cannot do this!","error");if(page.isSomethingLoading)return page.warnSomethingLoading();page.updateTrigger(e.trigger,"loading"),("number"!=typeof e.pageNum||e.pageNum<0)&&(e.pageNum=0);var a=void 0!==e.album?"api/album/"+e.album+"/"+e.pageNum:"api/uploads/"+e.pageNum,n={};e.all&&(n.all="1"),e.filters&&(n.filters=e.filters,/(^|\s)(date|expiry):[\d"]/.test(e.filters)&&(n.minoffset=(new Date).getTimezoneOffset())),axios.get(a,{headers:n}).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),t=a.data.files;if(e.pageNum&&0===t.length)return page.updateTrigger(e.trigger),e.autoPage?(e.pageNum=n-1,page.getUploads(e)):swal("An error occurred!","There are no more uploads to populate page "+(e.pageNum+1)+".","error");page.currentView=e.all?"uploadsAll":"uploads",page.cache={};var s=a.data.albums,i=a.data.users,l=a.data.basedomain;e.pageNum<0&&(e.pageNum=Math.max(0,n+e.pageNum));for(var o=page.paginate(a.data.count,25,e.pageNum),r='\n <div class="columns">\n '+('\n <div class="column">\n <form class="prevent-default">\n <div class="field has-addons">\n <div class="control is-expanded">\n <input id="filters" class="input is-small" type="text" placeholder="Filter uploads" value="'+page.escape(e.filters||"")+'">\n </div>\n <div class="control">\n <button type="button" class="button is-small is-primary is-outlined" title="Help?" data-action="upload-filters-help"'+(e.all?' data-all="true"':"")+'>\n <span class="icon">\n <i class="icon-help-circled"></i>\n </span>\n </button>\n </div>\n <div class="control">\n <button type="submit" class="button is-small is-info is-outlined" title="Filter uploads" data-action="filter-uploads">\n <span class="icon">\n <i class="icon-filter"></i>\n </span>\n </button>\n </div>\n </div>\n </form>\n </div>\n ')+'\n <div class="column is-one-quarter">\n <form class="prevent-default">\n <div class="field has-addons">\n <div class="control is-expanded">\n <input id="jumpToPage" class="input is-small" type="number" min="1" max="'+n+'" value="'+(e.pageNum+1)+'"'+(1===n?" disabled":"")+'>\n </div>\n <div class="control">\n <button type="submit" class="button is-small is-info is-outlined" title="Jump to page" data-action="jump-to-page">\n <span class="icon">\n <i class="icon-paper-plane"></i>\n </span>\n </button>\n </div>\n </div>\n </form>\n </div>\n </div>\n ',c='\n <div class="columns">\n <div class="column exclusive-operations has-text-left">\n <a class="button is-small is-primary is-outlined" title="Toggle original names" data-action="toggle-original-names">\n <span class="icon">\n <i class="icon-exchange"></i>\n </span>\n <span>Toggle original names</span>\n </a>\n </div>\n <div class="column has-text-centered">\n <a class="button is-small is-danger is-outlined" title="List view" data-action="view-list">\n <span class="icon">\n <i class="icon-th-list"></i>\n </span>\n </a>\n <a class="button is-small is-danger is-outlined" title="Thumbs view" data-action="view-thumbs">\n <span class="icon">\n <i class="icon-th-large"></i>\n </span>\n </a>\n </div>\n <div class="column bulk-operations has-text-right">\n <a class="button is-small is-info is-outlined" title="Clear selection" data-action="clear-selection">\n <span class="icon">\n <i class="icon-cancel"></i>\n </span>\n </a>\n '+(e.all?"":'\n <a class="button is-small is-warning is-outlined" title="Bulk add to album" data-action="add-selected-uploads-to-album">\n <span class="icon">\n <i class="icon-plus"></i>\n </span>\n </a>')+'\n <a class="button is-small is-danger is-outlined" title="Bulk delete" data-action="bulk-delete-uploads">\n <span class="icon">\n <i class="icon-trash"></i>\n </span>\n <span>Bulk delete</span>\n </a>\n </div>\n </div>\n ',d=r.replace(/id="filters"/,'id="bFilters"').replace(/(data-action="filter-uploads")/,'$1 data-filtersid="bFilters"').replace(/id="jumpToPage"/,'id="bJumpToPage"').replace(/(data-action="jump-to-page")/g,'$1 data-jumpid="bJumpToPage"'),u=o.replace(/(data-action="page-ellipsis")/g,'$1 data-jumpid="bJumpToPage"'),p=!1,g=page.views[page.currentView].originalNames,m=t.some((function(e){return void 0!==e.expirydate})),b=0;b<t.length;b++){t[b].file=l+"/"+t[b].name,t[b].thumb&&(t[b].thumb=l+"/"+t[b].thumb),t[b].type="other";var h=/.[\w]+(\?|$)/.exec(t[b].file),v=h&&h[0]?h[0].toLowerCase():null;page.imageExts.includes(v)?t[b].type="picture":page.videoExts.includes(v)&&(t[b].type="video"),page.cache[t[b].id]={name:t[b].name,original:t[b].original,thumb:t[b].thumb,file:t[b].file,type:t[b].type},t[b].prettyBytes=page.getPrettyBytes(parseInt(t[b].size)),t[b].prettyDate=page.getPrettyDate(new Date(1e3*t[b].timestamp)),m&&(t[b].prettyExpiryDate=t[b].expirydate?page.getPrettyDate(new Date(1e3*t[b].expirydate)):null),t[b].selected=page.selected[page.currentView].includes(t[b].id),t[b].selected||(p=!0),e.all?t[b].appendix=t[b].userid&&i[t[b].userid]||"":void 0===e.album&&(t[b].appendix=t[b].albumid&&s[t[b].albumid]||"")}if("thumbs"===page.views[page.currentView].type){page.dom.innerHTML="\n "+o+"\n "+r+"\n "+c+'\n <div id="table" class="columns is-multiline is-mobile is-centered">\n </div>\n '+c+"\n "+d+"\n "+u+"\n ";for(var f=document.querySelector("#table"),w=0;w<t.length;w++){var y=t[w],k=document.createElement("div");k.className="image-container column",k.dataset.id=y.id,void 0!==y.thumb?k.innerHTML='<a class="image" href="'+y.file+'" target="_blank"><img alt="'+y.name+'" data-src="'+y.thumb+'"/></a>':k.innerHTML='<a class="image" href="'+y.file+'" target="_blank"><h1 class="title">'+(y.extname||"N/A")+"</h1></a>",k.innerHTML+='\n <input type="checkbox" class="checkbox" title="Select" data-index="'+w+'" data-action="select"'+(y.selected?" checked":"")+'>\n <div class="controls">\n '+(y.thumb?'\n <a class="button is-small is-primary" title="Display preview" data-action="display-preview">\n <span class="icon">\n <i class="'+("other"!==y.type?"icon-"+y.type:"icon-doc-inv")+'"></i>\n </span>\n </a>':"")+'\n <a class="button is-small is-info clipboard-js" title="Copy link to clipboard" data-clipboard-text="'+y.file+'">\n <span class="icon">\n <i class="icon-clipboard"></i>\n </span>\n </a>\n <a class="button is-small is-warning" title="Add to album" data-action="add-to-album">\n <span class="icon">\n <i class="icon-plus"></i>\n </span>\n </a>\n <a class="button is-small is-danger" title="Delete" data-action="delete-upload">\n <span class="icon">\n <i class="icon-trash"></i>\n </span>\n </a>\n </div>\n <div class="details">\n <p class="name" title="'+y.file+'">'+y.name+"</p>\n "+(g?'<p class="originalname" title="'+y.original+'">'+y.original+"</p>":"")+'\n <p class="prettybytes">'+(y.appendix?"<span>"+y.appendix+"</span> ":"")+y.prettyBytes+"</p>\n "+(m&&y.prettyExpiryDate?'\n <p class="prettyexpirydate">EXP: '+y.prettyExpiryDate+"</p>":"")+"\n </div>\n ",f.appendChild(k),page.checkboxes=f.querySelectorAll('.checkbox[data-action="select"]')}}else{var x=e.all&&e.filters&&e.filters.includes("albumid:");page.dom.innerHTML="\n "+o+"\n "+r+"\n "+c+'\n <div class="table-container">\n <table class="table is-narrow is-fullwidth is-hoverable">\n <thead>\n <tr>\n <th class="controls"><input id="selectAll" class="checkbox" type="checkbox" title="Select all" data-action="select-all"></th>\n <th title="Key: name">File name</th>\n '+(g?'<th title="Key: original">Original name</th>':"")+"\n "+(void 0===e.album?'<th title="Key: '+(e.all?'userid">User':'albumid">Album')+"</th>":"")+"\n "+(x?'<th title="Key: albumid">Album</th>':"")+'\n <th title="Key: size">Size</th>\n '+(e.all?'<th title="Key: ip">IP</th>':"")+'\n <th title="Key: timestamp">Upload date</th>\n '+(m?'<th title="Key: expirydate">Expiry date</th>':"")+'\n <th></th>\n </tr>\n </thead>\n <tbody id="table">\n </tbody>\n </table>\n </div>\n '+c+"\n "+d+"\n "+u+"\n ";for(var T=document.querySelector("#table"),S=0;S<t.length;S++){var A=t[S],N=document.createElement("tr");N.dataset.id=A.id,N.innerHTML='\n <td class="controls"><input type="checkbox" class="checkbox" title="Select" data-index="'+S+'" data-action="select"'+(A.selected?" checked":"")+'></td>\n <th class="name"><a href="'+A.file+'" target="_blank" title="'+A.file+'">'+A.name+"</a></th>\n "+(g?'<th class="originalname" title="'+A.original+'">'+A.original+"</th>":"")+"\n "+(void 0===e.album?'<th class="appendix">'+A.appendix+"</th>":"")+"\n "+(x?'<th class="album">'+(A.albumid&&s[A.albumid]||"")+"</th>":"")+'\n <td class="prettybytes">'+A.prettyBytes+"</td>\n "+(e.all?'<td class="ip">'+(A.ip||"")+"</td>":"")+'\n <td class="prettydate">'+A.prettyDate+"</td>\n "+(m?'<td class="prettyexpirydate">'+(A.prettyExpiryDate||"-")+"</td>":"")+'\n <td class="controls has-text-right">\n <a class="button is-small is-primary is-outlined" title="'+(A.thumb?"Display preview":"File can't be previewed")+'" data-action="display-preview"'+(A.thumb?"":" disabled")+'>\n <span class="icon">\n <i class="'+("other"!==A.type?"icon-"+A.type:"icon-doc-inv")+'"></i>\n </span>\n </a>\n <a class="button is-small is-info is-outlined clipboard-js" title="Copy link to clipboard" data-clipboard-text="'+A.file+'">\n <span class="icon">\n <i class="icon-clipboard"></i>\n </span>\n </a>\n '+(e.all?"":'\n <a class="button is-small is-warning is-outlined" title="Add to album" data-action="add-to-album">\n <span class="icon">\n <i class="icon-plus"></i>\n </span>\n </a>')+'\n <a class="button is-small is-danger is-outlined" title="Delete" data-action="delete-upload">\n <span class="icon">\n <i class="icon-trash"></i>\n </span>\n </a>\n </td>\n ',T.appendChild(N),page.checkboxes=T.querySelectorAll('.checkbox[data-action="select"]')}}var L=document.querySelector("#selectAll");L&&!p&&t.length&&(L.checked=!0,L.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),page.views[page.currentView].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){if(page.isSomethingLoading)return page.warnSomethingLoading();"list"===e?(delete localStorage[lsKeys.viewType[page.currentView]],page.views[page.currentView].type=void 0):(localStorage[lsKeys.viewType[page.currentView]]=e,page.views[page.currentView].type=e),page.getUploads(Object.assign(page.views[page.currentView],{trigger:a}))},toggleOriginalNames:function(e){if(page.isSomethingLoading)return page.warnSomethingLoading();page.views[page.currentView].originalNames?(delete localStorage[lsKeys.originalNames[page.currentView]],page.views[page.currentView].originalNames=!1):(localStorage[lsKeys.originalNames[page.currentView]]="1",page.views[page.currentView].originalNames=!0),page.getUploads(Object.assign(page.views[page.currentView],{trigger:e}))},displayPreview:function(e){var a=page.cache[e];if(a.thumb){var n=document.createElement("div");if(n.innerHTML='\n <div class="content has-text-centered">\n <p>\n <div class="has-text-weight-bold">'+a.name+"</div>\n <div>"+a.original+'</div>\n </p>\n <p class="swal-display-thumb-container">\n <img id="swalThumb" src="'+a.thumb+'">\n </p>\n </div>\n ',a.file){var t=/.[\w]+(\?|$)/.exec(a.file),s=t&&t[0]?t[0].toLowerCase():null,i=page.imageExts.includes(s),l=!i&&page.videoExts.includes(s);(i||l)&&(n.innerHTML+='\n <div class="field has-text-right">\n <div class="controls">\n <a id="swalOriginal" type="button" class="button is-info" data-original="'+a.file+'">\n <span class="icon">\n <i class="icon-arrows-cw"></i>\n </span>\n <span>Load original</span>\n </a>\n </div>\n </div>\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.file,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 <span class="icon">\n <i class="icon-block"></i>\n </span>\n <span>Unable to load original</span>\n '};else if(l){s.classList.add("is-hidden");var o=document.createElement("video");o.id="swalVideo",o.controls=!0,o.autoplay=!0,o.src=a.file,s.insertAdjacentElement("afterend",o),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;a<page.checkboxes.length;a++){var n=page.getItemID(page.checkboxes[a]);isNaN(n)||page.checkboxes[a].checked!==e.checked&&(page.checkboxes[a].checked=e.checked,page.checkboxes[a].checked?page.selected[page.currentView].push(n):page.selected[page.currentView].splice(page.selected[page.currentView].indexOf(n),1))}page.selected[page.currentView].length?localStorage[lsKeys.selected[page.currentView]]=JSON.stringify(page.selected[page.currentView]):delete localStorage[lsKeys.selected[page.currentView]],e.title=e.checked?"Unselect all":"Select all"},selectInBetween:function(e,a){var n=parseInt(e.dataset.index),t=parseInt(a.dataset.index);if(!(Math.abs(n-t)<2))for(var s=0;s<page.checkboxes.length;s++)if(n>t&&s>t&&s<n||n<t&&s>n&&s<t){var i=page.checkboxes[s].checked=a.checked,l=page.getItemID(page.checkboxes[s]);!page.selected[page.currentView].includes(l)&&i?page.selected[page.currentView].push(l):page.selected[page.currentView].includes(l)&&!i&&page.selected[page.currentView].splice(page.selected[page.currentView].indexOf(l),1)}},select:function(e,a){var n=page.getItemID(e);isNaN(n)||(a.shiftKey&&page.lastSelected?(page.selectInBetween(e,page.lastSelected),e.checked=page.lastSelected.checked):page.lastSelected=e,!page.selected[page.currentView].includes(n)&&e.checked?page.selected[page.currentView].push(n):page.selected[page.currentView].includes(n)&&!e.checked&&page.selected[page.currentView].splice(page.selected[page.currentView].indexOf(n),1),page.selected[page.currentView].length?localStorage[lsKeys.selected[page.currentView]]=JSON.stringify(page.selected[page.currentView]):delete localStorage[lsKeys.selected[page.currentView]])},clearSelection:function(){var e=page.selected[page.currentView],a=page.getByView(page.currentView,"type"),n=e.length;if(!n)return swal("An error occurred!","You have not selected any "+a+".","error");var t=1===n?a.substring(0,a.length-1):a;return swal({title:"Are you sure?",text:"You are going to unselect "+n+" "+t+".",buttons:!0}).then((function(e){if(e){for(var a=page.checkboxes,s=0;s<a.length;s++)a[s].checked&&(a[s].checked=!1);page.selected[page.currentView]=[],delete localStorage[lsKeys.selected[page.currentView]];var i=document.querySelector("#selectAll");return i&&(i.checked=!1),swal("Cleared selection!","Unselected "+n+" "+t+".","success")}}))},uploadFiltersHelp:function(e){var a=Boolean(e.dataset.all),n=document.createElement("div");n.style="text-align: left",n.innerHTML=((a?"\n There are 2 filter keys, namely <b>user</b> (username) and <b>ip</b>.\n These keys can be specified more than once.\n For usernames with whitespaces, wrap them with double quotes (<code>\"</code>).\n Special cases such as uploads by non-registered users or have no IPs respectively, use <code>user:-</code> or <code>ip:-</code>.\n\n To exclude certain users/ips while still listing every other uploads, add negation sign (<code>-</code>) before the keys.\n Negation sign can also be used to exclude the special cases mentioned above (i.e. <code>-user:-</code> or <code>-ip:-</code>).\n\n If you know the ID of a user's album, you can list its uploads with <b>albumid</b> key.\n Negation sign works for this key as well.\n ":"\n There is only 1 filter key, namely <b>albumid</b>.\n This key can be specified more than once.\n Special case such as uploads with no albums, use <code>albumid:-</code>.\n\n To exclude certain albums while still listing every other uploads, add negation sign (<code>-</code>) before the keys.\n Negation sign can also be used to exclude the special case mentioned above (i.e. <code>-albumid:-</code>).\n ")+'\n There are 2 range keys: <b>date</b> (upload date) and <b>expiry</b> (expiry date).\n Their format is: <code>"YYYY/MM/DD HH:MM:SS-YYYY/MM/DD HH:MM:SS"</code> ("from" date and "to" date respectively).\n You may specify only one of the dates.\n If "to" date is missing, \'now\' will be used. If "from" date is missing, \'beginning of time\' will be used.\n If any of the subsequent date or time units are not specified, their first value will be used (e.g. January for month, 1 for day, and so on).\n If only time is specified, today\'s date will be used.\n If you do not need to specify both date and time, you may omit the double quotes.\n In conclusion, the following examples are all valid: <code>date:"2020/01/01 01:23-2018/01/01 06"</code>, <code>expiry:-2020/05</code>, <code>date:12:34:56</code>.\n These keys can only be specified once each.\n\n <b>Timezone?</b> 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 <b>sort</b> keys.\n Their formats are: <code>sort:columnName[:d[escending]]</code>, where <code>:d[escending]</code> is an optional tag to set the direction to descending.\n This key must be used with internal column names used in the database (<code>id</code>, <code>'+(a?"userid":"albumid")+"</code>, and so on),\n but there are 2 shortcuts available: <b>date</b> for <code>timestamp</code> column and <b>expiry</b> for <code>expirydate</code> column.\n This key can also be specified more than once, where their order will decide the sorting steps.\n\n Finally, there are type-<b>is</b> keys to refine by types.\n You can use <code>is:image</code> and <code>is:video</code> to list images and videos respectively.\n This will only use image/video extensions whose thumbnails can be generated by the safe.\n Negation sign works for this key as well.\n Mixing inclusion and exclusion is not allowed (i.e. <code>is:image -is:video</code>, since the second key is redundant).\n\n Any leftover keywords which do not use keys (non-keyed keywords) will be matched against the matches' file names.\n Excluding certain keywords is also supported by adding negation sign before the keywords.\n\n <b>Internal steps:</b>\n "+(a?"- Query uploads passing ALL exclusion filter keys OR matching ANY filter keys, if any.\n - Refine matches":"- Filter uploads")+" using date key, if any.\n - Refine matches using expiry key, if any.\n - Refine matches using type-is keys, if any.\n - Refine matches using ANY non-keyed keywords, if any.\n - Filter matches using ALL exclusion non-keyed keywords, if any.\n - Sort matches using sorting keys, if any.\n\n <b>Examples:</b>\n "+(a?'- Uploads from users named "demo" AND/OR "John Doe" AND/OR non-registered users:\n <code>user:demo user:"John Doe" user:-</code>\n - ALL uploads, but NOT the ones from user named "demo" AND "John Doe":\n <code>-user:demo -user:"John Doe"</code>\n - Uploads from IP "127.0.0.1" AND which file names match "*.rar" OR "*.zip":\n <code>ip:127.0.0.1 *.rar *.zip</code>\n ':"")+'- Uploads without albums:\n <code>albumid:-</code>\n - ALL uploads, but NOT the ones from album with ID 69:\n <code>-albumid:69</code>\n - Uploads uploaded since "1 June 2019 00:00:00":\n <code>date:2019/06</code>\n - Uploads uploaded between "7 April 2020 12:00:00" and "7 April 2020 23:59:59":\n <code>date:"2020/04/07 12-2020/04/07 23:59:59"</code>\n - Uploads uploaded before "5 February 2020 00:00:00":\n <code>date:-2020/02/05</code>\n - Uploads which file names match "*.gz" but NOT "*.tar.gz":\n <code>*.gz -*.tar.gz</code>\n - Sort matches by "size" column in ascending and descending order respectively:\n <code>'+(a?'user:"John Doe"':"*.txt")+" sort:size</code>\n <code>*.mp4 "+(a?"user:- ":"")+"sort:size:d</code>\n "+(page.permissions.moderator?"":"\n <b>Notice:</b> Regular users may face some limitations in the amount of keys that can be used at a time.\n ")+"\n <b>Friendly reminder:</b> This window can be scrolled up!\n ").trim().replace(/^\s*/g,"").replace(/\n/g,"<br>"),swal({content:n}).then((function(){document.body.querySelector(".swal-overlay .swal-modal").classList.remove("is-expanded")})),document.body.querySelector(".swal-overlay .swal-modal:not(.is-expanded)").classList.add("is-expanded")},filterUploads:function(e){var a=document.querySelector("#"+(e.dataset.filtersid||"filters")).value.trim().replace(/\t/g," ").replace(/(^|\s)((albumid|ip|user|date|expiry|is|sort|orderby):)\s+/g,"$2");page.getUploads(Object.assign(page.views[page.currentView],{filters:a,pageNum:0,trigger:e}))},viewUserUploads:function(e,a){var n=page.cache[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")})}},viewAlbumUploads:function(e,a){if(page.cache[e]){a.classList.add("is-loading");var n="albumsAll"===page.currentView&&page.permissions.moderator;page.getUploads({all:n,filters:"albumid:"+e,trigger:n?document.querySelector("#itemManageUploads"):document.querySelector("#itemUploads")})}},deleteUpload:function(e){page.postBulkDeleteUploads({all:"uploadsAll"===page.currentView,field:"id",values:[e],cb:function(a){!a.length&&page.selected[page.currentView].includes(e)&&page.selected[page.currentView].splice(page.selected[page.currentView].indexOf(e),1),page.selected[page.currentView].length?localStorage[lsKeys.selected[page.currentView]]=JSON.stringify(page.selected[page.currentView]):delete localStorage[lsKeys.selected[page.currentView]],page.getUploads(Object.assign(page.views[page.currentView],{autoPage:!0}))}})},bulkDeleteUploads:function(){if(!page.selected[page.currentView].length)return swal("An error occurred!","You have not selected any uploads.","error");page.postBulkDeleteUploads({all:"uploadsAll"===page.currentView,field:"id",values:page.selected[page.currentView],cb:function(e){e.length?page.selected[page.currentView]=page.selected[page.currentView].filter((function(a){return e.includes(a)})):page.selected[page.currentView]=[],page.selected[page.currentView].length?localStorage[lsKeys.selected[page.currentView]]=JSON.stringify(page.selected[page.currentView]):delete localStorage[lsKeys.selected[page.currentView]],page.getUploads(Object.assign(page.views[page.currentView],{autoPage:!0}))}})},deleteUploadsByNames:function(e){void 0===e&&(e={});var a="";page.permissions.moderator&&(a="<br><b>Hint:</b> You can use this feature to delete uploads by other users."),page.dom.innerHTML='\n <form class="prevent-default">\n <div class="field">\n <label class="label">Upload names:</label>\n <div class="control">\n <textarea id="bulkDeleteNames" class="textarea"></textarea>\n </div>\n <p class="help">Separate each entry with a new line.'+a+'</p>\n </div>\n <div class="field">\n <div class="control">\n <button type="submit" id="submitBulkDelete" class="button is-danger is-outlined is-fullwidth">\n <span class="icon">\n <i class="icon-trash"></i>\n </span>\n <span>Bulk delete</span>\n </button>\n </div>\n </div>\n </form>\n ',page.fadeAndScroll(),page.updateTrigger(e.trigger,"active"),document.querySelector("#submitBulkDelete").addEventListener("click",(function(){if(page.isSomethingLoading)return page.warnSomethingLoading();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="<p>You won't be able to recover "+n.replace(/^(\d*)(.*)/,"<b>$1</b>$2")+"!</p>";e.all&&(t+="\n<p><b>Warning:</b> You may be nuking "+(1===a?"an upload":"some uploads")+" by "+(1===a?"another user":"other users")+"!</p>");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<e.values.length?swal("Warning!","From "+n+", unable to delete "+s.length+" of them.","warning"):swal("Deleted!",n+" "+(1===a?"has":"have")+" been deleted.","success",{buttons:!1,timer:1500}),"function"==typeof e.cb&&e.cb(s)}})).catch(page.onAxiosError)}))},addSelectedUploadsToAlbum:function(){if("uploads"===page.currentView){if(!page.selected[page.currentView].length)return swal("An error occurred!","You have not selected any uploads.","error");page.addUploadsToAlbum(page.selected[page.currentView],(function(e){e&&(e.length?page.selected[page.currentView]=page.selected[page.currentView].filter((function(a){return e.includes(a)})):page.selected[page.currentView]=[],localStorage[lsKeys.selected[page.currentView]]=JSON.stringify(page.selected[page.currentView]),page.getUploads(page.views[page.currentView]))}))}},addToAlbum:function(e){page.addUploadsToAlbum([e],(function(e){e&&page.getUploads(page.views[page.currentView])}))},addUploadsToAlbum:function(e,a){var n=e.length,t=document.createElement("div");t.innerHTML='\n <div class="field has-text-centered">\n <p>You are about to add <b>'+n+"</b> upload"+(1===n?"":"s")+' to an album.</p>\n <p><b>If an upload is already in an album, it will be moved.</b></p>\n </div>\n <div class="field">\n <div class="control">\n <div class="select is-fullwidth">\n <select id="swalAlbum" disabled>\n <option value="-1">Remove from album</option>\n <option value="" selected disabled>Fetching albums list…</option>\n </select>\n </div>\n </div>\n </div>\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'<option value="'+e.id+'">'+e.name+"</option>"})).join("\n"),a.getElementsByTagName("option")[1].innerHTML="Choose an album",a.removeAttribute("disabled"))}else"No token provided"===e.data.description?page.verifyToken(page.token):swal("An error occurred!",e.data.description,"error")})).catch(page.onAxiosError)},getAlbums:function(e){if(void 0===e&&(e={}),e&&e.all&&!page.permissions.moderator)return swal("An error occurred!","You cannot do this!","error");if(page.isSomethingLoading)return page.warnSomethingLoading();page.updateTrigger(e.trigger,"loading"),"number"!=typeof e.pageNum&&(e.pageNum=0);var a={};e.all&&(a.all="1");var n="api/albums/"+e.pageNum;axios.get(n,{headers:a}).then((function(a){if(a){if(!1===a.data.success)return"No token provided"===a.data.description?page.verifyToken(page.token):(page.updateTrigger(e.trigger),swal("An error occurred!",a.data.description,"error"));var n=Math.ceil(a.data.count/25),t=a.data.albums;if(e.pageNum&&0===t.length)return page.updateTrigger(e.trigger),e.autoPage?(e.pageNum=n-1,page.getAlbums(e)):swal("An error occurred!","There are no more albums to populate page "+(e.pageNum+1)+".","error");page.currentView=e.all?"albumsAll":"albums",page.cache={};var s=a.data.users,i=a.data.homeDomain;e.pageNum<0&&(e.pageNum=Math.max(0,n+e.pageNum));var l=page.paginate(a.data.count,25,e.pageNum),o='\n <div class="columns">\n '+('\n <div class="column">\n <form class="prevent-default">\n <div class="field has-addons">\n <div class="control is-expanded">\n <input id="filters" class="input is-small" type="text" placeholder="Filter albums (WIP)" value="'+page.escape(e.filters||"")+'" disabled>\n </div>\n <div class="control">\n <button type="button" class="button is-small is-primary is-outlined" title="Help? (WIP)" data-action="album-filters-help" disabled>\n <span class="icon">\n <i class="icon-help-circled"></i>\n </span>\n </button>\n </div>\n <div class="control">\n <button type="submit" class="button is-small is-info is-outlined" title="Filter albums (WIP)" data-action="filter-albums" disabled>\n <span class="icon">\n <i class="icon-filter"></i>\n </span>\n </button>\n </div>\n </div>\n </form>\n </div>\n ')+'\n <div class="column is-one-quarter">\n <form class="prevent-default">\n <div class="field has-addons">\n <div class="control is-expanded">\n <input id="jumpToPage" class="input is-small" type="number" min="1" max="'+n+'" value="'+(e.pageNum+1)+'"'+(1===n?" disabled":"")+'>\n </div>\n <div class="control">\n <button type="submit" class="button is-small is-info is-outlined" title="Jump to page" data-action="jump-to-page">\n <span class="icon">\n <i class="icon-paper-plane"></i>\n </span>\n </button>\n </div>\n </div>\n </form>\n </div>\n </div>\n ',r='\n <div class="columns">\n <div class="column is-hidden-mobile"></div>\n <div class="column bulk-operations has-text-right">\n <a class="button is-small is-info is-outlined" title="Clear selection" data-action="clear-selection">\n <span class="icon">\n <i class="icon-cancel"></i>\n </span>\n </a>\n <a class="button is-small is-dangerish is-outlined" title="Bulk disable (WIP)" data-action="bulk-disable-albums" disabled>\n <span class="icon">\n <i class="icon-trash"></i>\n </span>\n '+(e.all?"":"<span>Bulk disable</span>")+"\n </a>\n "+(e.all?'<a class="button is-small is-danger is-outlined" title="Bulk delete (WIP)" data-action="bulk-delete-albums" disabled>\n <span class="icon">\n <i class="icon-trash"></i>\n </span>\n <span>Bulk delete</span>\n </a>':"")+"\n </div>\n </div>\n ",c=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"'),d=l.replace(/(data-action="page-ellipsis")/g,'$1 data-jumpid="bJumpToPage"'),u=!1,p='\n <h2 class="subtitle">Create new album</h2>\n <form class="prevent-default">\n <div class="field">\n <div class="control">\n <input id="albumName" class="input" type="text" placeholder="Name" maxlength="'+page.albumTitleMaxLength+'">\n </div>\n <p class="help">Max length is '+page.albumTitleMaxLength+' characters.</p>\n </div>\n <div class="field">\n <div class="control">\n <textarea id="albumDescription" class="textarea" placeholder="Description" rows="1" maxlength="'+page.albumDescMaxLength+'"></textarea>\n </div>\n <p class="help">Max length is '+page.albumDescMaxLength+' characters.</p>\n </div>\n <div class="field">\n <div class="control">\n <button type="submit" id="submitAlbum" class="button is-info is-outlined is-fullwidth" data-action="submit-album">\n <span class="icon">\n <i class="icon-paper-plane"></i>\n </span>\n <span>Create</span>\n </button>\n </div>\n </div>\n </form>\n <hr>\n ';page.dom.innerHTML="\n "+(e.all?"":p)+"\n "+l+"\n "+o+"\n "+r+'\n <div class="table-container">\n <table class="table is-narrow is-fullwidth is-hoverable">\n <thead>\n <tr>\n <th><input id="selectAll" class="checkbox" type="checkbox" title="Select all" data-action="select-all"></th>\n <th>ID</th>\n <th>Name</th>\n '+(e.all?"<th>User</th>":"")+'\n <th>Uploads</th>\n <th>Created at</th>\n <th>Public link</th>\n <th></th>\n </tr>\n </thead>\n <tbody id="table">\n </tbody>\n </table>\n </div>\n '+r+"\n "+c+"\n "+d+"\n ";for(var g=document.querySelector("#table"),m=0;m<t.length;m++){var b=t[m],h=i+"/a/"+b.identifier,v=page.selected[page.currentView].includes(b.id);v||(u=!0),b.prettyDate=page.getPrettyDate(new Date(1e3*b.timestamp));var f=0!==b.enabled;page.cache[b.id]={name:b.name,download:b.download,public:b.public,description:b.description,enabled:f};var w=document.createElement("tr");w.dataset.id=b.id,w.innerHTML='\n <td class="controls"><input type="checkbox" class="checkbox" title="Select" data-index="'+m+'" data-action="select"'+(v?" checked":"")+"></td>\n <th>"+b.id+"</th>\n <th"+(f?"":' class="has-text-grey"')+">"+b.name+"</td>\n "+(e.all?"<th>"+(b.userid&&s[b.userid]||"")+"</th>":"")+"\n <th>"+b.uploads+"</th>\n <td>"+b.prettyDate+"</td>\n <td><a "+(f&&b.public?"":'class="is-linethrough" ')+'href="'+h+'" target="_blank">'+h+'</a></td>\n <td class="has-text-right" data-id="'+b.id+'">\n <a class="button is-small is-primary is-outlined" title="Edit album" data-action="edit-album">\n <span class="icon is-small">\n <i class="icon-pencil"></i>\n </span>\n </a>\n <a class="button is-small is-info is-outlined" title="'+(b.uploads?"View uploads":"Album doesn't have uploads")+'" data-action="view-album-uploads" '+(b.uploads?"":"disabled")+'>\n <span class="icon">\n <i class="icon-docs"></i>\n </span>\n </a>\n <a class="button is-small is-info is-outlined clipboard-js" title="Copy link to clipboard" '+(b.public?'data-clipboard-text="'+h+'"':"disabled")+'>\n <span class="icon is-small">\n <i class="icon-clipboard"></i>\n </span>\n </a>\n <a class="button is-small is-warning is-outlined" title="Download album" '+(f&&b.download?'href="api/album/zip/'+b.identifier+"?v="+b.editedAt+'"':"disabled")+'>\n <span class="icon is-small">\n <i class="icon-download"></i>\n </span>\n </a>\n <a class="button is-small is-dangerish is-outlined" title="Disable album" data-action="disable-album"'+(f?"":" disabled")+'>\n <span class="icon is-small">\n <i class="icon-trash"></i>\n </span>\n </a>\n </td>\n ',g.appendChild(w),page.checkboxes=g.querySelectorAll('.checkbox[data-action="select"]')}var y=document.querySelector("#selectAll");y&&!u&&(y.checked=!0,y.title="Unselect all"),page.fadeAndScroll(),page.updateTrigger(e.trigger,"active"),"albumsAll"===page.currentView&&(page.views[page.currentView].filters=e.filters),page.views[page.currentView].pageNum=t.length?e.pageNum:0}})).catch((function(a){page.updateTrigger(e.trigger),page.onAxiosError(a)}))},editAlbum:function(e){var a=page.cache[e];if(a){var n=document.createElement("div");n.innerHTML='\n <div class="field">\n <div class="controls">\n <input id="swalName" class="input" type="text" placeholder="Name" maxlength="'+page.albumTitleMaxLength+'" value="'+(a.name||"").substring(0,page.albumTitleMaxLength)+'">\n </div>\n <p class="help">Max length is '+page.albumTitleMaxLength+' characters.</p>\n </div>\n <div class="field">\n <div class="control">\n <textarea id="swalDescription" class="textarea" placeholder="Description" rows="2" maxlength="'+page.albumDescMaxLength+'">'+(a.description||"").substring(0,page.albumDescMaxLength)+'</textarea>\n </div>\n <p class="help">Max length is '+page.albumDescMaxLength+" characters.</p>\n </div>\n "+("albumsAll"===page.currentView&&page.permissions.moderator?'<div class="field">\n <div class="control">\n <label class="checkbox">\n <input id="swalEnabled" type="checkbox" '+(a.enabled?"checked":"")+">\n Enabled\n </label>\n </div>\n </div>":"")+'\n <div class="field">\n <div class="control">\n <label class="checkbox">\n <input id="swalDownload" type="checkbox" '+(a.download?"checked":"")+'>\n Enable download\n </label>\n </div>\n </div>\n <div class="field">\n <div class="control">\n <label class="checkbox">\n <input id="swalPublic" type="checkbox" '+(a.public?"checked":"")+'>\n Enable public link\n </label>\n </div>\n </div>\n <div class="field">\n <div class="control">\n <label class="checkbox">\n <input id="swalRequestLink" type="checkbox">\n Request new public link\n </label>\n </div>\n </div>\n ',swal({title:"Edit album",icon:"info",content:n,buttons:{cancel:!0,confirm:{closeModal:!1}}}).then((function(n){if(n){var t={id:e,name:document.querySelector("#swalName").value.trim(),description:document.querySelector("#swalDescription").value.trim(),download:document.querySelector("#swalDownload").checked,public:document.querySelector("#swalPublic").checked,requestLink:document.querySelector("#swalRequestLink").checked};"albumsAll"===page.currentView&&page.permissions.moderator&&(t.enabled=document.querySelector("#swalEnabled").checked),axios.post("api/albums/edit",t).then((function(e){if(e){if(!1===e.data.success)return"No token provided"===e.data.description?page.verifyToken(page.token):swal("An error occurred!",e.data.description,"error");e.data.identifier?swal("Success!","The album's new identifier is: "+e.data.identifier+".","success"):e.data.name!==a.name?swal("Success!","The album was renamed to: "+e.data.name+".","success"):swal("Success!","The album was edited.","success",{buttons:!1,timer:1500}),page.getAlbumsSidebar(),page.getAlbums(Object.assign(page.views[page.currentView],{autoPage:!0}))}})).catch(page.onAxiosError)}}))}},disableAlbum:function(e){swal({title:"Are you sure?",text:"This won't delete the uploads associated with the album!",icon:"warning",dangerMode:!0,buttons:{cancel:!0,confirm:{text:"Yes, disable it!",closeModal:!1},purge:{text:"Umm, delete the uploads too, please?",value:"purge",className:"swal-button--danger",closeModal:!1}}}).then((function(a){a&&axios.post("api/albums/disable",{id:e,purge:"purge"===a}).then((function(e){if(!1===e.data.success){var a=Array.isArray(e.data.failed)?e.data.failed:[];return"No token provided"===e.data.description?page.verifyToken(page.token):a.length?swal("An error occurred!","Unable to delete "+a.length+" of the album's upload"+(1===a.length?"":"s")+".","error"):swal("An error occurred!",e.data.description,"error")}swal("Deleted!","Your album has been disabled.","success",{buttons:!1,timer:1500}),page.getAlbumsSidebar(),page.getAlbums(Object.assign(page.views[page.currentView],{autoPage:!0}))})).catch(page.onAxiosError)}))},submitAlbum:function(e){page.updateTrigger(e,"loading"),axios.post("api/albums",{name:document.querySelector("#albumName").value.trim(),description:document.querySelector("#albumDescription").value.trim()}).then((function(a){if(a){if(page.updateTrigger(e),!1===a.data.success)return"No token provided"===a.data.description?page.verifyToken(page.token):swal("An error occurred!",a.data.description,"error");swal("Woohoo!","Album was created successfully.","success",{buttons:!1,timer:1500}),page.getAlbumsSidebar(),page.getAlbums({pageNum:-1})}})).catch((function(a){page.updateTrigger(e),page.onAxiosError(a)}))},getAlbumsSidebar:function(){axios.get("api/albums",{headers:{sidebar:"1"}}).then((function(e){if(e){if(!1===e.data.success)return"No token provided"===e.data.description?page.verifyToken(page.token):swal("An error occurred!",e.data.description,"error");var a=e.data.albums,n=e.data.count,t=document.querySelector("#albumsContainer"),s=t.querySelectorAll("li > a");if(s.length){for(var i=0;i<s.length;i++)page.menus.splice(page.menus.indexOf(s[i]),1);t.innerHTML=""}if(void 0!==a){for(var l=0;l<a.length;l++){var o=a[l],r=document.createElement("li"),c=document.createElement("a");c.id=o.id,c.className="is-relative",c.innerHTML=o.name,c.addEventListener("click",(function(e){page.getUploads({album:parseInt(e.currentTarget.id),trigger:e.currentTarget})})),page.menus.push(c),r.appendChild(c),t.appendChild(r)}if(n>a.length){var d=document.createElement("li"),u=document.createElement("a");u.className="is-relative",u.innerHTML="...",u.title="You have "+n+" albums, but the sidebar can only list your first "+a.length+" albums.",u.addEventListener("click",(function(e){page.getAlbums({trigger:document.querySelector("#itemManageYourAlbums")})})),d.appendChild(u),t.appendChild(d)}}}})).catch(page.onAxiosError)},changeToken:function(e){void 0===e&&(e={}),page.dom.innerHTML='\n <div class="field">\n <label class="label">Your current token:</label>\n <div class="field">\n <div class="control">\n <input id="token" readonly class="input" type="text" placeholder="Your token" value="'+page.token+'">\n </div>\n </div>\n </div>\n <div class="field">\n <div class="control">\n <a id="getNewToken" class="button is-info is-outlined is-fullwidth">\n <span class="icon">\n <i class="icon-arrows-cw"></i>\n </span>\n <span>Request new token</span>\n </a>\n </div>\n </div>\n ',page.fadeAndScroll(),page.updateTrigger(e.trigger,"active"),document.querySelector("#getNewToken").addEventListener("click",(function(e){if(page.isSomethingLoading)return page.warnSomethingLoading();var a=e.currentTarget;page.updateTrigger(a,"loading"),axios.post("api/tokens/change").then((function(e){if(!1===e.data.success)return"No token provided"===e.data.description?page.verifyToken(page.token):(page.updateTrigger(a),swal("An error occurred!",e.data.description,"error"));page.updateTrigger(a),swal({title:"Woohoo!",text:"Your token was successfully changed.",icon:"success",buttons:!1,timer:1500}).then((function(){axios.defaults.headers.common.token=e.data.token,localStorage[lsKeys.token]=e.data.token,page.token=e.data.token,page.changeToken()}))})).catch((function(e){page.updateTrigger(a),page.onAxiosError(e)}))}))},changePassword:function(e){void 0===e&&(e={}),page.dom.innerHTML='\n <form class="prevent-default">\n <div class="field">\n <label class="label">New password:</label>\n <div class="control">\n <input id="password" class="input" type="password" minlength="6" maxlength="64">\n </div>\n </div>\n <div class="field">\n <label class="label">Re-type new password:</label>\n <div class="control">\n <input id="passwordConfirm" class="input" type="password" minlength="6" maxlength="64">\n </div>\n </div>\n <div class="field">\n <div class="control">\n <button type="submit" id="sendChangePassword" class="button is-info is-outlined is-fullwidth">\n <span class="icon">\n <i class="icon-paper-plane"></i>\n </span>\n <span>Set new password</span>\n </button>\n </div>\n </div>\n </form>\n ',page.fadeAndScroll(),page.updateTrigger(e.trigger,"active"),document.querySelector("#sendChangePassword").addEventListener("click",(function(e){if(page.isSomethingLoading)return page.warnSomethingLoading();page.dom.querySelector("form").checkValidity()&&(document.querySelector("#password").value===document.querySelector("#passwordConfirm").value?page.sendNewPassword(document.querySelector("#password").value,e.currentTarget):swal({title:"Password mismatch!",text:"Your passwords do not match, please try again.",icon:"error"}))}))},sendNewPassword:function(e,a){page.updateTrigger(a,"loading"),axios.post("api/password/change",{password:e}).then((function(e){if(!1===e.data.success)return"No token provided"===e.data.description?page.verifyToken(page.token):(page.updateTrigger(a),swal("An error occurred!",e.data.description,"error"));page.updateTrigger(a),swal({title:"Woohoo!",text:"Your password was successfully changed.",icon:"success",buttons:!1,timer:1500}).then((function(){page.changePassword()}))})).catch((function(e){page.updateTrigger(a),page.onAxiosError(e)}))},getUsers:function(e){if(void 0===e&&(e={}),page.isSomethingLoading)return page.warnSomethingLoading();if(!page.permissions.admin)return swal("An error occurred!","You cannot do this!","error");page.updateTrigger(e.trigger,"loading"),"number"!=typeof e.pageNum&&(e.pageNum=0);var a="api/users/"+e.pageNum;axios.get(a).then((function(a){if(!1===a.data.success)return"No token provided"===a.data.description?page.verifyToken(page.token):(page.updateTrigger(e.trigger),swal("An error occurred!",a.data.description,"error"));var n=Math.ceil(a.data.count/25),t=a.data.users;if(e.pageNum&&0===t.length)return page.updateTrigger(e.trigger),e.autoPage?(e.pageNum=n-1,page.getUsers(e)):swal("An error occurred!","There are no more users to populate page "+(e.pageNum+1)+".","error");page.currentView="users",page.cache={},e.pageNum<0&&(e.pageNum=Math.max(0,n+e.pageNum));var s=page.paginate(a.data.count,25,e.pageNum),i='\n <div class="columns">\n '+('\n <div class="column">\n <form class="prevent-default">\n <div class="field has-addons">\n <div class="control is-expanded">\n <input id="filters" class="input is-small" type="text" placeholder="Filter users (WIP)" value="'+page.escape(e.filters||"")+'" disabled>\n </div>\n <div class="control">\n <button type="button" class="button is-small is-primary is-outlined" title="Help? (WIP)" data-action="user-filters-help" disabled>\n <span class="icon">\n <i class="icon-help-circled"></i>\n </span>\n </button>\n </div>\n <div class="control">\n <button type="submit" class="button is-small is-info is-outlined" title="Filter users (WIP)" data-action="filter-users" disabled>\n <span class="icon">\n <i class="icon-filter"></i>\n </span>\n </button>\n </div>\n </div>\n </form>\n </div>\n ')+'\n <div class="column is-one-quarter">\n <form class="prevent-default">\n <div class="field has-addons">\n <div class="control is-expanded">\n <input id="jumpToPage" class="input is-small" type="number" min="1" max="'+n+'" value="'+(e.pageNum+1)+'"'+(1===n?" disabled":"")+'>\n </div>\n <div class="control">\n <button type="submit" class="button is-small is-info is-outlined" title="Jump to page" data-action="jump-to-page">\n <span class="icon">\n <i class="icon-paper-plane"></i>\n </span>\n </button>\n </div>\n </div>\n </form>\n </div>\n </div>\n ',l='\n <div class="columns">\n <div class="column exclusive-operations has-text-left">\n <a class="button is-small is-primary is-outlined" title="Create new user" data-action="create-user">\n <span class="icon">\n <i class="icon-plus"></i>\n </span>\n <span>Create new user</span>\n </a>\n </div>\n <div class="column bulk-operations has-text-right">\n <a class="button is-small is-info is-outlined" title="Clear selection" data-action="clear-selection">\n <span class="icon">\n <i class="icon-cancel"></i>\n </span>\n </a>\n <a class="button is-small is-dangerish is-outlined" title="Bulk disable (WIP)" data-action="bulk-disable-users" disabled>\n <span class="icon">\n <i class="icon-hammer"></i>\n </span>\n </a>\n <a class="button is-small is-danger is-outlined" title="Bulk delete (WIP)" data-action="bulk-delete-users" disabled>\n <span class="icon">\n <i class="icon-trash"></i>\n </span>\n <span>Bulk delete</span>\n </a>\n </div>\n </div>\n ',o=i.replace(/id="filters"/,'id="bFilters"').replace(/(data-action="filter-uploads")/,'$1 data-filtersid="bFilters"').replace(/id="jumpToPage"/,'id="bJumpToPage"').replace(/(data-action="jump-to-page")/g,'$1 data-jumpid="bJumpToPage"'),r=s.replace(/(data-action="page-ellipsis")/g,'$1 data-jumpid="bJumpToPage"'),c=!1;page.dom.innerHTML="\n "+s+"\n "+i+"\n "+l+'\n <div class="table-container">\n <table class="table is-narrow is-fullwidth is-hoverable">\n <thead>\n <tr>\n <th><input id="selectAll" class="checkbox" type="checkbox" title="Select all" data-action="select-all"></th>\n <th title="Key: username">Username</th>\n <th>Uploads</th>\n <th>Usage</th>\n <th title="Key: permission">Group</th>\n <th title="Key: registration">Registration date</th>\n <th title="Key: timestamp">Last token update</th>\n <th></th>\n </tr>\n </thead>\n <tbody id="table">\n </tbody>\n </table>\n </div>\n '+l+"\n "+o+"\n "+r+"\n ";for(var d=document.querySelector("#table"),u=0;u<t.length;u++){var p=t[u],g=page.selected[page.currentView].includes(p.id);g||(c=!0);for(var m=null,b=Object.keys(p.groups),h=0;h<b.length&&p.groups[b[h]];h++)m=b[h];var v=!1!==p.enabled&&0!==p.enabled;page.cache[p.id]={username:p.username,groups:p.groups,enabled:v,displayGroup:m};var f=p.registration?page.getPrettyDate(new Date(1e3*p.registration)):"-",w=p.timestamp?page.getPrettyDate(new Date(1e3*p.timestamp)):"-",y=document.createElement("tr");y.dataset.id=p.id,y.innerHTML='\n <td class="controls"><input type="checkbox" class="checkbox" title="Select" data-index="'+u+'" data-action="select"'+(g?" checked":"")+"></td>\n <th"+(v?"":' class="has-text-grey"')+">"+p.username+"</td>\n <th>"+p.uploads+"</th>\n <td>"+page.getPrettyBytes(p.usage)+"</td>\n <td>"+m+"</td>\n <td>"+f+"</td>\n <td>"+w+'</td>\n <td class="controls has-text-right">\n <a class="button is-small is-primary is-outlined" title="Edit user" data-action="edit-user">\n <span class="icon">\n <i class="icon-pencil"></i>\n </span>\n </a>\n <a class="button is-small is-info is-outlined" title="'+(p.uploads?"View uploads":"User doesn't have uploads")+'" data-action="view-user-uploads" '+(p.uploads?"":"disabled")+'>\n <span class="icon">\n <i class="icon-docs"></i>\n </span>\n </a>\n <a class="button is-small is-dangerish is-outlined" title="'+(v?"Disable user":"User is disabled")+'" data-action="disable-user" '+(v?"":"disabled")+'>\n <span class="icon">\n <i class="icon-hammer"></i>\n </span>\n </a>\n <a class="button is-small is-danger is-outlined" title="Delete user" data-action="delete-user">\n <span class="icon">\n <i class="icon-trash"></i>\n </span>\n </a>\n </td>\n ',d.appendChild(y),page.checkboxes=d.querySelectorAll('.checkbox[data-action="select"]')}var k=document.querySelector("#selectAll");k&&!c&&(k.checked=!0,k.title="Unselect all"),page.fadeAndScroll(),page.updateTrigger(e.trigger,"active"),page.views[page.currentView].pageNum=t.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'<option value="'+e+'"'+(!(n[a+1]&&page.permissions[n[a+1]])?" disabled":"")+">"+e+"</option>"})).join("\n"),a=document.createElement("div");a.innerHTML='\n <div class="field">\n <label class="label">Username</label>\n <div class="controls">\n <input id="swalUsername" class="input" type="text">\n </div>\n </div>\n <div class="field">\n <label class="label">Password (optional)</label>\n <div class="controls">\n <input id="swalPassword" class="input" type="text">\n </div>\n </div>\n <div class="field">\n <label class="label">User group</label>\n <div class="control">\n <div class="select is-fullwidth">\n <select id="swalGroup">\n '+e+"\n </select>\n </div>\n </div>\n </div>\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 <p>Username: <b>"+e.data.username+"</b></p>\n <p>Password: <code>"+e.data.password+"</code></p>\n <p>User group: <b>"+e.data.group+"</b></p>\n ",swal({title:"Created a new user!",icon:"success",content:a}),page.getUsers(Object.assign(page.views.users,{pageNum:-1}))}})).catch(page.onAxiosError)}))},editUser:function(e){var a=page.cache[e];if(a){var n=Object.keys(page.permissions).map((function(e,n,t){return'<option value="'+e+'"'+(e===a.displayGroup?" selected":"")+(!(t[n+1]&&page.permissions[t[n+1]])?" disabled":"")+">"+e+"</option>"})).join("\n"),t=document.createElement("div");t.innerHTML='\n <div class="field">\n <p>User ID: '+e+'</p>\n </div>\n <div class="field">\n <label class="label">Username</label>\n <div class="controls">\n <input id="swalUsername" class="input" type="text" value="'+(a.username||"")+'">\n </div>\n </div>\n <div class="field">\n <label class="label">User group</label>\n <div class="control">\n <div class="select is-fullwidth">\n <select id="swalGroup">\n '+n+'\n </select>\n </div>\n </div>\n </div>\n <div class="field">\n <div class="control">\n <label class="checkbox">\n <input id="swalEnabled" type="checkbox" '+(a.enabled?"checked":"")+'>\n Enabled\n </label>\n </div>\n </div>\n <div class="field">\n <div class="control">\n <label class="checkbox">\n <input id="swalResetPassword" type="checkbox">\n Reset password\n </label>\n </div>\n </div>\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+="<p>"+a.username+" was renamed into: <b>"+e.data.update.username+"</b>.</p>",n=!1,s=e.data.update.username),e.data.update.password&&(t.innerHTML+="\n <p>"+s+"'s new password is:</p>\n <p><code>"+e.data.update.password+"</code></p>\n ",n=!1),e.data.update.enabled!==a.enabled&&(t.innerHTML+="<p>"+s+" has been "+(e.data.update.enabled?"enabled":"disabled")+"!</p>"),t.innerHTML||(t.innerHTML="<p>"+s+" was edited!</p>"),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[e];if(a&&a.enabled){var n=document.createElement("div");n.innerHTML="\n <p>You will be disabling a user named <b>"+page.cache[e].username+"</b>.</p>\n <p>Their files will remain.</p>\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[e].username+" has been disabled.","success",{buttons:!1,timer:1500}),page.getUsers(page.views.users)}})).catch(page.onAxiosError)}))}},deleteUser:function(e){if(page.cache[e]){var a=document.createElement("div");a.innerHTML="\n <p>You will be deleting a user named <b>"+page.cache[e].username+"</b>.<p>\n <p>Their files will remain, unless you choose otherwise.</p>\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[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+='<li><a class="button pagination-link '+(t===n?" is-current":"")+'" aria-label="Goto page '+t+'" data-action="page-goto" data-goto="'+(t-1)+'">'+t+"</a></li>"},l=function(){s+='\n <li><a class="button pagination-link" aria-label="Goto page 1" data-action="page-goto" data-goto="0">1</a></li>\n <li data-action="page-ellipsis"><span class="pagination-ellipsis">&hellip;</span></li>\n '},o=function(){s+='\n <li data-action="page-ellipsis"><span class="pagination-ellipsis">&hellip;</span></li>\n <li><a class="button pagination-link" aria-label="Goto page '+t+'" data-action="page-goto" data-goto="'+(t-1)+'">'+t+"</a></li>\n "};return 7>=t?i(1,t):n<6?(i(1,6),o()):n>t-6+1?(l(),i(t-6+1,t)):(l(),i(n-3+1,n+3-1),o()),'\n <nav class="pagination is-centered is-small">\n <a class="button pagination-previous" data-action="page-prev"'+(1===n?" disabled":"")+'>Previous</a>\n <a class="button pagination-next" data-action="page-next"'+(n>=t?" disabled":"")+'>Next page</a>\n <ul class="pagination-list">'+s+"</ul>\n </nav>\n "},getStatistics:function(e){if(void 0===e&&(e={}),!page.permissions.admin)return swal("An error occurred!","You cannot do this!","error");if(page.isSomethingLoading)return page.warnSomethingLoading();page.updateTrigger(e.trigger,"loading");axios.get("api/stats").then((function(a){if(!1===a.data.success)return"No token provided"===a.data.description?page.verifyToken(page.token):(page.updateTrigger(e.trigger),swal("An error occurred!",a.data.description,"error"));for(var n="",t=Object.keys(a.data.stats),s=0;s<t.length;s++){var i="";if(a.data.stats[t[s]])try{for(var l=a.data.stats[t[s]]._types||{},o=Object.keys(a.data.stats[t[s]]),r=0;r<o.length;r++)if(!/^_/.test(o[r])){var c=a.data.stats[t[s]][o[r]],d=c;(l.number||[]).includes(o[r])&&(d=c.toLocaleString()),(l.byte||[]).includes(o[r])&&(d=page.getPrettyBytes(c)),(l.byteUsage||[]).includes(o[r])&&(d=page.getPrettyBytes(c.used)+" / "+page.getPrettyBytes(c.total)+" ("+Math.round(c.used/c.total*100)+"%)"),i+='\n <tr>\n <th class="capitalize">'+o[r].replace(/([A-Z])/g," $1").replace(/(^|\s)(cpu|db|zip)/gi,(function(e){return e.toUpperCase()}))+"</th>\n <td>"+d+"</td>\n </tr>\n "}}catch(e){i="\n <tr>\n <td>Error parsing response. Try again?</td>\n <td></td>\n </tr>\n ",page.onError(e)}else i+="\n <tr>\n <td>Generating, please try again later…</td>\n <td></td>\n </tr>\n ";n+='\n <div class="table-container">\n <table id="statistics" class="table is-narrow is-fullwidth is-hoverable">\n <thead>\n <tr>\n <th class="capitalize">'+t[s]+"</th>\n <td></td>\n </tr>\n </thead>\n <tbody>\n "+i+"\n </tbody>\n </table>\n </div>\n "}page.dom.innerHTML=n,page.fadeAndScroll(),page.updateTrigger(e.trigger,"active")})).catch((function(a){page.updateTrigger(e.trigger),page.onAxiosError(a)}))}};window.addEventListener("DOMContentLoaded",(function(){"function"!=typeof Object.assign&&Object.defineProperty(Object,"assign",{value:function(e,a){"use strict";var n=arguments;if(null==e)throw new TypeError("Cannot convert undefined or null to object");for(var t=Object(e),s=1;s<arguments.length;s++){var i=n[s];if(null!=i)for(var l in i)Object.prototype.hasOwnProperty.call(i,l)&&(t[l]=i[l])}return t},writable:!0,configurable:!0}),"ontouchstart"in document.documentElement||document.documentElement.classList.add("no-touch");for(var e=["uploads","uploadsAll","albums","albumsAll","users"],a=0;a<e.length;a++){var n=localStorage[lsKeys.selected[e[a]]];n&&(page.selected[e[a]]=JSON.parse(n))}page.preparePage(),page.clipboardJS=new ClipboardJS(".clipboard-js"),page.clipboardJS.on("success",(function(){return swal("","The link has been copied to clipboard.","success",{buttons:!1,timer:1500})})),page.clipboardJS.on("error",page.onError),page.lazyLoad=new LazyLoad}));
//# sourceMappingURL=dashboard.js.map