refacatored showError() and showSuccess()
This commit is contained in:
@@ -295,31 +295,25 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function showError(msg) {
|
function showError(msg) {
|
||||||
|
showMessage(msg, "error", 2000);
|
||||||
|
}
|
||||||
|
|
||||||
|
function showMessage(msg, type, duration = 2000) {
|
||||||
const original = "Drag & drop files here or click to select";
|
const original = "Drag & drop files here or click to select";
|
||||||
UI.dropzone.innerHTML = msg;
|
UI.dropzone.innerHTML = msg;
|
||||||
UI.dropzone.classList.add("error");
|
UI.dropzone.classList.add(type);
|
||||||
|
|
||||||
if (ErrorTimeout) clearTimeout(ErrorTimeout);
|
if (ErrorTimeout) clearTimeout(ErrorTimeout);
|
||||||
|
|
||||||
ErrorTimeout = setTimeout(() => {
|
ErrorTimeout = setTimeout(() => {
|
||||||
UI.dropzone.innerHTML = original;
|
UI.dropzone.innerHTML = original;
|
||||||
UI.dropzone.classList.remove("error");
|
UI.dropzone.classList.remove(type);
|
||||||
ErrorTimeout = null;
|
ErrorTimeout = null;
|
||||||
}, 2000);
|
}, duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
function showSuccess(msg) {
|
function showSuccess(msg) {
|
||||||
const original = "Drag & drop files here or click to select";
|
showMessage(msg, "success", 1500);
|
||||||
UI.dropzone.innerHTML = msg;
|
|
||||||
UI.dropzone.classList.add("success");
|
|
||||||
|
|
||||||
if (ErrorTimeout) clearTimeout(ErrorTimeout);
|
|
||||||
|
|
||||||
ErrorTimeout = setTimeout(() => {
|
|
||||||
UI.dropzone.innerHTML = original;
|
|
||||||
UI.dropzone.classList.remove("success");
|
|
||||||
ErrorTimeout = null;
|
|
||||||
}, 1500);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateUI() {
|
function updateUI() {
|
||||||
|
Reference in New Issue
Block a user