@@ 416,6 416,17 @@ function curTransitionState() {
};
}
+function updateActionDom(action) {
+ const btn = document.getElementById("action-" + action.name);
+ if (btn) {
+ if (state[action.stateBool]) {
+ btn.classList.add("on");
+ } else {
+ btn.classList.remove("on");
+ }
+ }
+}
+
function execAction(id, slow) {
const action = ACTIONS[id];
if (action.actionType === "move") {
@@ 432,14 443,7 @@ function execAction(id, slow) {
} else if (action.actionType === "toggle") {
state[action.stateBool] = !state[action.stateBool];
state.rendering.gridDirty = true;
- const btn = document.getElementById("action-" + action.name);
- if (btn) {
- if (state[action.stateBool]) {
- btn.classList.add("on");
- } else {
- btn.classList.remove("on");
- }
- }
+ updateActionDom(action);
}
stateUpdated();
}
@@ 508,6 512,7 @@ document.addEventListener("DOMContentLoaded", () => {
if (btn) {
btn.onclick = () => execAction(id, false);
}
+ updateActionDom(action);
});
stateUpdated();