From d367bc27fa5c0b13cbff3500a3d5d1bd5cc61423 Mon Sep 17 00:00:00 2001 From: ScruffyRules Date: Fri, 6 Oct 2017 16:58:39 +1030 Subject: Make ShareX link download a sharex file if you're logged in --- public/js/home.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'public/js') diff --git a/public/js/home.js b/public/js/home.js index 4412ac5..ff5ab8a 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 = "{ \ + \"Name\": \"" + location.hostname + "\", \ + \"DestinationType\": \"ImageUploader, FileUploader\", \ + \"RequestType\": \"POST\", \ + \"RequestURL\": \"" + location.origin + "/api/upload\", \ + \"FileFormName\": \"files[]\", \ + \"Headers\": { \ + \"token\": \" " + upload.token + "\" \ + }, \ + \"ResponseType\": \"Text\", \ + \"URL\": \"$json:files[0].url$\", \ + \"ThumbnailURL\": \"$json:files[0].url$\" \ +}"; + 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 -- cgit v1.2.3 From 9c07dda3178daaaa6d927b650f40306b435db0cb Mon Sep 17 00:00:00 2001 From: ScruffyRules Date: Fri, 6 Oct 2017 17:10:06 +1030 Subject: Fix up formatting in the sharex_file variable --- public/js/home.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'public/js') diff --git a/public/js/home.js b/public/js/home.js index ff5ab8a..83e935a 100644 --- a/public/js/home.js +++ b/public/js/home.js @@ -178,18 +178,18 @@ upload.prepareDropzone = function(){ upload.prepareShareX = function(){ if (upload.token) { var sharex_element = document.getElementById("ShareX"); - var sharex_file = "{ \ - \"Name\": \"" + location.hostname + "\", \ - \"DestinationType\": \"ImageUploader, FileUploader\", \ - \"RequestType\": \"POST\", \ - \"RequestURL\": \"" + location.origin + "/api/upload\", \ - \"FileFormName\": \"files[]\", \ - \"Headers\": { \ - \"token\": \" " + upload.token + "\" \ - }, \ - \"ResponseType\": \"Text\", \ - \"URL\": \"$json:files[0].url$\", \ - \"ThumbnailURL\": \"$json:files[0].url$\" \ + 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)) -- cgit v1.2.3