From 6c2eb4e98e62c83967e4fb672b692bb6448dcbaf Mon Sep 17 00:00:00 2001 From: Pitu Date: Mon, 30 Jan 2017 03:25:34 -0300 Subject: Added image pasting from clipboard --- public/js/upload.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'public/js/upload.js') diff --git a/public/js/upload.js b/public/js/upload.js index ba67d15..b620248 100644 --- a/public/js/upload.js +++ b/public/js/upload.js @@ -105,6 +105,7 @@ upload.prepareDropzone = function(){ }, init: function() { this.on('addedfile', function(file) { + myDropzone = this; document.getElementById('uploads').style.display = 'block'; }); } @@ -139,6 +140,22 @@ upload.prepareDropzone = function(){ } +//Handle image paste event +window.addEventListener('paste', function(event) { + var items = (event.clipboardData || event.originalEvent.clipboardData).items; + for (index in items) { + var item = items[index]; + if (item.kind === 'file') { + var blob = item.getAsFile(); + console.log(blob.type); + var file = new File([blob], "pasted-image."+blob.type.match(/(?:[^\/]*\/)([^;]*)/)[1]); + file.type = blob.type; + console.log(file); + myDropzone.addFile(file); + } + } +}); + window.onload = function () { upload.checkIfPublic(); }; \ No newline at end of file -- cgit v1.2.3 From b781237454e7db4c5cd5395c0198fe9c384751ca Mon Sep 17 00:00:00 2001 From: Pitu Date: Mon, 30 Jan 2017 04:41:44 -0300 Subject: Replaced auth header with token --- public/js/upload.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'public/js/upload.js') diff --git a/public/js/upload.js b/public/js/upload.js index b620248..b52f670 100644 --- a/public/js/upload.js +++ b/public/js/upload.js @@ -36,7 +36,6 @@ upload.verifyToken = function(token, reloadOnError){ reloadOnError = false; axios.post('/api/tokens/verify', { - type: 'client', token: token }) .then(function (response) { @@ -101,7 +100,7 @@ upload.prepareDropzone = function(){ maxFiles: 1000, autoProcessQueue: true, headers: { - 'auth': upload.token + 'token': upload.token }, init: function() { this.on('addedfile', function(file) { -- cgit v1.2.3