Refactored "location" -> "window.location"

In client JS files, for readibility and consistency.

They'd work the same either way, but I'd think they'd be easier to
read and understand this way.
This commit is contained in:
Bobby Wibowo 2020-05-26 02:39:28 +07:00
parent 98b2f32ec5
commit d666e278ec
No known key found for this signature in database
GPG Key ID: 51C3A1E1E22D26CF
10 changed files with 14 additions and 14 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2
dist/js/home.js vendored

File diff suppressed because one or more lines are too long

2
dist/js/home.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -1,2 +1,2 @@
lsKeys.siBytes="siBytes",page.prepareShareX=function(){var e=page.token?{token:page.token||"",albumid:page.album||""}:{};e.filelength=page.fileLength||"",e.age=page.uploadAge||"",e.striptags=page.stripTags||"";for(var t=[],a=Object.keys(e),r=0;r<a.length;r++)t.push(' "'+a[r]+'": "'+e[a[r]]+'"');var n=(location.hostname+location.pathname).replace(/\/(dashboard)?$/,""),o=n.replace(/\//g,"_"),i=document.querySelector("#ShareX"),s='{\n "Name": "'+o+'",\n "DestinationType": "ImageUploader, FileUploader",\n "RequestMethod": "POST",\n "RequestURL": "'+location.protocol+"//"+n+'/api/upload",\n "Headers": {\n'+t.join(",\n")+'\n },\n "Body": "MultipartFormData",\n "FileFormName": "files[]",\n "URL": "$json:files[0].url$",\n "ThumbnailURL": "$json:files[0].url$"\n}',l=new Blob([s],{type:"application/octet-binary"});i.setAttribute("href",URL.createObjectURL(l)),i.setAttribute("download",o+".sxcu")},page.getPrettyDate=function(e){return e.getFullYear()+"/"+(e.getMonth()<9?"0":"")+(e.getMonth()+1)+"/"+(e.getDate()<10?"0":"")+e.getDate()+" "+(e.getHours()<10?"0":"")+e.getHours()+":"+(e.getMinutes()<10?"0":"")+e.getMinutes()+":"+(e.getSeconds()<10?"0":"")+e.getSeconds()},page.getPrettyBytes=function(e){if("number"!=typeof e&&!isFinite(e))return e;var t="0"!==localStorage[lsKeys.siBytes],a=e<0?"-":"",r=t?1e3:1024;if(a&&(e=-e),e<r)return""+a+e+" B";var n=Math.min(Math.floor(Math.log(e)*Math.LOG10E/3),8);return""+a+Number((e/Math.pow(r,n)).toPrecision(3))+" "+((t?"kMGTPEZY":"KMGTPEZY").charAt(n-1)+(t?"":"i"))+"B"},page.escape=function(e){if(!e)return e;var t,a=String(e),r=/["'&<>]/.exec(a);if(!r)return a;var n="",o=0,i=0;for(o=r.index;o<a.length;o++){switch(a.charCodeAt(o)){case 34:t="&quot;";break;case 38:t="&amp;";break;case 39:t="&#39;";break;case 60:t="&lt;";break;case 62:t="&gt;";break;default:continue}i!==o&&(n+=a.substring(i,o)),i=o+1,n+=t}return i!==o?n+a.substring(i,o):n}; lsKeys.siBytes="siBytes",page.prepareShareX=function(){var e=page.token?{token:page.token||"",albumid:page.album||""}:{};e.filelength=page.fileLength||"",e.age=page.uploadAge||"",e.striptags=page.stripTags||"";for(var t=[],a=Object.keys(e),n=0;n<a.length;n++)t.push(' "'+a[n]+'": "'+e[a[n]]+'"');var r=(window.location.hostname+window.location.pathname).replace(/\/(dashboard)?$/,""),o=r.replace(/\//g,"_"),i=document.querySelector("#ShareX"),s='{\n "Name": "'+o+'",\n "DestinationType": "ImageUploader, FileUploader",\n "RequestMethod": "POST",\n "RequestURL": "'+window.location.protocol+"//"+r+'/api/upload",\n "Headers": {\n'+t.join(",\n")+'\n },\n "Body": "MultipartFormData",\n "FileFormName": "files[]",\n "URL": "$json:files[0].url$",\n "ThumbnailURL": "$json:files[0].url$"\n}',l=new Blob([s],{type:"application/octet-binary"});i.setAttribute("href",URL.createObjectURL(l)),i.setAttribute("download",o+".sxcu")},page.getPrettyDate=function(e){return e.getFullYear()+"/"+(e.getMonth()<9?"0":"")+(e.getMonth()+1)+"/"+(e.getDate()<10?"0":"")+e.getDate()+" "+(e.getHours()<10?"0":"")+e.getHours()+":"+(e.getMinutes()<10?"0":"")+e.getMinutes()+":"+(e.getSeconds()<10?"0":"")+e.getSeconds()},page.getPrettyBytes=function(e){if("number"!=typeof e&&!isFinite(e))return e;var t="0"!==localStorage[lsKeys.siBytes],a=e<0?"-":"",n=t?1e3:1024;if(a&&(e=-e),e<n)return""+a+e+" B";var r=Math.min(Math.floor(Math.log(e)*Math.LOG10E/3),8);return""+a+Number((e/Math.pow(n,r)).toPrecision(3))+" "+((t?"kMGTPEZY":"KMGTPEZY").charAt(r-1)+(t?"":"i"))+"B"},page.escape=function(e){if(!e)return e;var t,a=String(e),n=/["'&<>]/.exec(a);if(!n)return a;var r="",o=0,i=0;for(o=n.index;o<a.length;o++){switch(a.charCodeAt(o)){case 34:t="&quot;";break;case 38:t="&amp;";break;case 39:t="&#39;";break;case 60:t="&lt;";break;case 62:t="&gt;";break;default:continue}i!==o&&(r+=a.substring(i,o)),i=o+1,r+=t}return i!==o?r+a.substring(i,o):r};
//# sourceMappingURL=utils.js.map //# sourceMappingURL=utils.js.map

File diff suppressed because one or more lines are too long

View File

@ -158,7 +158,7 @@ page.checkClientVersion = apiVersion => {
} }
} }
}).then(() => { }).then(() => {
location.reload() window.location.reload()
}) })
} }

