var lsKeys={token:"token"},page={token:localStorage[lsKeys.token],urlPrefix:null,urlIdentifier:null,messageElement:document.querySelector("#message"),fileinfoContainer:document.querySelector("#fileinfo"),clipboardBtn:document.querySelector("#clipboardBtn"),playerBtn:document.querySelector("#playerBtn"),downloadBtn:document.querySelector("#downloadBtn"),deleteBtn:document.querySelector("#deleteBtn"),uploadRoot:null,titleFormat:null,file:null,clipboardJS:null,cloudflareErrors:{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"},updateMessageBody:function(e){page.messageElement.querySelector(".message-body").innerHTML=e,page.messageElement.classList.remove("is-hidden")},onError:function(e){console.error(e),page.updateMessageBody("\n
An error occurred!
\n"+e.toString()+"
Please check your console for more information.
\n ")},onAxiosError:function(e){if(!e.response)return page.onError(e);var t=page.cloudflareErrors[e.response.status]||e.response.statusText,a=e.response.data&&e.response.data.description?e.response.data.description:"";page.updateMessageBody("\n"+e.response.status+" "+t+"
\n"+a+"
\n ")},deleteFile:function(){if(page.file){var e=document.createElement("div");e.innerHTML="You won't be able to recover this file!
",swal({title:"Are you sure?",content:e,icon:"warning",dangerMode:!0,buttons:{cancel:!0,confirm:{text:"Yes, nuke it!",closeModal:!1}}}).then((function(e){e&&axios.post("../api/upload/delete",{id:page.file.id}).then((function(e){if(e){if(!1===e.data.success)return swal("An error occurred!",e.data.description,"error");(Array.isArray(e.data.failed)?e.data.failed:[]).length?swal("An error occurred!","Unable to delete this file.","error"):swal("Deleted!","This file has been deleted.","success",{buttons:!1})}})).catch(page.onAxiosError)}))}},loadFileinfo:function(){page.urlIdentifier&&axios.get("../api/upload/get/"+page.urlIdentifier).then((function(e){if(![200,304].includes(e.status))return page.onAxiosError(e);page.file=e.data.file,page.titleFormat&&(document.title=page.titleFormat.replace(/%identifier%/g,page.file.name));for(var t="",a=Object.keys(page.file),n=0;nFields | \nValues | \n\n |
---|
Failed to parse upload identifier from URL.
");page.urlIdentifier=a[1],t+=window.location.pathname.substring(0,window.location.pathname.indexOf(a[1])),page.urlPrefix=t,page.urlParams=new URLSearchParams(window.location.search),page.clipboardJS=new ClipboardJS(".clipboard-js"),page.clipboardJS.on("success",(function(){return swal("","The link has been copied to clipboard.","success",{buttons:!1,timer:1500})})),page.clipboardJS.on("error",page.onError),page.deleteBtn.addEventListener("click",page.deleteFile),page.loadFileinfo()}})); //# sourceMappingURL=file.js.map