fup: add drag and drop uploads

There's no UI indication that this is happening yet, but...
This commit is contained in:
Luke Granger-Brown 2021-03-22 01:08:42 +00:00
parent bb31335319
commit 01fb49549b

View file

@ -118,4 +118,32 @@ if (document.body.classList.contains('upload-page')) {
uploadFile(file, expiryEl.value); uploadFile(file, expiryEl.value);
} }
}); });
document.body.addEventListener('dragenter', (e) => {
e.preventDefault();
e.stopPropagation();
document.body.classList.add('dragging-over');
}, false);
document.body.addEventListener('dragover', (e) => {
e.preventDefault();
e.stopPropagation();
document.body.classList.add('dragging-over');
}, false);
document.body.addEventListener('dragleave', (e) => {
e.preventDefault();
e.stopPropagation();
document.body.classList.remove('dragging-over');
}, false);
document.body.addEventListener('drop', (e) => {
e.preventDefault();
e.stopPropagation();
document.body.classList.remove('dragging-over');
const dt = e.dataTransfer;
const files = dt.files;
for (const f of files) {
uploadFile(f, expiryEl.value);
}
}, false);
} }