feat(character-sheet): Create the clearSheet() helper

This commit is contained in:
2025-06-06 22:33:02 +02:00
parent e22f6fad5a
commit 363d287a28

View File

@@ -345,6 +345,28 @@
</div>
</div>
<script>
const poolTypes = ["might", "speed", "intellect"];
const inpCampaignName = document.getElementById("inp-campaign-name");
const inpCharacterName = document.getElementById("inp-character-name");
const inpMaxEffort = document.getElementById("inp-max-effort");
const inpArmor = document.getElementById("inp-armor");
const inpPoolValue = {
might: document.getElementById("inp-pool-value-might"),
speed: document.getElementById("inp-pool-value-speed"),
intellect: document.getElementById("inp-pool-value-intellect"),
};
const inpPoolMax = {
might: document.getElementById("inp-pool-max-might"),
speed: document.getElementById("inp-pool-max-speed"),
intellect: document.getElementById("inp-pool-max-intellect"),
};
const inpPoolEdge = {
might: document.getElementById("inp-pool-edge-might"),
speed: document.getElementById("inp-pool-edge-speed"),
intellect: document.getElementById("inp-pool-edge-intellect"),
};
const checkLocalStorage = () => {
let storage;
try {
@@ -374,6 +396,19 @@
input.disabled = !toUnlock;
};
const clearSheet = () => {
inpCampaignName.value = "";
inpCharacterName.value = "";
inpMaxEffort.value = 1;
inpArmor.value = 0;
for (var poolType of poolTypes) {
inpPoolValue[poolType].value = 0;
inpPoolMax[poolType].value = 0;
inpPoolEdge[poolType].value = 0;
}
};
document.addEventListener(
"DOMContentLoaded",
() => {
@@ -385,6 +420,8 @@
document
.querySelectorAll(".input-unlocker")
.forEach((elem) => {elem.addEventListener("change", toggleInputLockedHandler)});
clearSheet();
},
);
</script>