Completely re-structured the project from scratch, wrote a better bootstrap script, changed configuration format to yaml, improved Caddyfile, and more. #15 #16 #20

This commit is contained in:
ChaoticByte 2023-02-11 17:23:57 +01:00
parent 0012214f9b
commit 5572fec9c1
91 changed files with 739 additions and 1345 deletions

56
app/static/js/supply.js Normal file
View file

@ -0,0 +1,56 @@
document.addEventListener("DOMContentLoaded", () => {
// elements
let supplyDescriptionElement = document.getElementById("supplydescription");
let supplyPriceElement = document.getElementById("supplyprice");
let supplyFormElement = document.getElementById("supplyform");
let statusInfoElement = document.getElementById("statusinfo");
let supplySubmitButton = document.getElementById("supplysubmitbtn");
// custom submit method
supplyFormElement.addEventListener("submit", (event) => {
supplySubmitButton.disabled = true;
event.preventDefault(); // Don't do the default submit action!
if (isNaN(parseFloat(supplyPriceElement.value)) || supplyDescriptionElement.value == "") {
statusInfoElement.innerText = "Please enter a description and price."
supplySubmitButton.disabled = false;
}
let xhr = new XMLHttpRequest();
let formData = new FormData(supplyFormElement);
xhr.addEventListener("load", (event) => {
status_ = event.target.status;
response_ = event.target.responseText;
if (status_ == 200 && response_ == "success") {
statusInfoElement.innerText = "Success.";
window.location.replace("/");
}
else {
statusInfoElement.classList.add("errortext");
statusInfoElement.innerText = "An error occured.";
window.setTimeout(() => { window.location.reload() }, 5000);
}
})
xhr.addEventListener("error", (event) => {
statusInfoElement.classList.add("errortext");
statusInfoElement.innerText = "An error occured.";
window.setTimeout(() => { window.location.reload() }, 5000);
})
xhr.open("POST", "/api/supply");
xhr.send(formData);
});
})