filesafe/public/js/sharex.js
Bobby Wibowo 52d336cc45
Updated ESLint rule: curly
No more enforced curly for if/else/for/while/do blocks w/ one statement.

With that said, auto-fixed all JS files to follow the rule.

I'd also like to apologize for the inconveniences this commit cause,
after all it was me who intentionally enforced curly rule back then.

Why the change of heart?
After doing some more non-JS codes recently, I realized it was
pretty stupid of me to enforce that.
2018-12-19 00:01:28 +07:00

25 lines
865 B
JavaScript

/* global page */
page.prepareShareX = function () {
if (!page.token) return
const origin = (location.hostname + location.pathname).replace(/\/(dashboard)?$/, '')
const originClean = origin.replace(/\//g, '_')
const sharexElement = document.getElementById('ShareX')
const sharexFile = `{
"Name": "${originClean}",
"DestinationType": "ImageUploader, FileUploader",
"RequestType": "POST",
"RequestURL": "${location.protocol}//${origin}/api/upload",
"FileFormName": "files[]",
"Headers": {
"token": "${page.token}"
},
"ResponseType": "Text",
"URL": "$json:files[0].url$",
"ThumbnailURL": "$json:files[0].url$"
}\n`
const sharexBlob = new Blob([sharexFile], { type: 'application/octet-binary' })
sharexElement.setAttribute('href', URL.createObjectURL(sharexBlob))
sharexElement.setAttribute('download', `${originClean}.sxcu`)
}