From a8c702065fd1e51ed54a3fcf4d4b4317482bfa54 Mon Sep 17 00:00:00 2001 From: Bobby Wibowo Date: Tue, 26 Nov 2019 21:58:10 +0700 Subject: [PATCH] Implemented descriptive upload progress MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Say goodbye to upload progress bar đź‘‹ Bumped v1 version string --- TODO.md | 2 +- dist/css/home.css | 2 +- dist/css/home.css.map | 2 +- dist/js/home.js | 2 +- dist/js/home.js.map | 2 +- src/css/home.css | 5 +- src/js/home.js | 103 +++++++++++++++++++++++++++++++----------- src/versions.json | 2 +- views/home.njk | 6 +-- 9 files changed, 88 insertions(+), 38 deletions(-) diff --git a/TODO.md b/TODO.md index dd19cf6..2f90652 100644 --- a/TODO.md +++ b/TODO.md @@ -31,7 +31,7 @@ Due to the fact that it needs to have `page` variable defined first, it can't ev This may prevent proper async load of JS assets, which I'd like to look into, in pursuit of even more speed. * [ ] Remember last pages of uploads & users lists. Consider remembering last pages of each individual albums as well. When deleting an album, properly delete its remembered last page, if any. When listing albums sidebar and/or listing albums in Manage your albums, also delete remembered last pages of any missing albums (assume the albums were deleted from another device). -* [ ] Descriptive upload progress, such as upload speed. Also tell user which chunk is currently being uploaded, to avoid confusion when progress "stops" when shifting to the next chunk. +* [x] Descriptive upload progress, such as upload speed. Also tell user which chunk is currently being uploaded, to avoid confusion when progress "stops" when shifting to the next chunk. Low priority: diff --git a/dist/css/home.css b/dist/css/home.css index 376a4b8..2ef66db 100644 --- a/dist/css/home.css +++ b/dist/css/home.css @@ -1,2 +1,2 @@ -#b{width:200px;height:200px;border-radius:100%;display:inline-block;margin-bottom:40px;vertical-align:top;-webkit-animation-delay:.5s;animation-delay:.5s;-webkit-animation-duration:1.5s;animation-duration:1.5s;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-name:floatUp;animation-name:floatUp;-webkit-animation-timing-function:cubic-bezier(0,.71,.29,1);animation-timing-function:cubic-bezier(0,.71,.29,1)}#b img.logo{max-height:200px}#dropzone *{pointer-events:none}#panel,#tokenContainer{display:none}#maxSize{font-size:1rem}.dz-preview .dz-details{display:-webkit-box;display:flex}.dz-preview .dz-details .dz-filename,.dz-preview .dz-details .dz-size{-webkit-box-flex:1;flex:1}.dz-preview .dz-error-mark,.dz-preview .dz-success-mark,.dz-preview img{display:none}@-webkit-keyframes floatUp{0%{opacity:0;-webkit-transform:scale(.86);transform:scale(.86)}25%{opacity:1}67%{-webkit-transform:scale(1);transform:scale(1)}to{-webkit-transform:scale(1);transform:scale(1)}}@keyframes floatUp{0%{opacity:0;-webkit-transform:scale(.86);transform:scale(.86)}25%{opacity:1}67%{-webkit-transform:scale(1);transform:scale(1)}to{-webkit-transform:scale(1);transform:scale(1)}}.uploads.is-reversed{display:-webkit-box;display:flex;-webkit-box-orient:vertical;-webkit-box-direction:reverse;flex-direction:column-reverse}.uploads>div{-webkit-animation:fadeInOpacity .5s;animation:fadeInOpacity .5s;margin:1rem}.uploads.is-reversed>div{-webkit-box-flex:0;flex:0 0 auto}.uploads>div:first-child{margin-top:1.5rem}.uploads.nojs{margin-bottom:0}.uploads>div>.icon:not(.icon-block){color:#209cee}.uploads>div>.icon.icon-block{color:#da4453}.uploads progress{margin-top:.5rem;margin-bottom:1rem}.uploads img{max-width:200px}.name{font-size:1rem;color:#eff0f1}.link>a,.name{word-break:break-all}.clipboard-mobile{margin-top:5px}#albumDiv{-webkit-animation:fadeInOpacity .5s;animation:fadeInOpacity .5s}#albumDiv .control{text-align:inherit}#linksColumn{margin-top:-.25rem;margin-left:-.25rem;margin-right:-.25rem;-webkit-animation:fadeInOpacity .5s;animation:fadeInOpacity .5s}#linksColumn .column{padding:.25rem}#linksColumn>span{padding:0 .3rem;color:#7f8c8d}.git-commit a{display:inline-block;word-break:break-all}#tabs{margin-bottom:1rem;-webkit-animation:fadeInOpacity .5s;animation:fadeInOpacity .5s}#tabs ul{border-bottom:1px solid #585858}#tabs li a{color:#bdc3c7;border-bottom-color:#585858}#tabs.is-boxed li.is-active a{color:#209cee;background:#000;border-color:#585858 #585858 #000}#tabs.is-boxed li:not(.is-active) a:hover{background:#585858}.tab-content{margin-bottom:-.75rem;-webkit-animation:fadeInOpacity .5s;animation:fadeInOpacity .5s}#tab-config.tab-content form{margin-bottom:.75rem}#urlMaxSize{font-weight:700}.render{position:fixed;right:0;bottom:0;font-size:1rem;color:#bdc3c7;cursor:pointer}.render.button{border-bottom-left-radius:0;border-bottom-right-radius:0;right:1%;opacity:.25;-webkit-transition:opacity .25s;transition:opacity .25s}.render.button:hover{opacity:1}input[type=file].is-fullwidth{width:100%} +#b{width:200px;height:200px;border-radius:100%;display:inline-block;margin-bottom:40px;vertical-align:top;-webkit-animation-delay:.5s;animation-delay:.5s;-webkit-animation-duration:1.5s;animation-duration:1.5s;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-name:floatUp;animation-name:floatUp;-webkit-animation-timing-function:cubic-bezier(0,.71,.29,1);animation-timing-function:cubic-bezier(0,.71,.29,1)}#b img.logo{max-height:200px}#dropzone *{pointer-events:none}#panel,#tokenContainer{display:none}#maxSize{font-size:1rem}.dz-preview .dz-details{display:-webkit-box;display:flex}.dz-preview .dz-details .dz-filename,.dz-preview .dz-details .dz-size{-webkit-box-flex:1;flex:1}.dz-preview .dz-error-mark,.dz-preview .dz-success-mark,.dz-preview img{display:none}@-webkit-keyframes floatUp{0%{opacity:0;-webkit-transform:scale(.86);transform:scale(.86)}25%{opacity:1}67%{-webkit-transform:scale(1);transform:scale(1)}to{-webkit-transform:scale(1);transform:scale(1)}}@keyframes floatUp{0%{opacity:0;-webkit-transform:scale(.86);transform:scale(.86)}25%{opacity:1}67%{-webkit-transform:scale(1);transform:scale(1)}to{-webkit-transform:scale(1);transform:scale(1)}}.uploads.is-reversed{display:-webkit-box;display:flex;-webkit-box-orient:vertical;-webkit-box-direction:reverse;flex-direction:column-reverse}.uploads>div{-webkit-animation:fadeInOpacity .5s;animation:fadeInOpacity .5s;margin:1rem}.uploads.is-reversed>div{-webkit-box-flex:0;flex:0 0 auto}.uploads>div:first-child{margin-top:1.5rem}.uploads.nojs{margin-bottom:0}.uploads>div>.icon:not(.icon-block){color:#209cee}.uploads>div>.icon.icon-block{color:#da4453}.uploads .descriptive-progress{color:#bdc3c7}.uploads img{max-width:200px}.name{font-size:1rem;color:#eff0f1}.link>a,.name{word-break:break-all}.clipboard-mobile{margin-top:5px}#albumDiv{-webkit-animation:fadeInOpacity .5s;animation:fadeInOpacity .5s}#albumDiv .control{text-align:inherit}#linksColumn{margin-top:-.25rem;margin-left:-.25rem;margin-right:-.25rem;-webkit-animation:fadeInOpacity .5s;animation:fadeInOpacity .5s}#linksColumn .column{padding:.25rem}#linksColumn>span{padding:0 .3rem;color:#7f8c8d}.git-commit a{display:inline-block;word-break:break-all}#tabs{margin-bottom:1rem;-webkit-animation:fadeInOpacity .5s;animation:fadeInOpacity .5s}#tabs ul{border-bottom:1px solid #585858}#tabs li a{color:#bdc3c7;border-bottom-color:#585858}#tabs.is-boxed li.is-active a{color:#209cee;background:#000;border-color:#585858 #585858 #000}#tabs.is-boxed li:not(.is-active) a:hover{background:#585858}.tab-content{margin-bottom:-.75rem;-webkit-animation:fadeInOpacity .5s;animation:fadeInOpacity .5s}#tab-config.tab-content form{margin-bottom:.75rem}#urlMaxSize{font-weight:700}.render{position:fixed;right:0;bottom:0;font-size:1rem;color:#bdc3c7;cursor:pointer}.render.button{border-bottom-left-radius:0;border-bottom-right-radius:0;right:1%;opacity:.25;-webkit-transition:opacity .25s;transition:opacity .25s}.render.button:hover{opacity:1}input[type=file].is-fullwidth{width:100%} /*# sourceMappingURL=home.css.map */ diff --git a/dist/css/home.css.map b/dist/css/home.css.map index b4792d0..8a97a98 100644 --- a/dist/css/home.css.map +++ b/dist/css/home.css.map @@ -1 +1 @@ -{"version":3,"sources":["css/home.css"],"names":[],"mappings":"AAAA,GACE,WAAY,CACZ,YAAa,CACb,kBAAmB,CACnB,oBAAqB,CACrB,kBAAmB,C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AEhB,iCACF,CAEA,0CACE,kBACF,CAEA,aACE,qBAAuB,CACvB,mCAA4B,CAA5B,2BACF,CAEA,6BACE,oBACF,CAEA,YACE,eACF,CAEA,QACE,cAAe,CACf,OAAQ,CACR,QAAS,CACT,cAAe,CACf,aAAc,CACd,cACF,CAEA,eACE,2BAA4B,CAC5B,4BAA6B,CAC7B,QAAS,CACT,WAAa,CACb,+BAAwB,CAAxB,uBACF,CAEA,qBACE,SACF,CAEA,8BACE,UACF","file":"home.css","sourcesContent":["#b {\n width: 200px;\n height: 200px;\n border-radius: 100%;\n display: inline-block;\n margin-bottom: 40px;\n vertical-align: top;\n animation-delay: 0.5s;\n animation-duration: 1.5s;\n animation-fill-mode: both;\n animation-name: floatUp;\n animation-timing-function: cubic-bezier(0, 0.71, 0.29, 1)\n}\n\n#b img.logo {\n max-height: 200px\n}\n\n#dropzone * {\n pointer-events: none\n}\n\n#tokenContainer,\n#panel {\n display: none\n}\n\n#maxSize {\n font-size: 1rem\n}\n\n.dz-preview .dz-details {\n display: flex\n}\n\n.dz-preview .dz-details .dz-size,\n.dz-preview .dz-details .dz-filename {\n flex: 1\n}\n\n.dz-preview img,\n.dz-preview .dz-success-mark,\n.dz-preview .dz-error-mark {\n display: none\n}\n\n@-webkit-keyframes floatUp {\n 0% {\n opacity: 0;\n transform: scale(0.86)\n }\n\n 25% {\n opacity: 100\n }\n\n 67% {\n transform: scale(1)\n }\n\n 100% {\n transform: scale(1)\n }\n}\n\n@keyframes floatUp {\n 0% {\n opacity: 0;\n transform: scale(0.86)\n }\n\n 25% {\n opacity: 100\n }\n\n 67% {\n transform: scale(1)\n }\n\n 100% {\n transform: scale(1)\n }\n}\n\n.uploads.is-reversed {\n display: flex;\n flex-direction: column-reverse\n}\n\n.uploads > div {\n animation: fadeInOpacity 0.5s;\n margin: 1rem\n}\n\n.uploads.is-reversed > div {\n flex: 0 0 auto\n}\n\n.uploads > div:first-child {\n margin-top: 1.5rem\n}\n\n.uploads.nojs {\n margin-bottom: 0\n}\n\n.uploads > div > .icon:not(.icon-block) {\n color: #209cee\n}\n\n.uploads > div > .icon.icon-block {\n color: #da4453\n}\n\n.uploads progress {\n margin-top: 0.5rem;\n margin-bottom: 1rem\n}\n\n.uploads img {\n max-width: 200px\n}\n\n.name {\n font-size: 1rem;\n color: #eff0f1;\n word-break: break-all\n}\n\n.link > a {\n word-break: break-all\n}\n\n.clipboard-mobile {\n margin-top: 5px\n}\n\n#albumDiv {\n animation: fadeInOpacity 0.5s\n}\n\n#albumDiv .control {\n text-align: inherit\n}\n\n#linksColumn {\n margin-top: -0.25rem;\n margin-left: -0.25rem;\n margin-right: -0.25rem;\n animation: fadeInOpacity 0.5s\n}\n\n#linksColumn .column {\n padding: 0.25rem\n}\n\n#linksColumn > span {\n padding: 0 0.3rem;\n color: #7f8c8d\n}\n\n.git-commit a {\n display: inline-block;\n word-break: break-all\n}\n\n#tabs {\n margin-bottom: 1rem;\n animation: fadeInOpacity 0.5s\n}\n\n#tabs ul {\n border-bottom: 1px solid #585858\n}\n\n#tabs li a {\n color: #bdc3c7;\n border-bottom-color: #585858\n}\n\n#tabs.is-boxed li.is-active a {\n color: #209cee;\n background: #000;\n border-color: #585858;\n border-bottom-color: #000\n}\n\n#tabs.is-boxed li:not(.is-active) a:hover {\n background: #585858\n}\n\n.tab-content {\n margin-bottom: -0.75rem;\n animation: fadeInOpacity 0.5s\n}\n\n#tab-config.tab-content form {\n margin-bottom: 0.75rem\n}\n\n#urlMaxSize {\n font-weight: bold\n}\n\n.render {\n position: fixed;\n right: 0;\n bottom: 0;\n font-size: 1rem;\n color: #bdc3c7;\n cursor: pointer\n}\n\n.render.button {\n border-bottom-left-radius: 0;\n border-bottom-right-radius: 0;\n right: 1%;\n opacity: 0.25;\n transition: opacity 0.25s\n}\n\n.render.button:hover {\n opacity: 1\n}\n\ninput[type=\"file\"].is-fullwidth {\n width: 100%\n}\n"]} \ No newline at end of file +{"version":3,"sources":["css/home.css"],"names":[],"mappings":"AAAA,G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,aAAc,CACd,2BACF,CAEA,8BACE,aAAc,CACd,eAAgB,CAEhB,iCACF,CAEA,0CACE,kBACF,CAEA,aACE,qBAAuB,CACvB,mCAA4B,CAA5B,2BACF,CAEA,6BACE,oBACF,CAEA,YACE,eACF,CAEA,QACE,cAAe,CACf,OAAQ,CACR,QAAS,CACT,cAAe,CACf,aAAc,CACd,cACF,CAEA,eACE,2BAA4B,CAC5B,4BAA6B,CAC7B,QAAS,CACT,WAAa,CACb,+BAAwB,CAAxB,uBACF,CAEA,qBACE,SACF,CAEA,8BACE,UACF","file":"home.css","sourcesContent":["#b {\n width: 200px;\n height: 200px;\n border-radius: 100%;\n display: inline-block;\n margin-bottom: 40px;\n vertical-align: top;\n animation-delay: 0.5s;\n animation-duration: 1.5s;\n animation-fill-mode: both;\n animation-name: floatUp;\n animation-timing-function: cubic-bezier(0, 0.71, 0.29, 1)\n}\n\n#b img.logo {\n max-height: 200px\n}\n\n#dropzone * {\n pointer-events: none\n}\n\n#tokenContainer,\n#panel {\n display: none\n}\n\n#maxSize {\n font-size: 1rem\n}\n\n.dz-preview .dz-details {\n display: flex\n}\n\n.dz-preview .dz-details .dz-size,\n.dz-preview .dz-details .dz-filename {\n flex: 1\n}\n\n.dz-preview img,\n.dz-preview .dz-success-mark,\n.dz-preview .dz-error-mark {\n display: none\n}\n\n@-webkit-keyframes floatUp {\n 0% {\n opacity: 0;\n transform: scale(0.86)\n }\n\n 25% {\n opacity: 100\n }\n\n 67% {\n transform: scale(1)\n }\n\n 100% {\n transform: scale(1)\n }\n}\n\n@keyframes floatUp {\n 0% {\n opacity: 0;\n transform: scale(0.86)\n }\n\n 25% {\n opacity: 100\n }\n\n 67% {\n transform: scale(1)\n }\n\n 100% {\n transform: scale(1)\n }\n}\n\n.uploads.is-reversed {\n display: flex;\n flex-direction: column-reverse\n}\n\n.uploads > div {\n animation: fadeInOpacity 0.5s;\n margin: 1rem\n}\n\n.uploads.is-reversed > div {\n flex: 0 0 auto\n}\n\n.uploads > div:first-child {\n margin-top: 1.5rem\n}\n\n.uploads.nojs {\n margin-bottom: 0\n}\n\n.uploads > div > .icon:not(.icon-block) {\n color: #209cee\n}\n\n.uploads > div > .icon.icon-block {\n color: #da4453\n}\n\n.uploads .descriptive-progress {\n color: #bdc3c7\n}\n\n.uploads img {\n max-width: 200px\n}\n\n.name {\n font-size: 1rem;\n color: #eff0f1;\n word-break: break-all\n}\n\n.link > a {\n word-break: break-all\n}\n\n.clipboard-mobile {\n margin-top: 5px\n}\n\n#albumDiv {\n animation: fadeInOpacity 0.5s\n}\n\n#albumDiv .control {\n text-align: inherit\n}\n\n#linksColumn {\n margin-top: -0.25rem;\n margin-left: -0.25rem;\n margin-right: -0.25rem;\n animation: fadeInOpacity 0.5s\n}\n\n#linksColumn .column {\n padding: 0.25rem\n}\n\n#linksColumn > span {\n padding: 0 0.3rem;\n color: #7f8c8d\n}\n\n.git-commit a {\n display: inline-block;\n word-break: break-all\n}\n\n#tabs {\n margin-bottom: 1rem;\n animation: fadeInOpacity 0.5s\n}\n\n#tabs ul {\n border-bottom: 1px solid #585858\n}\n\n#tabs li a {\n color: #bdc3c7;\n border-bottom-color: #585858\n}\n\n#tabs.is-boxed li.is-active a {\n color: #209cee;\n background: #000;\n border-color: #585858;\n border-bottom-color: #000\n}\n\n#tabs.is-boxed li:not(.is-active) a:hover {\n background: #585858\n}\n\n.tab-content {\n margin-bottom: -0.75rem;\n animation: fadeInOpacity 0.5s\n}\n\n#tab-config.tab-content form {\n margin-bottom: 0.75rem\n}\n\n#urlMaxSize {\n font-weight: bold\n}\n\n.render {\n position: fixed;\n right: 0;\n bottom: 0;\n font-size: 1rem;\n color: #bdc3c7;\n cursor: pointer\n}\n\n.render.button {\n border-bottom-left-radius: 0;\n border-bottom-right-radius: 0;\n right: 1%;\n opacity: 0.25;\n transition: opacity 0.25s\n}\n\n.render.button:hover {\n opacity: 1\n}\n\ninput[type=\"file\"].is-fullwidth {\n width: 100%\n}\n"]} \ No newline at end of file diff --git a/dist/js/home.js b/dist/js/home.js index c8bf73a..016c118 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"},page={token:localStorage[lsKeys.token],private:null,enableUserAccounts:null,maxSize:null,chunkSize:null,temporaryUploadAges:null,fileIdentifierLength:null,album:null,parallelUploads:2,previewImages:null,fileLength:null,uploadAge:null,maxSizeBytes:null,urlMaxSize:null,urlMaxSizeBytes:null,tabs:[],activeTab:null,albumSelect:null,previewTemplate:null,dropzone:null,clipboardJS:null,lazyLoad:null,imageExts:[".webp",".jpg",".jpeg",".bmp",".gif",".png",".tiff",".tif",".svg"],videoExts:[".webm",".mp4",".wmv",".avi",".mov",".mkv"],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(){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")},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 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.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. Log in to upload.":e.innerText="Running in private mode. Log 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"),location.reload())})):(localStorage[lsKeys.token]=e,page.token=e,page.prepareUpload())})).catch(page.onInitError)},prepareUpload:function(){page.token&&(document.querySelector("#albumDiv").classList.remove("is-hidden"),page.albumSelect=document.querySelector("#albumSelect"),page.albumSelect.addEventListener("change",(function(){page.album=parseInt(page.albumSelect.value),"function"==typeof page.prepareShareX&&page.prepareShareX()})),page.fetchAlbums()),page.prepareUploadConfig(),document.querySelector("#maxSize > span").innerHTML=page.getPrettyBytes(page.maxSizeBytes),document.querySelector("#loginToUpload").classList.add("is-hidden"),!page.token&&page.enableUserAccounts&&(document.querySelector("#loginLinkText").innerHTML="Create an account and keep track of your uploads"),page.prepareDropzone(),"function"==typeof page.prepareShareX&&page.prepareShareX();var e=document.querySelector("#urlMaxSize");e&&(page.urlMaxSize=parseInt(e.innerHTML),page.urlMaxSizeBytes=1e6*page.urlMaxSize,e.innerHTML=page.getPrettyBytes(page.urlMaxSizeBytes),document.querySelector("#uploadUrls").addEventListener("click",(function(e){page.uploadUrls(e.currentTarget)})));for(var a=document.querySelector("#tabs"),t=a.querySelectorAll("li"),n=function(e){var a=t[e].dataset.id,n=document.querySelector("#"+a);n&&(t[e].addEventListener("click",(function(){page.setActiveTab(e)})),page.tabs.push({tab:t[e],content:n}))},r=0;r a"),n=e.previewElement.querySelector(".clipboard-mobile > .clipboard-js");t.href=t.innerHTML=n.dataset.clipboardText=a.url,n.parentElement.classList.remove("is-hidden");var r=/.[\w]+(\?|$)/.exec(a.url),l=r&&r[0]?r[0].toLowerCase():null;if(page.imageExts.includes(l))if(page.previewImages){var i=e.previewElement.querySelector("img");i.setAttribute("alt",a.name||""),i.dataset.src=a.url,i.classList.remove("is-hidden"),i.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 o=e.previewElement.querySelector(".expiry-date");o.innerHTML="EXP: "+page.getPrettyDate(new Date(1e3*a.expirydate)),o.classList.remove("is-hidden")}}},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,swal("Woohoo!","Album was created successfully.","success")})).catch(page.onError)}}))},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:"This allows your files to automatically be deleted after a certain period of time."},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.
\n Trying to select their texts manually from top to bottom will end up selecting the texts from bottom to top instead.',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"),c=document.createElement("form");c.addEventListener("submit",(function(e){return e.preventDefault()}));for(var d=Object.keys(n),p=0;p\n "+S.text+("default"===S.value?" (default)":"")+"\n \n ")}h.innerHTML='\n \n "}else void 0!==g.number&&((h=document.createElement("input")).id=h.name=u,h.className="input is-fullwidth",h.type="number",void 0!==g.number.min&&(h.min=g.number.min),void 0!==g.number.max&&(h.max=g.number.max),"number"==typeof f?h.value=f:void 0!==e[u]&&(h.value=e[u]));var w=void 0;if(g.disabled)h.disabled=g.disabled,w="This option is currently disabled.";else if("string"==typeof g.help)w=g.help;else if(!0===g.help&&void 0!==g.number){var x=[];void 0!==e[u]&&x.push("Default is "+e[u]+(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||"")+"."),w=x.join(" ")}m.innerHTML='\n \n
\n '+(w?'

