calculateCraftSchedule added

This commit is contained in:
ferricles 2022-05-22 14:27:57 -07:00
parent 0bed0dab91
commit 9ebc65ff90

View file

@ -44,23 +44,24 @@ function init_crafter() {
try {
document.getElementById("recipe-choice").addEventListener("change", (event) => {
updateMaterials();
calculateCraft();
calculateCraftSchedule();
});
document.getElementById("level-choice").addEventListener("change", (event) => {
updateMaterials();
calculateCraft();
calculateCraftSchedule();
});
document.getElementById("recipe-choice").setAttribute("oninput", "updateCraftedImage()");
document.getElementById("recipe-choice").setAttribute("change", "updateCraftedImage()");
for (let i = 1; i < 4; ++i) {
document.getElementById("mat-1-"+i).setAttribute("onclick", document.getElementById("mat-1-"+i).getAttribute("onclick") + "; calculateCraft();");
document.getElementById("mat-2-"+i).setAttribute("onclick", document.getElementById("mat-2-"+i).getAttribute("onclick") + "; calculateCraft();");
document.getElementById("mat-1-"+i).setAttribute("onclick", document.getElementById("mat-1-"+i).getAttribute("onclick") + "; calculateCraftSchedule();");
document.getElementById("mat-2-"+i).setAttribute("onclick", document.getElementById("mat-2-"+i).getAttribute("onclick") + "; calculateCraftSchedule();");
}
for (let i = 1; i < 7; ++i) {
document.getElementById("ing-choice-" + i ).setAttribute("oninput", "calculateCraft();");
document.getElementById("ing-choice-" + i ).setAttribute("oninput", "calculateCraftSchedule();");
}
for (const str of ["slow", "normal", "fast"]) {
document.getElementById(str + "-atk-button").setAttribute("onclick", document.getElementById(str + "-atk-button").getAttribute("onclick") + "; calculateCraft();");
document.getElementById(str + "-atk-button").setAttribute("onclick", document.getElementById(str + "-atk-button").getAttribute("onclick") + "; calculateCraftSchedule();");
}
@ -102,6 +103,20 @@ function toggleAtkSpd(buttonId) {
}
}
let doCraftTask = null;
function calculateCraftSchedule(){
console.log("Craft Schedule called");
if (doCraftTask !== null) {
clearTimeout(doCraftTask);
}
doCraftTask = setTimeout(function(){
doCraftTask = null;
calculateCraft();
window.dispatchEvent(new Event('resize'));
}, 250);
}
function calculateCraft() {
//Make things display.
for (let i of document.getElementsByClassName("hide-container-block")) {