mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2024-12-13 16:06:21 +00:00
9e9b0d4439
Updated some dev dependencies. --- Gulp will now build CSS/JS files during development into dist-dev directory, to prevent IDE's Git from unnecessarily building diff's. Added dist-dev to ignore files. --- The entire config fille will now be passed to Nunjuck templates for ease of access of config values. Root domain for use in Nunjuck templates will now be parsed from config. Better page titles. Updated help message for "Uploads history order" option in homepage's config tab. Added "Load images for preview" option to homepage's config tab. Setting this to false will now prevent image uploads from loading themselves for previews. Uploads' original names in homepage's uploads history are now selectable. Min/max length for user/pass are now enforced in auth's front-end. Improved performance of album public pages. Their generated HTML pages will now be cached into memory. Unfortunately, No-JS version of their pages will be cached separately, so each album may take up to double the memory space. File names in thumbnails no longer have their full URLs as tooltips. I saw no point in that behavior. Added video icons. Homepage's uploads history will now display video icons for videos. "View thumbnail" button in Dashboard is now renamed to "Show preview". Their icons will also be changed depending on their file types. Added max length for albums' title & description. These will be enforced both in front-end and back-end. Existing albums that have surpassed the limits will not be enforced. A few other small improvements.
1 line
42 KiB
Plaintext
1 line
42 KiB
Plaintext
{"version":3,"sources":["home.js"],"names":["const","lsKeys","token","chunkSize","parallelUploads","uploadsHistoryOrder","previewImages","fileLength","uploadAge","page","localStorage","private","enableUserAccounts","maxSize","temporaryUploadAges","fileIdentifierLength","album","maxSizeBytes","urlMaxSize","urlMaxSizeBytes","tabs","activeTab","albumSelect","previewTemplate","dropzone","clipboardJS","lazyLoad","imageExts","videoExts","albumTitleMaxLength","albumDescMaxLength","onInitError","error","console","document","querySelector","classList","add","querySelectorAll","forEach","element","uploadButton","innerText","remove","addEventListener","location","reload","response","onUnexpectedError","statusText","520","521","522","523","524","525","526","527","530","status","description","data","swal","skipLog","content","createElement","innerHTML","toString","title","icon","checkIfPublic","onFailure","let","renderShown","axios","get","onDownloadProgress","doRender","then","parseInt","preparePage","catch","prepareUpload","verifyToken","button","href","reloadOnError","post","success","text","removeItem","value","prepareShareX","fetchAlbums","prepareUploadConfig","getPrettyBytes","prepareDropzone","event","uploadUrls","currentTarget","tabsContainer","loop","i","id","dataset","tabContent","setActiveTab","push","tab","length","index","headers","Array","isArray","albums","option","name","appendChild","previewNode","parentNode","removeChild","tabDiv","div","className","previewsContainer","Dropzone","body","url","paramName","clickable","maxFilesize","uploadMultiple","createImageThumbnails","autoProcessQueue","chunking","Boolean","parallelChunkUploads","chunksUploaded","file","done","previewElement","setAttribute","files","uuid","upload","original","type","albumid","filelength","age","updateTemplate","on","xhr","chunked","setRequestHeader","progress","test","size","updateTemplateIcon","contains","urls","split","filter","trim","join","map","firstChild","posted","result","removeAttribute","run","templateElement","iconClass","iconElement","a","clipboard","clipboardText","parentElement","exec","extname","toLowerCase","includes","img","src","onerror","update","expirydate","expiryDate","getPrettyDate","Date","createAlbum","buttons","cancel","confirm","closeModal","download","checked","public","selected","fallback","numConfig","min","max","fileLengthDiv","stored","default","helpText","range","force","disabled","isNaN","Object","keys","key","uploadAgeDiv","parseFloat","getPrettyUploadAge","form","preventDefault","siBytes","uploadFields","checkValidity","prefKeys","elements","numKeys","parsed","Math","hours","minutes","days","window","items","clipboardData","originalEvent","item","kind","blob","getAsFile","File","match","addFile","onload","ClipboardJS","LazyLoad","elements_selector"],"mappings":"AAEAA,IAAMC,OAAS,CACbC,MAAO,QACPC,UAAW,YACXC,gBAAiB,kBACjBC,oBAAqB,sBACrBC,cAAe,gBACfC,WAAY,aACZC,UAAW,aAGPC,KAAO,CAEXP,MAAOQ,aAAaT,OAAOC,OAG3BS,QAAS,KACTC,mBAAoB,KACpBC,QAAS,KACTV,UAAW,KACXW,oBAAqB,KACrBC,qBAAsB,KAGtBC,MAAO,KAEPZ,gBAAiB,KACjBE,cAAe,KACfC,WAAY,KACZC,UAAW,KAEXS,aAAc,KACdC,WAAY,KACZC,gBAAiB,KAEjBC,KAAM,GACNC,UAAW,KACXC,YAAa,KACbC,gBAAiB,KAEjBC,SAAU,KACVC,YAAa,KACbC,SAAU,KAIVC,UAAW,CAAC,QAAS,O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AEvC,OAAUF,EAAK,SAAkB,IAAVA,EAAc,GAAK,OAK9CG,OAAO1L,iBAAiB,SAAO,SAAEqD,GAG/B,IAFAjG,IAAMuO,GAAStI,EAAMuI,eAAiBvI,EAAMwI,cAAcD,eAAeD,MACnEzH,EAAQqG,OAAOC,KAAKmB,GACjBjI,EAAI,EAAGA,EAAIQ,EAAMD,OAAQP,IAAK,CACrCtG,IAAM0O,EAAOH,EAAMzH,EAAMR,IACzB,GAAkB,SAAdoI,EAAKC,KAAiB,CACxB3O,IAAM4O,EAAOF,EAAKG,YACZnG,EAAO,IAAIoG,KAAK,CAACF,GAAO,gBAAgBA,EAAK1F,KAAK6F,MAAM,uBAAsB,GAAM,CACxF7F,KAAM0F,EAAK1F,OAEbzI,KAAKe,SAASwN,QAAQtG,QAK5B4F,OAAOW,OAAM,WACXxO,KAAK6D,gBAEL7D,KAAKgB,YAAc,IAAIyN,YAAY,iBAEnCzO,KAAKgB,YAAY8H,GAAG,WAAS,WAC3B,OAAOzF,KAAK,UAAW,yCAA0C,cAGnErD,KAAKgB,YAAY8H,GAAG,QAAS9I,KAAKuC,mBAElCvC,KAAKiB,SAAW,IAAIyN,SAAS,CAC3BC,kBAAmB,uBAGrBlN,SAASC,cAAc,gBAAgBS,iBAAiB,SAAO,WAC7DnC,KAAKqL","file":"home.js","sourcesContent":["/* global swal, axios, Dropzone, ClipboardJS, LazyLoad */\n\nconst lsKeys = {\n token: 'token',\n chunkSize: 'chunkSize',\n parallelUploads: 'parallelUploads',\n uploadsHistoryOrder: 'uploadsHistoryOrder',\n previewImages: 'previewImages',\n fileLength: 'fileLength',\n uploadAge: 'uploadAge'\n}\n\nconst page = {\n // user token\n token: localStorage[lsKeys.token],\n\n // configs from api/check\n private: null,\n enableUserAccounts: null,\n maxSize: null,\n chunkSize: null,\n temporaryUploadAges: null,\n fileIdentifierLength: null,\n\n // store album id that will be used with upload requests\n album: null,\n\n parallelUploads: null,\n previewImages: null,\n fileLength: null,\n uploadAge: null,\n\n maxSizeBytes: null,\n urlMaxSize: null,\n urlMaxSizeBytes: null,\n\n tabs: [],\n activeTab: null,\n albumSelect: null,\n previewTemplate: null,\n\n dropzone: null,\n clipboardJS: null,\n lazyLoad: null,\n\n // Include BMP for uploads preview only, cause the real images will be used\n // Sharp isn't capable of making their thumbnails for dashboard and album public pages\n imageExts: ['.webp', '.jpg', '.jpeg', '.bmp', '.gif', '.png', '.tiff', '.tif', '.svg'],\n videoExts: ['.webm', '.mp4', '.wmv', '.avi', '.mov', '.mkv'],\n\n albumTitleMaxLength: 280,\n albumDescMaxLength: 4000\n}\n\n// Error handler for all API requests on init\npage.onInitError = error => {\n console.error(error)\n\n // Hide these elements\n document.querySelector('#albumDiv').classList.add('is-hidden')\n document.querySelector('#tabs').classList.add('is-hidden')\n document.querySelectorAll('.tab-content').forEach(element => {\n return element.classList.add('is-hidden')\n })\n\n // Update upload button\n const uploadButton = document.querySelector('#loginToUpload')\n uploadButton.innerText = 'An error occurred. Try to reload?'\n uploadButton.classList.remove('is-loading')\n uploadButton.classList.remove('is-hidden')\n\n uploadButton.addEventListener('click', () => {\n location.reload()\n })\n\n // Defer to the other handler if not API errors\n if (!error.response)\n return page.onUnexpectedError(error, true)\n\n // Better error messages for 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 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 : 'Please check the console for more information.'\n return swal(`${error.response.status} ${statusText}`, description, 'error')\n}\n\n// Error handler for all other unexpected errors\npage.onUnexpectedError = (error, skipLog) => {\n if (!skipLog) console.error(error)\n\n if (error.response)\n return swal('An error occurred!', 'There was an error with the request, please check the console for more information.', '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\npage.checkIfPublic = onFailure => {\n let renderShown = false\n return axios.get('api/check', {\n onDownloadProgress: () => {\n // Only show render after this request has been initiated\n if (!renderShown && typeof page.doRender === 'function') {\n page.doRender()\n renderShown = true\n }\n }\n }).then(response => {\n page.private = response.data.private\n page.enableUserAccounts = response.data.enableUserAccounts\n page.maxSize = parseInt(response.data.maxSize)\n page.maxSizeBytes = page.maxSize * 1e6\n page.chunkSize = parseInt(response.data.chunkSize)\n page.temporaryUploadAges = response.data.temporaryUploadAges\n page.fileIdentifierLength = response.data.fileIdentifierLength\n return page.preparePage(onFailure)\n }).catch(page.onInitError)\n}\n\npage.preparePage = () => {\n if (page.private)\n if (page.token) {\n return page.verifyToken(page.token, true)\n } else {\n const button = document.querySelector('#loginToUpload')\n button.href = 'auth'\n button.classList.remove('is-loading')\n if (page.enableUserAccounts)\n button.innerText = 'Anonymous upload is disabled. Log in to upload.'\n else\n button.innerText = 'Running in private mode. Log in to upload.'\n }\n else\n return page.prepareUpload()\n}\n\npage.verifyToken = (token, reloadOnError) => {\n return axios.post('api/tokens/verify', { token }).then(response => {\n if (response.data.success === false)\n return swal({\n title: 'An error occurred!',\n text: response.data.description,\n icon: 'error'\n }).then(() => {\n if (!reloadOnError) return\n localStorage.removeItem('token')\n location.reload()\n })\n\n localStorage.token = token\n page.token = token\n return page.prepareUpload()\n }).catch(page.onInitError)\n}\n\npage.prepareUpload = () => {\n // I think this fits best here because we need to check for a valid token before we can get the albums\n if (page.token) {\n // Display the album selection\n document.querySelector('#albumDiv').classList.remove('is-hidden')\n\n page.albumSelect = document.querySelector('#albumSelect')\n page.albumSelect.addEventListener('change', () => {\n page.album = parseInt(page.albumSelect.value)\n // Re-generate ShareX config file\n if (typeof page.prepareShareX === 'function')\n page.prepareShareX()\n })\n\n // Fetch albums\n page.fetchAlbums()\n }\n\n // Prepare & generate config tab\n page.prepareUploadConfig()\n\n // Update elements wherever applicable\n document.querySelector('#maxSize > span').innerHTML = page.getPrettyBytes(page.maxSizeBytes)\n document.querySelector('#loginToUpload').classList.add('is-hidden')\n\n if (!page.token && page.enableUserAccounts)\n document.querySelector('#loginLinkText').innerHTML = 'Create an account and keep track of your uploads'\n\n // Prepare & generate files upload tab\n page.prepareDropzone()\n\n // Generate ShareX config file\n if (typeof page.prepareShareX === 'function')\n page.prepareShareX()\n\n // Prepare urls upload tab\n const urlMaxSize = document.querySelector('#urlMaxSize')\n if (urlMaxSize) {\n page.urlMaxSize = parseInt(urlMaxSize.innerHTML)\n page.urlMaxSizeBytes = page.urlMaxSize * 1e6\n urlMaxSize.innerHTML = page.getPrettyBytes(page.urlMaxSizeBytes)\n document.querySelector('#uploadUrls').addEventListener('click', event => {\n page.uploadUrls(event.currentTarget)\n })\n }\n\n // Get all tabs\n const tabsContainer = document.querySelector('#tabs')\n const tabs = tabsContainer.querySelectorAll('li')\n for (let i = 0; i < tabs.length; i++) {\n const id = tabs[i].dataset.id\n const tabContent = document.querySelector(`#${id}`)\n if (!tabContent) continue\n\n tabs[i].addEventListener('click', () => {\n page.setActiveTab(i)\n })\n page.tabs.push({ tab: tabs[i], content: tabContent })\n }\n\n // Set first valid tab as the default active tab\n if (page.tabs.length) {\n page.setActiveTab(0)\n tabsContainer.classList.remove('is-hidden')\n }\n}\n\npage.setActiveTab = index => {\n for (let i = 0; i < page.tabs.length; i++)\n if (i === index) {\n page.tabs[i].tab.classList.add('is-active')\n page.tabs[i].content.classList.remove('is-hidden')\n page.activeTab = index\n } else {\n page.tabs[i].tab.classList.remove('is-active')\n page.tabs[i].content.classList.add('is-hidden')\n }\n}\n\npage.fetchAlbums = () => {\n return axios.get('api/albums', { headers: { token: page.token } }).then(response => {\n if (response.data.success === false)\n return swal('An error occurred!', response.data.description, 'error')\n\n // Create an option for each album\n if (Array.isArray(response.data.albums) && response.data.albums.length)\n for (let i = 0; i < response.data.albums.length; i++) {\n const album = response.data.albums[i]\n const option = document.createElement('option')\n option.value = album.id\n option.innerHTML = album.name\n page.albumSelect.appendChild(option)\n }\n }).catch(page.onInitError)\n}\n\npage.prepareDropzone = () => {\n // Parse template element\n const previewNode = document.querySelector('#tpl')\n page.previewTemplate = previewNode.innerHTML\n previewNode.parentNode.removeChild(previewNode)\n\n // Generate files upload tab\n const tabDiv = document.querySelector('#tab-files')\n const div = document.createElement('div')\n div.className = 'control is-expanded'\n div.innerHTML = `\n <div id=\"dropzone\" class=\"button is-danger is-fullwidth is-unselectable\">\n <span class=\"icon\">\n <i class=\"icon-upload-cloud\"></i>\n </span>\n <span>Click here or drag & drop files</span>\n </div>\n `\n tabDiv.querySelector('.dz-container').appendChild(div)\n\n const previewsContainer = tabDiv.querySelector('#tab-files .field.uploads')\n\n page.dropzone = new Dropzone(document.body, {\n url: 'api/upload',\n paramName: 'files[]',\n clickable: tabDiv.querySelector('#dropzone'),\n maxFilesize: page.maxSizeBytes / 1024 / 1024, // this option expects MiB\n parallelUploads: page.parallelUploads,\n uploadMultiple: false,\n previewsContainer,\n previewTemplate: page.previewTemplate,\n createImageThumbnails: false,\n autoProcessQueue: true,\n headers: { token: page.token },\n chunking: Boolean(page.chunkSize),\n chunkSize: page.chunkSize * 1e6, // the option below expects Bytes\n parallelChunkUploads: false, // when set to true, it often hangs with hundreds of parallel uploads\n chunksUploaded (file, done) {\n file.previewElement.querySelector('.progress').setAttribute('value', 100)\n file.previewElement.querySelector('.progress').innerHTML = '100%'\n\n return axios.post('api/upload/finishchunks', {\n // This API supports an array of multiple files\n files: [{\n uuid: file.upload.uuid,\n original: file.name,\n type: file.type,\n albumid: page.album,\n filelength: page.fileLength,\n age: page.uploadAge\n }]\n }, { headers: { token: page.token } }).catch(error => {\n // Format error for display purpose\n return error.response.data ? error.response : {\n data: {\n success: false,\n description: error.toString()\n }\n }\n }).then(response => {\n file.previewElement.querySelector('.progress').classList.add('is-hidden')\n\n if (response.data.success === false)\n file.previewElement.querySelector('.error').innerHTML = response.data.description\n\n if (response.data.files && response.data.files[0])\n page.updateTemplate(file, response.data.files[0])\n\n return done()\n })\n }\n })\n\n page.dropzone.on('addedfile', file => {\n // Set active tab to file uploads, if necessary\n if (page.activeTab !== 0)\n page.setActiveTab(0)\n // Add file entry\n tabDiv.querySelector('.uploads').classList.remove('is-hidden')\n file.previewElement.querySelector('.name').innerHTML = file.name\n })\n\n page.dropzone.on('sending', (file, xhr) => {\n if (file.upload.chunked) return\n // Add headers if not uploading chunks\n if (page.album !== null) xhr.setRequestHeader('albumid', page.album)\n if (page.fileLength !== null) xhr.setRequestHeader('filelength', page.fileLength)\n if (page.uploadAge !== null) xhr.setRequestHeader('age', page.uploadAge)\n })\n\n // Update the total progress bar\n page.dropzone.on('uploadprogress', (file, progress) => {\n // For some reason, chunked uploads fire 100% progress event\n // for each chunk's successful uploads\n if (file.upload.chunked && progress === 100) return\n file.previewElement.querySelector('.progress').setAttribute('value', progress)\n file.previewElement.querySelector('.progress').innerHTML = `${progress}%`\n })\n\n page.dropzone.on('success', (file, response) => {\n if (!response) return\n file.previewElement.querySelector('.progress').classList.add('is-hidden')\n\n if (response.success === false)\n file.previewElement.querySelector('.error').innerHTML = response.description\n\n if (response.files && response.files[0])\n page.updateTemplate(file, response.files[0])\n })\n\n page.dropzone.on('error', (file, error) => {\n // Clean up file size errors\n if ((typeof error === 'string' && /^File is too big/.test(error)) ||\n (typeof error === 'object' && /File too large/.test(error.description)))\n error = `File too large (${page.getPrettyBytes(file.size)}).`\n\n page.updateTemplateIcon(file.previewElement, 'icon-block')\n file.previewElement.querySelector('.progress').classList.add('is-hidden')\n file.previewElement.querySelector('.name').innerHTML = file.name\n file.previewElement.querySelector('.error').innerHTML = error.description || error\n })\n}\n\npage.uploadUrls = button => {\n const tabDiv = document.querySelector('#tab-urls')\n if (!tabDiv || button.classList.contains('is-loading'))\n return\n\n button.classList.add('is-loading')\n\n function done (error) {\n if (error) swal('An error occurred!', error, 'error')\n button.classList.remove('is-loading')\n }\n\n function run () {\n const headers = {\n token: page.token,\n albumid: page.album,\n age: page.uploadAge,\n filelength: page.fileLength\n }\n\n const previewsContainer = tabDiv.querySelector('.uploads')\n const urls = document.querySelector('#urls').value\n .split(/\\r?\\n/)\n .filter(url => {\n return url.trim().length\n })\n document.querySelector('#urls').value = urls.join('\\n')\n\n if (!urls.length)\n return done('You have not entered any URLs.')\n\n tabDiv.querySelector('.uploads').classList.remove('is-hidden')\n const files = urls.map(url => {\n const previewTemplate = document.createElement('template')\n previewTemplate.innerHTML = page.previewTemplate.trim()\n const previewElement = previewTemplate.content.firstChild\n previewElement.querySelector('.name').innerHTML = url\n previewsContainer.appendChild(previewElement)\n return { url, previewElement }\n })\n\n function post (i) {\n if (i === files.length)\n return done()\n\n function posted (result) {\n files[i].previewElement.querySelector('.progress').classList.add('is-hidden')\n if (result.success) {\n page.updateTemplate(files[i], result.files[0])\n } else {\n page.updateTemplateIcon(files[i].previewElement, 'icon-block')\n files[i].previewElement.querySelector('.error').innerHTML = result.description\n }\n return post(i + 1)\n }\n\n // Animate progress bar\n files[i].previewElement.querySelector('.progress').removeAttribute('value')\n\n return axios.post('api/upload', { urls: [files[i].url] }, { headers }).then(response => {\n return posted(response.data)\n }).catch(error => {\n return posted({\n success: false,\n description: error.response ? error.response.data.description : error.toString()\n })\n })\n }\n return post(0)\n }\n return run()\n}\n\npage.updateTemplateIcon = (templateElement, iconClass) => {\n const iconElement = templateElement.querySelector('.icon')\n if (!iconElement) return\n iconElement.classList.add(iconClass)\n iconElement.classList.remove('is-hidden')\n}\n\npage.updateTemplate = (file, response) => {\n if (!response.url) return\n\n const a = file.previewElement.querySelector('.link > a')\n const clipboard = file.previewElement.querySelector('.clipboard-mobile > .clipboard-js')\n a.href = a.innerHTML = clipboard.dataset.clipboardText = response.url\n clipboard.parentElement.classList.remove('is-hidden')\n\n const exec = /.[\\w]+(\\?|$)/.exec(response.url)\n const extname = exec && exec[0]\n ? exec[0].toLowerCase()\n : null\n\n if (page.imageExts.includes(extname))\n if (page.previewImages) {\n const img = file.previewElement.querySelector('img')\n img.setAttribute('alt', response.name || '')\n img.dataset.src = response.url\n img.classList.remove('is-hidden')\n img.onerror = event => {\n // Hide image elements that fail to load\n // Consequently include WEBP in browsers that do not have WEBP support (e.i. IE)\n event.currentTarget.classList.add('is-hidden')\n page.updateTemplateIcon(file.previewElement, 'icon-picture')\n }\n page.lazyLoad.update(file.previewElement.querySelectorAll('img'))\n } else {\n page.updateTemplateIcon(file.previewElement, 'icon-picture')\n }\n else if (page.videoExts.includes(extname))\n page.updateTemplateIcon(file.previewElement, 'icon-video')\n else\n page.updateTemplateIcon(file.previewElement, 'icon-doc-inv')\n\n if (response.expirydate) {\n const expiryDate = file.previewElement.querySelector('.expiry-date')\n expiryDate.innerHTML = `EXP: ${page.getPrettyDate(new Date(response.expirydate * 1000))}`\n expiryDate.classList.remove('is-hidden')\n }\n}\n\npage.createAlbum = () => {\n const div = document.createElement('div')\n div.innerHTML = `\n <div class=\"field\">\n <div class=\"controls\">\n <input id=\"swalName\" 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=\"swalDescription\" class=\"textarea\" placeholder=\"Description\" rows=\"2\" 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 <label class=\"checkbox\">\n <input id=\"swalDownload\" type=\"checkbox\" 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\" checked>\n Enable public link\n </label>\n </div>\n </div>\n `\n\n swal({\n title: 'Create new album',\n icon: 'info',\n content: div,\n buttons: {\n cancel: true,\n confirm: {\n closeModal: false\n }\n }\n }).then(value => {\n if (!value) return\n\n const name = document.querySelector('#swalName').value.trim()\n axios.post('api/albums', {\n name,\n description: document.querySelector('#swalDescription').value.trim(),\n download: document.querySelector('#swalDownload').checked,\n public: document.querySelector('#swalPublic').checked\n }, {\n headers: {\n token: page.token\n }\n }).then(response => {\n if (response.data.success === false)\n return swal('An error occurred!', response.data.description, 'error')\n\n const option = document.createElement('option')\n page.albumSelect.appendChild(option)\n option.value = response.data.id\n option.innerHTML = name\n option.selected = true\n\n swal('Woohoo!', 'Album was created successfully.', 'success')\n }).catch(page.onUnexpectedError)\n })\n}\n\npage.prepareUploadConfig = () => {\n const fallback = {\n chunkSize: page.chunkSize,\n parallelUploads: 2\n }\n\n page.chunkSize = parseInt(localStorage[lsKeys.chunkSize]) || fallback.chunkSize\n page.parallelUploads = parseInt(localStorage[lsKeys.parallelUploads]) || fallback.parallelUploads\n document.querySelector('#chunkSize').value = page.chunkSize\n document.querySelector('#parallelUploads').value = page.parallelUploads\n\n const numConfig = {\n chunkSize: { min: 1, max: 95 },\n parallelUploads: { min: 1, max: 8 }\n }\n\n document.querySelector('#chunkSizeDiv .help').innerHTML =\n `Default is ${fallback.chunkSize} MB. Max is ${numConfig.chunkSize.max} MB.`\n document.querySelector('#parallelUploadsDiv .help').innerHTML =\n `Default is ${fallback.parallelUploads}. Max is ${numConfig.parallelUploads.max}.`\n\n const fileLengthDiv = document.querySelector('#fileLengthDiv')\n if (page.fileIdentifierLength && fileLengthDiv) {\n const element = document.querySelector('#fileLength')\n const stored = parseInt(localStorage[lsKeys.fileLength])\n\n fallback.fileLength = page.fileIdentifierLength.default\n let helpText = `Default is ${page.fileIdentifierLength.default}.`\n\n const range = typeof page.fileIdentifierLength.min === 'number' &&\n typeof page.fileIdentifierLength.max === 'number'\n\n if (range) {\n helpText += ` Min is ${page.fileIdentifierLength.min}. Max is ${page.fileIdentifierLength.max}`\n numConfig.fileLength = {\n min: page.fileIdentifierLength.min,\n max: page.fileIdentifierLength.max\n }\n }\n\n if (page.fileIdentifierLength.force) {\n helpText += ' This option is currently disabled.'\n element.disabled = true\n }\n\n if (page.fileIdentifierLength.force ||\n isNaN(stored) ||\n !range ||\n stored < page.fileIdentifierLength.min ||\n stored > page.fileIdentifierLength.max) {\n element.value = fallback.fileLength\n page.fileLength = null\n } else {\n element.value = stored\n page.fileLength = stored\n }\n\n fileLengthDiv.classList.remove('is-hidden')\n fileLengthDiv.querySelector('.help').innerHTML = helpText\n }\n\n Object.keys(numConfig).forEach(key => {\n document.querySelector(`#${key}`).setAttribute('min', numConfig[key].min)\n document.querySelector(`#${key}`).setAttribute('max', numConfig[key].max)\n })\n\n const uploadAgeDiv = document.querySelector('#uploadAgeDiv')\n if (Array.isArray(page.temporaryUploadAges) && page.temporaryUploadAges.length && uploadAgeDiv) {\n const element = document.querySelector('#uploadAge')\n const stored = parseFloat(localStorage[lsKeys.uploadAge])\n for (let i = 0; i < page.temporaryUploadAges.length; i++) {\n const age = page.temporaryUploadAges[i]\n const option = document.createElement('option')\n option.value = i === 0 ? 'default' : age\n option.innerHTML = page.getPrettyUploadAge(age) +\n (i === 0 ? ' (default)' : '')\n element.appendChild(option)\n if (age === stored) {\n element.value = option.value\n page.uploadAge = stored\n }\n }\n uploadAgeDiv.classList.remove('is-hidden')\n }\n\n const tabContent = document.querySelector('#tab-config')\n const form = tabContent.querySelector('form')\n form.addEventListener('submit', event => {\n event.preventDefault()\n })\n\n const siBytes = localStorage[lsKeys.siBytes] !== '0'\n if (!siBytes) document.querySelector('#siBytes').value = '0'\n\n const olderOnTop = localStorage[lsKeys.uploadsHistoryOrder] !== '0'\n if (!olderOnTop) {\n document.querySelector('#uploadsHistoryOrder').value = '0'\n const uploadFields = document.querySelectorAll('.tab-content > .uploads')\n for (let i = 0; i < uploadFields.length; i++)\n uploadFields[i].classList.add('is-reversed')\n }\n\n page.previewImages = localStorage[lsKeys.previewImages] !== '0'\n\n document.querySelector('#saveConfig').addEventListener('click', () => {\n if (!form.checkValidity())\n return\n\n const prefKeys = ['siBytes', 'uploadsHistoryOrder', 'previewImages', 'uploadAge']\n for (let i = 0; i < prefKeys.length; i++) {\n const value = form.elements[prefKeys[i]].value\n if (value !== 'default' && value !== fallback[prefKeys[i]])\n localStorage[lsKeys[prefKeys[i]]] = value\n else\n localStorage.removeItem(lsKeys[prefKeys[i]])\n }\n\n const numKeys = Object.keys(numConfig)\n for (let i = 0; i < numKeys.length; i++) {\n const parsed = parseInt(form.elements[numKeys[i]].value) || 0\n const value = Math.min(Math.max(parsed, numConfig[numKeys[i]].min), numConfig[numKeys[i]].max)\n if (value > 0 && value !== fallback[numKeys[i]])\n localStorage[lsKeys[numKeys[i]]] = value\n else\n localStorage.removeItem(lsKeys[numKeys[i]])\n }\n\n swal({\n title: 'Woohoo!',\n text: 'Configuration saved into this browser.',\n icon: 'success'\n }).then(() => {\n location.reload()\n })\n })\n}\n\npage.getPrettyUploadAge = hours => {\n if (hours === 0) {\n return 'Permanent'\n } else if (hours < 1) {\n const minutes = hours * 60\n return `${minutes} minute${minutes === 1 ? '' : 's'}`\n } else if (hours >= 24) {\n const days = hours / 24\n return `${days} day${days === 1 ? '' : 's'}`\n } else {\n return `${hours} hour${hours === 1 ? '' : 's'}`\n }\n}\n\n// Handle image paste event\nwindow.addEventListener('paste', event => {\n const items = (event.clipboardData || event.originalEvent.clipboardData).items\n const index = Object.keys(items)\n for (let i = 0; i < index.length; i++) {\n const item = items[index[i]]\n if (item.kind === 'file') {\n const blob = item.getAsFile()\n const file = new File([blob], `pasted-image.${blob.type.match(/(?:[^/]*\\/)([^;]*)/)[1]}`, {\n type: blob.type\n })\n page.dropzone.addFile(file)\n }\n }\n})\n\nwindow.onload = () => {\n page.checkIfPublic()\n\n page.clipboardJS = new ClipboardJS('.clipboard-js')\n\n page.clipboardJS.on('success', () => {\n return swal('Copied!', 'The link has been copied to clipboard.', 'success')\n })\n\n page.clipboardJS.on('error', page.onUnexpectedError)\n\n page.lazyLoad = new LazyLoad({\n elements_selector: '.field.uploads img'\n })\n\n document.querySelector('#createAlbum').addEventListener('click', () => {\n page.createAlbum()\n })\n}\n"]} |