'+w+"

":"")+"\n ",m.querySelector("div.control").appendChild(h),c.appendChild(m)}}var k=document.createElement("div");k.className="field",k.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 ',c.appendChild(k),c.querySelector("#saveConfig").addEventListener("click",(function(){if(c.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")},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 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.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. Log in to upload.":e.innerText="Running in private mode. Log 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"),location.reload())})):(localStorage[lsKeys.token]=e,page.token=e,page.prepareUpload())})).catch(page.onInitError)},prepareUpload:function(){page.token&&(document.querySelector("#albumDiv").classList.remove("is-hidden"),page.albumSelect=document.querySelector("#albumSelect"),page.albumSelect.addEventListener("change",(function(){page.album=parseInt(page.albumSelect.value),"function"==typeof page.prepareShareX&&page.prepareShareX()})),page.fetchAlbums()),page.prepareUploadConfig(),document.querySelector("#maxSize > span").innerHTML=page.getPrettyBytes(page.maxSizeBytes),document.querySelector("#loginToUpload").classList.add("is-hidden"),!page.token&&page.enableUserAccounts&&(document.querySelector("#loginLinkText").innerHTML="Create an account and keep track of your uploads"),page.prepareDropzone(),"function"==typeof page.prepareShareX&&page.prepareShareX();var e=document.querySelector("#urlMaxSize");e&&(page.urlMaxSize=parseInt(e.innerHTML),page.urlMaxSizeBytes=1e6*page.urlMaxSize,e.innerHTML=page.getPrettyBytes(page.urlMaxSizeBytes),document.querySelector("#uploadUrls").addEventListener("click",(function(e){page.uploadUrls(e.currentTarget)})));for(var a=document.querySelector("#tabs"),t=a.querySelectorAll("li"),n=function(e){var a=t[e].dataset.id,n=document.querySelector("#"+a);n&&(t[e].addEventListener("click",(function(){page.setActiveTab(e)})),page.tabs.push({tab:t[e],content:n}))},r=0;r .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")}}},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,swal("Woohoo!","Album was created successfully.","success")})).catch(page.onError)}}))},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:"This allows your files to automatically be deleted after a certain period of time."},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.
\n Trying to select their texts manually from top to bottom will end up selecting the texts from bottom to top instead.',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"),d=document.createElement("form");d.addEventListener("submit",(function(e){return e.preventDefault()}));for(var c=Object.keys(n),p=0;p\n "+S.text+("default"===S.value?" (default)":"")+"\n \n ")}h.innerHTML='\n \n "}else void 0!==g.number&&((h=document.createElement("input")).id=h.name=u,h.className="input is-fullwidth",h.type="number",void 0!==g.number.min&&(h.min=g.number.min),void 0!==g.number.max&&(h.max=g.number.max),"number"==typeof v?h.value=v:void 0!==e[u]&&(h.value=e[u]));var w=void 0;if(g.disabled)h.disabled=g.disabled,w="This option is currently disabled.";else if("string"==typeof g.help)w=g.help;else if(!0===g.help&&void 0!==g.number){var x=[];void 0!==e[u]&&x.push("Default is "+e[u]+(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||"")+"."),w=x.join(" ")}m.innerHTML='\n \n
\n '+(w?'

