1
0
Fork 0
mirror of https://codeberg.org/icewind/shelve.git synced 2026-06-03 12:04:09 +02:00
This commit is contained in:
Robin Appelman 2020-01-25 23:03:11 +01:00
commit fc84fdec52
5 changed files with 180 additions and 5 deletions

View file

@ -308,6 +308,18 @@
expireInput.value = expire;
}
function resetForm() {
form.reset();
let token = localStorage.getItem('token');
if (token) {
tokenInput.value = token;
}
let expire = localStorage.getItem('expire');
if (expire) {
expireInput.value = expire;
}
}
// automatically submit the form on file select
input.addEventListener('change', function (e) {
showFiles(e.target.files);
@ -339,9 +351,7 @@
droppedFiles = e.dataTransfer.files; // the files that were dropped
showFiles(droppedFiles);
triggerFormSubmit();
});
}
@ -369,9 +379,10 @@
ajax.open(form.getAttribute('method'), form.getAttribute('action'), true);
ajax.onload = function () {
resetForm();
box.classList.remove('is-uploading');
if (ajax.status >= 200 && ajax.status < 400) {
console.log(ajax.responseText);
var data = JSON.parse(ajax.responseText);
box.classList.add(data.success == true ? 'is-success' : 'is-error');
if (!data.success) {