1
0
Fork 0

Round price and fix event when plate changed

This commit is contained in:
Ethanell 2020-03-06 17:10:14 +01:00
parent aed4b62f07
commit 1589c70984

View file

@ -54,21 +54,12 @@ function addplate(id, name) {
let e = document.querySelector(`input[id=${id} ]`); let e = document.querySelector(`input[id=${id} ]`);
e.addEventListener("click", () => { e.addEventListener("click", () => {
radiocheck(e, "plate",0); radiocheck(e, "plate",0);
document.querySelectorAll("input[name=ingredient]").forEach( el => { document.querySelectorAll("input[name=ingredient],input[name=sauce]").forEach( el => {
if (e.checked && !db["plate"][e.id]["avoid ingredient"]) if (el.checked)
el.disabled = false; el.click();
else {
el.disabled = true;
el.checked = false
}
}); });
document.querySelectorAll("input[name=sauce]").forEach( el => { document.querySelectorAll("input[name=ingredient],input[name=sauce]").forEach( el => {
if (e.checked && !db["plate"][e.id]["avoid sauce"]) el.disabled = !(e.checked && !db["plate"][e.id]["avoid " + el.name]);
el.disabled = false;
else {
el.disabled = true;
el.checked = false
}
}); });
}) })
} }
@ -182,6 +173,7 @@ function price () {
for (let i in current["price"]) { for (let i in current["price"]) {
p += current["price"][i] p += current["price"][i]
} }
p = p.toFixed(2);
document.querySelector("#resume h2").innerHTML = p+"€"; document.querySelector("#resume h2").innerHTML = p+"€";
} }