'+w+"

":"")+"\n ",m.querySelector("div.control").appendChild(h),d.appendChild(m)}}var k=document.createElement("div");k.className="field",k.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 ',d.appendChild(k),d.querySelector("#saveConfig").addEventListener("click",(function(){if(d.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 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.checkIfPublic = () => {\n let renderShown = false\n return axios.get('api/check', {\n onDownloadProgress: () => {\n // Only show render after this request has been initiated\n if (!renderShown && typeof page.doRender === 'function') {\n page.doRender()\n renderShown = true\n }\n }\n }).then(response => {\n page.private = response.data.private\n page.enableUserAccounts = response.data.enableUserAccounts\n page.maxSize = parseInt(response.data.maxSize)\n page.maxSizeBytes = page.maxSize * 1e6\n page.chunkSize = parseInt(response.data.chunkSize)\n page.temporaryUploadAges = response.data.temporaryUploadAges\n page.fileIdentifierLength = response.data.fileIdentifierLength\n return page.preparePage()\n }).catch(page.onInitError)\n}\n\npage.preparePage = () => {\n if (page.private)\n if (page.token) {\n return page.verifyToken(page.token, true)\n } else {\n const button = document.querySelector('#loginToUpload')\n button.href = 'auth'\n button.classList.remove('is-loading')\n if (page.enableUserAccounts)\n button.innerText = 'Anonymous upload is disabled. Log in to upload.'\n else\n button.innerText = 'Running in private mode. Log in to upload.'\n }\n else\n return page.prepareUpload()\n}\n\npage.verifyToken = (token, reloadOnError) => {\n return axios.post('api/tokens/verify', { token }).then(response => {\n if (response.data.success === false)\n return swal({\n title: 'An error occurred!',\n text: response.data.description,\n icon: 'error'\n }).then(() => {\n if (!reloadOnError) return\n localStorage.removeItem('token')\n location.reload()\n })\n\n localStorage[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 // Display the album selection\n document.querySelector('#albumDiv').classList.remove('is-hidden')\n\n page.albumSelect = document.querySelector('#albumSelect')\n page.albumSelect.addEventListener('change', () => {\n page.album = parseInt(page.albumSelect.value)\n // Re-generate ShareX config file\n if (typeof page.prepareShareX === 'function')\n page.prepareShareX()\n })\n\n // Fetch albums\n page.fetchAlbums()\n }\n\n // Prepare & generate config tab\n page.prepareUploadConfig()\n\n // Update elements wherever applicable\n document.querySelector('#maxSize > span').innerHTML = page.getPrettyBytes(page.maxSizeBytes)\n document.querySelector('#loginToUpload').classList.add('is-hidden')\n\n if (!page.token && page.enableUserAccounts)\n document.querySelector('#loginLinkText').innerHTML = 'Create an account and keep track of your uploads'\n\n // Prepare & generate files upload tab\n page.prepareDropzone()\n\n // Generate ShareX config file\n if (typeof page.prepareShareX === 'function')\n page.prepareShareX()\n\n // Prepare urls upload tab\n const urlMaxSize = document.querySelector('#urlMaxSize')\n if (urlMaxSize) {\n page.urlMaxSize = parseInt(urlMaxSize.innerHTML)\n page.urlMaxSizeBytes = page.urlMaxSize * 1e6\n urlMaxSize.innerHTML = page.getPrettyBytes(page.urlMaxSizeBytes)\n document.querySelector('#uploadUrls').addEventListener('click', event => {\n page.uploadUrls(event.currentTarget)\n })\n }\n\n // Get all tabs\n const tabsContainer = document.querySelector('#tabs')\n const tabs = tabsContainer.querySelectorAll('li')\n for (let i = 0; i < tabs.length; i++) {\n const id = tabs[i].dataset.id\n const tabContent = document.querySelector(`#${id}`)\n if (!tabContent) continue\n\n tabs[i].addEventListener('click', () => {\n page.setActiveTab(i)\n })\n page.tabs.push({ tab: tabs[i], content: tabContent })\n }\n\n // Set first valid tab as the default active tab\n if (page.tabs.length) {\n page.setActiveTab(0)\n tabsContainer.classList.remove('is-hidden')\n }\n}\n\npage.setActiveTab = index => {\n for (let i = 0; i < page.tabs.length; i++)\n if (i === index) {\n page.tabs[i].tab.classList.add('is-active')\n page.tabs[i].content.classList.remove('is-hidden')\n page.activeTab = index\n } else {\n page.tabs[i].tab.classList.remove('is-active')\n page.tabs[i].content.classList.add('is-hidden')\n }\n}\n\npage.fetchAlbums = () => {\n return axios.get('api/albums', { headers: { token: page.token } }).then(response => {\n if (response.data.success === false)\n return swal('An error occurred!', response.data.description, 'error')\n\n // Create an option for each album\n if (Array.isArray(response.data.albums) && response.data.albums.length)\n for (let i = 0; i < response.data.albums.length; i++) {\n const album = response.data.albums[i]\n const option = document.createElement('option')\n option.value = album.id\n option.innerHTML = album.name\n page.albumSelect.appendChild(option)\n }\n }).catch(page.onInitError)\n}\n\npage.prepareDropzone = () => {\n // Parse template element\n const previewNode = document.querySelector('#tpl')\n page.previewTemplate = previewNode.innerHTML\n previewNode.parentNode.removeChild(previewNode)\n\n // Generate files upload tab\n const tabDiv = document.querySelector('#tab-files')\n const div = document.createElement('div')\n div.className = 'control is-expanded'\n div.innerHTML = `\n
\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, // the option below expects Bytes\n parallelChunkUploads: false, // when set to true, it often hangs with hundreds of parallel uploads\n timeout: 0,\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 // Add file entry\n tabDiv.querySelector('.uploads').classList.remove('is-hidden')\n file.previewElement.querySelector('.name').innerHTML = file.name\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 // Skip adding additional headers if chunked uploads\n if (file.upload.chunked) return\n\n // Continue otherwise\n if (page.album !== null) xhr.setRequestHeader('albumid', page.album)\n if (page.fileLength !== null) xhr.setRequestHeader('filelength', page.fileLength)\n if (page.uploadAge !== null) xhr.setRequestHeader('age', page.uploadAge)\n })\n\n // Update the total progress bar\n this.on('uploadprogress', (file, progress) => {\n // For some reason, chunked uploads fire 100% progress event\n // for each chunk's successful uploads\n if (file.upload.chunked && progress === 100) return\n file.previewElement.querySelector('.progress').setAttribute('value', progress)\n file.previewElement.querySelector('.progress').innerHTML = `${progress}%`\n })\n\n this.on('success', (file, response) => {\n if (!response) return\n file.previewElement.querySelector('.progress').classList.add('is-hidden')\n\n if (response.success === false)\n file.previewElement.querySelector('.error').innerHTML = response.description\n\n if (response.files && response.files[0])\n page.updateTemplate(file, response.files[0])\n })\n\n 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 file.previewElement.querySelector('.progress').classList.add('is-hidden')\n file.previewElement.querySelector('.name').innerHTML = file.name\n file.previewElement.querySelector('.error').innerHTML = error.description || error\n })\n },\n chunksUploaded (file, done) {\n file.previewElement.querySelector('.progress').setAttribute('value', 100)\n file.previewElement.querySelector('.progress').innerHTML = '100%'\n\n return axios.post('api/upload/finishchunks', {\n // This API supports an array of multiple files\n files: [{\n uuid: file.upload.uuid,\n original: file.name,\n type: file.type,\n albumid: page.album,\n filelength: page.fileLength,\n age: page.uploadAge\n }]\n }, { headers: { token: page.token } }).catch(error => {\n // Format error for display purpose\n return error.response.data ? error.response : {\n data: {\n success: false,\n description: error.toString()\n }\n }\n }).then(response => {\n file.previewElement.querySelector('.progress').classList.add('is-hidden')\n\n if (response.data.success === false)\n file.previewElement.querySelector('.error').innerHTML = response.data.description\n\n if (response.data.files && response.data.files[0])\n page.updateTemplate(file, response.data.files[0])\n\n return done()\n })\n }\n })\n}\n\npage.uploadUrls = button => {\n const tabDiv = document.querySelector('#tab-urls')\n if (!tabDiv || button.classList.contains('is-loading'))\n return\n\n button.classList.add('is-loading')\n\n function done (error) {\n if (error) swal('An error occurred!', error, 'error')\n button.classList.remove('is-loading')\n }\n\n function run () {\n const headers = {\n token: page.token,\n albumid: page.album,\n age: page.uploadAge,\n filelength: page.fileLength\n }\n\n const previewsContainer = tabDiv.querySelector('.uploads')\n const urls = document.querySelector('#urls').value\n .split(/\\r?\\n/)\n .filter(url => {\n return url.trim().length\n })\n document.querySelector('#urls').value = urls.join('\\n')\n\n if (!urls.length)\n return done('You have not entered any URLs.')\n\n tabDiv.querySelector('.uploads').classList.remove('is-hidden')\n const files = urls.map(url => {\n const previewTemplate = document.createElement('template')\n previewTemplate.innerHTML = page.previewTemplate.trim()\n const previewElement = previewTemplate.content.firstChild\n previewElement.querySelector('.name').innerHTML = url\n previewsContainer.appendChild(previewElement)\n return { url, previewElement }\n })\n\n function post (i) {\n if (i === files.length)\n return done()\n\n function posted (result) {\n files[i].previewElement.querySelector('.progress').classList.add('is-hidden')\n if (result.success) {\n page.updateTemplate(files[i], result.files[0])\n } else {\n page.updateTemplateIcon(files[i].previewElement, 'icon-block')\n files[i].previewElement.querySelector('.error').innerHTML = result.description\n }\n return post(i + 1)\n }\n\n // Animate progress bar\n files[i].previewElement.querySelector('.progress').removeAttribute('value')\n\n return axios.post('api/upload', { urls: [files[i].url] }, { headers }).then(response => {\n return posted(response.data)\n }).catch(error => {\n return posted({\n success: false,\n description: error.response ? error.response.data.description : error.toString()\n })\n })\n }\n return post(0)\n }\n return run()\n}\n\npage.updateTemplateIcon = (templateElement, iconClass) => {\n const iconElement = templateElement.querySelector('.icon')\n if (!iconElement) return\n iconElement.classList.add(iconClass)\n iconElement.classList.remove('is-hidden')\n}\n\npage.updateTemplate = (file, response) => {\n if (!response.url) return\n\n const a = file.previewElement.querySelector('.link > a')\n const clipboard = file.previewElement.querySelector('.clipboard-mobile > .clipboard-js')\n a.href = a.innerHTML = clipboard.dataset.clipboardText = response.url\n clipboard.parentElement.classList.remove('is-hidden')\n\n const exec = /.[\\w]+(\\?|$)/.exec(response.url)\n const extname = exec && exec[0]\n ? exec[0].toLowerCase()\n : null\n\n if (page.imageExts.includes(extname))\n if (page.previewImages) {\n const img = file.previewElement.querySelector('img')\n img.setAttribute('alt', response.name || '')\n img.dataset.src = response.url\n img.classList.remove('is-hidden')\n img.onerror = event => {\n // Hide image elements that fail to load\n // Consequently include WEBP in browsers that do not have WEBP support (e.i. IE)\n event.currentTarget.classList.add('is-hidden')\n page.updateTemplateIcon(file.previewElement, 'icon-picture')\n }\n page.lazyLoad.update(file.previewElement.querySelectorAll('img'))\n } else {\n page.updateTemplateIcon(file.previewElement, 'icon-picture')\n }\n else if (page.videoExts.includes(extname))\n page.updateTemplateIcon(file.previewElement, 'icon-video')\n else\n page.updateTemplateIcon(file.previewElement, 'icon-doc-inv')\n\n if (response.expirydate) {\n const expiryDate = file.previewElement.querySelector('.expiry-date')\n expiryDate.innerHTML = `EXP: ${page.getPrettyDate(new Date(response.expirydate * 1000))}`\n expiryDate.classList.remove('is-hidden')\n }\n}\n\npage.createAlbum = () => {\n const div = document.createElement('div')\n div.innerHTML = `\n
\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\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: 'This allows your files to automatically be deleted after a certain period of time.'\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.
\n Trying to select their texts manually from top to bottom will end up selecting the texts from bottom to top instead.`,\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 value = localStorage[lsKeys[key]]\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 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 control.disabled = conf.disabled\n help = 'This option is currently disabled.'\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 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 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","page","localStorage","private","enableUserAccounts","maxSize","temporaryUploadAges","fileIdentifierLength","album","maxSizeBytes","urlMaxSize","urlMaxSizeBytes","tabs","activeTab","albumSelect","previewTemplate","dropzone","clipboardJS","lazyLoad","imageExts","videoExts","albumTitleMaxLength","albumDescMaxLength","onInitError","error","document","querySelector","classList","add","querySelectorAll","forEach","element","uploadButton","innerText","remove","addEventListener","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","checkIfPublic","let","renderShown","axios","get","onDownloadProgress","doRender","then","parseInt","preparePage","catch","prepareUpload","verifyToken","button","href","reloadOnError","post","success","text","removeItem","value","prepareShareX","fetchAlbums","prepareUploadConfig","getPrettyBytes","prepareDropzone","event","uploadUrls","currentTarget","tabsContainer","loop","i","id","dataset","tabContent","setActiveTab","push","tab","length","index","headers","Array","isArray","albums","option","name","appendChild","previewNode","parentNode","removeChild","tabDiv","div","className","previewsContainer","Dropzone","body","url","paramName","clickable","maxFilesize","uploadMultiple","createImageThumbnails","autoProcessQueue","chunking","Boolean","parallelChunkUploads","timeout","init","this","on","file","previewElement","xhr","ontimeout","instances","getUploadingFiles","filter","instance","_handleUploadError","undefined","_start","Date","now","upload","chunked","setRequestHeader","chunks","progress","total","Math","max","size","percentage","bytesSent","toFixed","prefix","upl","elapsed","bytesPerSec","prettyBytesPerSec","files","updateTemplate","test","updateTemplateIcon","chunksUploaded","done","uuid","original","type","albumid","filelength","age","contains","urls","split","trim","join","map","firstChild","posted","result","run","templateElement","iconClass","iconElement","link","a","clipboard","clipboardText","parentElement","exec","extname","toLowerCase","includes","img","setAttribute","src","onerror","update","expirydate","expiryDate","getPrettyDate","createAlbum","buttons","cancel","confirm","closeModal","download","checked","public","selected","fallback","min","config","siBytes","label","select","help","valueHandler","display","number","round","disabled","force","isNaN","suffix","uploadFields","stored","parseFloat","String","getPrettyUploadAge","default","form","preventDefault","configKeys","Object","keys","key","conf","field","parsed","control","opts","j","opt","tmp","submit","checkValidity","elements","hours","minutes","days","window","items","clipboardData","originalEvent","item","kind","blob","getAsFile","File","match","addFile","onload","ClipboardJS","timer","LazyLoad","elements_selector"],"mappings":"AAEAA,IAAMC,OAAS,CACbC,MAAO,QACPC,UAAW,YACXC,gBAAiB,kBACjBC,oBAAqB,sBACrBC,cAAe,gBACfC,WAAY,aACZC,UAAW,aAGPC,KAAO,CAEXP,MAAOQ,aAAaT,OAAOC,OAG3BS,QAAS,KACTC,mBAAoB,KACpBC,QAAS,KACTV,UAAW,KACXW,oBAAqB,KACrBC,qBAAsB,KAGtBC,MAAO,KAEPZ,gBAAiB,EACjBE,cAAe,KACfC,WAAY,KACZC,UAAW,KAEXS,aAAc,KACdC,WAAY,KACZC,gBAAiB,KAEjBC,KAAM,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nCzQ,KAAKgB,YAAYkH,GAAG,WAAS,WAC3B,OAAOrF,KAAK,GAAI,yCAA0C,UAAW,CACnE+J,SAAS,EACT8D,MAAO,UAIX1Q,KAAKgB,YAAYkH,GAAG,QAASlI,KAAKuC,SAElCvC,KAAKiB,SAAW,IAAI0P,SAAS,CAC3BC,kBAAmB,uBAGrBpP,SAASC,cAAc,gBAAgBS,iBAAiB,SAAO,WAC7DlC,KAAK2M","file":"home.js","sourcesContent":["/* global swal, axios, Dropzone, ClipboardJS, LazyLoad */\n\nconst lsKeys = {\n token: 'token',\n chunkSize: 'chunkSize',\n parallelUploads: 'parallelUploads',\n uploadsHistoryOrder: 'uploadsHistoryOrder',\n previewImages: 'previewImages',\n fileLength: 'fileLength',\n uploadAge: 'uploadAge'\n}\n\nconst page = {\n // user token\n token: localStorage[lsKeys.token],\n\n // configs from api/check\n private: null,\n enableUserAccounts: null,\n maxSize: null,\n chunkSize: null,\n temporaryUploadAges: null,\n fileIdentifierLength: null,\n\n // store album id that will be used with upload requests\n album: null,\n\n parallelUploads: 2,\n previewImages: null,\n fileLength: null,\n uploadAge: null,\n\n maxSizeBytes: null,\n urlMaxSize: null,\n urlMaxSizeBytes: null,\n\n tabs: [],\n activeTab: null,\n albumSelect: null,\n previewTemplate: null,\n\n dropzone: null,\n clipboardJS: null,\n lazyLoad: null,\n\n // Include BMP for uploads preview only, cause the real images will be used\n // Sharp isn't capable of making their thumbnails for dashboard and album public pages\n imageExts: ['.webp', '.jpg', '.jpeg', '.bmp', '.gif', '.png', '.tiff', '.tif', '.svg'],\n videoExts: ['.webm', '.mp4', '.wmv', '.avi', '.mov', '.mkv'],\n\n albumTitleMaxLength: 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 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.checkIfPublic = () => {\n let renderShown = false\n return axios.get('api/check', {\n onDownloadProgress: () => {\n // Only show render after this request has been initiated\n if (!renderShown && typeof page.doRender === 'function') {\n page.doRender()\n renderShown = true\n }\n }\n }).then(response => {\n page.private = response.data.private\n page.enableUserAccounts = response.data.enableUserAccounts\n page.maxSize = parseInt(response.data.maxSize)\n page.maxSizeBytes = page.maxSize * 1e6\n page.chunkSize = parseInt(response.data.chunkSize)\n page.temporaryUploadAges = response.data.temporaryUploadAges\n page.fileIdentifierLength = response.data.fileIdentifierLength\n return page.preparePage()\n }).catch(page.onInitError)\n}\n\npage.preparePage = () => {\n if (page.private)\n if (page.token) {\n return page.verifyToken(page.token, true)\n } else {\n const button = document.querySelector('#loginToUpload')\n button.href = 'auth'\n button.classList.remove('is-loading')\n if (page.enableUserAccounts)\n button.innerText = 'Anonymous upload is disabled. Log in to upload.'\n else\n button.innerText = 'Running in private mode. Log in to upload.'\n }\n else\n return page.prepareUpload()\n}\n\npage.verifyToken = (token, reloadOnError) => {\n return axios.post('api/tokens/verify', { token }).then(response => {\n if (response.data.success === false)\n return swal({\n title: 'An error occurred!',\n text: response.data.description,\n icon: 'error'\n }).then(() => {\n if (!reloadOnError) return\n localStorage.removeItem('token')\n location.reload()\n })\n\n localStorage[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 // Display the album selection\n document.querySelector('#albumDiv').classList.remove('is-hidden')\n\n page.albumSelect = document.querySelector('#albumSelect')\n page.albumSelect.addEventListener('change', () => {\n page.album = parseInt(page.albumSelect.value)\n // Re-generate ShareX config file\n if (typeof page.prepareShareX === 'function')\n page.prepareShareX()\n })\n\n // Fetch albums\n page.fetchAlbums()\n }\n\n // Prepare & generate config tab\n page.prepareUploadConfig()\n\n // Update elements wherever applicable\n document.querySelector('#maxSize > span').innerHTML = page.getPrettyBytes(page.maxSizeBytes)\n document.querySelector('#loginToUpload').classList.add('is-hidden')\n\n if (!page.token && page.enableUserAccounts)\n document.querySelector('#loginLinkText').innerHTML = 'Create an account and keep track of your uploads'\n\n // Prepare & generate files upload tab\n page.prepareDropzone()\n\n // Generate ShareX config file\n if (typeof page.prepareShareX === 'function')\n page.prepareShareX()\n\n // Prepare urls upload tab\n const urlMaxSize = document.querySelector('#urlMaxSize')\n if (urlMaxSize) {\n page.urlMaxSize = parseInt(urlMaxSize.innerHTML)\n page.urlMaxSizeBytes = page.urlMaxSize * 1e6\n urlMaxSize.innerHTML = page.getPrettyBytes(page.urlMaxSizeBytes)\n document.querySelector('#uploadUrls').addEventListener('click', event => {\n page.uploadUrls(event.currentTarget)\n })\n }\n\n // Get all tabs\n const tabsContainer = document.querySelector('#tabs')\n const tabs = tabsContainer.querySelectorAll('li')\n for (let i = 0; i < tabs.length; i++) {\n const id = tabs[i].dataset.id\n const tabContent = document.querySelector(`#${id}`)\n if (!tabContent) continue\n\n tabs[i].addEventListener('click', () => {\n page.setActiveTab(i)\n })\n page.tabs.push({ tab: tabs[i], content: tabContent })\n }\n\n // Set first valid tab as the default active tab\n if (page.tabs.length) {\n page.setActiveTab(0)\n tabsContainer.classList.remove('is-hidden')\n }\n}\n\npage.setActiveTab = index => {\n for (let i = 0; i < page.tabs.length; i++)\n if (i === index) {\n page.tabs[i].tab.classList.add('is-active')\n page.tabs[i].content.classList.remove('is-hidden')\n page.activeTab = index\n } else {\n page.tabs[i].tab.classList.remove('is-active')\n page.tabs[i].content.classList.add('is-hidden')\n }\n}\n\npage.fetchAlbums = () => {\n return axios.get('api/albums', { headers: { token: page.token } }).then(response => {\n if (response.data.success === false)\n return swal('An error occurred!', response.data.description, 'error')\n\n // Create an option for each album\n if (Array.isArray(response.data.albums) && response.data.albums.length)\n for (let i = 0; i < response.data.albums.length; i++) {\n const album = response.data.albums[i]\n const option = document.createElement('option')\n option.value = album.id\n option.innerHTML = album.name\n page.albumSelect.appendChild(option)\n }\n }).catch(page.onInitError)\n}\n\npage.prepareDropzone = () => {\n // Parse template element\n const previewNode = document.querySelector('#tpl')\n page.previewTemplate = previewNode.innerHTML\n previewNode.parentNode.removeChild(previewNode)\n\n // Generate files upload tab\n const tabDiv = document.querySelector('#tab-files')\n const div = document.createElement('div')\n div.className = 'control is-expanded'\n div.innerHTML = `\n
\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 // Add start timestamp of upload attempt\n if (xhr._start === undefined)\n xhr._start = Date.now()\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 }\n\n // If not chunked uploads OR first chunk\n if (!file.upload.chunked || file.upload.chunks.length === 1)\n file.previewElement.querySelector('.descriptive-progress').innerHTML = 'Uploading\\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 prefix = file.upload.chunked\n ? `Uploading chunk ${file.upload.chunks.length}/${file.upload.totalChunkCount}\\u2026`\n : 'Uploading\\u2026'\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 const bytesSent = upl.bytesSent\n const elapsed = (Date.now() - xhr._start) / 1000\n\n const bytesPerSec = elapsed ? (bytesSent / elapsed) : 0\n const prettyBytesPerSec = page.getPrettyBytes(bytesPerSec)\n\n file.previewElement.querySelector('.descriptive-progress').innerHTML =\n `${prefix} ${percentage}%${prettyBytesPerSec ? ` at ~${prettyBytesPerSec}/s` : ''}`\n })\n\n this.on('success', (file, response) => {\n if (!response) return\n file.previewElement.querySelector('.descriptive-progress').classList.add('is-hidden')\n\n if (response.success === false) {\n file.previewElement.querySelector('.error').innerHTML = response.description\n file.previewElement.querySelector('.error').classList.remove('is-hidden')\n }\n\n if (response.files && response.files[0])\n page.updateTemplate(file, response.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 file.previewElement.querySelector('.name').innerHTML = file.name\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 }\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.uploadUrls = button => {\n const tabDiv = document.querySelector('#tab-urls')\n if (!tabDiv || button.classList.contains('is-loading'))\n return\n\n button.classList.add('is-loading')\n\n function done (error) {\n if (error) swal('An error occurred!', error, 'error')\n button.classList.remove('is-loading')\n }\n\n function run () {\n const headers = {\n token: page.token,\n albumid: page.album,\n age: page.uploadAge,\n filelength: page.fileLength\n }\n\n const previewsContainer = tabDiv.querySelector('.uploads')\n\n const urls = document.querySelector('#urls').value\n .split(/\\r?\\n/)\n .filter(url => {\n return url.trim().length\n })\n document.querySelector('#urls').value = urls.join('\\n')\n\n if (!urls.length)\n return done('You have not entered any URLs.')\n\n tabDiv.querySelector('.uploads').classList.remove('is-hidden')\n\n const files = urls.map(url => {\n const previewTemplate = document.createElement('template')\n previewTemplate.innerHTML = page.previewTemplate.trim()\n\n const previewElement = previewTemplate.content.firstChild\n previewElement.querySelector('.name').innerHTML = url\n previewElement.querySelector('.descriptive-progress').innerHTML = 'Waiting in queue\\u2026'\n\n previewsContainer.appendChild(previewElement)\n return { url, previewElement }\n })\n\n function post (i) {\n if (i === files.length)\n return done()\n\n function posted (result) {\n files[i].previewElement.querySelector('.descriptive-progress').classList.add('is-hidden')\n\n if (result.success) {\n page.updateTemplate(files[i], result.files[0])\n } else {\n page.updateTemplateIcon(files[i].previewElement, 'icon-block')\n files[i].previewElement.querySelector('.error').innerHTML = result.description\n files[i].previewElement.querySelector('.error').classList.remove('is-hidden')\n }\n\n return post(i + 1)\n }\n\n files[i].previewElement.querySelector('.descriptive-progress').innerHTML =\n 'Waiting for server to fetch URL\\u2026'\n\n return axios.post('api/upload', { urls: [files[i].url] }, { headers }).then(response => {\n return posted(response.data)\n }).catch(error => {\n return posted({\n success: false,\n description: error.response ? error.response.data.description : error.toString()\n })\n })\n }\n return post(0)\n }\n return run()\n}\n\npage.updateTemplateIcon = (templateElement, iconClass) => {\n const iconElement = templateElement.querySelector('.icon')\n if (!iconElement) return\n\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.i. IE)\n event.currentTarget.classList.add('is-hidden')\n page.updateTemplateIcon(file.previewElement, 'icon-picture')\n }\n page.lazyLoad.update(file.previewElement.querySelectorAll('img'))\n } else {\n page.updateTemplateIcon(file.previewElement, 'icon-picture')\n }\n else if (page.videoExts.includes(extname))\n page.updateTemplateIcon(file.previewElement, 'icon-video')\n else\n page.updateTemplateIcon(file.previewElement, 'icon-doc-inv')\n\n if (response.expirydate) {\n const expiryDate = file.previewElement.querySelector('.expiry-date')\n expiryDate.innerHTML = `EXP: ${page.getPrettyDate(new Date(response.expirydate * 1000))}`\n expiryDate.classList.remove('is-hidden')\n }\n}\n\npage.createAlbum = () => {\n const div = document.createElement('div')\n div.innerHTML = `\n
\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\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: 'This allows your files to automatically be deleted after a certain period of time.'\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.
\n Trying to select their texts manually from top to bottom will end up selecting the texts from bottom to top instead.`,\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 value = localStorage[lsKeys[key]]\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 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 control.disabled = conf.disabled\n help = 'This option is currently disabled.'\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 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 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/src/css/home.css b/src/css/home.css index 38c1037..b7c51c1 100644 --- a/src/css/home.css +++ b/src/css/home.css @@ -112,9 +112,8 @@ color: #da4453 } -.uploads progress { - margin-top: 0.5rem; - margin-bottom: 1rem +.uploads .descriptive-progress { + color: #bdc3c7 } .uploads img { diff --git a/src/js/home.js b/src/js/home.js index 02b249c..95fd6d3 100644 --- a/src/js/home.js +++ b/src/js/home.js @@ -304,17 +304,21 @@ page.prepareDropzone = () => { autoProcessQueue: true, headers: { token: page.token }, chunking: Boolean(page.chunkSize), - chunkSize: page.chunkSize * 1e6, // the option below expects Bytes - parallelChunkUploads: false, // when set to true, it often hangs with hundreds of parallel uploads + chunkSize: page.chunkSize * 1e6, // this option expects Bytes + parallelChunkUploads: false, // for now, enabling this breaks descriptive upload progress timeout: 0, + init () { this.on('addedfile', file => { // Set active tab to file uploads, if necessary if (page.activeTab !== 0) page.setActiveTab(0) + // Add file entry tabDiv.querySelector('.uploads').classList.remove('is-hidden') + file.previewElement.querySelector('.name').innerHTML = file.name + file.previewElement.querySelector('.descriptive-progress').innerHTML = 'Waiting in queue\u2026' }) this.on('sending', (file, xhr) => { @@ -326,30 +330,55 @@ page.prepareDropzone = () => { page.dropzone._handleUploadError(instances, xhr, 'Connection timed out. Try to reduce upload chunk size.') } - // Skip adding additional headers if chunked uploads - if (file.upload.chunked) return + // Add start timestamp of upload attempt + if (xhr._start === undefined) + xhr._start = Date.now() - // Continue otherwise - if (page.album !== null) xhr.setRequestHeader('albumid', page.album) - if (page.fileLength !== null) xhr.setRequestHeader('filelength', page.fileLength) - if (page.uploadAge !== null) xhr.setRequestHeader('age', page.uploadAge) + // If not chunked uploads, add extra headers + if (!file.upload.chunked) { + if (page.album !== null) xhr.setRequestHeader('albumid', page.album) + if (page.fileLength !== null) xhr.setRequestHeader('filelength', page.fileLength) + if (page.uploadAge !== null) xhr.setRequestHeader('age', page.uploadAge) + } + + // If not chunked uploads OR first chunk + if (!file.upload.chunked || file.upload.chunks.length === 1) + file.previewElement.querySelector('.descriptive-progress').innerHTML = 'Uploading\u2026' }) - // Update the total progress bar + // Update descriptive progress this.on('uploadprogress', (file, progress) => { - // For some reason, chunked uploads fire 100% progress event - // for each chunk's successful uploads - if (file.upload.chunked && progress === 100) return - file.previewElement.querySelector('.progress').setAttribute('value', progress) - file.previewElement.querySelector('.progress').innerHTML = `${progress}%` + // Total bytes will eventually be bigger than file size when chunked + const total = Math.max(file.size, file.upload.total) + const percentage = (file.upload.bytesSent / total * 100).toFixed(0) + + const prefix = file.upload.chunked + ? `Uploading chunk ${file.upload.chunks.length}/${file.upload.totalChunkCount}\u2026` + : 'Uploading\u2026' + + const upl = file.upload.chunked + ? file.upload.chunks[file.upload.chunks.length - 1] + : file.upload + const xhr = upl.xhr || file.xhr + + const bytesSent = upl.bytesSent + const elapsed = (Date.now() - xhr._start) / 1000 + + const bytesPerSec = elapsed ? (bytesSent / elapsed) : 0 + const prettyBytesPerSec = page.getPrettyBytes(bytesPerSec) + + file.previewElement.querySelector('.descriptive-progress').innerHTML = + `${prefix} ${percentage}%${prettyBytesPerSec ? ` at ~${prettyBytesPerSec}/s` : ''}` }) this.on('success', (file, response) => { if (!response) return - file.previewElement.querySelector('.progress').classList.add('is-hidden') + file.previewElement.querySelector('.descriptive-progress').classList.add('is-hidden') - if (response.success === false) + if (response.success === false) { file.previewElement.querySelector('.error').innerHTML = response.description + file.previewElement.querySelector('.error').classList.remove('is-hidden') + } if (response.files && response.files[0]) page.updateTemplate(file, response.files[0]) @@ -362,14 +391,18 @@ page.prepareDropzone = () => { error = `File too large (${page.getPrettyBytes(file.size)}).` page.updateTemplateIcon(file.previewElement, 'icon-block') - file.previewElement.querySelector('.progress').classList.add('is-hidden') + + file.previewElement.querySelector('.descriptive-progress').classList.add('is-hidden') file.previewElement.querySelector('.name').innerHTML = file.name + file.previewElement.querySelector('.error').innerHTML = error.description || error + file.previewElement.querySelector('.error').classList.remove('is-hidden') }) }, + chunksUploaded (file, done) { - file.previewElement.querySelector('.progress').setAttribute('value', 100) - file.previewElement.querySelector('.progress').innerHTML = '100%' + file.previewElement.querySelector('.descriptive-progress').innerHTML = + `Rebuilding ${file.upload.totalChunkCount} chunks\u2026` return axios.post('api/upload/finishchunks', { // This API supports an array of multiple files @@ -381,7 +414,11 @@ page.prepareDropzone = () => { filelength: page.fileLength, age: page.uploadAge }] - }, { headers: { token: page.token } }).catch(error => { + }, { + headers: { + token: page.token + } + }).catch(error => { // Format error for display purpose return error.response.data ? error.response : { data: { @@ -390,10 +427,12 @@ page.prepareDropzone = () => { } } }).then(response => { - file.previewElement.querySelector('.progress').classList.add('is-hidden') + file.previewElement.querySelector('.descriptive-progress').classList.add('is-hidden') - if (response.data.success === false) + if (response.data.success === false) { file.previewElement.querySelector('.error').innerHTML = response.data.description + file.previewElement.querySelector('.error').classList.remove('is-hidden') + } if (response.data.files && response.data.files[0]) page.updateTemplate(file, response.data.files[0]) @@ -425,6 +464,7 @@ page.uploadUrls = button => { } const previewsContainer = tabDiv.querySelector('.uploads') + const urls = document.querySelector('#urls').value .split(/\r?\n/) .filter(url => { @@ -436,11 +476,15 @@ page.uploadUrls = button => { return done('You have not entered any URLs.') tabDiv.querySelector('.uploads').classList.remove('is-hidden') + const files = urls.map(url => { const previewTemplate = document.createElement('template') previewTemplate.innerHTML = page.previewTemplate.trim() + const previewElement = previewTemplate.content.firstChild previewElement.querySelector('.name').innerHTML = url + previewElement.querySelector('.descriptive-progress').innerHTML = 'Waiting in queue\u2026' + previewsContainer.appendChild(previewElement) return { url, previewElement } }) @@ -450,18 +494,21 @@ page.uploadUrls = button => { return done() function posted (result) { - files[i].previewElement.querySelector('.progress').classList.add('is-hidden') + files[i].previewElement.querySelector('.descriptive-progress').classList.add('is-hidden') + if (result.success) { page.updateTemplate(files[i], result.files[0]) } else { page.updateTemplateIcon(files[i].previewElement, 'icon-block') files[i].previewElement.querySelector('.error').innerHTML = result.description + files[i].previewElement.querySelector('.error').classList.remove('is-hidden') } + return post(i + 1) } - // Animate progress bar - files[i].previewElement.querySelector('.progress').removeAttribute('value') + files[i].previewElement.querySelector('.descriptive-progress').innerHTML = + 'Waiting for server to fetch URL\u2026' return axios.post('api/upload', { urls: [files[i].url] }, { headers }).then(response => { return posted(response.data) @@ -480,6 +527,7 @@ page.uploadUrls = button => { page.updateTemplateIcon = (templateElement, iconClass) => { const iconElement = templateElement.querySelector('.icon') if (!iconElement) return + iconElement.classList.add(iconClass) iconElement.classList.remove('is-hidden') } @@ -487,9 +535,12 @@ page.updateTemplateIcon = (templateElement, iconClass) => { page.updateTemplate = (file, response) => { if (!response.url) return - const a = file.previewElement.querySelector('.link > a') + const link = file.previewElement.querySelector('.link') + const a = link.querySelector('a') const clipboard = file.previewElement.querySelector('.clipboard-mobile > .clipboard-js') a.href = a.innerHTML = clipboard.dataset.clipboardText = response.url + + link.classList.remove('is-hidden') clipboard.parentElement.classList.remove('is-hidden') const exec = /.[\w]+(\?|$)/.exec(response.url) diff --git a/src/versions.json b/src/versions.json index 04ec0ba..1769d71 100644 --- a/src/versions.json +++ b/src/versions.json @@ -1,5 +1,5 @@ { - "1": "1574772425", + "1": "1574780211", "2": "1568894058", "3": "1568894058", "4": "1568894058", diff --git a/views/home.njk b/views/home.njk index 036969c..a5da3ec 100644 --- a/views/home.njk +++ b/views/home.njk @@ -140,9 +140,9 @@

- -

-

+ +