filesafe/dist/js/home.js.map
Bobby Wibowo 4d308206c7
Updated
Added new option "Uploads history order" into homepage's config tab.
When set to "Newer files on top", this will use flex-direction CSS
property to reverse sort the uploads history.

Added new entires to todo.md.

Bumped v1 version string.
2019-09-15 14:20:55 +07:00

1 line
40 KiB
Plaintext

{"version":3,"sources":["home.js"],"names":["const","lsKeys","token","chunkSize","parallelUploads","uploadsHistoryOrder","fileLength","uploadAge","page","localStorage","private","enableUserAccounts","maxSize","temporaryUploadAges","fileIdentifierLength","album","maxSizeBytes","urlMaxSize","urlMaxSizeBytes","tabs","activeTab","albumSelect","previewTemplate","dropzone","clipboardJS","lazyLoad","imageExtensions","checkIfPublic","onFailure","axios","get","then","response","data","parseInt","preparePage","catch","prepareUpload","verifyToken","button","document","querySelector","href","classList","remove","innerText","reloadOnError","post","success","swal","title","text","description","icon","removeItem","location","reload","addEventListener","value","prepareShareX","fetchAlbums","prepareUploadConfig","innerHTML","getPrettyBytes","add","prepareDropzone","event","uploadUrls","currentTarget","tabsContainer","querySelectorAll","loop","i","id","dataset","tabContent","setActiveTab","push","tab","content","length","index","let","headers","Array","isArray","albums","option","createElement","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","error","toString","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","includes","toLowerCase","img","src","onerror","update","expirydate","expiryDate","getPrettyDate","Date","createAlbum","buttons","cancel","confirm","closeModal","download","checked","public","selected","console","fallback","numConfig","min","max","fileLengthDiv","element","stored","default","helpText","range","force","disabled","isNaN","Object","keys","forEach","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","undefined","uploadButton","statusText","520","521","522","523","524","525","526","527","530","status","ClipboardJS","LazyLoad","elements_selector"],"mappings":"AAEAA,IAAMC,OAAS,CACbC,MAAO,QACPC,UAAW,YACXC,gBAAiB,kBACjBC,oBAAqB,sBACrBC,WAAY,aACZC,UAAW,aAGPC,KAAO,CAEXN,MAAOO,aAAaR,OAAOC,OAG3BQ,QAAS,KACTC,mBAAoB,KACpBC,QAAS,KACTT,UAAW,KACXU,oBAAqB,KACrBC,qBAAsB,KAGtBC,MAAO,KAEPX,gBAAiB,KACjBC,oBAAqB,KACrBC,WAAY,KACZC,UAAW,KAEXS,aAAc,KACdC,WAAY,KACZC,gBAAiB,KAEjBC,KAAM,GACNC,UAAW,KACXC,YAAa,KACbC,gBAAiB,KAEjBC,SAAU,KACVC,YAAa,KACbC,SAAU,KAEVC,gBAAiB,CAAC,QAAS,OAAQ,QAAS,OAAQ,OAAQ,OAAQ,QAGtEC,cAAkB,SAAGC,GACnB,OAAOC,MAAMC,IAAI,aACdC,MAAI,SAACC,GAQJ,OAPAxB,KAAKE,QAAUsB,EAASC,KAAKvB,QAC7BF,KAAKG,mBAAqBqB,EAASC,KAAKtB,mBACxCH,KAAKI,QAAUsB,SAASF,EAASC,KAAKrB,SACtCJ,KAAKQ,aAA8B,IAAfR,KAAKI,QACzBJ,KAAKL,UAAY+B,SAASF,EAASC,KAAK9B,WACxCK,KAAKK,oBAAsBmB,EAASC,KAAKpB,oBACzCL,KAAKM,qBAAuBkB,EAASC,KAAKnB,qBACnCN,KAAK2B,YAAYP,MAEzBQ,MAAMR,IAGXO,YAAgB,SAAGP,GACjB,IAAIpB,KAAKE,QAaP,OAAOF,KAAK6B,cAAcT,GAZ1B,GAAIpB,KAAKN,MACP,OAAOM,KAAK8B,YAAY9B,KAAKN,MAAO0B,GA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,aAE9BgL,EAAanK,iBAAiB,SAAO,WACnCF,SAASC,YAIPmE,EAAM3F,SAAU,CAClB6I,QAAQlD,MAAMA,EAAM3F,UAEpBhC,IAWM6N,EAXmB,CACvBC,IAAK,gBACLC,IAAK,qBACLC,IAAK,uBACLC,IAAK,wBACLC,IAAK,qBACLC,IAAK,uBACLC,IAAK,0BACLC,IAAK,gBACLC,IAAK,oBAE6B3G,EAAM3F,SAASuM,SAAW5G,EAAM3F,SAAS6L,WACvEzK,EAAcuE,EAAM3F,SAASC,MAAQ0F,EAAM3F,SAASC,KAAKmB,YAC3DuE,EAAM3F,SAASC,KAAKmB,YACpB,iDACJ,OAAOH,KAAQ0E,EAAM3F,SAAS,OAAM,IAAI6L,EAAczK,EAAa,SAEnEpD,IAAM+E,EAAUvC,SAASgD,cAAc,OAEvC,OADAT,EAAQjB,UAAY,SAAS6D,EAAMC,WAAU,UACtC3E,KAAK,CACVC,MAAO,qBACPG,KAAM,QA/BN0B,QAgCAA,KAKNvE,KAAKmB,cAAcC,GAEnBpB,KAAKgB,YAAc,IAAIgN,YAAY,iBAEnChO,KAAKgB,YAAYsG,GAAG,WAAS,WAC3B,OAAO7E,KAAK,UAAW,yCAA0C,cAGnEzC,KAAKgB,YAAYsG,GAAG,QAASlG,GAE7BpB,KAAKiB,SAAW,IAAIgN,SAAS,CAC3BC,kBAAmB,uBAGrBlM,SAASC,cAAc,gBAAgBgB,iBAAiB,SAAO,WAC7DjD,KAAK4J","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 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 uploadsHistoryOrder: 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 imageExtensions: ['.webp', '.jpg', '.jpeg', '.bmp', '.gif', '.png', '.svg']\n}\n\npage.checkIfPublic = onFailure => {\n return axios.get('api/check')\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 })\n .catch(onFailure)\n}\n\npage.preparePage = onFailure => {\n if (page.private)\n if (page.token) {\n return page.verifyToken(page.token, onFailure, 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(onFailure)\n}\n\npage.verifyToken = (token, onFailure, 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(onFailure)\n }).catch(onFailure)\n}\n\npage.prepareUpload = onFailure => {\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(onFailure)\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 = onFailure => {\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(onFailure)\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 if (exec && exec[0] && page.imageExtensions.includes(exec[0].toLowerCase())) {\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-doc-inv')\n }\n\n if (response.expirydate) {\n const expiryDate = file.previewElement.querySelector('.expiry-date')\n expiryDate.innerHTML = `Expiry date: ${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\">\n </div>\n </div>\n <div class=\"field\">\n <div class=\"control\">\n <textarea id=\"swalDescription\" class=\"textarea\" placeholder=\"Description\" rows=\"2\"></textarea>\n </div>\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(error => {\n console.error(error)\n return swal('An error occurred!', 'There was an error with the request, please check the console for more information.', 'error')\n })\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 document.querySelector('#saveConfig').addEventListener('click', () => {\n if (!form.checkValidity())\n return\n\n const prefKeys = ['siBytes', 'uploadsHistoryOrder', '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 // Global error callback\n function onFailure (error) {\n if (error === undefined) return\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 // Show alert modal\n if (error.response) {\n console.error(error.response)\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 } else {\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\n page.checkIfPublic(onFailure)\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', onFailure)\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"]}