Redesigned the user interface #23
This commit is contained in:
parent
f7048d1e9f
commit
d93591bcb2
32 changed files with 846 additions and 1297 deletions
|
@ -1,28 +1,18 @@
|
|||
document.addEventListener("DOMContentLoaded", () => {
|
||||
|
||||
// elements
|
||||
|
||||
let depositForm = document.getElementById("depositform");
|
||||
let statusInfo = document.getElementById("statusinfo");
|
||||
let depositSubmitButton = document.getElementById("depositsubmitbtn");
|
||||
|
||||
// event listener for deposit form
|
||||
// this implements a custom submit method
|
||||
|
||||
depositForm.addEventListener("submit", (event) => {
|
||||
|
||||
depositSubmitButton.disabled = true;
|
||||
|
||||
event.preventDefault(); // Don't do the default submit action!
|
||||
|
||||
let xhr = new XMLHttpRequest();
|
||||
let formData = new FormData(depositForm);
|
||||
|
||||
xhr.addEventListener("load", (event) => {
|
||||
|
||||
status_ = event.target.status;
|
||||
response_ = event.target.responseText;
|
||||
|
||||
if (status_ == 200 && response_ == "success") {
|
||||
statusInfo.innerText = "Success. Redirecting soon.";
|
||||
window.location.replace("/");
|
||||
|
@ -32,18 +22,13 @@ document.addEventListener("DOMContentLoaded", () => {
|
|||
statusInfo.innerText = "An error occured. Redirecting in 5 seconds...";
|
||||
window.setTimeout(() => { window.location.replace("/") }, 5000);
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
xhr.addEventListener("error", (event) => {
|
||||
statusInfo.classList.add("errortext");
|
||||
statusInfo.innerText = "An error occured. Redirecting in 5 seconds...";
|
||||
window.setTimeout(() => { window.location.replace("/") }, 5000);
|
||||
})
|
||||
|
||||
xhr.open("POST", "/api/deposit");
|
||||
xhr.send(formData);
|
||||
|
||||
});
|
||||
|
||||
})
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue