mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2024-12-15 17:06:22 +00:00
24ed7c48bb
Bumped v1 version string
1 line
147 KiB
Plaintext
1 line
147 KiB
Plaintext
{"version":3,"sources":["dashboard.js"],"names":["const","lsKeys","token","viewType","uploads","uploadsAll","selected","albums","albumsAll","users","originalNames","page","section","dom","localStorage","username","permissions","menusContainer","menus","currentView","views","type","album","pageNum","filters","all","checkboxes","lastSelected","selectAlbumContainer","cache","clipboardJS","lazyLoad","imageExts","videoExts","isSomethingLoading","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","warnSomethingLoading","call","Object","assign","trigger","currentTarget","push","length","moderator","getAlbumsSidebar","prepareShareX","updateTrigger","timer","newState","parentNode","tagName","let","getItemID","element","parent","parseInt","dataset","id","includes","action","hasAttribute","stopPropagation","setUploadsView","toggleOriginalNames","addToAlbum","deleteUpload","addSelectedUploadsToAlbum","bulkDeleteUploads","displayPreview","uploadFiltersHelp","filterUploads","submitAlbum","editAlbum","disableAlbum","viewAlbumUploads","createUser","editUser","disableUser","deleteUser","viewUserUploads","getNewToken","clearSelection","select","selectAll","focusJumpToPage","switchPage","fadeAndScroll","disableFading","clearTimeout","setTimeout","scrollIntoView","behavior","block","inline","getByView","view","get","func","goto","jumpToPage","jumpid","checkValidity","parsed","value","isNaN","focus","url","undefined","test","minoffset","Date","getTimezoneOffset","pages","Math","ceil","count","files","autoPage","basedomain","max","pagination","paginate","extraControls","escape","controls","bottomExtraControls","replace","bottomPagination","unselected","showOriginalNames","hasExpiryDateColumn","some","file","expirydate","thumb","exec","extname","toLowerCase","name","original","prettyBytes","getPrettyBytes","size","prettyDate","getPrettyDate","timestamp","prettyExpiryDate","appendix","userid","albumid","table","upload","div","className","appendChild","querySelectorAll","allAlbums","tr","ip","checked","update","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","user","postBulkDeleteUploads","field","values","cb","failed","filter","textArea","seen","names","split","map","trimmed","prototype","hasOwnProperty","join","objective","dangerMode","cancel","fields","Array","isArray","addUploadsToAlbum","ids","callback","choose","added","list","getElementsByTagName","removeAttribute","homeDomain","createNewAlbum","albumUrl","enabled","download","public","requestLink","identifier","purge","sidebar","albumsContainer","oldAlbums","li","a","sendNewPassword","pass","password","admin","displayGroup","groups","keys","registration","prettyTokenUpdate","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","s","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,OAAQ,iBACRC,UAAW,oBACXC,MAAO,iBAETC,cAAe,CACbN,QAAS,gBACTC,WAAY,qBAIVM,KAAO,CAEXC,QAAS,KAETC,IAAK,KAGLX,MAAOY,aAAab,OAAOC,OAG3Ba,SAAU,KACVC,YAAa,KAGbC,eAAgB,KAChBC,MAAO,GAEPC,YAAa,KACbC,MAAO,CAELhB,QAAS,CACPiB,KAAMP,aAAab,OAAOE,SAAS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MAAM,IAAIkQ,UAAU,8CAEtB,IADAnW,IAAMoW,EAAK9O,OAAOrB,GACTiB,EAAI,EAAGA,EAAIgP,UAAUvO,OAAQT,IAAK,CACzClH,IAAMqW,EAAaH,EAAUhP,GAC7B,GAAImP,MAAAA,EACF,IAAKrW,IAAMsW,KAAWD,EAEhB/O,OAAOmK,UAAUC,eAAerK,KAAKgP,EAAYC,KACnDF,EAAGE,GAAWD,EAAWC,IAEjC,OAAOF,GAETG,UAAU,EACVC,cAAc,IAIZ,iBAAkBjU,SAASkU,iBAC/BlU,SAASkU,gBAAgBhU,UAAUC,IAAI,YAGzC,IADA1C,IAAM0W,EAAe,CAAC,UAAW,aAAc,SAAU,YAAa,SAC7DxP,EAAI,EAAGA,EAAIwP,EAAa/O,OAAQT,IAAK,CAC5ClH,IAAM2W,EAAK7V,aAAab,OAAOK,SAASoW,EAAaxP,KACjDyP,IAAIhW,KAAKL,SAASoW,EAAaxP,IAAM0I,KAAKgH,MAAMD,IAGtDhW,KAAK0D,cAEL1D,KAAKmB,YAAc,IAAI+U,YAAY,iBAEnClW,KAAKmB,YAAYgV,GAAG,WAAS,WAC3B,OAAO3T,KAAK,GAAI,yCAA0C,UAAW,CACnE2B,SAAS,EACTkD,MAAO,UAIXrH,KAAKmB,YAAYgV,GAAG,QAASnW,KAAKiC,SAElCjC,KAAKoB,SAAW,IAAIgV","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 albums: 'selectedAlbums',\n albumsAll: 'selectedAlbumsAll',\n users: 'selectedUsers'\n },\n originalNames: {\n uploads: 'originalNames',\n uploadsAll: 'originalNamesAll'\n }\n}\n\nconst page = {\n // #dashboard\n section: null,\n // #page\n dom: null,\n\n // user token\n token: localStorage[lsKeys.token],\n\n // from api/tokens/verify\n username: null,\n permissions: null,\n\n // sidebar menus\n menusContainer: null,\n menus: [],\n\n currentView: null,\n views: {\n // params of uploads view\n uploads: {\n type: localStorage[lsKeys.viewType.uploads],\n originalNames: localStorage[lsKeys.originalNames.uploads] === '1',\n album: null, // album's id\n pageNum: null\n },\n // params of uploads view (all)\n uploadsAll: {\n type: localStorage[lsKeys.viewType.uploadsAll],\n originalNames: localStorage[lsKeys.originalNames.uploadsAll] === '1',\n filters: null,\n pageNum: null,\n all: true\n },\n // params of albums view\n albums: {\n filters: null,\n pageNum: null\n },\n // params of albums view (all)\n albumsAll: {\n filters: null,\n pageNum: null,\n all: true\n },\n // params of users view\n users: {\n filters: null,\n pageNum: null\n }\n },\n\n // ids of selected items (shared across pages and will be synced with localStorage)\n selected: {\n uploads: [],\n uploadsAll: [],\n albums: [],\n albumsAll: [],\n users: []\n },\n checkboxes: [],\n lastSelected: [],\n\n // select album dom for dialogs/modals\n selectAlbumContainer: null,\n\n // cache for dialogs/modals\n cache: {},\n\n clipboardJS: null,\n lazyLoad: null,\n\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 isSomethingLoading: false,\n fadingIn: null,\n\n albumTitleMaxLength: 70,\n albumDescMaxLength: 4000\n}\n\npage.unhide = () => {\n document.querySelector('#loader').classList.add('is-hidden')\n page.section.classList.remove('is-hidden')\n}\n\n// Handler for regular JS errors\npage.onError = error => {\n console.error(error)\n\n const content = document.createElement('div')\n content.innerHTML = `<code>${error.toString()}</code>`\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 window.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.section = document.querySelector('#dashboard')\n page.dom = page.section.querySelector('#page')\n\n // Capture all click events\n page.dom.addEventListener('click', page.domClick, true)\n\n // Capture all submit events\n page.dom.addEventListener('submit', event => {\n // Prevent default if necessary\n if (event.target && event.target.classList.contains('prevent-default'))\n return event.preventDefault()\n }, true)\n\n page.menusContainer = document.querySelector('#menu')\n\n // All item menus in the sidebar\n const itemMenus = [\n { selector: '#itemUploads', onclick: page.getUploads },\n { selector: '#itemDeleteUploadsByNames', onclick: page.deleteUploadsByNames },\n { selector: '#itemManageYourAlbums', onclick: page.getAlbums },\n { selector: '#itemManageToken', onclick: page.changeToken },\n { selector: '#itemChangePassword', onclick: page.changePassword },\n { selector: '#itemLogout', onclick: page.logout },\n { selector: '#itemManageUploads', onclick: page.getUploads, params: { all: true }, group: 'moderator' },\n { selector: '#itemManageAlbums', onclick: page.getAlbums, params: { all: true }, group: 'moderator' },\n { selector: '#itemStatistics', onclick: page.getStatistics, group: 'admin' },\n { selector: '#itemManageUsers', onclick: page.getUsers, group: 'admin' }\n ]\n\n for (let i = 0; i < itemMenus.length; i++) {\n // Skip item menu if not enough permission\n if (itemMenus[i].group && !page.permissions[itemMenus[i].group])\n continue\n\n // Add onclick event listener\n const item = document.querySelector(itemMenus[i].selector)\n item.addEventListener('click', event => {\n if (page.isSomethingLoading)\n return page.warnSomethingLoading()\n\n // eslint-disable-next-line compat/compat\n itemMenus[i].onclick.call(null, Object.assign(itemMenus[i].params || {}, {\n trigger: event.currentTarget\n }))\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.warnSomethingLoading = () => {\n swal('Please wait!', 'Something else is still loading\\u2026', 'warning', {\n buttons: false,\n timer: 3000\n })\n}\n\npage.updateTrigger = (trigger, newState) => {\n if (!trigger) return\n\n // Disable menus container and pagination when loading\n if (newState === 'loading') {\n page.isSomethingLoading = true\n page.section.classList.add('is-loading')\n } else {\n page.section.classList.remove('is-loading')\n page.isSomethingLoading = false\n }\n\n if (newState === 'loading') {\n trigger.classList.add('is-loading')\n } else if (newState === 'active') {\n if (trigger.parentNode.tagName !== 'LI')\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 'toggle-original-names':\n return page.toggleOriginalNames(element)\n case 'add-to-album':\n return page.addToAlbum(id)\n case 'delete-upload':\n return page.deleteUpload(id)\n case 'add-selected-uploads-to-album':\n return page.addSelectedUploadsToAlbum()\n case 'bulk-delete-uploads':\n return page.bulkDeleteUploads()\n case 'display-preview':\n return page.displayPreview(id)\n // Manage uploads\n case 'upload-filters-help':\n return page.uploadFiltersHelp(element)\n case 'filter-uploads':\n return page.filterUploads(element)\n // Manage your albums\n case 'submit-album':\n return page.submitAlbum(element)\n case 'edit-album':\n return page.editAlbum(id)\n case 'disable-album':\n return page.disableAlbum(id)\n case 'view-album-uploads':\n return page.viewAlbumUploads(id, element)\n // Manage users\n case 'create-user':\n return page.createUser()\n case 'edit-user':\n return page.editUser(id)\n case 'disable-user':\n return page.disableUser(id)\n case 'delete-user':\n return page.deleteUser(id)\n case 'view-user-uploads':\n return page.viewUserUploads(id, element)\n // Others\n case 'get-new-token':\n return page.getNewToken(element)\n // Uploads & Users\n case 'clear-selection':\n return page.clearSelection()\n case 'select':\n return page.select(element, event)\n case 'select-all':\n return page.selectAll(element)\n case 'page-ellipsis':\n return page.focusJumpToPage(element)\n case 'page-prev':\n case 'page-next':\n case 'page-goto':\n case 'jump-to-page':\n return page.switchPage(action, element)\n }\n}\n\npage.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.getByView = (view, get) => {\n switch (view) {\n case 'uploads':\n case 'uploadsAll':\n return {\n type: 'uploads',\n func: page.getUploads\n }[get]\n case 'albums':\n case 'albumsAll':\n return {\n type: 'albums',\n func: page.getAlbums\n }[get]\n case 'users':\n return {\n type: 'users',\n func: page.getUsers\n }[get]\n default:\n return null\n }\n}\n\npage.switchPage = (action, element) => {\n if (page.isSomethingLoading)\n return page.warnSomethingLoading()\n\n // eslint-disable-next-line compat/compat\n const params = Object.assign(page.views[page.currentView], {\n trigger: element\n })\n\n const func = page.getByView(page.currentView, 'func')\n\n switch (action) {\n case 'page-prev':\n params.pageNum = page.views[page.currentView].pageNum - 1\n if (params.pageNum < 0)\n return swal('An error occurred!', 'This is already the first page.', 'error')\n return func(params)\n case 'page-next':\n params.pageNum = page.views[page.currentView].pageNum + 1\n return func(params)\n case 'page-goto':\n params.pageNum = parseInt(element.dataset.goto)\n return func(params)\n case 'jump-to-page': {\n const jumpToPage = document.querySelector(`#${element.dataset.jumpid || 'jumpToPage'}`)\n if (!jumpToPage.checkValidity()) return\n const parsed = parseInt(jumpToPage.value)\n params.pageNum = isNaN(parsed) ? 0 : (parsed - 1)\n if (params.pageNum < 0) params.pageNum = 0\n return func(params)\n }\n }\n}\n\npage.focusJumpToPage = element => {\n const jumpToPage = document.querySelector(`#${element.dataset.jumpid || 'jumpToPage'}`)\n if (!jumpToPage) return\n jumpToPage.focus()\n jumpToPage.select()\n}\n\npage.getUploads = (params = {}) => {\n if (params && params.all && !page.permissions.moderator)\n return swal('An error occurred!', 'You cannot do this!', 'error')\n\n if (page.isSomethingLoading)\n return page.warnSomethingLoading()\n\n page.updateTrigger(params.trigger, 'loading')\n\n if (typeof params.pageNum !== 'number' || params.pageNum < 0)\n params.pageNum = 0\n\n const url = params.album !== undefined\n ? `api/album/${params.album}/${params.pageNum}`\n : `api/uploads/${params.pageNum}`\n\n const headers = {}\n\n if (params.all)\n headers.all = '1'\n\n if (params.filters) {\n headers.filters = params.filters\n\n // Send client timezone offset if properly using date: and/or :expiry filters\n // Server will pretend client is on UTC if unset\n if (/(^|\\s)(date|expiry):[\\d\"]/.test(params.filters))\n headers.minoffset = new Date().getTimezoneOffset()\n }\n\n 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 page.updateTrigger(params.trigger)\n if (params.autoPage) {\n params.pageNum = pages - 1\n return page.getUploads(params)\n } else {\n return swal('An error occurred!', `There are no more uploads to populate page ${params.pageNum + 1}.`, 'error')\n }\n }\n\n page.currentView = params.all ? 'uploadsAll' : 'uploads'\n page.cache = {}\n\n const albums = response.data.albums\n const users = response.data.users\n const basedomain = response.data.basedomain\n\n if (params.pageNum < 0) params.pageNum = Math.max(0, pages + params.pageNum)\n const pagination = page.paginate(response.data.count, 25, params.pageNum)\n\n const filter = `\n <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(params.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\"${params.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 const extraControls = `\n <div class=\"columns\">\n ${filter}\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=\"${pages}\" value=\"${params.pageNum + 1}\"${pages === 1 ? ' 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 `\n\n const controls = `\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 ${params.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 `\n\n // Do some string replacements for bottom controls\n const bottomFiltersId = 'bFilters'\n const bottomJumpId = 'bJumpToPage'\n const bottomExtraControls = extraControls\n .replace(/id=\"filters\"/, `id=\"${bottomFiltersId}\"`)\n .replace(/(data-action=\"filter-uploads\")/, `$1 data-filtersid=\"${bottomFiltersId}\"`)\n .replace(/id=\"jumpToPage\"/, `id=\"${bottomJumpId}\"`)\n .replace(/(data-action=\"jump-to-page\")/g, `$1 data-jumpid=\"${bottomJumpId}\"`)\n const bottomPagination = pagination\n .replace(/(data-action=\"page-ellipsis\")/g, `$1 data-jumpid=\"${bottomJumpId}\"`)\n\n // Whether there are any unselected items\n let unselected = false\n\n const showOriginalNames = page.views[page.currentView].originalNames\n const hasExpiryDateColumn = files.some(file => {\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[files[i].id] = {\n name: files[i].name,\n original: files[i].original,\n thumb: files[i].thumb,\n file: 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 <div id=\"table\" class=\"columns is-multiline is-mobile is-centered\">\n </div>\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 = `<a class=\"image\" href=\"${upload.file}\" target=\"_blank\"><img alt=\"${upload.name}\" data-src=\"${upload.thumb}\"/></a>`\n else\n div.innerHTML = `<a class=\"image\" href=\"${upload.file}\" target=\"_blank\"><h1 class=\"title\">${upload.extname || 'N/A'}</h1></a>`\n\n div.innerHTML += `\n <input type=\"checkbox\" class=\"checkbox\" title=\"Select\" data-index=\"${i}\" data-action=\"select\"${upload.selected ? ' checked' : ''}>\n <div class=\"controls\">\n ${upload.thumb ? `\n <a class=\"button is-small is-primary\" title=\"Display preview\" data-action=\"display-preview\">\n <span class=\"icon\">\n <i class=\"${upload.type !== 'other' ? `icon-${upload.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=\"${upload.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=\"${upload.file}\">${upload.name}</p>\n ${showOriginalNames ? `<p class=\"originalname\" title=\"${upload.original}\">${upload.original}</p>` : ''}\n <p class=\"prettybytes\">${upload.appendix ? `<span>${upload.appendix}</span> – ` : ''}${upload.prettyBytes}</p>\n ${hasExpiryDateColumn && upload.prettyExpiryDate ? `\n <p class=\"prettyexpirydate\">EXP: ${upload.prettyExpiryDate}</p>` : ''}\n </div>\n `\n\n table.appendChild(div)\n page.checkboxes = table.querySelectorAll('.checkbox[data-action=\"select\"]')\n }\n } else {\n const allAlbums = params.all && params.filters && params.filters.includes('albumid:')\n page.dom.innerHTML = `\n ${pagination}\n ${extraControls}\n ${controls}\n <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 ${showOriginalNames ? '<th title=\"Key: original\">Original name</th>' : ''}\n ${params.album === undefined ? `<th title=\"Key: ${params.all ? 'userid\">User' : 'albumid\">Album'}</th>` : ''}\n ${allAlbums ? '<th title=\"Key: albumid\">Album</th>' : ''}\n <th title=\"Key: size\">Size</th>\n ${params.all ? '<th title=\"Key: ip\">IP</th>' : ''}\n <th title=\"Key: timestamp\">Upload date</th>\n ${hasExpiryDateColumn ? '<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 ${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 <td class=\"controls\"><input type=\"checkbox\" class=\"checkbox\" title=\"Select\" data-index=\"${i}\" data-action=\"select\"${upload.selected ? ' checked' : ''}></td>\n <th class=\"name\"><a href=\"${upload.file}\" target=\"_blank\" title=\"${upload.file}\">${upload.name}</a></th>\n ${showOriginalNames ? `<th class=\"originalname\" title=\"${upload.original}\">${upload.original}</th>` : ''}\n ${params.album === undefined ? `<th class=\"appendix\">${upload.appendix}</th>` : ''}\n ${allAlbums ? `<th class=\"album\">${upload.albumid ? (albums[upload.albumid] || '') : ''}</th>` : ''}\n <td class=\"prettybytes\">${upload.prettyBytes}</td>\n ${params.all ? `<td class=\"ip\">${upload.ip || ''}</td>` : ''}\n <td class=\"prettydate\">${upload.prettyDate}</td>\n ${hasExpiryDateColumn ? `<td class=\"prettyexpirydate\">${upload.prettyExpiryDate || '-'}</td>` : ''}\n <td class=\"controls has-text-right\">\n <a class=\"button is-small is-primary is-outlined\" title=\"${upload.thumb ? 'Display preview' : 'File can\\'t be previewed'}\" data-action=\"display-preview\"${upload.thumb ? '' : ' disabled'}>\n <span class=\"icon\">\n <i class=\"${upload.type !== 'other' ? `icon-${upload.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=\"${upload.file}\">\n <span class=\"icon\">\n <i class=\"icon-clipboard\"></i>\n </span>\n </a>\n ${params.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 `\n\n table.appendChild(tr)\n page.checkboxes = table.querySelectorAll('.checkbox[data-action=\"select\"]')\n }\n }\n\n const selectAll = document.querySelector('#selectAll')\n if (selectAll && !unselected && files.length) {\n selectAll.checked = true\n selectAll.title = 'Unselect all'\n }\n\n 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 page.views[page.currentView].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 if (page.isSomethingLoading)\n return page.warnSomethingLoading()\n\n if (view === 'list') {\n delete localStorage[lsKeys.viewType[page.currentView]]\n page.views[page.currentView].type = undefined\n } else {\n localStorage[lsKeys.viewType[page.currentView]] = view\n page.views[page.currentView].type = view\n }\n\n // eslint-disable-next-line compat/compat\n page.getUploads(Object.assign(page.views[page.currentView], {\n trigger: element\n }))\n}\n\npage.toggleOriginalNames = element => {\n if (page.isSomethingLoading)\n return page.warnSomethingLoading()\n\n if (page.views[page.currentView].originalNames) {\n delete localStorage[lsKeys.originalNames[page.currentView]]\n page.views[page.currentView].originalNames = false\n } else {\n localStorage[lsKeys.originalNames[page.currentView]] = '1'\n page.views[page.currentView].originalNames = true\n }\n\n // eslint-disable-next-line compat/compat\n page.getUploads(Object.assign(page.views[page.currentView], {\n trigger: element\n }))\n}\n\npage.displayPreview = id => {\n const file = page.cache[id]\n if (!file.thumb) return\n\n const div = document.createElement('div')\n div.innerHTML = `\n <div class=\"content has-text-centered\">\n <p>\n <div class=\"has-text-weight-bold\">${file.name}</div>\n <div>${file.original}</div>\n </p>\n <p class=\"swal-display-thumb-container\">\n <img id=\"swalThumb\" src=\"${file.thumb}\">\n </p>\n </div>\n `\n\n if (file.file) {\n const exec = /.[\\w]+(\\?|$)/.exec(file.file)\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 <div class=\"field has-text-right\">\n <div class=\"controls\">\n <a id=\"swalOriginal\" type=\"button\" class=\"button is-info\" data-original=\"${file.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\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.file\n thumb.onload = () => {\n trigger.classList.add('is-hidden')\n document.body.querySelector('.swal-overlay .swal-modal:not(.is-expanded)').classList.add('is-expanded')\n }\n thumb.onerror = event => {\n event.currentTarget.classList.add('is-hidden')\n trigger.className = 'button is-danger is-fullwidth'\n trigger.innerHTML = `\n <span class=\"icon\">\n <i class=\"icon-block\"></i>\n </span>\n <span>Unable to load original</span>\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.file\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.length; i++) {\n const id = page.getItemID(page.checkboxes[i])\n if (isNaN(id)) continue\n if (page.checkboxes[i].checked !== element.checked) {\n page.checkboxes[i].checked = element.checked\n if (page.checkboxes[i].checked)\n page.selected[page.currentView].push(id)\n else\n page.selected[page.currentView].splice(page.selected[page.currentView].indexOf(id), 1)\n }\n }\n\n 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.length; i++)\n if ((thisIndex > lastIndex && i > lastIndex && i < thisIndex) ||\n (thisIndex < lastIndex && i > thisIndex && i < lastIndex)) {\n // Check or uncheck depending on the state of the initial checkbox\n const checked = page.checkboxes[i].checked = lastElement.checked\n const id = page.getItemID(page.checkboxes[i])\n if (!page.selected[page.currentView].includes(id) && checked)\n page.selected[page.currentView].push(id)\n else if (page.selected[page.currentView].includes(id) && !checked)\n page.selected[page.currentView].splice(page.selected[page.currentView].indexOf(id), 1)\n }\n}\n\npage.select = (element, event) => {\n const id = page.getItemID(element)\n if (isNaN(id)) return\n\n if (event.shiftKey && page.lastSelected) {\n page.selectInBetween(element, page.lastSelected)\n // Check or uncheck depending on the state of the initial checkbox\n element.checked = page.lastSelected.checked\n } else {\n page.lastSelected = element\n }\n\n if (!page.selected[page.currentView].includes(id) && element.checked)\n page.selected[page.currentView].push(id)\n else if (page.selected[page.currentView].includes(id) && !element.checked)\n page.selected[page.currentView].splice(page.selected[page.currentView].indexOf(id), 1)\n\n // 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.getByView(page.currentView, 'type')\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\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 <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>${all ? '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 ${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 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 ${all ? `- 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>${all ? 'user:\"John Doe\"' : '*.txt'} sort:size</code>\n <code>*.mp4 ${all ? '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>')\n\n swal({ content }).then(() => {\n // Restore modal size\n document.body.querySelector('.swal-overlay .swal-modal').classList.remove('is-expanded')\n })\n\n // Expand modal size\n document.body.querySelector('.swal-overlay .swal-modal:not(.is-expanded)').classList.add('is-expanded')\n}\n\npage.filterUploads = element => {\n const filters = document.querySelector(`#${element.dataset.filtersid || 'filters'}`).value\n .trim()\n .replace(/\\t/g, ' ')\n .replace(/(^|\\s)((albumid|ip|user|date|expiry|is|sort|orderby):)\\s+/g, '$2')\n // eslint-disable-next-line compat/compat\n page.getUploads(Object.assign(page.views[page.currentView], {\n filters,\n pageNum: 0,\n trigger: element\n }))\n}\n\npage.viewUserUploads = (id, element) => {\n const user = page.cache[id]\n if (!user) return\n element.classList.add('is-loading')\n // Wrap username in quotes if it contains whitespaces\n const username = user.username.includes(' ')\n ? `\"${user.username}\"`\n : user.username\n page.getUploads({\n all: true,\n filters: `user:${username}`,\n trigger: document.querySelector('#itemManageUploads')\n })\n}\n\npage.viewAlbumUploads = (id, element) => {\n if (!page.cache[id]) return\n element.classList.add('is-loading')\n // eslint-disable-next-line compat/compat\n const all = page.currentView === 'albumsAll' && page.permissions.moderator\n page.getUploads({\n all,\n filters: `albumid:${id}`,\n trigger: all\n ? document.querySelector('#itemManageUploads')\n : document.querySelector('#itemUploads')\n })\n}\n\npage.deleteUpload = id => {\n page.postBulkDeleteUploads({\n all: page.currentView === 'uploadsAll',\n field: 'id',\n values: [id],\n cb (failed) {\n // Remove from remembered checkboxes if necessary\n if (!failed.length && page.selected[page.currentView].includes(id))\n page.selected[page.currentView].splice(page.selected[page.currentView].indexOf(id), 1)\n\n // 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 = '<br><b>Hint:</b> You can use this feature to delete uploads by other users.'\n\n 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.${appendix}</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 `\n page.fadeAndScroll()\n page.updateTrigger(params.trigger, 'active')\n\n document.querySelector('#submitBulkDelete').addEventListener('click', () => {\n if (page.isSomethingLoading)\n return page.warnSomethingLoading()\n\n const textArea = document.querySelector('#bulkDeleteNames')\n\n // Clean up\n const seen = {}\n const names = textArea.value\n .split(/\\r?\\n/)\n .map(name => {\n const trimmed = name.trim()\n return /^[^\\s]+$/.test(trimmed)\n ? trimmed\n : ''\n })\n .filter(name => {\n // Filter out invalid and duplicate names\n return (!name || Object.prototype.hasOwnProperty.call(seen, name))\n ? false\n : (seen[name] = true)\n })\n\n // Update textarea with cleaned names\n textArea.value = names.join('\\n')\n\n if (!names.length)\n return swal('An error occurred!', 'You have not entered any upload names.', 'error')\n\n 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*)(.*)/, '<b>$1</b>$2')\n let text = `<p>You won't be able to recover ${boldObjective}!</p>`\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<p><b>Warning:</b> You may be nuking ${obj1} by ${obj2}!</p>`\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 <div class=\"field has-text-centered\">\n <p>You are about to add <b>${count}</b> upload${count === 1 ? '' : '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\\u2026</option>\n </select>\n </div>\n </div>\n </div>\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 `<option value=\"${album.id}\">${album.name}</option>`\n })\n .join('\\n')\n\n select.getElementsByTagName('option')[1].innerHTML = 'Choose an album'\n select.removeAttribute('disabled')\n }).catch(page.onAxiosError)\n}\n\npage.getAlbums = (params = {}) => {\n if (params && params.all && !page.permissions.moderator)\n return swal('An error occurred!', 'You cannot do this!', 'error')\n\n if (page.isSomethingLoading)\n return page.warnSomethingLoading()\n\n page.updateTrigger(params.trigger, 'loading')\n\n if (typeof params.pageNum !== 'number')\n params.pageNum = 0\n\n const headers = {}\n\n if (params.all)\n headers.all = '1'\n\n const url = `api/albums/${params.pageNum}`\n axios.get(url, { headers }).then(response => {\n if (!response) return\n\n if (response.data.success === false)\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n page.updateTrigger(params.trigger)\n return swal('An error occurred!', response.data.description, 'error')\n }\n\n const pages = Math.ceil(response.data.count / 25)\n const albums = response.data.albums\n if (params.pageNum && (albums.length === 0)) {\n page.updateTrigger(params.trigger)\n if (params.autoPage) {\n params.pageNum = pages - 1\n return page.getAlbums(params)\n } else {\n return swal('An error occurred!', `There are no more albums to populate page ${params.pageNum + 1}.`, 'error')\n }\n }\n\n page.currentView = params.all ? 'albumsAll' : 'albums'\n page.cache = {}\n\n const users = response.data.users\n const homeDomain = response.data.homeDomain\n\n if (params.pageNum < 0) params.pageNum = Math.max(0, pages + params.pageNum)\n const pagination = page.paginate(response.data.count, 25, params.pageNum)\n\n const filter = `\n <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(params.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 const extraControls = `\n <div class=\"columns\">\n ${filter}\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=\"${pages}\" value=\"${params.pageNum + 1}\"${pages === 1 ? ' 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 `\n\n const controls = `\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 ${!params.all ? '<span>Bulk disable</span>' : ''}\n </a>\n ${params.all\n ? `<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 : ''}\n </div>\n </div>\n `\n\n // Do some string replacements for bottom controls\n const bottomFiltersId = 'bFilters'\n const bottomJumpId = 'bJumpToPage'\n const bottomExtraControls = extraControls\n .replace(/id=\"filters\"/, `id=\"${bottomFiltersId}\"`)\n .replace(/(data-action=\"filter-uploads\")/, `$1 data-filtersid=\"${bottomFiltersId}\"`)\n .replace(/id=\"jumpToPage\"/, `id=\"${bottomJumpId}\"`)\n .replace(/(data-action=\"jump-to-page\")/g, `$1 data-jumpid=\"${bottomJumpId}\"`)\n const bottomPagination = pagination\n .replace(/(data-action=\"page-ellipsis\")/g, `$1 data-jumpid=\"${bottomJumpId}\"`)\n\n // Whether there are any unselected items\n let unselected = false\n\n const createNewAlbum = `\n <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 `\n\n page.dom.innerHTML = `\n ${!params.all ? createNewAlbum : ''}\n ${pagination}\n ${extraControls}\n ${controls}\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 ${params.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 ${controls}\n ${bottomExtraControls}\n ${bottomPagination}\n `\n\n const table = document.querySelector('#table')\n\n for (let i = 0; i < albums.length; i++) {\n const album = albums[i]\n const albumUrl = `${homeDomain}/a/${album.identifier}`\n\n const selected = page.selected[page.currentView].includes(album.id)\n if (!selected) unselected = true\n\n // Prettify\n album.prettyDate = page.getPrettyDate(new Date(album.timestamp * 1000))\n\n // Server-side explicitly expect this value to consider an album as disabled\n const enabled = album.enabled !== 0\n page.cache[album.id] = {\n name: album.name,\n download: album.download,\n public: album.public,\n description: album.description,\n enabled\n }\n\n const tr = document.createElement('tr')\n tr.dataset.id = album.id\n tr.innerHTML = `\n <td class=\"controls\"><input type=\"checkbox\" class=\"checkbox\" title=\"Select\" data-index=\"${i}\" data-action=\"select\"${selected ? ' checked' : ''}></td>\n <th>${album.id}</th>\n <th${enabled ? '' : ' class=\"has-text-grey\"'}>${album.name}</td>\n ${params.all ? `<th>${album.userid ? (users[album.userid] || '') : ''}</th>` : ''}\n <th>${album.uploads}</th>\n <td>${album.prettyDate}</td>\n <td><a ${enabled && album.public ? '' : 'class=\"is-linethrough\" '}href=\"${albumUrl}\" target=\"_blank\">${albumUrl}</a></td>\n <td class=\"has-text-right\" data-id=\"${album.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=\"${album.uploads ? 'View uploads' : 'Album doesn\\'t have uploads'}\" data-action=\"view-album-uploads\" ${album.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\" ${album.public ? `data-clipboard-text=\"${albumUrl}\"` : '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\" ${enabled && album.download ? `href=\"api/album/zip/${album.identifier}?v=${album.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\"${enabled ? '' : ' disabled'}>\n <span class=\"icon is-small\">\n <i class=\"icon-trash\"></i>\n </span>\n </a>\n </td>\n `\n\n table.appendChild(tr)\n page.checkboxes = table.querySelectorAll('.checkbox[data-action=\"select\"]')\n }\n\n const selectAll = document.querySelector('#selectAll')\n if (selectAll && !unselected) {\n selectAll.checked = true\n selectAll.title = 'Unselect all'\n }\n\n page.fadeAndScroll()\n page.updateTrigger(params.trigger, 'active')\n\n if (page.currentView === 'albumsAll')\n page.views[page.currentView].filters = params.filters\n page.views[page.currentView].pageNum = albums.length ? params.pageNum : 0\n }).catch(error => {\n page.updateTrigger(params.trigger)\n page.onAxiosError(error)\n })\n}\n\npage.editAlbum = id => {\n const album = page.cache[id]\n if (!album) return\n\n const div = document.createElement('div')\n div.innerHTML = `\n <div class=\"field\">\n <div class=\"controls\">\n <input id=\"swalName\" class=\"input\" type=\"text\" placeholder=\"Name\" maxlength=\"${page.albumTitleMaxLength}\" value=\"${(album.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}\">${(album.description || '').substring(0, page.albumDescMaxLength)}</textarea>\n </div>\n <p class=\"help\">Max length is ${page.albumDescMaxLength} characters.</p>\n </div>\n ${page.currentView === 'albumsAll' && page.permissions.moderator\n ? `<div class=\"field\">\n <div class=\"control\">\n <label class=\"checkbox\">\n <input id=\"swalEnabled\" type=\"checkbox\" ${album.enabled ? 'checked' : ''}>\n Enabled\n </label>\n </div>\n </div>`\n : ''}\n <div class=\"field\">\n <div class=\"control\">\n <label class=\"checkbox\">\n <input id=\"swalDownload\" type=\"checkbox\" ${album.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\" ${album.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 `\n\n swal({\n title: 'Edit album',\n icon: 'info',\n content: div,\n buttons: {\n cancel: true,\n confirm: {\n closeModal: false\n }\n }\n }).then(value => {\n if (!value) return\n\n const post = {\n id,\n name: document.querySelector('#swalName').value.trim(),\n description: document.querySelector('#swalDescription').value.trim(),\n download: document.querySelector('#swalDownload').checked,\n public: document.querySelector('#swalPublic').checked,\n requestLink: document.querySelector('#swalRequestLink').checked\n }\n\n if (page.currentView === 'albumsAll' && page.permissions.moderator)\n post.enabled = document.querySelector('#swalEnabled').checked\n\n axios.post('api/albums/edit', post).then(response => {\n if (!response) return\n\n if (response.data.success === false)\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n return swal('An error occurred!', response.data.description, 'error')\n }\n\n if (response.data.identifier)\n swal('Success!', `The album's new identifier is: ${response.data.identifier}.`, 'success')\n else if (response.data.name !== album.name)\n swal('Success!', `The album was renamed to: ${response.data.name}.`, 'success')\n else\n swal('Success!', 'The album was edited.', 'success', {\n buttons: false,\n timer: 1500\n })\n\n page.getAlbumsSidebar()\n // Reload albums list\n // eslint-disable-next-line compat/compat\n page.getAlbums(Object.assign(page.views[page.currentView], {\n autoPage: true\n }))\n }).catch(page.onAxiosError)\n })\n}\n\npage.disableAlbum = id => {\n swal({\n title: 'Are you sure?',\n text: 'This won\\'t delete the uploads associated with the album!',\n icon: 'warning',\n dangerMode: true,\n buttons: {\n cancel: true,\n confirm: {\n text: 'Yes, disable it!',\n closeModal: false\n },\n purge: {\n text: 'Umm, delete the uploads 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/disable', {\n id,\n purge: proceed === 'purge'\n }).then(response => {\n if (response.data.success === false) {\n const failed = Array.isArray(response.data.failed)\n ? response.data.failed\n : []\n\n if (response.data.description === 'No token provided')\n return page.verifyToken(page.token)\n else if (failed.length)\n return swal('An error occurred!', `Unable to delete ${failed.length} of the album's upload${failed.length === 1 ? '' : 's'}.`, 'error')\n else\n return swal('An error occurred!', response.data.description, 'error')\n }\n\n swal('Deleted!', 'Your album has been disabled.', 'success', {\n buttons: false,\n timer: 1500\n })\n\n page.getAlbumsSidebar()\n // Reload albums list\n // eslint-disable-next-line compat/compat\n page.getAlbums(Object.assign(page.views[page.currentView], {\n autoPage: true\n }))\n }).catch(page.onAxiosError)\n })\n}\n\npage.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 pageNum: -1\n })\n }).catch(error => {\n page.updateTrigger(element)\n page.onAxiosError(error)\n })\n}\n\npage.getAlbumsSidebar = () => {\n axios.get('api/albums', { headers: { sidebar: '1' } }).then(response => {\n if (!response) return\n\n if (response.data.success === false)\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n return swal('An error occurred!', response.data.description, 'error')\n }\n\n const albums = response.data.albums\n const count = response.data.count\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 (albums === undefined)\n return\n\n for (let i = 0; i < albums.length; i++) {\n const album = albums[i]\n const li = document.createElement('li')\n const a = document.createElement('a')\n a.id = album.id\n a.className = 'is-relative'\n a.innerHTML = album.name\n\n a.addEventListener('click', event => {\n page.getUploads({\n album: parseInt(event.currentTarget.id),\n trigger: event.currentTarget\n })\n })\n page.menus.push(a)\n\n li.appendChild(a)\n albumsContainer.appendChild(li)\n }\n\n if (count > albums.length) {\n const li = document.createElement('li')\n const a = document.createElement('a')\n a.className = 'is-relative'\n a.innerHTML = '...'\n a.title = `You have ${count} albums, but the sidebar can only list your first ${albums.length} albums.`\n\n a.addEventListener('click', event => {\n page.getAlbums({\n trigger: document.querySelector('#itemManageYourAlbums')\n })\n })\n\n li.appendChild(a)\n albumsContainer.appendChild(li)\n }\n }).catch(page.onAxiosError)\n}\n\npage.changeToken = (params = {}) => {\n 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 `\n page.fadeAndScroll()\n page.updateTrigger(params.trigger, 'active')\n\n document.querySelector('#getNewToken').addEventListener('click', event => {\n if (page.isSomethingLoading)\n return page.warnSomethingLoading()\n\n const trigger = event.currentTarget\n page.updateTrigger(trigger, 'loading')\n axios.post('api/tokens/change').then(response => {\n if (response.data.success === false)\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n page.updateTrigger(trigger)\n return swal('An error occurred!', response.data.description, 'error')\n }\n\n 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 <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 `\n page.fadeAndScroll()\n page.updateTrigger(params.trigger, 'active')\n\n document.querySelector('#sendChangePassword').addEventListener('click', event => {\n if (page.isSomethingLoading)\n return page.warnSomethingLoading()\n\n if (!page.dom.querySelector('form').checkValidity())\n return\n\n if (document.querySelector('#password').value === document.querySelector('#passwordConfirm').value)\n page.sendNewPassword(document.querySelector('#password').value, event.currentTarget)\n else\n swal({\n title: 'Password mismatch!',\n text: 'Your passwords do not match, please try again.',\n icon: 'error'\n })\n })\n}\n\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 if (page.isSomethingLoading)\n return page.warnSomethingLoading()\n\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 if (typeof params.pageNum !== 'number')\n params.pageNum = 0\n\n const url = `api/users/${params.pageNum}`\n axios.get(url).then(response => {\n if (response.data.success === false)\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n page.updateTrigger(params.trigger)\n return swal('An error occurred!', response.data.description, 'error')\n }\n\n const pages = Math.ceil(response.data.count / 25)\n const users = response.data.users\n if (params.pageNum && (users.length === 0)) {\n page.updateTrigger(params.trigger)\n if (params.autoPage) {\n params.pageNum = pages - 1\n return page.getUsers(params)\n } else {\n return swal('An error occurred!', `There are no more users to populate page ${params.pageNum + 1}.`, 'error')\n }\n }\n\n page.currentView = 'users'\n page.cache = {}\n\n if (params.pageNum < 0) params.pageNum = Math.max(0, pages + params.pageNum)\n const pagination = page.paginate(response.data.count, 25, params.pageNum)\n\n const filter = `\n <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(params.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 const extraControls = `\n <div class=\"columns\">\n ${filter}\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=\"${pages}\" value=\"${params.pageNum + 1}\"${pages === 1 ? ' 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 `\n\n const controls = `\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 `\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 <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 ${controls}\n ${bottomExtraControls}\n ${bottomPagination}\n `\n\n const table = document.querySelector('#table')\n\n for (let i = 0; i < users.length; i++) {\n const user = users[i]\n const selected = page.selected[page.currentView].includes(user.id)\n if (!selected) unselected = true\n\n let displayGroup = null\n const groups = Object.keys(user.groups)\n for (let i = 0; i < groups.length; i++) {\n if (!user.groups[groups[i]]) break\n displayGroup = groups[i]\n }\n\n // Server-side explicitly expects either of these two values to consider a user as disabled\n const enabled = user.enabled !== false && user.enabled !== 0\n page.cache[user.id] = {\n username: user.username,\n groups: user.groups,\n enabled,\n displayGroup\n }\n\n const prettyDate = user.registration\n ? page.getPrettyDate(new Date(user.registration * 1000))\n : '-'\n const prettyTokenUpdate = user.timestamp\n ? page.getPrettyDate(new Date(user.timestamp * 1000))\n : '-'\n\n const tr = document.createElement('tr')\n tr.dataset.id = user.id\n tr.innerHTML = `\n <td class=\"controls\"><input type=\"checkbox\" class=\"checkbox\" title=\"Select\" data-index=\"${i}\" data-action=\"select\"${selected ? ' checked' : ''}></td>\n <th${enabled ? '' : ' class=\"has-text-grey\"'}>${user.username}</td>\n <th>${user.uploads}</th>\n <td>${page.getPrettyBytes(user.usage)}</td>\n <td>${displayGroup}</td>\n <td>${prettyDate}</td>\n <td>${prettyTokenUpdate}</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=\"${user.uploads ? 'View uploads' : 'User doesn\\'t have uploads'}\" data-action=\"view-user-uploads\" ${user.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=\"${enabled ? 'Disable user' : 'User is disabled'}\" data-action=\"disable-user\" ${enabled ? '' : '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 `\n\n table.appendChild(tr)\n page.checkboxes = table.querySelectorAll('.checkbox[data-action=\"select\"]')\n }\n\n const selectAll = document.querySelector('#selectAll')\n if (selectAll && !unselected) {\n selectAll.checked = true\n selectAll.title = 'Unselect all'\n }\n\n page.fadeAndScroll()\n page.updateTrigger(params.trigger, 'active')\n\n page.views[page.currentView].pageNum = 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 `<option value=\"${g}\"${disabled ? ' disabled' : ''}>${g}</option>`\n }).join('\\n')\n\n const div = document.createElement('div')\n div.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 ${groupOptions}\n </select>\n </div>\n </div>\n </div>\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 <p>Username: <b>${response.data.username}</b></p>\n <p>Password: <code>${response.data.password}</code></p>\n <p>User group: <b>${response.data.group}</b></p>\n `\n swal({\n title: 'Created a new user!',\n icon: 'success',\n content: div\n })\n\n // Load last page of users list\n // eslint-disable-next-line compat/compat\n page.getUsers(Object.assign(page.views.users, {\n pageNum: -1\n }))\n }).catch(page.onAxiosError)\n })\n}\n\npage.editUser = id => {\n const user = page.cache[id]\n if (!user) return\n\n 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 `<option value=\"${g}\"${selected ? ' selected' : ''}${disabled ? ' disabled' : ''}>${g}</option>`\n }).join('\\n')\n\n const div = document.createElement('div')\n div.innerHTML = `\n <div class=\"field\">\n <p>User ID: ${id}</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=\"${user.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 ${groupOptions}\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\" ${user.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 `\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 += `<p>${user.username} was renamed into: <b>${response.data.update.username}</b>.</p>`\n autoClose = false\n displayName = response.data.update.username\n }\n\n if (response.data.update.password) {\n div.innerHTML += `\n <p>${displayName}'s new password is:</p>\n <p><code>${response.data.update.password}</code></p>\n `\n autoClose = false\n }\n\n if (response.data.update.enabled !== user.enabled)\n div.innerHTML += `<p>${displayName} has been ${response.data.update.enabled ? 'enabled' : 'disabled'}!</p>`\n\n if (!div.innerHTML)\n div.innerHTML = `<p>${displayName} was edited!</p>`\n\n swal({\n title: 'Success!',\n icon: 'success',\n content: div,\n buttons: !autoClose,\n timer: autoClose ? 1500 : null\n })\n page.getUsers(page.views.users)\n }).catch(page.onAxiosError)\n })\n}\n\npage.disableUser = id => {\n const user = page.cache[id]\n if (!user || !user.enabled) return\n\n const content = document.createElement('div')\n content.innerHTML = `\n <p>You will be disabling a user named <b>${page.cache[id].username}</b>.</p>\n <p>Their files will remain.</p>\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[id].username} has been disabled.`, 'success', {\n buttons: false,\n timer: 1500\n })\n page.getUsers(page.views.users)\n }).catch(page.onAxiosError)\n })\n}\n\npage.deleteUser = id => {\n const user = page.cache[id]\n if (!user) return\n\n const content = document.createElement('div')\n content.innerHTML = `\n <p>You will be deleting a user named <b>${page.cache[id].username}</b>.<p>\n <p>Their files will remain, unless you choose otherwise.</p>\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[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 += `<li><a class=\"button pagination-link ${i === currentPage ? ' is-current' : ''}\" aria-label=\"Goto page ${i}\" data-action=\"page-goto\" data-goto=\"${i - 1}\">${i}</a></li>`\n },\n startDots () {\n template += `\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\">…</span></li>\n `\n },\n endDots () {\n template += `\n <li data-action=\"page-ellipsis\"><span class=\"pagination-ellipsis\">…</span></li>\n <li><a class=\"button pagination-link\" aria-label=\"Goto page ${numPages}\" data-action=\"page-goto\" data-goto=\"${numPages - 1}\">${numPages}</a></li>\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 <nav class=\"pagination is-centered is-small\">\n <a class=\"button pagination-previous\" data-action=\"page-prev\"${currentPage === 1 ? ' disabled' : ''}>Previous</a>\n <a class=\"button pagination-next\" data-action=\"page-next\"${currentPage >= numPages ? ' disabled' : ''}>Next page</a>\n <ul class=\"pagination-list\">${template}</ul>\n </nav>\n `\n}\n\npage.getStatistics = (params = {}) => {\n if (!page.permissions.admin)\n return swal('An error occurred!', 'You cannot do this!', 'error')\n\n if (page.isSomethingLoading)\n return page.warnSomethingLoading()\n\n page.updateTrigger(params.trigger, 'loading')\n\n const url = 'api/stats'\n axios.get(url).then(response => {\n if (response.data.success === false)\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n page.updateTrigger(params.trigger)\n return swal('An error occurred!', response.data.description, 'error')\n }\n\n 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 <tr>\n <td>Generating, please try again later\\u2026</td>\n <td></td>\n </tr>\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 .replace(/(^|\\s)(cpu|db|zip)/gi, s => s.toUpperCase())\n rows += `\n <tr>\n <th class=\"capitalize\">${string}</th>\n <td>${parsed}</td>\n </tr>\n `\n }\n } catch (error) {\n rows = `\n <tr>\n <td>Error parsing response. Try again?</td>\n <td></td>\n </tr>\n `\n page.onError(error)\n }\n\n content += `\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\">${keys[i]}</th>\n <td></td>\n </tr>\n </thead>\n <tbody>\n ${rows}\n </tbody>\n </table>\n </div>\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.addEventListener('DOMContentLoaded', () => {\n // Polyfill Object.assign()\n // eslint-disable-next-line compat/compat\n if (typeof Object.assign !== 'function')\n // Must be writable: true, enumerable: false, configurable: true\n Object.defineProperty(Object, 'assign', {\n value: function assign (target, varArgs) { // .length of function is 2\n 'use strict'\n if (target === null || 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', 'albums', 'albumsAll', 'users']\n for (let i = 0; i < selectedKeys.length; i++) {\n const ls = localStorage[lsKeys.selected[selectedKeys[i]]]\n if (ls) page.selected[selectedKeys[i]] = JSON.parse(ls)\n }\n\n page.preparePage()\n\n page.clipboardJS = new ClipboardJS('.clipboard-js')\n\n page.clipboardJS.on('success', () => {\n return swal('', 'The link has been copied to clipboard.', 'success', {\n buttons: false,\n timer: 1500\n })\n })\n\n page.clipboardJS.on('error', page.onError)\n\n page.lazyLoad = new LazyLoad()\n})\n"]} |