Fixed the synth list for needed mats not being consistent and having empty elements
parent
3e2b73d130
commit
c3304099bd
|
@ -11,6 +11,7 @@ document.addEventListener("DOMContentLoaded", (event) => {
|
||||||
updateSynthRecipeState(recipe);
|
updateSynthRecipeState(recipe);
|
||||||
|
|
||||||
recipe.addEventListener("input", function () {
|
recipe.addEventListener("input", function () {
|
||||||
|
// Change the recipe's state and update and needed materials list based on the remaining recipes
|
||||||
localStorage.setItem("kh1-synth-" + this.id, this.checked);
|
localStorage.setItem("kh1-synth-" + this.id, this.checked);
|
||||||
updateSynthRecipeState(this);
|
updateSynthRecipeState(this);
|
||||||
calcNeededMats();
|
calcNeededMats();
|
||||||
|
@ -24,9 +25,17 @@ document.addEventListener("DOMContentLoaded", (event) => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
markedNeededMaterials = Array(
|
// Turn the single saved string into an array with each material
|
||||||
localStorage.getItem("kh1-synth-needed-mats") ?? [],
|
if (localStorage.getItem("kh1-synth-needed-mats") != null) {
|
||||||
|
let saved = localStorage.getItem("kh1-synth-needed-mats");
|
||||||
|
saved = saved.split(",");
|
||||||
|
markedNeededMaterials = saved;
|
||||||
|
markedNeededMaterials = markedNeededMaterials.filter(
|
||||||
|
(n) => n && n !== "",
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
markedNeededMaterials = new Array();
|
||||||
|
}
|
||||||
|
|
||||||
calcNeededMats();
|
calcNeededMats();
|
||||||
});
|
});
|
||||||
|
@ -118,6 +127,7 @@ function updateMarkedNeededMats(ingredient) {
|
||||||
} else {
|
} else {
|
||||||
markedNeededMaterials.push(ingredient);
|
markedNeededMaterials.push(ingredient);
|
||||||
}
|
}
|
||||||
|
markedNeededMaterials = markedNeededMaterials.filter((n) => n && n !== "");
|
||||||
localStorage.setItem("kh1-synth-needed-mats", markedNeededMaterials);
|
localStorage.setItem("kh1-synth-needed-mats", markedNeededMaterials);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue