oh wow i was meant to push this a long time ago
This commit is contained in:
23
js/loader.js
23
js/loader.js
@ -7,6 +7,15 @@ let pageData;
|
||||
let starredGames = [];
|
||||
let globalPlays = null;
|
||||
|
||||
function getHiddenGames() {
|
||||
try {
|
||||
const parsed = JSON.parse(localStorage.getItem("selenite.hiddenGames") || "[]");
|
||||
return parsed;
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
async function loadGames() {
|
||||
if (type == "g") pageData = { path: "/resources/games-tagged.json", prefix: "semag", type: "g" };
|
||||
else if (type == "a") pageData = { path: "/resources/apps.json", prefix: "sppa", type: "a" };
|
||||
@ -22,10 +31,18 @@ async function loadGames() {
|
||||
const gamesFragment = document.createDocumentFragment();
|
||||
const topFragment = document.createDocumentFragment();
|
||||
|
||||
const hiddenGames = pageData.type === "g" ? getHiddenGames() : [];
|
||||
const hiddenSet = new Set(hiddenGames);
|
||||
|
||||
starredGames = JSON.parse(localStorage.getItem("selenite.starred") || "[]");
|
||||
if (hiddenGames.length > 0) {
|
||||
starredGames = starredGames.filter((game) => !hiddenSet.has(game));
|
||||
localStorage.setItem("selenite.starred", JSON.stringify(starredGames));
|
||||
}
|
||||
const starredSet = new Set(starredGames);
|
||||
|
||||
data.forEach((element) => {
|
||||
if (hiddenSet.has(element.directory)) return;
|
||||
const isStarred = starredSet.has(element.directory);
|
||||
const newElement = document.createElement("a");
|
||||
newElement.dataset.target = element.directory;
|
||||
@ -98,7 +115,11 @@ async function loadGames() {
|
||||
|
||||
gamesElement.appendChild(gamesFragment);
|
||||
if (topGElement) topGElement.appendChild(topFragment);
|
||||
document.getElementById("gameCount").innerText = `${data.length} games loaded!`;
|
||||
const visibleGameCount = elements.length;
|
||||
const hiddenCount = hiddenGames.length;
|
||||
document.getElementById("gameCount").innerText = hiddenCount > 0
|
||||
? `${visibleGameCount} games loaded (${hiddenCount} hidden)`
|
||||
: `${visibleGameCount} games loaded!`;
|
||||
document.getElementById("loadingMsg").style.display = "none";
|
||||
document.getElementById("allHeader").style.display = "block";
|
||||
const topHeader = document.getElementById("topHeader");
|
||||
|
||||
Reference in New Issue
Block a user