View File

@ -75,7 +75,7 @@ page.onInitError = error => {
uploadButton.classList.remove('is-hidden') uploadButton.classList.remove('is-hidden')
uploadButton.addEventListener('click', () => { uploadButton.addEventListener('click', () => {
location.reload() window.location.reload()
}) })
if (error.response) if (error.response)
@ -137,7 +137,7 @@ page.checkClientVersion = apiVersion => {
} }
} }
}).then(() => { }).then(() => {
location.reload() window.location.reload()
}) })
} }
@ -195,7 +195,7 @@ page.verifyToken = (token, reloadOnError) => {
}).then(() => { }).then(() => {
if (!reloadOnError) return if (!reloadOnError) return
localStorage.removeItem('token') localStorage.removeItem('token')
location.reload() window.location.reload()
}) })
localStorage[lsKeys.token] = token localStorage[lsKeys.token] = token
@ -1027,7 +1027,7 @@ page.prepareUploadConfig = () => {
text: 'Configuration saved into this browser.', text: 'Configuration saved into this browser.',
icon: 'success' icon: 'success'
}).then(() => { }).then(() => {
location.reload() window.location.reload()
}) })
}) })

View File

@ -18,7 +18,7 @@ page.prepareShareX = () => {
// Pad by 4 space // Pad by 4 space
headers.push(` "${keys[i]}": "${values[keys[i]]}"`) headers.push(` "${keys[i]}": "${values[keys[i]]}"`)
const origin = (location.hostname + location.pathname).replace(/\/(dashboard)?$/, '') const origin = (window.location.hostname + window.location.pathname).replace(/\/(dashboard)?$/, '')
const originClean = origin.replace(/\//g, '_') const originClean = origin.replace(/\//g, '_')
const sharexElement = document.querySelector('#ShareX') const sharexElement = document.querySelector('#ShareX')
@ -26,7 +26,7 @@ page.prepareShareX = () => {
"Name": "${originClean}", "Name": "${originClean}",
"DestinationType": "ImageUploader, FileUploader", "DestinationType": "ImageUploader, FileUploader",
"RequestMethod": "POST", "RequestMethod": "POST",
"RequestURL": "${location.protocol}//${origin}/api/upload", "RequestURL": "${window.location.protocol}//${origin}/api/upload",
"Headers": { "Headers": {
${headers.join(',\n')} ${headers.join(',\n')}
}, },

View File

@ -1,5 +1,5 @@
{ {
"1": "1590283732", "1": "1590435470",
"2": "1589010026", "2": "1589010026",
"3": "1581416390", "3": "1581416390",
"4": "1581416390", "4": "1581416390",