diff --git a/config.sample.js b/config.sample.js index ea87199..f4c60c7 100644 --- a/config.sample.js +++ b/config.sample.js @@ -206,6 +206,27 @@ module.exports = { */ maxSize: '512MB', + /* + Chunk size for chunked uploads. Needs to be in MB. + If this is enabled, every files uploaded from the homepage uploader + will forcibly be chunked by the size specified in "default". + Users can configure the chunk size they want from the homepage uploader, + but you can force allowed max size of each chunk with "max". + Min size will always be 1MB. + Users will still be able to upload bigger files with the API + as long as they don't surpass the limit specified in the "maxSize" option above. + Once all chunks have been uploads, their total size + will be tested against the "maxSize" option again. + This option is mainly useful for hosters that use Cloudflare, + since Cloudflare limits upload size to 100MB on their Free plan. + https://support.cloudflare.com/hc/en-us/articles/200172516#h_51422705-42d0-450d-8eb1-5321dcadb5bc + NOTE: Set to falsy value to disable chunked uploads. + */ + chunkSize: { + max: '95MB', + default: '25MB' + }, + /* Max file size allowed for upload by URLs. Needs to be in MB. NOTE: Set to falsy value to disable upload by URLs. @@ -341,16 +362,6 @@ module.exports = { */ storeIP: true, - /* - Chunk size for chunk uploads. Needs to be in MB. - If this is enabled, every files uploaded from the homepage uploader will forcibly be chunked - by the size specified in "chunkSize". People will still be able to upload bigger files with - the API as long as they don't surpass the limit specified in the "maxSize" option above. - Total size of the whole chunks will also later be checked against the "maxSize" option. - NOTE: Set to falsy value to disable chunked uploads. - */ - chunkSize: '10MB', - /* The length of the randomly generated identifier for uploaded files. If "force" is set to true, files will always use "default". diff --git a/controllers/multerStorageController.js b/controllers/multerStorageController.js new file mode 100644 index 0000000..7c55ecc --- /dev/null +++ b/controllers/multerStorageController.js @@ -0,0 +1,79 @@ +const fs = require('fs') +const os = require('os') +const path = require('path') +const crypto = require('crypto') +const blake3 = require('blake3') +const mkdirp = require('mkdirp') + +function getFilename (req, file, cb) { + // This won't be used since we use our own filename function. + crypto.randomBytes(16, function (err, raw) { + cb(err, err ? undefined : raw.toString('hex')) + }) +} + +function getDestination (req, file, cb) { + cb(null, os.tmpdir()) +} + +function DiskStorage (opts) { + this.getFilename = (opts.filename || getFilename) + + if (typeof opts.destination === 'string') { + mkdirp.sync(opts.destination) + this.getDestination = function ($0, $1, cb) { cb(null, opts.destination) } + } else { + this.getDestination = (opts.destination || getDestination) + } +} + +DiskStorage.prototype._handleFile = function _handleFile (req, file, cb) { + const that = this + + that.getDestination(req, file, function (err, destination) { + if (err) return cb(err) + + that.getFilename(req, file, function (err, filename) { + if (err) return cb(err) + + const finalPath = path.join(destination, filename) + const outStream = fs.createWriteStream(finalPath) + file.stream.pipe(outStream) + + let hash = null + if (!file._ischunk) { + hash = blake3.createHash() + file.stream.on('data', d => hash.update(d)) + file.stream.on('error', err => { + hash.dispose() + return cb(err) + }) + } + + outStream.on('error', cb) + outStream.on('finish', function () { + cb(null, { + destination, + filename, + path: finalPath, + size: outStream.bytesWritten, + hash: hash && hash.digest('hex') + }) + }) + }) + }) +} + +DiskStorage.prototype._removeFile = function _removeFile (req, file, cb) { + const path = file.path + + delete file.destination + delete file.filename + delete file.path + + fs.unlink(path, cb) +} + +module.exports = function (opts) { + return new DiskStorage(opts) +} diff --git a/controllers/uploadController.js b/controllers/uploadController.js index 18b909c..51c352d 100644 --- a/controllers/uploadController.js +++ b/controllers/uploadController.js @@ -1,10 +1,11 @@ -const crypto = require('crypto') +const blake3 = require('blake3') const fetch = require('node-fetch') const fs = require('fs') const multer = require('multer') const path = require('path') const randomstring = require('randomstring') const searchQuery = require('search-query-parser') +const multerStorage = require('./multerStorageController') const paths = require('./pathsController') const perms = require('./permissionController') const utils = require('./utilsController') @@ -25,7 +26,9 @@ const urlMaxSizeBytes = parseInt(config.uploads.urlMaxSize) * 1e6 const maxFilesPerUpload = 20 -const chunkedUploads = Boolean(config.uploads.chunkSize) +const chunkedUploads = config.uploads.chunkSize && + typeof config.uploads.chunkSize === 'object' && + config.uploads.chunkSize.default const chunksData = {} // Hard-coded min chunk size of 1 MB (e.g. 50 MB = max 50 chunks) const maxChunksCount = maxSize @@ -84,34 +87,35 @@ const executeMulter = multer({ else return cb(null, true) }, - storage: multer.diskStorage({ + storage: multerStorage({ destination (req, file, cb) { - // If chunked uploads is disabled or the uploaded file is not a chunk - if (!chunkedUploads || (req.body.uuid === undefined && req.body.chunkindex === undefined)) - return cb(null, paths.uploads) + // Is file a chunk!? + file._ischunk = chunkedUploads && req.body.uuid !== undefined && req.body.chunkindex !== undefined - initChunks(req.body.uuid) - .then(uuidDir => cb(null, uuidDir)) - .catch(error => { - logger.error(error) - return cb('Could not process the chunked upload. Try again?') - }) + if (file._ischunk) + initChunks(req.body.uuid) + .then(uuidDir => cb(null, uuidDir)) + .catch(error => { + logger.error(error) + return cb('Could not process the chunked upload. Try again?') + }) + else + return cb(null, paths.uploads) }, filename (req, file, cb) { - // If chunked uploads is disabled or the uploaded file is not a chunk - if (!chunkedUploads || (req.body.uuid === undefined && req.body.chunkindex === undefined)) { + if (file._ischunk) { + // index.extension (i.e. 0, 1, ..., n - will prepend zeros depending on the amount of chunks) + const digits = req.body.totalchunkcount !== undefined ? `${req.body.totalchunkcount - 1}`.length : 1 + const zeros = new Array(digits + 1).join('0') + const name = (zeros + req.body.chunkindex).slice(-digits) + return cb(null, name) + } else { const length = self.parseFileIdentifierLength(req.headers.filelength) return self.getUniqueRandomName(length, file.extname) .then(name => cb(null, name)) .catch(error => cb(error)) } - - // index.extension (i.e. 0, 1, ..., n - will prepend zeros depending on the amount of chunks) - const digits = req.body.totalchunkcount !== undefined ? `${req.body.totalchunkcount - 1}`.length : 1 - const zeros = new Array(digits + 1).join('0') - const name = (zeros + req.body.chunkindex).slice(-digits) - return cb(null, name) } }) }).array('files[]') @@ -452,7 +456,7 @@ self.actuallyFinishChunks = async (req, res, user) => { // Combine chunks const destination = path.join(paths.uploads, name) - await self.combineChunks(destination, file.uuid) + const hash = await self.combineChunks(destination, file.uuid) // Continue even when encountering errors await self.cleanUpChunks(file.uuid).catch(logger.error) @@ -472,6 +476,7 @@ self.actuallyFinishChunks = async (req, res, user) => { extname: file.extname, mimetype: file.type || '', size: file.size, + hash, albumid, age: file.age } @@ -504,15 +509,22 @@ self.actuallyFinishChunks = async (req, res, user) => { self.combineChunks = async (destination, uuid) => { let errorObj const writeStream = fs.createWriteStream(destination, { flags: 'a' }) + const hash = blake3.createHash() try { chunksData[uuid].chunks.sort() for (const chunk of chunksData[uuid].chunks) await new Promise((resolve, reject) => { - fs.createReadStream(path.join(chunksData[uuid].root, chunk)) - .on('error', error => reject(error)) - .on('end', () => resolve()) - .pipe(writeStream, { end: false }) + const stream = fs.createReadStream(path.join(chunksData[uuid].root, chunk)) + stream.pipe(writeStream, { end: false }) + + stream.on('data', d => hash.update(d)) + stream.on('error', error => { + hash.dispose() + reject(error) + }) + + stream.on('end', () => resolve()) }) } catch (error) { errorObj = error @@ -523,6 +535,9 @@ self.combineChunks = async (destination, uuid) => { // Re-throw error if (errorObj) throw errorObj + + // Return hash + return hash.digest('hex') } self.cleanUpChunks = async (uuid) => { @@ -602,17 +617,8 @@ self.storeFilesToDb = async (req, res, user, infoMap) => { const albumids = [] await Promise.all(infoMap.map(async info => { - // Create hash of the file - const hash = await new Promise((resolve, reject) => { - const result = crypto.createHash('md5') - fs.createReadStream(info.path) - .on('error', error => reject(error)) - .on('end', () => resolve(result.digest('hex'))) - .on('data', data => result.update(data, 'utf8')) - }) - // Check if the file exists by checking its hash and size - const dbFile = await db.table('files') + const dbFile = info.data.hash && await db.table('files') .where(function () { if (user === undefined) this.whereNull('userid') @@ -620,7 +626,7 @@ self.storeFilesToDb = async (req, res, user, infoMap) => { this.where('userid', user.id) }) .where({ - hash, + hash: info.data.hash, size: info.data.size }) // Select expirydate to display expiration date of existing files as well @@ -646,7 +652,7 @@ self.storeFilesToDb = async (req, res, user, infoMap) => { original: info.data.originalname, type: info.data.mimetype, size: info.data.size, - hash, + hash: info.data.hash, // Only disable if explicitly set to false in config ip: config.uploads.storeIP !== false ? req.ip : null, timestamp diff --git a/dist/js/home.js b/dist/js/home.js index 0380a3b..cfc6fc4 100644 --- a/dist/js/home.js +++ b/dist/js/home.js @@ -1,2 +1,2 @@ -var lsKeys={token:"token",chunkSize:"chunkSize",parallelUploads:"parallelUploads",uploadsHistoryOrder:"uploadsHistoryOrder",previewImages:"previewImages",fileLength:"fileLength",uploadAge:"uploadAge",stripTags:"stripTags"},page={token:localStorage[lsKeys.token],private:null,enableUserAccounts:null,maxSize:null,chunkSize:null,temporaryUploadAges:null,fileIdentifierLength:null,stripTagsConfig:null,album:null,parallelUploads:2,previewImages:null,fileLength:null,uploadAge:null,maxSizeBytes:null,urlMaxSize:null,urlMaxSizeBytes:null,tabs:[],activeTab:null,albumSelect:null,albumSelectOnChange:null,previewTemplate:null,dropzone:null,clipboardJS:null,lazyLoad:null,urlsQueue:[],activeUrlsQueue:0,imageExts:[".webp",".jpg",".jpeg",".bmp",".gif",".png",".tiff",".tif",".svg"],videoExts:[".webm",".mp4",".wmv",".avi",".mov",".mkv",".m4v",".m2ts"],albumTitleMaxLength:70,albumDescMaxLength:4e3,onInitError:function(e){document.querySelector("#albumDiv").classList.add("is-hidden"),document.querySelector("#tabs").classList.add("is-hidden"),document.querySelectorAll(".tab-content").forEach((function(e){return e.classList.add("is-hidden")}));var a=document.querySelector("#loginToUpload");a.innerText="An error occurred. Try to reload?",a.classList.remove("is-loading"),a.classList.remove("is-hidden"),a.addEventListener("click",(function(){window.location.reload()})),e.response?page.onAxiosError(e):page.onError(e)},onError:function(e){console.error(e);var a=document.createElement("div");return a.innerHTML=""+e.toString()+"",swal({title:"An error occurred!",icon:"error",content:a})},onAxiosError:function(e){console.error(e);var a={520:"Unknown Error",521:"Web Server Is Down",522:"Connection Timed Out",523:"Origin Is Unreachable",524:"A Timeout Occurred",525:"SSL Handshake Failed",526:"Invalid SSL Certificate",527:"Railgun Error",530:"Origin DNS Error"}[e.response.status]||e.response.statusText,t=e.response.data&&e.response.data.description?e.response.data.description:"There was an error with the request, please check the console for more information.";return swal(e.response.status+" "+a,t,"error")},checkClientVersion:function(e){var a=document.querySelector("#mainScript").src.match(/\?_=(\d+)$/);if(a&&a[1]&&a[1]!==e)return swal({title:"Updated detected!",text:"Client assets have been updated. Reload to display the latest version?",icon:"info",buttons:{confirm:{text:"Reload",closeModal:!1}}}).then((function(){window.location.reload()}))},checkIfPublic:function(){var e=!1;return axios.get("api/check",{onDownloadProgress:function(){e||"function"!=typeof page.doRender||(page.doRender(),e=!0)}}).then((function(e){return e.data.version&&page.checkClientVersion(e.data.version),page.private=e.data.private,page.enableUserAccounts=e.data.enableUserAccounts,page.maxSize=parseInt(e.data.maxSize),page.maxSizeBytes=1e6*page.maxSize,page.chunkSize=parseInt(e.data.chunkSize),page.temporaryUploadAges=e.data.temporaryUploadAges,page.fileIdentifierLength=e.data.fileIdentifierLength,page.stripTagsConfig=e.data.stripTags,page.preparePage()})).catch(page.onInitError)},preparePage:function(){if(!page.private)return page.prepareUpload();if(page.token)return page.verifyToken(page.token,!0);var e=document.querySelector("#loginToUpload");e.href="auth",e.classList.remove("is-loading"),page.enableUserAccounts?e.innerText="Anonymous upload is disabled.\nLog in or register to upload.":e.innerText="Running in private mode.\nLog in to upload."},verifyToken:function(e,a){return axios.post("api/tokens/verify",{token:e}).then((function(t){return!1===t.data.success?swal({title:"An error occurred!",text:t.data.description,icon:"error"}).then((function(){a&&(localStorage.removeItem("token"),window.location.reload())})):(localStorage[lsKeys.token]=e,page.token=e,page.prepareUpload())})).catch(page.onInitError)},prepareUpload:function(){if(page.token){var e=document.querySelector('#linksColumn a[href="auth"]');e&&e.setAttribute("href","dashboard"),document.querySelector("#albumDiv").classList.remove("is-hidden"),page.albumSelect=document.querySelector("#albumSelect"),page.albumSelectOnChange=function(){page.album=parseInt(page.albumSelect.value),"function"==typeof page.prepareShareX&&page.prepareShareX()},page.albumSelect.addEventListener("change",page.albumSelectOnChange),page.fetchAlbums()}else page.enableUserAccounts&&(document.querySelector("#loginLinkText").innerHTML="Create an account and keep track of your uploads");page.prepareUploadConfig(),document.querySelector("#maxSize > span").innerHTML=page.getPrettyBytes(page.maxSizeBytes),document.querySelector("#loginToUpload").classList.add("is-hidden"),page.prepareDropzone(),"function"==typeof page.prepareShareX&&page.prepareShareX();var a=document.querySelector("#urlMaxSize");a&&(page.urlMaxSize=parseInt(a.innerHTML),page.urlMaxSizeBytes=1e6*page.urlMaxSize,a.innerHTML=page.getPrettyBytes(page.urlMaxSizeBytes),document.querySelector("#uploadUrls").addEventListener("click",(function(e){page.addUrlsToQueue()})));for(var t=document.querySelector("#tabs"),n=t.querySelectorAll("li"),r=function(e){var a=n[e].dataset.id,t=document.querySelector("#"+a);t&&(n[e].addEventListener("click",(function(){page.setActiveTab(e)})),page.tabs.push({tab:n[e],content:t}))},i=0;i2){for(var f=0,v=0,h=!1,b=m-1;b--;)if(h)l._uplSpeedCalc.data.splice(b,1);else if((f=c-l._uplSpeedCalc.data[b].timestamp)>1e3){var y=f-1e3,S=f-(c-l._uplSpeedCalc.data[b+1].timestamp);v+=(S-y)/S*l._uplSpeedCalc.data[b+1].bytes,h=!0}else v+=l._uplSpeedCalc.data[b+1].bytes;h||(v*=1e3/f),t=page.getPrettyBytes(v)}}e.previewElement.querySelector(".descriptive-progress").innerHTML=o+" "+r+"%"+(t?" at "+t+"/s":"")})),this.on("success",(function(e,a){a&&(e.previewElement.querySelector(".descriptive-progress").classList.add("is-hidden"),!1===a.success&&(e.previewElement.querySelector(".error").innerHTML=a.description,e.previewElement.querySelector(".error").classList.remove("is-hidden")),Array.isArray(a.files)&&a.files[0]&&page.updateTemplate(e,a.files[0]))})),this.on("error",(function(e,a){("string"==typeof a&&/^File is too big/.test(a)||"object"==typeof a&&/File too large/.test(a.description))&&(a="File too large ("+page.getPrettyBytes(e.size)+")."),page.updateTemplateIcon(e.previewElement,"icon-block"),e.previewElement.querySelector(".descriptive-progress").classList.add("is-hidden"),e.previewElement.querySelector(".error").innerHTML=a.description||a,e.previewElement.querySelector(".error").classList.remove("is-hidden")}))},chunksUploaded:function(e,a){return e.previewElement.querySelector(".descriptive-progress").innerHTML="Rebuilding "+e.upload.totalChunkCount+" chunks…",axios.post("api/upload/finishchunks",{files:[{uuid:e.upload.uuid,original:e.name,type:e.type,albumid:page.album,filelength:page.fileLength,age:page.uploadAge}]},{headers:{token:page.token,striptags:page.stripTags}}).catch((function(e){return e.response.data?e.response:{data:{success:!1,description:e.toString()}}})).then((function(t){return e.previewElement.querySelector(".descriptive-progress").classList.add("is-hidden"),!1===t.data.success&&(e.previewElement.querySelector(".error").innerHTML=t.data.description,e.previewElement.querySelector(".error").classList.remove("is-hidden")),t.data.files&&t.data.files[0]&&page.updateTemplate(e,t.data.files[0]),a()}))}})},addUrlsToQueue:function(){var e=document.querySelector("#urls").value.split(/\r?\n/).filter((function(e){return e.trim().length}));if(!e.length)return swal("An error occurred!","You have not entered any URLs.","error");var a=document.querySelector("#tab-urls");a.querySelector(".uploads").classList.remove("is-hidden");for(var t=0;t .clipboard-js");n.href=n.innerHTML=r.dataset.clipboardText=a.url,t.classList.remove("is-hidden"),r.parentElement.classList.remove("is-hidden");var i=/.[\w]+(\?|$)/.exec(a.url),l=i&&i[0]?i[0].toLowerCase():null;if(page.imageExts.includes(l))if(page.previewImages){var o=e.previewElement.querySelector("img");o.setAttribute("alt",a.name||""),o.dataset.src=a.url,o.classList.remove("is-hidden"),o.onerror=function(a){a.currentTarget.classList.add("is-hidden"),page.updateTemplateIcon(e.previewElement,"icon-picture")},page.lazyLoad.update(e.previewElement.querySelectorAll("img"))}else page.updateTemplateIcon(e.previewElement,"icon-picture");else page.videoExts.includes(l)?page.updateTemplateIcon(e.previewElement,"icon-video"):page.updateTemplateIcon(e.previewElement,"icon-doc-inv");if(a.expirydate){var s=e.previewElement.querySelector(".expiry-date");s.innerHTML="EXP: "+page.getPrettyDate(new Date(1e3*a.expirydate)),s.classList.remove("is-hidden")}}},page.createAlbum=function(){var e=document.createElement("div");e.innerHTML='\n
\n
\n \n
\n

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

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

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

\n
\n
\n
\n \n
\n
\n
\n
\n \n
\n
\n ',swal({title:"Create new album",icon:"info",content:e,buttons:{cancel:!0,confirm:{closeModal:!1}}}).then((function(e){if(e){var a=document.querySelector("#swalName").value.trim();axios.post("api/albums",{name:a,description:document.querySelector("#swalDescription").value.trim(),download:document.querySelector("#swalDownload").checked,public:document.querySelector("#swalPublic").checked},{headers:{token:page.token}}).then((function(e){if(!1===e.data.success)return swal("An error occurred!",e.data.description,"error");var t=document.createElement("option");page.albumSelect.appendChild(t),t.value=e.data.id,t.innerHTML=a,t.selected=!0,page.albumSelectOnChange(),swal("Woohoo!","Album was created successfully.","success")})).catch(page.onError)}}))},page.prepareUploadConfig=function(){var e={chunkSize:page.chunkSize,parallelUploads:page.parallelUploads},a=Array.isArray(page.temporaryUploadAges)&&page.temporaryUploadAges.length,t=page.fileIdentifierLength&&"number"==typeof page.fileIdentifierLength.min&&"number"==typeof page.fileIdentifierLength.max,n={siBytes:{label:"File size display",select:[{value:"default",text:"1000 B = 1 kB = 1 Kilobyte"},{value:"0",text:"1024 B = 1 KiB = 1 Kibibyte"}],help:"This will be used in our homepage, dashboard, and album public pages.",valueHandler:function(){}},fileLength:{display:t,label:"File identifier length",number:t?{min:page.fileIdentifierLength.min,max:page.fileIdentifierLength.max,round:!0}:void 0,help:!0,disabled:t&&page.fileIdentifierLength.force},uploadAge:{display:a,label:"Upload age",select:[],help:"Whether to automatically delete your uploads after a certain amount of time."},stripTags:{display:page.stripTagsConfig,label:"Strip tags",select:page.stripTagsConfig?[{value:page.stripTagsConfig.default?"default":"1",text:"Yes"},{value:page.stripTagsConfig.default?"0":"default",text:"No"}]:null,help:"Whether to strip tags (e.g. EXIF) from your uploads.
\n This only applies to regular image"+(page.stripTagsConfig&&page.stripTagsConfig.video?" and video":"")+" uploads (i.e. not URL uploads).",disabled:page.stripTagsConfig&&page.stripTagsConfig.force},chunkSize:{display:!isNaN(page.chunkSize),label:"Upload chunk size (MB)",number:{min:1,max:95,suffix:" MB",round:!0},help:!0},parallelUploads:{label:"Parallel uploads",number:{min:1,max:10,round:!0},help:!0},uploadsHistoryOrder:{label:"Uploads history order",select:[{value:"default",text:"Older files on top"},{value:"0",text:"Newer files on top"}],help:'"Newer files on top" will use a CSS technique, which unfortunately come with some undesirable side effects.
\n This also affects text selection, such as when trying to select text from top to bottom will result in them being selected from bottom to top instead, and vice versa.',valueHandler:function(e){if("0"===e)for(var a=document.querySelectorAll(".tab-content > .uploads"),t=0;t=page.fileIdentifierLength.min&&o<=page.fileIdentifierLength.max&&(n.fileLength.value=o)}var s=document.querySelector("#tab-config"),p=document.createElement("form");p.addEventListener("submit",(function(e){return e.preventDefault()}));for(var u=Object.keys(n),d=0;d\n "+w.text+("default"===w.value?" (default)":"")+"\n \n ")}b.innerHTML='\n \n "}else void 0!==g.number&&((b=document.createElement("input")).id=b.name=c,b.className="input is-fullwidth",b.type="number",void 0!==g.number.min&&(b.min=g.number.min),void 0!==g.number.max&&(b.max=g.number.max),"number"==typeof f?b.value=f:void 0!==e[c]&&(b.value=e[c]));var k=void 0;if(g.disabled)Array.isArray(g.select)?b.querySelector("select").disabled=g.disabled:b.disabled=g.disabled,k="This option is currently not configurable.";else if("string"==typeof g.help)k=g.help;else if(!0===g.help&&void 0!==g.number){var x=[];void 0!==e[c]&&x.push("Default is "+e[c]+(g.number.suffix||"")+"."),void 0!==g.number.min&&x.push("Min is "+g.number.min+(g.number.suffix||"")+"."),void 0!==g.number.max&&x.push("Max is "+g.number.max+(g.number.suffix||"")+"."),k=x.join(" ")}m.innerHTML='\n \n
\n '+(k?'

'+k+"

":"")+"\n ",m.querySelector("div.control").appendChild(b),p.appendChild(m)}}var T=document.createElement("div");T.className="field",T.innerHTML='\n

\n \n

\n

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

\n ',p.appendChild(T),p.querySelector("#saveConfig").addEventListener("click",(function(){if(p.checkValidity()){for(var a=Object.keys(n).filter((function(e){return!1!==n[e].display&&!0!==n[e].disabled})),t=0;t=24){var t=e/24;return t+" day"+(1===t?"":"s")}return e+" hour"+(1===e?"":"s")},window.addEventListener("paste",(function(e){for(var a=(e.clipboardData||e.originalEvent.clipboardData).items,t=Object.keys(a),n=0;n",swal({title:"An error occurred!",icon:"error",content:a})},onAxiosError:function(e){console.error(e);var a={520:"Unknown Error",521:"Web Server Is Down",522:"Connection Timed Out",523:"Origin Is Unreachable",524:"A Timeout Occurred",525:"SSL Handshake Failed",526:"Invalid SSL Certificate",527:"Railgun Error",530:"Origin DNS Error"}[e.response.status]||e.response.statusText,t=e.response.data&&e.response.data.description?e.response.data.description:"There was an error with the request, please check the console for more information.";return swal(e.response.status+" "+a,t,"error")},checkClientVersion:function(e){var a=document.querySelector("#mainScript").src.match(/\?_=(\d+)$/);if(a&&a[1]&&a[1]!==e)return swal({title:"Updated detected!",text:"Client assets have been updated. Reload to display the latest version?",icon:"info",buttons:{confirm:{text:"Reload",closeModal:!1}}}).then((function(){window.location.reload()}))},checkIfPublic:function(){var e=!1;return axios.get("api/check",{onDownloadProgress:function(){e||"function"!=typeof page.doRender||(page.doRender(),e=!0)}}).then((function(e){return e.data.version&&page.checkClientVersion(e.data.version),page.private=e.data.private,page.enableUserAccounts=e.data.enableUserAccounts,page.maxSize=parseInt(e.data.maxSize),page.maxSizeBytes=1e6*page.maxSize,page.chunkSizeConfig={max:e.data.chunkSize&&parseInt(e.data.chunkSize.max)||95,default:e.data.chunkSize&&parseInt(e.data.chunkSize.default)},page.temporaryUploadAges=e.data.temporaryUploadAges,page.fileIdentifierLength=e.data.fileIdentifierLength,page.stripTagsConfig=e.data.stripTags,page.preparePage()})).catch(page.onInitError)},preparePage:function(){if(!page.private)return page.prepareUpload();if(page.token)return page.verifyToken(page.token,!0);var e=document.querySelector("#loginToUpload");e.href="auth",e.classList.remove("is-loading"),page.enableUserAccounts?e.innerText="Anonymous upload is disabled.\nLog in or register to upload.":e.innerText="Running in private mode.\nLog in to upload."},verifyToken:function(e,a){return axios.post("api/tokens/verify",{token:e}).then((function(t){return!1===t.data.success?swal({title:"An error occurred!",text:t.data.description,icon:"error"}).then((function(){a&&(localStorage.removeItem("token"),window.location.reload())})):(localStorage[lsKeys.token]=e,page.token=e,page.prepareUpload())})).catch(page.onInitError)},prepareUpload:function(){if(page.token){var e=document.querySelector('#linksColumn a[href="auth"]');e&&e.setAttribute("href","dashboard"),document.querySelector("#albumDiv").classList.remove("is-hidden"),page.albumSelect=document.querySelector("#albumSelect"),page.albumSelectOnChange=function(){page.album=parseInt(page.albumSelect.value),"function"==typeof page.prepareShareX&&page.prepareShareX()},page.albumSelect.addEventListener("change",page.albumSelectOnChange),page.fetchAlbums()}else page.enableUserAccounts&&(document.querySelector("#loginLinkText").innerHTML="Create an account and keep track of your uploads");page.prepareUploadConfig(),document.querySelector("#maxSize > span").innerHTML=page.getPrettyBytes(page.maxSizeBytes),document.querySelector("#loginToUpload").classList.add("is-hidden"),page.prepareDropzone(),"function"==typeof page.prepareShareX&&page.prepareShareX();var a=document.querySelector("#urlMaxSize");a&&(page.urlMaxSize=parseInt(a.innerHTML),page.urlMaxSizeBytes=1e6*page.urlMaxSize,a.innerHTML=page.getPrettyBytes(page.urlMaxSizeBytes),document.querySelector("#uploadUrls").addEventListener("click",(function(e){page.addUrlsToQueue()})));for(var t=document.querySelector("#tabs"),n=t.querySelectorAll("li"),r=function(e){var a=n[e].dataset.id,t=document.querySelector("#"+a);t&&(n[e].addEventListener("click",(function(){page.setActiveTab(e)})),page.tabs.push({tab:n[e],content:t}))},i=0;i2){for(var f=0,h=0,v=!1,b=m-1;b--;)if(v)l._uplSpeedCalc.data.splice(b,1);else if((f=c-l._uplSpeedCalc.data[b].timestamp)>1e3){var y=f-1e3,S=f-(c-l._uplSpeedCalc.data[b+1].timestamp);h+=(S-y)/S*l._uplSpeedCalc.data[b+1].bytes,v=!0}else h+=l._uplSpeedCalc.data[b+1].bytes;v||(h*=1e3/f),t=page.getPrettyBytes(h)}}e.previewElement.querySelector(".descriptive-progress").innerHTML=o+" "+r+"%"+(t?" at "+t+"/s":"")})),this.on("success",(function(e,a){a&&(e.previewElement.querySelector(".descriptive-progress").classList.add("is-hidden"),!1===a.success&&(e.previewElement.querySelector(".error").innerHTML=a.description,e.previewElement.querySelector(".error").classList.remove("is-hidden")),Array.isArray(a.files)&&a.files[0]&&page.updateTemplate(e,a.files[0]))})),this.on("error",(function(e,a){("string"==typeof a&&/^File is too big/.test(a)||"object"==typeof a&&/File too large/.test(a.description))&&(a="File too large ("+page.getPrettyBytes(e.size)+")."),page.updateTemplateIcon(e.previewElement,"icon-block"),e.previewElement.querySelector(".descriptive-progress").classList.add("is-hidden"),e.previewElement.querySelector(".error").innerHTML=a.description||a,e.previewElement.querySelector(".error").classList.remove("is-hidden")}))},chunksUploaded:function(e,a){return e.previewElement.querySelector(".descriptive-progress").innerHTML="Rebuilding "+e.upload.totalChunkCount+" chunks…",axios.post("api/upload/finishchunks",{files:[{uuid:e.upload.uuid,original:e.name,type:e.type,albumid:page.album,filelength:page.fileLength,age:page.uploadAge}]},{headers:{token:page.token,striptags:page.stripTags}}).catch((function(e){return e.response.data?e.response:{data:{success:!1,description:e.toString()}}})).then((function(t){return e.previewElement.querySelector(".descriptive-progress").classList.add("is-hidden"),!1===t.data.success&&(e.previewElement.querySelector(".error").innerHTML=t.data.description,e.previewElement.querySelector(".error").classList.remove("is-hidden")),t.data.files&&t.data.files[0]&&page.updateTemplate(e,t.data.files[0]),a()}))}})},addUrlsToQueue:function(){var e=document.querySelector("#urls").value.split(/\r?\n/).filter((function(e){return e.trim().length}));if(!e.length)return swal("An error occurred!","You have not entered any URLs.","error");var a=document.querySelector("#tab-urls");a.querySelector(".uploads").classList.remove("is-hidden");for(var t=0;t .clipboard-js");n.href=n.innerHTML=r.dataset.clipboardText=a.url,t.classList.remove("is-hidden"),r.parentElement.classList.remove("is-hidden");var i=/.[\w]+(\?|$)/.exec(a.url),l=i&&i[0]?i[0].toLowerCase():null;if(page.imageExts.includes(l))if(page.previewImages){var o=e.previewElement.querySelector("img");o.setAttribute("alt",a.name||""),o.dataset.src=a.url,o.classList.remove("is-hidden"),o.onerror=function(a){a.currentTarget.classList.add("is-hidden"),page.updateTemplateIcon(e.previewElement,"icon-picture")},page.lazyLoad.update(e.previewElement.querySelectorAll("img"))}else page.updateTemplateIcon(e.previewElement,"icon-picture");else page.videoExts.includes(l)?page.updateTemplateIcon(e.previewElement,"icon-video"):page.updateTemplateIcon(e.previewElement,"icon-doc-inv");if(a.expirydate){var s=e.previewElement.querySelector(".expiry-date");s.innerHTML="EXP: "+page.getPrettyDate(new Date(1e3*a.expirydate)),s.classList.remove("is-hidden")}}},page.createAlbum=function(){var e=document.createElement("div");e.innerHTML='\n
\n
\n \n
\n

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

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

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

\n
\n
\n
\n \n
\n
\n
\n
\n \n
\n
\n ',swal({title:"Create new album",icon:"info",content:e,buttons:{cancel:!0,confirm:{closeModal:!1}}}).then((function(e){if(e){var a=document.querySelector("#swalName").value.trim();axios.post("api/albums",{name:a,description:document.querySelector("#swalDescription").value.trim(),download:document.querySelector("#swalDownload").checked,public:document.querySelector("#swalPublic").checked},{headers:{token:page.token}}).then((function(e){if(!1===e.data.success)return swal("An error occurred!",e.data.description,"error");var t=document.createElement("option");page.albumSelect.appendChild(t),t.value=e.data.id,t.innerHTML=a,t.selected=!0,page.albumSelectOnChange(),swal("Woohoo!","Album was created successfully.","success")})).catch(page.onError)}}))},page.prepareUploadConfig=function(){var e={chunkSize:page.chunkSizeConfig.default,parallelUploads:2},a=Array.isArray(page.temporaryUploadAges)&&page.temporaryUploadAges.length,t=page.fileIdentifierLength&&"number"==typeof page.fileIdentifierLength.min&&"number"==typeof page.fileIdentifierLength.max,n={siBytes:{label:"File size display",select:[{value:"default",text:"1000 B = 1 kB = 1 Kilobyte"},{value:"0",text:"1024 B = 1 KiB = 1 Kibibyte"}],help:"This will be used in our homepage, dashboard, and album public pages.",valueHandler:function(){}},fileLength:{display:t,label:"File identifier length",number:t?{min:page.fileIdentifierLength.min,max:page.fileIdentifierLength.max,round:!0}:void 0,help:!0,disabled:t&&page.fileIdentifierLength.force},uploadAge:{display:a,label:"Upload age",select:[],help:"Whether to automatically delete your uploads after a certain amount of time."},stripTags:{display:page.stripTagsConfig,label:"Strip tags",select:page.stripTagsConfig?[{value:page.stripTagsConfig.default?"default":"1",text:"Yes"},{value:page.stripTagsConfig.default?"0":"default",text:"No"}]:null,help:"Whether to strip tags (e.g. EXIF) from your uploads.
\n This only applies to regular image"+(page.stripTagsConfig&&page.stripTagsConfig.video?" and video":"")+" uploads (i.e. not URL uploads).",disabled:page.stripTagsConfig&&page.stripTagsConfig.force},chunkSize:{display:Boolean(page.chunkSizeConfig.default),label:"Upload chunk size (MB)",number:{min:1,max:page.chunkSizeConfig.max,suffix:" MB",round:!0},help:!0},parallelUploads:{label:"Parallel uploads",number:{min:1,max:10,round:!0},help:!0},uploadsHistoryOrder:{label:"Uploads history order",select:[{value:"default",text:"Older files on top"},{value:"0",text:"Newer files on top"}],help:'"Newer files on top" will use a CSS technique, which unfortunately come with some undesirable side effects.
\n This also affects text selection, such as when trying to select text from top to bottom will result in them being selected from bottom to top instead, and vice versa.',valueHandler:function(e){if("0"===e)for(var a=document.querySelectorAll(".tab-content > .uploads"),t=0;t=page.fileIdentifierLength.min&&o<=page.fileIdentifierLength.max&&(n.fileLength.value=o)}var s=document.querySelector("#tab-config"),u=document.createElement("form");u.addEventListener("submit",(function(e){return e.preventDefault()}));for(var p=Object.keys(n),d=0;d=g.number.min&&(f=h)}else{var v=localStorage[lsKeys[c]];f=Array.isArray(g.select)?g.select.find((function(e){return e.value===v}))?v:void 0:v}"function"==typeof g.valueHandler?g.valueHandler(f):void 0!==f?page[c]=f:void 0!==e[c]&&(page[c]=e[c])}var b=void 0;if(Array.isArray(g.select)){(b=document.createElement("div")).className="select is-fullwidth";for(var y=[],S=0;S\n "+w.text+("default"===w.value?" (default)":"")+"\n \n ")}b.innerHTML='\n \n "}else void 0!==g.number&&((b=document.createElement("input")).id=b.name=c,b.className="input is-fullwidth",b.type="number",void 0!==g.number.min&&(b.min=g.number.min),void 0!==g.number.max&&(b.max=g.number.max),"number"==typeof f?b.value=f:void 0!==e[c]&&(b.value=e[c]));var L=void 0;if(g.disabled)Array.isArray(g.select)?b.querySelector("select").disabled=g.disabled:b.disabled=g.disabled,L="This option is currently not configurable.";else if("string"==typeof g.help)L=g.help;else if(!0===g.help&&void 0!==g.number){var x=[];void 0!==e[c]&&x.push("Default is "+e[c]+(g.number.suffix||"")+"."),void 0!==g.number.min&&x.push("Min is "+g.number.min+(g.number.suffix||"")+"."),void 0!==g.number.max&&x.push("Max is "+g.number.max+(g.number.suffix||"")+"."),L=x.join(" ")}m.innerHTML='\n \n
\n '+(L?'

'+L+"

":"")+"\n ",m.querySelector("div.control").appendChild(b),u.appendChild(m)}}var T=document.createElement("div");T.className="field",T.innerHTML='\n

\n \n

\n

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

\n ',u.appendChild(T),u.querySelector("#saveConfig").addEventListener("click",(function(){if(u.checkValidity()){for(var a=Object.keys(n).filter((function(e){return!1!==n[e].display&&!0!==n[e].disabled})),t=0;t=24){var t=e/24;return t+" day"+(1===t?"":"s")}return e+" hour"+(1===e?"":"s")},window.addEventListener("paste",(function(e){for(var a=(e.clipboardData||e.originalEvent.clipboardData).items,t=Object.keys(a),n=0;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 window.location.reload()\n })\n\n if (error.response)\n page.onAxiosError(error)\n else\n page.onError(error)\n}\n\n// Handler for regular JS errors\npage.onError = error => {\n console.error(error)\n\n const content = document.createElement('div')\n content.innerHTML = `${error.toString()}`\n return swal({\n title: 'An error occurred!',\n icon: 'error',\n content\n })\n}\n\n// Handler for Axios errors\npage.onAxiosError = error => {\n console.error(error)\n\n // Better Cloudflare errors\n const cloudflareErrors = {\n 520: 'Unknown Error',\n 521: 'Web Server Is Down',\n 522: 'Connection Timed Out',\n 523: 'Origin Is Unreachable',\n 524: 'A Timeout Occurred',\n 525: 'SSL Handshake Failed',\n 526: 'Invalid SSL Certificate',\n 527: 'Railgun Error',\n 530: 'Origin DNS Error'\n }\n\n const statusText = cloudflareErrors[error.response.status] || error.response.statusText\n const description = error.response.data && error.response.data.description\n ? error.response.data.description\n : 'There was an error with the request, please check the console for more information.'\n\n return swal(`${error.response.status} ${statusText}`, description, 'error')\n}\n\npage.checkClientVersion = apiVersion => {\n const self = document.querySelector('#mainScript')\n const match = self.src.match(/\\?_=(\\d+)$/)\n if (match && match[1] && match[1] !== apiVersion)\n return swal({\n title: 'Updated detected!',\n text: 'Client assets have been updated. Reload to display the latest version?',\n icon: 'info',\n buttons: {\n confirm: {\n text: 'Reload',\n closeModal: false\n }\n }\n }).then(() => {\n window.location.reload()\n })\n}\n\npage.checkIfPublic = () => {\n let renderShown = false\n return axios.get('api/check', {\n onDownloadProgress: () => {\n // Only show render after this request has been initiated to avoid blocking\n if (!renderShown && typeof page.doRender === 'function') {\n page.doRender()\n renderShown = true\n }\n }\n }).then(response => {\n if (response.data.version)\n page.checkClientVersion(response.data.version)\n\n page.private = response.data.private\n page.enableUserAccounts = response.data.enableUserAccounts\n page.maxSize = parseInt(response.data.maxSize)\n page.maxSizeBytes = page.maxSize * 1e6\n page.chunkSize = parseInt(response.data.chunkSize)\n page.temporaryUploadAges = response.data.temporaryUploadAges\n page.fileIdentifierLength = response.data.fileIdentifierLength\n page.stripTagsConfig = response.data.stripTags\n\n return page.preparePage()\n }).catch(page.onInitError)\n}\n\npage.preparePage = () => {\n if (page.private)\n if (page.token) {\n return page.verifyToken(page.token, true)\n } else {\n const button = document.querySelector('#loginToUpload')\n button.href = 'auth'\n button.classList.remove('is-loading')\n if (page.enableUserAccounts)\n button.innerText = 'Anonymous upload is disabled.\\nLog in or register to upload.'\n else\n button.innerText = 'Running in private mode.\\nLog 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 window.location.reload()\n })\n\n localStorage[lsKeys.token] = token\n page.token = token\n return page.prepareUpload()\n }).catch(page.onInitError)\n}\n\npage.prepareUpload = () => {\n // I think this fits best here because we need to check for a valid token before we can get the albums\n if (page.token) {\n // Change /auth link to /dashboard\n const authLink = document.querySelector('#linksColumn a[href=\"auth\"]')\n if (authLink)\n authLink.setAttribute('href', 'dashboard')\n\n // Display the album selection\n document.querySelector('#albumDiv').classList.remove('is-hidden')\n\n page.albumSelect = document.querySelector('#albumSelect')\n page.albumSelectOnChange = () => {\n page.album = parseInt(page.albumSelect.value)\n // Re-generate ShareX config file\n if (typeof page.prepareShareX === 'function')\n page.prepareShareX()\n }\n page.albumSelect.addEventListener('change', page.albumSelectOnChange)\n\n // Fetch albums\n page.fetchAlbums()\n } else if (page.enableUserAccounts) {\n document.querySelector('#loginLinkText').innerHTML = 'Create an account and keep track of your uploads'\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 // Prepare & generate files upload tab\n page.prepareDropzone()\n\n // Generate ShareX config file\n if (typeof page.prepareShareX === 'function')\n page.prepareShareX()\n\n // Prepare urls upload tab\n const urlMaxSize = document.querySelector('#urlMaxSize')\n if (urlMaxSize) {\n page.urlMaxSize = parseInt(urlMaxSize.innerHTML)\n page.urlMaxSizeBytes = page.urlMaxSize * 1e6\n urlMaxSize.innerHTML = page.getPrettyBytes(page.urlMaxSizeBytes)\n document.querySelector('#uploadUrls').addEventListener('click', event => {\n page.addUrlsToQueue()\n })\n }\n\n // Get all tabs\n const tabsContainer = document.querySelector('#tabs')\n const tabs = tabsContainer.querySelectorAll('li')\n for (let i = 0; i < tabs.length; i++) {\n const id = tabs[i].dataset.id\n const tabContent = document.querySelector(`#${id}`)\n if (!tabContent) continue\n\n tabs[i].addEventListener('click', () => {\n page.setActiveTab(i)\n })\n page.tabs.push({ tab: tabs[i], content: tabContent })\n }\n\n // Set first valid tab as the default active tab\n if (page.tabs.length) {\n page.setActiveTab(0)\n tabsContainer.classList.remove('is-hidden')\n }\n}\n\npage.setActiveTab = index => {\n for (let i = 0; i < page.tabs.length; i++)\n if (i === index) {\n page.tabs[i].tab.classList.add('is-active')\n page.tabs[i].content.classList.remove('is-hidden')\n page.activeTab = index\n } else {\n page.tabs[i].tab.classList.remove('is-active')\n page.tabs[i].content.classList.add('is-hidden')\n }\n}\n\npage.fetchAlbums = () => {\n return axios.get('api/albums', { headers: { token: page.token } }).then(response => {\n if (response.data.success === false)\n return swal('An error occurred!', response.data.description, 'error')\n\n // Create an option for each album\n if (Array.isArray(response.data.albums) && response.data.albums.length)\n for (let i = 0; i < response.data.albums.length; i++) {\n const album = response.data.albums[i]\n const option = document.createElement('option')\n option.value = album.id\n option.innerHTML = album.name\n page.albumSelect.appendChild(option)\n }\n }).catch(page.onInitError)\n}\n\npage.prepareDropzone = () => {\n // Parse template element\n const previewNode = document.querySelector('#tpl')\n page.previewTemplate = previewNode.innerHTML\n previewNode.parentNode.removeChild(previewNode)\n\n // Generate files upload tab\n const tabDiv = document.querySelector('#tab-files')\n const div = document.createElement('div')\n div.className = 'control is-expanded'\n div.innerHTML = `\n
\n \n \n \n Click here or drag & drop files\n
\n `\n tabDiv.querySelector('.dz-container').appendChild(div)\n\n const previewsContainer = tabDiv.querySelector('#tab-files .field.uploads')\n\n page.dropzone = new Dropzone(document.body, {\n url: 'api/upload',\n paramName: 'files[]',\n clickable: tabDiv.querySelector('#dropzone'),\n maxFilesize: page.maxSizeBytes / 1024 / 1024, // this option expects MiB\n parallelUploads: page.parallelUploads,\n uploadMultiple: false,\n previewsContainer,\n previewTemplate: page.previewTemplate,\n createImageThumbnails: false,\n autoProcessQueue: true,\n headers: { token: page.token },\n chunking: Boolean(page.chunkSize),\n chunkSize: page.chunkSize * 1e6, // this option expects Bytes\n parallelChunkUploads: false, // for now, enabling this breaks descriptive upload progress\n timeout: 0,\n\n init () {\n this.on('addedfile', file => {\n // Set active tab to file uploads, if necessary\n if (page.activeTab !== 0)\n page.setActiveTab(0)\n\n // Add file entry\n tabDiv.querySelector('.uploads').classList.remove('is-hidden')\n\n file.previewElement.querySelector('.name').innerHTML = file.name\n file.previewElement.querySelector('.descriptive-progress').innerHTML = 'Waiting in queue\\u2026'\n })\n\n this.on('sending', (file, xhr) => {\n // Add timeout listener (hacky method due to lack of built-in timeout handler)\n if (!xhr.ontimeout)\n xhr.ontimeout = () => {\n const instances = page.dropzone.getUploadingFiles()\n .filter(instance => instance.xhr === xhr)\n page.dropzone._handleUploadError(instances, xhr, 'Connection timed out. Try to reduce upload chunk size.')\n }\n\n // Attach necessary data for initial upload speed calculation\n if (xhr._uplSpeedCalc === undefined)\n xhr._uplSpeedCalc = {\n lastSent: 0,\n data: [{ timestamp: Date.now(), bytes: 0 }]\n }\n\n // If not chunked uploads, add extra headers\n if (!file.upload.chunked) {\n if (page.album !== null) xhr.setRequestHeader('albumid', page.album)\n if (page.fileLength !== null) xhr.setRequestHeader('filelength', page.fileLength)\n if (page.uploadAge !== null) xhr.setRequestHeader('age', page.uploadAge)\n if (page.stripTags !== null) xhr.setRequestHeader('striptags', page.stripTags)\n }\n\n if (!file.upload.chunked)\n file.previewElement.querySelector('.descriptive-progress').innerHTML = 'Uploading\\u2026'\n else if (file.upload.chunks.length === 1)\n file.previewElement.querySelector('.descriptive-progress').innerHTML = `Uploading chunk 1/${file.upload.totalChunkCount}\\u2026`\n })\n\n // Update descriptive progress\n this.on('uploadprogress', (file, progress) => {\n // Total bytes will eventually be bigger than file size when chunked\n const total = Math.max(file.size, file.upload.total)\n const percentage = (file.upload.bytesSent / total * 100).toFixed(0)\n\n const upl = file.upload.chunked\n ? file.upload.chunks[file.upload.chunks.length - 1]\n : file.upload\n const xhr = upl.xhr || file.xhr\n\n let prefix = 'Uploading\\u2026'\n let skipProgress = false\n if (file.upload.chunked) {\n const done = upl.bytesSent === upl.total\n const last = file.upload.chunks.length === file.upload.totalChunkCount\n let chunkIndex = file.upload.chunks.length\n if (done && !last) {\n chunkIndex++\n skipProgress = true\n }\n prefix = `Uploading chunk ${chunkIndex}/${file.upload.totalChunkCount}\\u2026`\n }\n\n // Real-time upload speed calculation\n let prettyBytesPerSec\n if (!skipProgress) {\n const now = Date.now()\n const bytesSent = upl.bytesSent - xhr._uplSpeedCalc.lastSent\n\n // Push data of current iteration\n xhr._uplSpeedCalc.lastSent = upl.bytesSent\n xhr._uplSpeedCalc.data.push({ timestamp: now, bytes: bytesSent })\n\n // Wait till at least the 2nd iteration (3 data including initial data)\n const length = xhr._uplSpeedCalc.data.length\n if (length > 2) {\n // Calculate using data from all iterations\n let elapsed = 0\n let bytesPerSec = 0\n let fullSec = false\n let i = length - 1 // Always start with 2nd from last item\n while (i--) {\n // Splice data of unrequired iterations\n if (fullSec) {\n xhr._uplSpeedCalc.data.splice(i, 1)\n continue\n }\n // Sum data\n elapsed = now - xhr._uplSpeedCalc.data[i].timestamp\n if (elapsed > 1000) {\n const excessDuration = elapsed - 1000\n const newerIterationElapsed = now - xhr._uplSpeedCalc.data[i + 1].timestamp\n const duration = elapsed - newerIterationElapsed\n const fragment = (duration - excessDuration) / duration * xhr._uplSpeedCalc.data[i + 1].bytes\n bytesPerSec += fragment\n fullSec = true\n } else {\n bytesPerSec += xhr._uplSpeedCalc.data[i + 1].bytes\n }\n }\n\n // If not enough data\n if (!fullSec)\n bytesPerSec = 1000 / elapsed * bytesPerSec\n\n // Get pretty bytes\n prettyBytesPerSec = page.getPrettyBytes(bytesPerSec)\n }\n }\n\n file.previewElement.querySelector('.descriptive-progress').innerHTML =\n `${prefix} ${percentage}%${prettyBytesPerSec ? ` at ${prettyBytesPerSec}/s` : ''}`\n })\n\n this.on('success', (file, data) => {\n if (!data) return\n file.previewElement.querySelector('.descriptive-progress').classList.add('is-hidden')\n\n if (data.success === false) {\n file.previewElement.querySelector('.error').innerHTML = data.description\n file.previewElement.querySelector('.error').classList.remove('is-hidden')\n }\n\n if (Array.isArray(data.files) && data.files[0])\n page.updateTemplate(file, data.files[0])\n })\n\n this.on('error', (file, error) => {\n // Clean up file size errors\n if ((typeof error === 'string' && /^File is too big/.test(error)) ||\n (typeof error === 'object' && /File too large/.test(error.description)))\n error = `File too large (${page.getPrettyBytes(file.size)}).`\n\n page.updateTemplateIcon(file.previewElement, 'icon-block')\n\n file.previewElement.querySelector('.descriptive-progress').classList.add('is-hidden')\n\n file.previewElement.querySelector('.error').innerHTML = error.description || error\n file.previewElement.querySelector('.error').classList.remove('is-hidden')\n })\n },\n\n chunksUploaded (file, done) {\n file.previewElement.querySelector('.descriptive-progress').innerHTML =\n `Rebuilding ${file.upload.totalChunkCount} chunks\\u2026`\n\n return axios.post('api/upload/finishchunks', {\n // This API supports an array of multiple files\n files: [{\n uuid: file.upload.uuid,\n original: file.name,\n type: file.type,\n albumid: page.album,\n filelength: page.fileLength,\n age: page.uploadAge\n }]\n }, {\n headers: {\n token: page.token,\n // Unlike the options above (e.g. albumid, filelength, etc.),\n // strip tags cannot yet be configured per file with this API\n striptags: page.stripTags\n }\n }).catch(error => {\n // Format error for display purpose\n return error.response.data ? error.response : {\n data: {\n success: false,\n description: error.toString()\n }\n }\n }).then(response => {\n file.previewElement.querySelector('.descriptive-progress').classList.add('is-hidden')\n\n if (response.data.success === false) {\n file.previewElement.querySelector('.error').innerHTML = response.data.description\n file.previewElement.querySelector('.error').classList.remove('is-hidden')\n }\n\n if (response.data.files && response.data.files[0])\n page.updateTemplate(file, response.data.files[0])\n\n return done()\n })\n }\n })\n}\n\npage.addUrlsToQueue = () => {\n const urls = document.querySelector('#urls').value\n .split(/\\r?\\n/)\n .filter(url => {\n return url.trim().length\n })\n\n if (!urls.length)\n return swal('An error occurred!', 'You have not entered any URLs.', 'error')\n\n const tabDiv = document.querySelector('#tab-urls')\n tabDiv.querySelector('.uploads').classList.remove('is-hidden')\n\n for (let i = 0; i < urls.length; i++) {\n const previewTemplate = document.createElement('template')\n previewTemplate.innerHTML = page.previewTemplate.trim()\n\n const previewElement = previewTemplate.content.firstChild\n previewElement.querySelector('.name').innerHTML = urls[i]\n previewElement.querySelector('.descriptive-progress').innerHTML = 'Waiting in queue\\u2026'\n\n const previewsContainer = tabDiv.querySelector('.uploads')\n previewsContainer.appendChild(previewElement)\n\n page.urlsQueue.push({\n url: urls[i],\n previewElement\n })\n }\n\n page.processUrlsQueue()\n document.querySelector('#urls').value = ''\n}\n\npage.processUrlsQueue = () => {\n if (!page.urlsQueue.length) return\n\n function finishedUrlUpload (file, data) {\n file.previewElement.querySelector('.descriptive-progress').classList.add('is-hidden')\n\n if (data.success === false) {\n const match = data.description.match(/ over limit: (\\d+)$/)\n if (match && match[1])\n data.description = `File exceeded limit of ${page.getPrettyBytes(match[1])}.`\n\n file.previewElement.querySelector('.error').innerHTML = data.description\n file.previewElement.querySelector('.error').classList.remove('is-hidden')\n }\n\n if (Array.isArray(data.files) && data.files[0])\n page.updateTemplate(file, data.files[0])\n\n page.activeUrlsQueue--\n return shiftQueue()\n }\n\n function initUrlUpload (file) {\n file.previewElement.querySelector('.descriptive-progress').innerHTML =\n 'Waiting for server to fetch URL\\u2026'\n\n return axios.post('api/upload', {\n urls: [file.url]\n }, {\n headers: {\n token: page.token,\n albumid: page.album,\n age: page.uploadAge,\n filelength: page.fileLength\n }\n }).catch(error => {\n // Format error for display purpose\n return error.response.data ? error.response : {\n data: {\n success: false,\n description: error.toString()\n }\n }\n }).then(response => {\n return finishedUrlUpload(file, response.data)\n })\n }\n\n function shiftQueue () {\n while (page.urlsQueue.length && (page.activeUrlsQueue < page.parallelUploads)) {\n page.activeUrlsQueue++\n initUrlUpload(page.urlsQueue.shift())\n }\n }\n\n return shiftQueue()\n}\n\npage.updateTemplateIcon = (templateElement, iconClass) => {\n const iconElement = templateElement.querySelector('.icon')\n if (!iconElement) return\n\n iconElement.classList.add(iconClass)\n iconElement.classList.remove('is-hidden')\n}\n\npage.updateTemplate = (file, response) => {\n if (!response.url) return\n\n const link = file.previewElement.querySelector('.link')\n const a = link.querySelector('a')\n const clipboard = file.previewElement.querySelector('.clipboard-mobile > .clipboard-js')\n a.href = a.innerHTML = clipboard.dataset.clipboardText = response.url\n\n link.classList.remove('is-hidden')\n clipboard.parentElement.classList.remove('is-hidden')\n\n const exec = /.[\\w]+(\\?|$)/.exec(response.url)\n const extname = exec && exec[0]\n ? exec[0].toLowerCase()\n : null\n\n if (page.imageExts.includes(extname))\n if (page.previewImages) {\n const img = file.previewElement.querySelector('img')\n img.setAttribute('alt', response.name || '')\n img.dataset.src = response.url\n img.classList.remove('is-hidden')\n img.onerror = event => {\n // Hide image elements that fail to load\n // Consequently include WEBP in browsers that do not have WEBP support (e.g. IE)\n event.currentTarget.classList.add('is-hidden')\n page.updateTemplateIcon(file.previewElement, 'icon-picture')\n }\n page.lazyLoad.update(file.previewElement.querySelectorAll('img'))\n } else {\n page.updateTemplateIcon(file.previewElement, 'icon-picture')\n }\n else if (page.videoExts.includes(extname))\n page.updateTemplateIcon(file.previewElement, 'icon-video')\n else\n page.updateTemplateIcon(file.previewElement, 'icon-doc-inv')\n\n if (response.expirydate) {\n const expiryDate = file.previewElement.querySelector('.expiry-date')\n expiryDate.innerHTML = `EXP: ${page.getPrettyDate(new Date(response.expirydate * 1000))}`\n expiryDate.classList.remove('is-hidden')\n }\n}\n\npage.createAlbum = () => {\n const div = document.createElement('div')\n div.innerHTML = `\n
\n
\n \n
\n

Max length is ${page.albumTitleMaxLength} characters.

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

Max length is ${page.albumDescMaxLength} characters.

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

${help}

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

\n \n

\n

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

\n `\n\n form.appendChild(submit)\n form.querySelector('#saveConfig').addEventListener('click', () => {\n if (!form.checkValidity())\n return\n\n const keys = Object.keys(config)\n .filter(key => config[key].display !== false && config[key].disabled !== true)\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i]\n\n let value\n if (config[key].select !== undefined) {\n if (form.elements[key].value !== 'default')\n value = form.elements[key].value\n } else if (config[key].number !== undefined) {\n const parsed = parseInt(form.elements[key].value)\n if (!isNaN(parsed))\n value = Math.min(Math.max(parsed, config[key].number.min), config[key].number.max)\n }\n\n if (value !== undefined && value !== fallback[key])\n localStorage[lsKeys[key]] = value\n else\n localStorage.removeItem(lsKeys[key])\n }\n\n swal({\n title: 'Woohoo!',\n text: 'Configuration saved into this browser.',\n icon: 'success'\n }).then(() => {\n window.location.reload()\n })\n })\n\n tabContent.appendChild(form)\n}\n\npage.getPrettyUploadAge = hours => {\n if (hours === 0) {\n return 'Permanent'\n } else if (hours < 1) {\n const minutes = hours * 60\n return `${minutes} minute${minutes === 1 ? '' : 's'}`\n } else if (hours >= 24) {\n const days = hours / 24\n return `${days} day${days === 1 ? '' : 's'}`\n } else {\n return `${hours} hour${hours === 1 ? '' : 's'}`\n }\n}\n\n// Handle image paste event\nwindow.addEventListener('paste', event => {\n const items = (event.clipboardData || event.originalEvent.clipboardData).items\n const index = Object.keys(items)\n for (let i = 0; i < index.length; i++) {\n const item = items[index[i]]\n if (item.kind === 'file') {\n const blob = item.getAsFile()\n /* eslint-disable-next-line compat/compat */\n const file = new File([blob], `pasted-image.${blob.type.match(/(?:[^/]*\\/)([^;]*)/)[1]}`, {\n type: blob.type\n })\n page.dropzone.addFile(file)\n }\n }\n})\n\nwindow.onload = () => {\n if (window.cookieconsent)\n window.cookieconsent.initialise({\n cookie: {\n name: 'cookieconsent_status',\n path: window.location.pathname,\n expiryDays: 730,\n secure: window.location.protocol === 'https:'\n },\n palette: {\n popup: {\n background: '#282828',\n text: '#eff0f1'\n },\n button: {\n background: '#209cee',\n text: '#ffffff'\n }\n },\n theme: 'classic',\n position: 'bottom-left',\n content: {\n message: 'We use cookies to offer you a better browsing experience and to analyze our traffic. You consent to our cookies if you continue to use this website.',\n dismiss: 'Got it!',\n link: 'Details in our Cookie Policy',\n href: 'cookiepolicy'\n }\n })\n\n page.checkIfPublic()\n\n page.clipboardJS = new ClipboardJS('.clipboard-js')\n\n page.clipboardJS.on('success', () => {\n return swal('', 'The link has been copied to clipboard.', 'success', {\n buttons: false,\n timer: 1500\n })\n })\n\n page.clipboardJS.on('error', page.onError)\n\n page.lazyLoad = new LazyLoad({\n elements_selector: '.field.uploads img'\n })\n\n document.querySelector('#createAlbum').addEventListener('click', () => {\n page.createAlbum()\n })\n}\n"]} \ No newline at end of file +{"version":3,"sources":["home.js"],"names":["const","lsKeys","token","chunkSize","parallelUploads","uploadsHistoryOrder","previewImages","fileLength","uploadAge","stripTags","page","localStorage","private","enableUserAccounts","maxSize","chunkSizeConfig","temporaryUploadAges","fileIdentifierLength","stripTagsConfig","album","maxSizeBytes","urlMaxSize","urlMaxSizeBytes","tabs","activeTab","albumSelect","albumSelectOnChange","previewTemplate","dropzone","clipboardJS","lazyLoad","urlsQueue","activeUrlsQueue","imageExts","videoExts","albumTitleMaxLength","albumDescMaxLength","onInitError","error","document","querySelector","classList","add","querySelectorAll","forEach","element","uploadButton","innerText","remove","addEventListener","window","location","reload","response","onAxiosError","onError","console","content","createElement","innerHTML","toString","swal","title","icon","statusText","520","521","522","523","524","525","526","527","530","status","description","data","checkClientVersion","apiVersion","match","src","text","buttons","confirm","closeModal","then","checkIfPublic","let","renderShown","axios","get","onDownloadProgress","doRender","version","parseInt","max","default","preparePage","catch","prepareUpload","verifyToken","button","href","reloadOnError","post","success","removeItem","authLink","setAttribute","value","prepareShareX","fetchAlbums","prepareUploadConfig","getPrettyBytes","prepareDropzone","event","addUrlsToQueue","tabsContainer","loop","i","id","dataset","tabContent","setActiveTab","push","tab","length","index","headers","Array","isArray","albums","option","name","appendChild","previewNode","parentNode","removeChild","tabDiv","div","className","previewsContainer","Dropzone","body","url","paramName","clickable","maxFilesize","uploadMultiple","createImageThumbnails","autoProcessQueue","chunking","Boolean","parallelChunkUploads","timeout","init","this","on","file","previewElement","xhr","ontimeout","instances","getUploadingFiles","filter","instance","_handleUploadError","undefined","_uplSpeedCalc","lastSent","timestamp","Date","now","bytes","upload","chunked","setRequestHeader","chunks","progress","prettyBytesPerSec","total","Math","size","percentage","bytesSent","toFixed","upl","prefix","skipProgress","done","last","totalChunkCount","chunkIndex","elapsed","bytesPerSec","fullSec","splice","excessDuration","duration","files","updateTemplate","test","updateTemplateIcon","chunksUploaded","uuid","original","type","albumid","filelength","age","striptags","urls","split","trim","firstChild","processUrlsQueue","shiftQueue","initUrlUpload","finishedUrlUpload","shift","templateElement","iconClass","iconElement","link","a","clipboard","clipboardText","parentElement","exec","extname","toLowerCase","includes","img","onerror","currentTarget","update","expirydate","expiryDate","getPrettyDate","createAlbum","cancel","download","checked","public","selected","fallback","min","config","siBytes","label","select","help","valueHandler","display","number","round","disabled","force","video","suffix","uploadFields","stored","parseFloat","String","getPrettyUploadAge","isNaN","form","preventDefault","configKeys","Object","keys","key","conf","field","parsed","find","sel","control","opts","j","opt","join","tmp","submit","checkValidity","elements","hours","minutes","days","items","clipboardData","originalEvent","item","kind","blob","getAsFile","File","addFile","onload","cookieconsent","initialise","cookie","path","pathname","expiryDays","secure","protocol","palette","popup","background","theme","position","message","dismiss","ClipboardJS","timer","LazyLoad","elements_selector"],"mappings":"AAEAA,IAAMC,OAAS,CACbC,MAAO,QACPC,UAAW,YACXC,gBAAiB,kBACjBC,oBAAqB,sBACrBC,cAAe,gBACfC,WAAY,aACZC,UAAW,YACXC,UAAW,aAGPC,KAAO,CAEXR,MAAOS,aAAaV,OAAOC,OAG3BU,QAAS,KACTC,mBAAoB,KACpBC,QAAS,KACTC,gBAAiB,KACjBC,oBAAqB,KACrBC,qBAAsB,KACtBC,gBAAiB,KAGjBC,MAAO,KAEPf,gBAAiB,KACjBE,cAAe,KACfC,WAAY,KACZC,UAAW,KACXC,UAAW,KAEXW,aAAc,KACdC,WAAY,KACZC,gBAAiB,KACjBnB,UAAW,KAEXoB,KAAM,GACNC,UAAW,KACXC,YAAa,KACbC,oBAAqB,KACrBC,gBAAiB,KAEjBC,SAAU,KACVC,YAAa,KACbC,SAAU,KAGVC,UAAW,GACXC,gBAAiB,EAIjBC,UAAW,CAAC,QAAS,OAAQ,QAAS,OAAQ,OAAQ,OAAQ,QAAS,OAAQ,QAC/EC,UAAW,CAAC,QAAS,OAAQ,OAAQ,OAAQ,OAAQ,OAAQ,OAAQ,SAErEC,oBAAqB,GACrBC,mBAAoB,IAItBC,YAAgB,SAAGC,GAEjBC,SAASC,cAAc,aAAaC,UAAUC,IAAI,aAClDH,SAASC,cAAc,SAASC,UAAUC,IAAI,aAC9CH,SAASI,iBAAiB,gBAAgBC,SAAO,SAACC,GAChD,OAAOA,EAAQJ,UAAUC,IAAI,gB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B,OAAQ,CACNgN,WAAY,UACZpO,KAAM,YAGVqO,MAAO,UACPC,SAAU,cACV9P,QAAS,CACP+P,QAAS,uJACTC,QAAS,UACT1F,KAAM,+BACNzH,KAAM,kBAIZ5F,KAAK4E,gBAEL5E,KAAKmB,YAAc,IAAI6R,YAAY,iBAEnChT,KAAKmB,YAAYgI,GAAG,WAAS,WAC3B,OAAOhG,KAAK,GAAI,yCAA0C,UAAW,CACnEqB,SAAS,EACTyO,MAAO,UAIXjT,KAAKmB,YAAYgI,GAAG,QAASnJ,KAAK6C,SAElC7C,KAAKoB,SAAW,IAAI8R,SAAS,CAC3BC,kBAAmB,uBAGrBtR,SAASC,cAAc,gBAAgBS,iBAAiB,SAAO,WAC7DvC,KAAKqO","file":"home.js","sourcesContent":["/* global swal, axios, Dropzone, ClipboardJS, LazyLoad */\n\nconst lsKeys = {\n token: 'token',\n chunkSize: 'chunkSize',\n parallelUploads: 'parallelUploads',\n uploadsHistoryOrder: 'uploadsHistoryOrder',\n previewImages: 'previewImages',\n fileLength: 'fileLength',\n uploadAge: 'uploadAge',\n stripTags: 'stripTags'\n}\n\nconst page = {\n // user token\n token: localStorage[lsKeys.token],\n\n // configs from api/check\n private: null,\n enableUserAccounts: null,\n maxSize: null,\n chunkSizeConfig: null,\n temporaryUploadAges: null,\n fileIdentifierLength: null,\n stripTagsConfig: null,\n\n // store album id that will be used with upload requests\n album: null,\n\n parallelUploads: null,\n previewImages: null,\n fileLength: null,\n uploadAge: null,\n stripTags: null,\n\n maxSizeBytes: null,\n urlMaxSize: null,\n urlMaxSizeBytes: null,\n chunkSize: null,\n\n tabs: [],\n activeTab: null,\n albumSelect: null,\n albumSelectOnChange: null,\n previewTemplate: null,\n\n dropzone: null,\n clipboardJS: null,\n lazyLoad: null,\n\n // additional vars for url uploads\n urlsQueue: [],\n activeUrlsQueue: 0,\n\n // Include BMP for uploads preview only, cause the real images will be used\n // Sharp isn't capable of making their thumbnails for dashboard and album public pages\n imageExts: ['.webp', '.jpg', '.jpeg', '.bmp', '.gif', '.png', '.tiff', '.tif', '.svg'],\n videoExts: ['.webm', '.mp4', '.wmv', '.avi', '.mov', '.mkv', '.m4v', '.m2ts'],\n\n albumTitleMaxLength: 70,\n albumDescMaxLength: 4000\n}\n\n// Handler for errors during initialization\npage.onInitError = error => {\n // Hide these elements\n document.querySelector('#albumDiv').classList.add('is-hidden')\n document.querySelector('#tabs').classList.add('is-hidden')\n document.querySelectorAll('.tab-content').forEach(element => {\n return element.classList.add('is-hidden')\n })\n\n // Update upload button\n const uploadButton = document.querySelector('#loginToUpload')\n uploadButton.innerText = 'An error occurred. Try to reload?'\n uploadButton.classList.remove('is-loading')\n uploadButton.classList.remove('is-hidden')\n\n uploadButton.addEventListener('click', () => {\n window.location.reload()\n })\n\n if (error.response)\n page.onAxiosError(error)\n else\n page.onError(error)\n}\n\n// Handler for regular JS errors\npage.onError = error => {\n console.error(error)\n\n const content = document.createElement('div')\n content.innerHTML = `${error.toString()}`\n return swal({\n title: 'An error occurred!',\n icon: 'error',\n content\n })\n}\n\n// Handler for Axios errors\npage.onAxiosError = error => {\n console.error(error)\n\n // Better Cloudflare errors\n const cloudflareErrors = {\n 520: 'Unknown Error',\n 521: 'Web Server Is Down',\n 522: 'Connection Timed Out',\n 523: 'Origin Is Unreachable',\n 524: 'A Timeout Occurred',\n 525: 'SSL Handshake Failed',\n 526: 'Invalid SSL Certificate',\n 527: 'Railgun Error',\n 530: 'Origin DNS Error'\n }\n\n const statusText = cloudflareErrors[error.response.status] || error.response.statusText\n const description = error.response.data && error.response.data.description\n ? error.response.data.description\n : 'There was an error with the request, please check the console for more information.'\n\n return swal(`${error.response.status} ${statusText}`, description, 'error')\n}\n\npage.checkClientVersion = apiVersion => {\n const self = document.querySelector('#mainScript')\n const match = self.src.match(/\\?_=(\\d+)$/)\n if (match && match[1] && match[1] !== apiVersion)\n return swal({\n title: 'Updated detected!',\n text: 'Client assets have been updated. Reload to display the latest version?',\n icon: 'info',\n buttons: {\n confirm: {\n text: 'Reload',\n closeModal: false\n }\n }\n }).then(() => {\n window.location.reload()\n })\n}\n\npage.checkIfPublic = () => {\n let renderShown = false\n return axios.get('api/check', {\n onDownloadProgress: () => {\n // Only show render after this request has been initiated to avoid blocking\n if (!renderShown && typeof page.doRender === 'function') {\n page.doRender()\n renderShown = true\n }\n }\n }).then(response => {\n if (response.data.version)\n page.checkClientVersion(response.data.version)\n\n page.private = response.data.private\n page.enableUserAccounts = response.data.enableUserAccounts\n\n page.maxSize = parseInt(response.data.maxSize)\n page.maxSizeBytes = page.maxSize * 1e6\n page.chunkSizeConfig = {\n max: (response.data.chunkSize && parseInt(response.data.chunkSize.max)) || 95,\n default: response.data.chunkSize && parseInt(response.data.chunkSize.default)\n }\n\n page.temporaryUploadAges = response.data.temporaryUploadAges\n page.fileIdentifierLength = response.data.fileIdentifierLength\n page.stripTagsConfig = response.data.stripTags\n\n return page.preparePage()\n }).catch(page.onInitError)\n}\n\npage.preparePage = () => {\n if (page.private)\n if (page.token) {\n return page.verifyToken(page.token, true)\n } else {\n const button = document.querySelector('#loginToUpload')\n button.href = 'auth'\n button.classList.remove('is-loading')\n if (page.enableUserAccounts)\n button.innerText = 'Anonymous upload is disabled.\\nLog in or register to upload.'\n else\n button.innerText = 'Running in private mode.\\nLog 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 window.location.reload()\n })\n\n localStorage[lsKeys.token] = token\n page.token = token\n return page.prepareUpload()\n }).catch(page.onInitError)\n}\n\npage.prepareUpload = () => {\n // I think this fits best here because we need to check for a valid token before we can get the albums\n if (page.token) {\n // Change /auth link to /dashboard\n const authLink = document.querySelector('#linksColumn a[href=\"auth\"]')\n if (authLink)\n authLink.setAttribute('href', 'dashboard')\n\n // Display the album selection\n document.querySelector('#albumDiv').classList.remove('is-hidden')\n\n page.albumSelect = document.querySelector('#albumSelect')\n page.albumSelectOnChange = () => {\n page.album = parseInt(page.albumSelect.value)\n // Re-generate ShareX config file\n if (typeof page.prepareShareX === 'function')\n page.prepareShareX()\n }\n page.albumSelect.addEventListener('change', page.albumSelectOnChange)\n\n // Fetch albums\n page.fetchAlbums()\n } else if (page.enableUserAccounts) {\n document.querySelector('#loginLinkText').innerHTML = 'Create an account and keep track of your uploads'\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 // Prepare & generate files upload tab\n page.prepareDropzone()\n\n // Generate ShareX config file\n if (typeof page.prepareShareX === 'function')\n page.prepareShareX()\n\n // Prepare urls upload tab\n const urlMaxSize = document.querySelector('#urlMaxSize')\n if (urlMaxSize) {\n page.urlMaxSize = parseInt(urlMaxSize.innerHTML)\n page.urlMaxSizeBytes = page.urlMaxSize * 1e6\n urlMaxSize.innerHTML = page.getPrettyBytes(page.urlMaxSizeBytes)\n document.querySelector('#uploadUrls').addEventListener('click', event => {\n page.addUrlsToQueue()\n })\n }\n\n // Get all tabs\n const tabsContainer = document.querySelector('#tabs')\n const tabs = tabsContainer.querySelectorAll('li')\n for (let i = 0; i < tabs.length; i++) {\n const id = tabs[i].dataset.id\n const tabContent = document.querySelector(`#${id}`)\n if (!tabContent) continue\n\n tabs[i].addEventListener('click', () => {\n page.setActiveTab(i)\n })\n page.tabs.push({ tab: tabs[i], content: tabContent })\n }\n\n // Set first valid tab as the default active tab\n if (page.tabs.length) {\n page.setActiveTab(0)\n tabsContainer.classList.remove('is-hidden')\n }\n}\n\npage.setActiveTab = index => {\n for (let i = 0; i < page.tabs.length; i++)\n if (i === index) {\n page.tabs[i].tab.classList.add('is-active')\n page.tabs[i].content.classList.remove('is-hidden')\n page.activeTab = index\n } else {\n page.tabs[i].tab.classList.remove('is-active')\n page.tabs[i].content.classList.add('is-hidden')\n }\n}\n\npage.fetchAlbums = () => {\n return axios.get('api/albums', { headers: { token: page.token } }).then(response => {\n if (response.data.success === false)\n return swal('An error occurred!', response.data.description, 'error')\n\n // Create an option for each album\n if (Array.isArray(response.data.albums) && response.data.albums.length)\n for (let i = 0; i < response.data.albums.length; i++) {\n const album = response.data.albums[i]\n const option = document.createElement('option')\n option.value = album.id\n option.innerHTML = album.name\n page.albumSelect.appendChild(option)\n }\n }).catch(page.onInitError)\n}\n\npage.prepareDropzone = () => {\n // Parse template element\n const previewNode = document.querySelector('#tpl')\n page.previewTemplate = previewNode.innerHTML\n previewNode.parentNode.removeChild(previewNode)\n\n // Generate files upload tab\n const tabDiv = document.querySelector('#tab-files')\n const div = document.createElement('div')\n div.className = 'control is-expanded'\n div.innerHTML = `\n
\n \n \n \n Click here or drag & drop files\n
\n `\n tabDiv.querySelector('.dz-container').appendChild(div)\n\n const previewsContainer = tabDiv.querySelector('#tab-files .field.uploads')\n\n page.dropzone = new Dropzone(document.body, {\n url: 'api/upload',\n paramName: 'files[]',\n clickable: tabDiv.querySelector('#dropzone'),\n maxFilesize: page.maxSizeBytes / 1024 / 1024, // this option expects MiB\n parallelUploads: page.parallelUploads,\n uploadMultiple: false,\n previewsContainer,\n previewTemplate: page.previewTemplate,\n createImageThumbnails: false,\n autoProcessQueue: true,\n headers: { token: page.token },\n chunking: Boolean(page.chunkSize),\n chunkSize: page.chunkSize * 1e6, // this option expects Bytes\n parallelChunkUploads: false, // for now, enabling this breaks descriptive upload progress\n timeout: 0,\n\n init () {\n this.on('addedfile', file => {\n // Set active tab to file uploads, if necessary\n if (page.activeTab !== 0)\n page.setActiveTab(0)\n\n // Add file entry\n tabDiv.querySelector('.uploads').classList.remove('is-hidden')\n\n file.previewElement.querySelector('.name').innerHTML = file.name\n file.previewElement.querySelector('.descriptive-progress').innerHTML = 'Waiting in queue\\u2026'\n })\n\n this.on('sending', (file, xhr) => {\n // Add timeout listener (hacky method due to lack of built-in timeout handler)\n if (!xhr.ontimeout)\n xhr.ontimeout = () => {\n const instances = page.dropzone.getUploadingFiles()\n .filter(instance => instance.xhr === xhr)\n page.dropzone._handleUploadError(instances, xhr, 'Connection timed out. Try to reduce upload chunk size.')\n }\n\n // Attach necessary data for initial upload speed calculation\n if (xhr._uplSpeedCalc === undefined)\n xhr._uplSpeedCalc = {\n lastSent: 0,\n data: [{ timestamp: Date.now(), bytes: 0 }]\n }\n\n // If not chunked uploads, add extra headers\n if (!file.upload.chunked) {\n if (page.album !== null) xhr.setRequestHeader('albumid', page.album)\n if (page.fileLength !== null) xhr.setRequestHeader('filelength', page.fileLength)\n if (page.uploadAge !== null) xhr.setRequestHeader('age', page.uploadAge)\n if (page.stripTags !== null) xhr.setRequestHeader('striptags', page.stripTags)\n }\n\n if (!file.upload.chunked)\n file.previewElement.querySelector('.descriptive-progress').innerHTML = 'Uploading\\u2026'\n else if (file.upload.chunks.length === 1)\n file.previewElement.querySelector('.descriptive-progress').innerHTML = `Uploading chunk 1/${file.upload.totalChunkCount}\\u2026`\n })\n\n // Update descriptive progress\n this.on('uploadprogress', (file, progress) => {\n // Total bytes will eventually be bigger than file size when chunked\n const total = Math.max(file.size, file.upload.total)\n const percentage = (file.upload.bytesSent / total * 100).toFixed(0)\n\n const upl = file.upload.chunked\n ? file.upload.chunks[file.upload.chunks.length - 1]\n : file.upload\n const xhr = upl.xhr || file.xhr\n\n let prefix = 'Uploading\\u2026'\n let skipProgress = false\n if (file.upload.chunked) {\n const done = upl.bytesSent === upl.total\n const last = file.upload.chunks.length === file.upload.totalChunkCount\n let chunkIndex = file.upload.chunks.length\n if (done && !last) {\n chunkIndex++\n skipProgress = true\n }\n prefix = `Uploading chunk ${chunkIndex}/${file.upload.totalChunkCount}\\u2026`\n }\n\n // Real-time upload speed calculation\n let prettyBytesPerSec\n if (!skipProgress) {\n const now = Date.now()\n const bytesSent = upl.bytesSent - xhr._uplSpeedCalc.lastSent\n\n // Push data of current iteration\n xhr._uplSpeedCalc.lastSent = upl.bytesSent\n xhr._uplSpeedCalc.data.push({ timestamp: now, bytes: bytesSent })\n\n // Wait till at least the 2nd iteration (3 data including initial data)\n const length = xhr._uplSpeedCalc.data.length\n if (length > 2) {\n // Calculate using data from all iterations\n let elapsed = 0\n let bytesPerSec = 0\n let fullSec = false\n let i = length - 1 // Always start with 2nd from last item\n while (i--) {\n // Splice data of unrequired iterations\n if (fullSec) {\n xhr._uplSpeedCalc.data.splice(i, 1)\n continue\n }\n // Sum data\n elapsed = now - xhr._uplSpeedCalc.data[i].timestamp\n if (elapsed > 1000) {\n const excessDuration = elapsed - 1000\n const newerIterationElapsed = now - xhr._uplSpeedCalc.data[i + 1].timestamp\n const duration = elapsed - newerIterationElapsed\n const fragment = (duration - excessDuration) / duration * xhr._uplSpeedCalc.data[i + 1].bytes\n bytesPerSec += fragment\n fullSec = true\n } else {\n bytesPerSec += xhr._uplSpeedCalc.data[i + 1].bytes\n }\n }\n\n // If not enough data\n if (!fullSec)\n bytesPerSec = 1000 / elapsed * bytesPerSec\n\n // Get pretty bytes\n prettyBytesPerSec = page.getPrettyBytes(bytesPerSec)\n }\n }\n\n file.previewElement.querySelector('.descriptive-progress').innerHTML =\n `${prefix} ${percentage}%${prettyBytesPerSec ? ` at ${prettyBytesPerSec}/s` : ''}`\n })\n\n this.on('success', (file, data) => {\n if (!data) return\n file.previewElement.querySelector('.descriptive-progress').classList.add('is-hidden')\n\n if (data.success === false) {\n file.previewElement.querySelector('.error').innerHTML = data.description\n file.previewElement.querySelector('.error').classList.remove('is-hidden')\n }\n\n if (Array.isArray(data.files) && data.files[0])\n page.updateTemplate(file, data.files[0])\n })\n\n this.on('error', (file, error) => {\n // Clean up file size errors\n if ((typeof error === 'string' && /^File is too big/.test(error)) ||\n (typeof error === 'object' && /File too large/.test(error.description)))\n error = `File too large (${page.getPrettyBytes(file.size)}).`\n\n page.updateTemplateIcon(file.previewElement, 'icon-block')\n\n file.previewElement.querySelector('.descriptive-progress').classList.add('is-hidden')\n\n file.previewElement.querySelector('.error').innerHTML = error.description || error\n file.previewElement.querySelector('.error').classList.remove('is-hidden')\n })\n },\n\n chunksUploaded (file, done) {\n file.previewElement.querySelector('.descriptive-progress').innerHTML =\n `Rebuilding ${file.upload.totalChunkCount} chunks\\u2026`\n\n return axios.post('api/upload/finishchunks', {\n // This API supports an array of multiple files\n files: [{\n uuid: file.upload.uuid,\n original: file.name,\n type: file.type,\n albumid: page.album,\n filelength: page.fileLength,\n age: page.uploadAge\n }]\n }, {\n headers: {\n token: page.token,\n // Unlike the options above (e.g. albumid, filelength, etc.),\n // strip tags cannot yet be configured per file with this API\n striptags: page.stripTags\n }\n }).catch(error => {\n // Format error for display purpose\n return error.response.data ? error.response : {\n data: {\n success: false,\n description: error.toString()\n }\n }\n }).then(response => {\n file.previewElement.querySelector('.descriptive-progress').classList.add('is-hidden')\n\n if (response.data.success === false) {\n file.previewElement.querySelector('.error').innerHTML = response.data.description\n file.previewElement.querySelector('.error').classList.remove('is-hidden')\n }\n\n if (response.data.files && response.data.files[0])\n page.updateTemplate(file, response.data.files[0])\n\n return done()\n })\n }\n })\n}\n\npage.addUrlsToQueue = () => {\n const urls = document.querySelector('#urls').value\n .split(/\\r?\\n/)\n .filter(url => {\n return url.trim().length\n })\n\n if (!urls.length)\n return swal('An error occurred!', 'You have not entered any URLs.', 'error')\n\n const tabDiv = document.querySelector('#tab-urls')\n tabDiv.querySelector('.uploads').classList.remove('is-hidden')\n\n for (let i = 0; i < urls.length; i++) {\n const previewTemplate = document.createElement('template')\n previewTemplate.innerHTML = page.previewTemplate.trim()\n\n const previewElement = previewTemplate.content.firstChild\n previewElement.querySelector('.name').innerHTML = urls[i]\n previewElement.querySelector('.descriptive-progress').innerHTML = 'Waiting in queue\\u2026'\n\n const previewsContainer = tabDiv.querySelector('.uploads')\n previewsContainer.appendChild(previewElement)\n\n page.urlsQueue.push({\n url: urls[i],\n previewElement\n })\n }\n\n page.processUrlsQueue()\n document.querySelector('#urls').value = ''\n}\n\npage.processUrlsQueue = () => {\n if (!page.urlsQueue.length) return\n\n function finishedUrlUpload (file, data) {\n file.previewElement.querySelector('.descriptive-progress').classList.add('is-hidden')\n\n if (data.success === false) {\n const match = data.description.match(/ over limit: (\\d+)$/)\n if (match && match[1])\n data.description = `File exceeded limit of ${page.getPrettyBytes(match[1])}.`\n\n file.previewElement.querySelector('.error').innerHTML = data.description\n file.previewElement.querySelector('.error').classList.remove('is-hidden')\n }\n\n if (Array.isArray(data.files) && data.files[0])\n page.updateTemplate(file, data.files[0])\n\n page.activeUrlsQueue--\n return shiftQueue()\n }\n\n function initUrlUpload (file) {\n file.previewElement.querySelector('.descriptive-progress').innerHTML =\n 'Waiting for server to fetch URL\\u2026'\n\n return axios.post('api/upload', {\n urls: [file.url]\n }, {\n headers: {\n token: page.token,\n albumid: page.album,\n age: page.uploadAge,\n filelength: page.fileLength\n }\n }).catch(error => {\n // Format error for display purpose\n return error.response.data ? error.response : {\n data: {\n success: false,\n description: error.toString()\n }\n }\n }).then(response => {\n return finishedUrlUpload(file, response.data)\n })\n }\n\n function shiftQueue () {\n while (page.urlsQueue.length && (page.activeUrlsQueue < page.parallelUploads)) {\n page.activeUrlsQueue++\n initUrlUpload(page.urlsQueue.shift())\n }\n }\n\n return shiftQueue()\n}\n\npage.updateTemplateIcon = (templateElement, iconClass) => {\n const iconElement = templateElement.querySelector('.icon')\n if (!iconElement) return\n\n iconElement.classList.add(iconClass)\n iconElement.classList.remove('is-hidden')\n}\n\npage.updateTemplate = (file, response) => {\n if (!response.url) return\n\n const link = file.previewElement.querySelector('.link')\n const a = link.querySelector('a')\n const clipboard = file.previewElement.querySelector('.clipboard-mobile > .clipboard-js')\n a.href = a.innerHTML = clipboard.dataset.clipboardText = response.url\n\n link.classList.remove('is-hidden')\n clipboard.parentElement.classList.remove('is-hidden')\n\n const exec = /.[\\w]+(\\?|$)/.exec(response.url)\n const extname = exec && exec[0]\n ? exec[0].toLowerCase()\n : null\n\n if (page.imageExts.includes(extname))\n if (page.previewImages) {\n const img = file.previewElement.querySelector('img')\n img.setAttribute('alt', response.name || '')\n img.dataset.src = response.url\n img.classList.remove('is-hidden')\n img.onerror = event => {\n // Hide image elements that fail to load\n // Consequently include WEBP in browsers that do not have WEBP support (e.g. IE)\n event.currentTarget.classList.add('is-hidden')\n page.updateTemplateIcon(file.previewElement, 'icon-picture')\n }\n page.lazyLoad.update(file.previewElement.querySelectorAll('img'))\n } else {\n page.updateTemplateIcon(file.previewElement, 'icon-picture')\n }\n else if (page.videoExts.includes(extname))\n page.updateTemplateIcon(file.previewElement, 'icon-video')\n else\n page.updateTemplateIcon(file.previewElement, 'icon-doc-inv')\n\n if (response.expirydate) {\n const expiryDate = file.previewElement.querySelector('.expiry-date')\n expiryDate.innerHTML = `EXP: ${page.getPrettyDate(new Date(response.expirydate * 1000))}`\n expiryDate.classList.remove('is-hidden')\n }\n}\n\npage.createAlbum = () => {\n const div = document.createElement('div')\n div.innerHTML = `\n
\n
\n \n
\n

Max length is ${page.albumTitleMaxLength} characters.

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

Max length is ${page.albumDescMaxLength} characters.

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

${help}

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

\n \n

\n

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

\n `\n\n form.appendChild(submit)\n form.querySelector('#saveConfig').addEventListener('click', () => {\n if (!form.checkValidity())\n return\n\n const keys = Object.keys(config)\n .filter(key => config[key].display !== false && config[key].disabled !== true)\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i]\n\n let value\n if (config[key].select !== undefined) {\n if (form.elements[key].value !== 'default')\n value = form.elements[key].value\n } else if (config[key].number !== undefined) {\n const parsed = parseInt(form.elements[key].value)\n if (!isNaN(parsed))\n value = Math.min(Math.max(parsed, config[key].number.min), config[key].number.max)\n }\n\n if (value !== undefined && value !== fallback[key])\n localStorage[lsKeys[key]] = value\n else\n localStorage.removeItem(lsKeys[key])\n }\n\n swal({\n title: 'Woohoo!',\n text: 'Configuration saved into this browser.',\n icon: 'success'\n }).then(() => {\n window.location.reload()\n })\n })\n\n tabContent.appendChild(form)\n}\n\npage.getPrettyUploadAge = hours => {\n if (hours === 0) {\n return 'Permanent'\n } else if (hours < 1) {\n const minutes = hours * 60\n return `${minutes} minute${minutes === 1 ? '' : 's'}`\n } else if (hours >= 24) {\n const days = hours / 24\n return `${days} day${days === 1 ? '' : 's'}`\n } else {\n return `${hours} hour${hours === 1 ? '' : 's'}`\n }\n}\n\n// Handle image paste event\nwindow.addEventListener('paste', event => {\n const items = (event.clipboardData || event.originalEvent.clipboardData).items\n const index = Object.keys(items)\n for (let i = 0; i < index.length; i++) {\n const item = items[index[i]]\n if (item.kind === 'file') {\n const blob = item.getAsFile()\n /* eslint-disable-next-line compat/compat */\n const file = new File([blob], `pasted-image.${blob.type.match(/(?:[^/]*\\/)([^;]*)/)[1]}`, {\n type: blob.type\n })\n page.dropzone.addFile(file)\n }\n }\n})\n\nwindow.onload = () => {\n if (window.cookieconsent)\n window.cookieconsent.initialise({\n cookie: {\n name: 'cookieconsent_status',\n path: window.location.pathname,\n expiryDays: 730,\n secure: window.location.protocol === 'https:'\n },\n palette: {\n popup: {\n background: '#282828',\n text: '#eff0f1'\n },\n button: {\n background: '#209cee',\n text: '#ffffff'\n }\n },\n theme: 'classic',\n position: 'bottom-left',\n content: {\n message: 'We use cookies to offer you a better browsing experience and to analyze our traffic. You consent to our cookies if you continue to use this website.',\n dismiss: 'Got it!',\n link: 'Details in our Cookie Policy',\n href: 'cookiepolicy'\n }\n })\n\n page.checkIfPublic()\n\n page.clipboardJS = new ClipboardJS('.clipboard-js')\n\n page.clipboardJS.on('success', () => {\n return swal('', 'The link has been copied to clipboard.', 'success', {\n buttons: false,\n timer: 1500\n })\n })\n\n page.clipboardJS.on('error', page.onError)\n\n page.lazyLoad = new LazyLoad({\n elements_selector: '.field.uploads img'\n })\n\n document.querySelector('#createAlbum').addEventListener('click', () => {\n page.createAlbum()\n })\n}\n"]} \ No newline at end of file diff --git a/package.json b/package.json index 89fda05..062cfcd 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ }, "dependencies": { "bcrypt": "^4.0.1", + "blake3": "^2.1.4", "body-parser": "^1.19.0", "clamdjs": "^1.0.2", "express": "^4.17.1", diff --git a/src/js/home.js b/src/js/home.js index 8314f37..aa6713b 100644 --- a/src/js/home.js +++ b/src/js/home.js @@ -19,7 +19,7 @@ const page = { private: null, enableUserAccounts: null, maxSize: null, - chunkSize: null, + chunkSizeConfig: null, temporaryUploadAges: null, fileIdentifierLength: null, stripTagsConfig: null, @@ -27,14 +27,16 @@ const page = { // store album id that will be used with upload requests album: null, - parallelUploads: 2, + parallelUploads: null, previewImages: null, fileLength: null, uploadAge: null, + stripTags: null, maxSizeBytes: null, urlMaxSize: null, urlMaxSizeBytes: null, + chunkSize: null, tabs: [], activeTab: null, @@ -157,9 +159,14 @@ page.checkIfPublic = () => { page.private = response.data.private page.enableUserAccounts = response.data.enableUserAccounts + page.maxSize = parseInt(response.data.maxSize) page.maxSizeBytes = page.maxSize * 1e6 - page.chunkSize = parseInt(response.data.chunkSize) + page.chunkSizeConfig = { + max: (response.data.chunkSize && parseInt(response.data.chunkSize.max)) || 95, + default: response.data.chunkSize && parseInt(response.data.chunkSize.default) + } + page.temporaryUploadAges = response.data.temporaryUploadAges page.fileIdentifierLength = response.data.fileIdentifierLength page.stripTagsConfig = response.data.stripTags @@ -754,11 +761,12 @@ page.createAlbum = () => { page.prepareUploadConfig = () => { const fallback = { - chunkSize: page.chunkSize, - parallelUploads: page.parallelUploads + chunkSize: page.chunkSizeConfig.default, + parallelUploads: 2 } - const temporaryUploadAges = Array.isArray(page.temporaryUploadAges) && page.temporaryUploadAges.length + const temporaryUploadAges = Array.isArray(page.temporaryUploadAges) && + page.temporaryUploadAges.length const fileIdentifierLength = page.fileIdentifierLength && typeof page.fileIdentifierLength.min === 'number' && typeof page.fileIdentifierLength.max === 'number' @@ -802,11 +810,11 @@ page.prepareUploadConfig = () => { disabled: page.stripTagsConfig && page.stripTagsConfig.force }, chunkSize: { - display: !isNaN(page.chunkSize), + display: Boolean(page.chunkSizeConfig.default), label: 'Upload chunk size (MB)', number: { min: 1, - max: 95, + max: page.chunkSizeConfig.max, suffix: ' MB', round: true }, @@ -895,7 +903,7 @@ page.prepareUploadConfig = () => { value = conf.value } else if (conf.number !== undefined) { const parsed = parseInt(localStorage[lsKeys[key]]) - if (!isNaN(parsed)) + if (!isNaN(parsed) && parsed <= conf.number.max && parsed >= conf.number.min) value = parsed } else { const stored = localStorage[lsKeys[key]] @@ -911,6 +919,8 @@ page.prepareUploadConfig = () => { conf.valueHandler(value) else if (value !== undefined) page[key] = value + else if (fallback[key] !== undefined) + page[key] = fallback[key] } let control diff --git a/src/versions.json b/src/versions.json index 15ec58b..ffd57a7 100644 --- a/src/versions.json +++ b/src/versions.json @@ -1,5 +1,5 @@ { - "1": "1590617686", + "1": "1590695426", "2": "1589010026", "3": "1581416390", "4": "1581416390", diff --git a/yarn.lock b/yarn.lock index a528cbb..92faea3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -788,6 +788,11 @@ bl@^4.0.1: inherits "^2.0.4" readable-stream "^3.4.0" +blake3@^2.1.4: + version "2.1.4" + resolved "https://registry.yarnpkg.com/blake3/-/blake3-2.1.4.tgz#78117bc9e80941097fdf7d03e897a9ee595ecd62" + integrity sha512-70hmx0lPd6zmtNwxPT4/1P0pqaEUlTJ0noUBvCXPLfMpN0o8PPaK3q7ZlpRIyhrqcXxeMAJSowNm/L9oi/x1XA== + body-parser@1.19.0, body-parser@^1.19.0: version "1.19.0" resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.19.0.tgz#96b2709e57c9c4e09a6fd66a8fd979844f69f08a"