diff options
Diffstat (limited to 'public/static/scripts/form.js')
| -rw-r--r-- | public/static/scripts/form.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/public/static/scripts/form.js b/public/static/scripts/form.js new file mode 100644 index 0000000..6e4f608 --- /dev/null +++ b/public/static/scripts/form.js @@ -0,0 +1,29 @@ +document.onpaste = () => { + var items = (event.clipboardData || event.originalEvent.clipboardData).items; + + for (index in items) { + var item = items[index]; + if (item.kind === 'file') { + file = item.getAsFile(); + showFile(file); + } + } +}; + +function showFile(file) { + setFormDetailsVisiblity(file != null); + + if (file == null) { + fileUploadWrapper.innerHTML = '<h1>Click, drop, or paste files here</h1>'; + + if (fileURLWrapper) { + fileURLWrapper.style.display = 'flex'; + } + } else { + fileUploadWrapper.innerHTML = `<h1>File: ${file.name}</h1>`; + + if (fileURLWrapper) { + fileURLWrapper.style.display = 'none'; + } + } +}
\ No newline at end of file |
