diff options
-rw-r--r-- | static/gomf.js | 25 |
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(); }; |