summaryrefslogtreecommitdiffstats
path: root/static/gomf.js
diff options
context:
space:
mode:
authorclsr <clsr@clsr.net>2016-12-16 16:06:41 +0100
committerclsr <clsr@clsr.net>2016-12-16 16:06:41 +0100
commit4baf4bd43c646428ac39306eb67bc718db5094a2 (patch)
tree7205d9d5d474a41e9f8fde2a0d0292f098603c6e /static/gomf.js
parent5ae48682ec2a668f8389860a6d9943bc9605f950 (diff)
downloadgomf-web-4baf4bd43c646428ac39306eb67bc718db5094a2.tar.gz
gomf-web-4baf4bd43c646428ac39306eb67bc718db5094a2.zip
Add support for uploading pasted blobsHEADv0.1.2master
Diffstat (limited to 'static/gomf.js')
-rw-r--r--static/gomf.js25
1 files changed, 21 insertions, 4 deletions
diff --git a/static/gomf.js b/static/gomf.js
index da14d14..86bb007 100644
--- a/static/gomf.js
+++ b/static/gomf.js
@@ -95,10 +95,6 @@
input.type = 'text';
input.readOnly = true;
input.value = resp;
- console.log(input);
- console.log(resp);
- console.log(input.value);
- console.log(input.value.length);
input.size = input.value.length;
input.addEventListener('click', function() {
this.select();
@@ -162,17 +158,38 @@
upload(e.dataTransfer.files);
};
+ var paste = function(e) {
+ var data = e.clipboardData || e.originalEvent.clipboardData;
+ var items = data.items;
+ var files = [];
+ for (var i in items) {
+ var item = items[i];
+ if (item.kind == 'file') {
+ var f = item.getAsFile();
+ f.name = f.name || 'clipboard-' + i;
+ files.push(f);
+ }
+ }
+ if (files.length) {
+ upload(files);
+ }
+ }
+
fileInput.addEventListener('change', submit);
fileInput.addEventListener('dragenter', dragenter);
fileInput.addEventListener('dragover', dragenter);
fileInput.addEventListener('drop', drop);
+ fileInput.focus();
+
fileName.textContent = 'Select or drop files here';
fileName.originalText = fileName.textContent;
fileDiv.className = 'file';
fileInput.multiple = 'multiple';
fileSubmit.style.display = 'none';
+ document.addEventListener('paste', paste);
+
updateName();
};