Refactored CSS and HTML templates and polished UI (#10), changed JavaScript variable names to camelCase, adjusted filenames and some url parameter names in urlpatterns, and more.
This commit is contained in:
parent
1e32e2b5dd
commit
8599f49857
30 changed files with 401 additions and 403 deletions
|
@ -2,28 +2,28 @@ document.addEventListener("DOMContentLoaded", () => {
|
|||
|
||||
// elements
|
||||
|
||||
let supply_description = document.getElementById("supplyDescription");
|
||||
let supply_price = document.getElementById("supplyPrice");
|
||||
let supplyDescriptionElement = document.getElementById("supplydescription");
|
||||
let supplyPriceElement = document.getElementById("supplyprice");
|
||||
|
||||
let supply_form = document.getElementById("supplyForm");
|
||||
let status_info = document.getElementById("statusInfo");
|
||||
let supply_submit_button = document.getElementById("supplySubmitBtn");
|
||||
let supplyFormElement = document.getElementById("supplyform");
|
||||
let statusInfoElement = document.getElementById("statusinfo");
|
||||
let supplySubmitButton = document.getElementById("supplysubmitbtn");
|
||||
|
||||
// custom submit method
|
||||
|
||||
supply_form.addEventListener("submit", (event) => {
|
||||
supplyFormElement.addEventListener("submit", (event) => {
|
||||
|
||||
supply_submit_button.disabled = true;
|
||||
supplySubmitButton.disabled = true;
|
||||
|
||||
event.preventDefault(); // Don't do the default submit action!
|
||||
|
||||
if (isNaN(parseFloat(supply_price.value)) || supply_description.value == "") {
|
||||
status_info.innerText = "Please enter a description and price."
|
||||
supply_submit_button.disabled = false;
|
||||
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(supply_form);
|
||||
let formData = new FormData(supplyFormElement);
|
||||
|
||||
xhr.addEventListener("load", (event) => {
|
||||
|
||||
|
@ -31,20 +31,20 @@ document.addEventListener("DOMContentLoaded", () => {
|
|||
response_ = event.target.responseText;
|
||||
|
||||
if (status_ == 200 && response_ == "success") {
|
||||
status_info.innerText = "Success.";
|
||||
statusInfoElement.innerText = "Success.";
|
||||
window.location.replace("/");
|
||||
}
|
||||
else {
|
||||
status_info.classList.add("errorText");
|
||||
status_info.innerText = "An error occured.";
|
||||
statusInfoElement.classList.add("errortext");
|
||||
statusInfoElement.innerText = "An error occured.";
|
||||
window.setTimeout(() => { window.location.reload() }, 5000);
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
xhr.addEventListener("error", (event) => {
|
||||
status_info.classList.add("errorText");
|
||||
status_info.innerText = "An error occured.";
|
||||
statusInfoElement.classList.add("errortext");
|
||||
statusInfoElement.innerText = "An error occured.";
|
||||
window.setTimeout(() => { window.location.reload() }, 5000);
|
||||
})
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue