oh wow i was meant to push this a long time ago

This commit is contained in:
sky
2026-06-11 23:04:06 -04:00
parent e12d4d3017
commit 0605271327
7 changed files with 141 additions and 113 deletions

View File

@ -131,7 +131,8 @@
} else {
localStorage.setItem("selenite.disableCDN", "true")
}
})
});
initHiddenGameSettings();
function generatePallete(color) {
let theme = {};
let chromaColor = chroma(color);
@ -145,6 +146,85 @@
return theme;
}
});
function getHiddenGames() {
try {
const parsed = JSON.parse(localStorage.getItem("selenite.hiddenGames") || "[]");
return parsed;
} catch {
return [];
}
}
function setHiddenGames(games) {
localStorage.setItem("selenite.hiddenGames", JSON.stringify(games));
}
function updateHiddenGamesCount(total) {
const hiddenCount = getHiddenGames().length;
const countEl = document.getElementById("hiddenGamesCount");
countEl.innerText = `${hiddenCount} hidden${total ? ` / ${total} total` : ""}`;
}
function renderHiddenGameList(games, hiddenSet, filter = "") {
const list = document.getElementById("hiddenGamesList");
list.innerHTML = "";
const input = filter.trim().toUpperCase();
const shown = games.filter((game) => game.name.toUpperCase().includes(input));
if (shown.length === 0) {
const empty = document.createElement("p");
empty.innerText = "no games matched your search";
list.appendChild(empty);
return;
}
shown.forEach((game) => {
const row = document.createElement("label");
row.className = "hidden-game-row";
const checkbox = document.createElement("input");
checkbox.type = "checkbox";
checkbox.checked = hiddenSet.has(game.directory);
checkbox.addEventListener("change", () => {
const next = new Set(getHiddenGames());
if (checkbox.checked) next.add(game.directory);
else next.delete(game.directory);
const hidden = [...next].sort();
setHiddenGames(hidden);
updateHiddenGamesCount(games.length);
});
const text = document.createElement("span");
text.innerText = game.name;
row.appendChild(checkbox);
row.appendChild(text);
list.appendChild(row);
});
}
async function initHiddenGameSettings() {
const searchInput = document.getElementById("hiddenGamesSearch");
let games = [];
try {
games = await (await fetch("/resources/games-tagged.json")).json();
} catch {
document.getElementById("hiddenGamesList").innerHTML = "<p>failed to load games list</p>";
return;
}
games.sort((a, b) => a.name.localeCompare(b.name));
renderHiddenGameList(games, new Set(getHiddenGames()));
updateHiddenGamesCount(games.length);
searchInput.addEventListener("input", () => {
renderHiddenGameList(games, new Set(getHiddenGames()), searchInput.value);
});
}
function wipeData() {
if(prompt("Wiping your data means you will lose all progress in every game, and every setting you have selected.\nAre you sure you would like to continue?\n\nType \"please wipe my data\" to continue.") == "please wipe my data") {
localStorage.clear();
@ -254,6 +334,12 @@
<button onclick="deleteAllCaches()">wipe all cache</button>
<input id="toggleCDN" name="toggleCDN" type="checkbox"></inpuit> <label for="toggleCDN">cdn enabled</label>
</section>
<section>
<h2>hidden games</h2>
<p id="hiddenGamesCount">0 hidden</p>
<input type="text" id="hiddenGamesSearch" placeholder="search games">
<div id="hiddenGamesList"></div>
</section>
</sections>
</body>
</html>