diff options
| author | Kana <[email protected]> | 2017-10-11 20:59:25 -0300 |
|---|---|---|
| committer | GitHub <[email protected]> | 2017-10-11 20:59:25 -0300 |
| commit | 0a4729d2bd4e1a4aa04b74cb06bd4a6017153ed3 (patch) | |
| tree | 175a610b9cb01132de332dcb86fdba132b8b5dcd /public/js | |
| parent | Aligned the album download button (diff) | |
| parent | Fix up formatting in the sharex_file variable (diff) | |
| download | host.fuwn.me-0a4729d2bd4e1a4aa04b74cb06bd4a6017153ed3.tar.xz host.fuwn.me-0a4729d2bd4e1a4aa04b74cb06bd4a6017153ed3.zip | |
Merge pull request #58 from ScruffyRules/sharex
Make ShareX link download a sharex file if you're logged in
Diffstat (limited to 'public/js')
| -rw-r--r-- | public/js/home.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/public/js/home.js b/public/js/home.js index 4412ac5..83e935a 100644 --- a/public/js/home.js +++ b/public/js/home.js @@ -172,6 +172,29 @@ upload.prepareDropzone = function(){ }); + upload.prepareShareX(); +} + +upload.prepareShareX = function(){ + if (upload.token) { + var sharex_element = document.getElementById("ShareX"); + var sharex_file = "{\r\n\ + \"Name\": \"" + location.hostname + "\",\r\n\ + \"DestinationType\": \"ImageUploader, FileUploader\",\r\n\ + \"RequestType\": \"POST\",\r\n\ + \"RequestURL\": \"" + location.origin + "/api/upload\",\r\n\ + \"FileFormName\": \"files[]\",\r\n\ + \"Headers\": {\r\n\ + \"token\": \" " + upload.token + "\"\r\n\ + },\r\n\ + \"ResponseType\": \"Text\",\r\n\ + \"URL\": \"$json:files[0].url$\",\r\n\ + \"ThumbnailURL\": \"$json:files[0].url$\"\r\n\ +}"; + var sharex_blob = new Blob([sharex_file], {type: "application/octet-binary"}); + sharex_element.setAttribute("href", URL.createObjectURL(sharex_blob)) + sharex_element.setAttribute("download", location.hostname + ".sxcu"); + } } //Handle image paste event |