Modularize frontend app script

This commit is contained in:
2026-02-03 01:47:53 +01:00
parent e4402c08d5
commit 8db4670f11
6 changed files with 1044 additions and 1035 deletions

33
wwwroot/js/state.js Normal file
View File

@@ -0,0 +1,33 @@
export const state = {
isAuthenticated: false,
authMode: "login",
me: null,
phase: null,
prevPhase: null,
counts: null,
mySuggestions: [],
allSuggestions: [],
allSuggestionsSig: null,
myVotes: [],
results: [],
votesRendered: false,
};
export function clearUserState() {
state.me = null;
state.phase = null;
state.prevPhase = null;
state.counts = null;
state.mySuggestions = [];
state.allSuggestions = [];
state.myVotes = [];
state.results = [];
state.votesRendered = false;
const adminCard = document.getElementById("admin-card");
if (adminCard) adminCard.classList.add("hidden");
}
export const getSavedUsername = () =>
localStorage.getItem("last_username") || "";
export const setSavedUsername = (name) =>
localStorage.setItem("last_username", name);