From 0765072ea272078eada55236686b47ed1237e3ea Mon Sep 17 00:00:00 2001 From: wearrrrr Date: Tue, 6 Aug 2024 23:17:17 -0500 Subject: [PATCH] Move the window global in settings.ts to Alu.settings --- src/alu.d.ts | 5 ++++- src/components/ts/Alu.ts | 5 ++++- src/components/ts/settings.ts | 15 +++++++-------- src/pages/[lang]/games.astro | 1 - src/pages/index.astro | 2 ++ src/types.d.ts | 4 ---- 6 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/alu.d.ts b/src/alu.d.ts index be7b4be..c628288 100644 --- a/src/alu.d.ts +++ b/src/alu.d.ts @@ -1,7 +1,10 @@ export declare global { namespace Alu { let store: AluStore; - let loadedContentStorage: Record; + let settings: { + loadedContentStorage: Record; + currentTab: string; + }; type DefaultKeys = { [key: string]: AluKey; diff --git a/src/components/ts/Alu.ts b/src/components/ts/Alu.ts index 58ddabf..a843789 100644 --- a/src/components/ts/Alu.ts +++ b/src/components/ts/Alu.ts @@ -4,7 +4,10 @@ function instantiateAlu() { if (globalThis.Alu) return; globalThis.Alu = { store: new AluStore(), - loadedContentStorage: {}, + settings: { + loadedContentStorage: {}, + currentTab: "", + } }; } diff --git a/src/components/ts/settings.ts b/src/components/ts/settings.ts index c29a038..fa6b1c5 100644 --- a/src/components/ts/settings.ts +++ b/src/components/ts/settings.ts @@ -1,13 +1,13 @@ -window.loadedContentStorage = {}; -window.currentlySelectedTab; +// Alu.settings.loadedContentStorage = {}; document.addEventListener("astro:before-swap", () => { - window.currentlySelectedTab = ""; + Alu.settings.currentTab = ""; + Alu.settings.loadedContentStorage = {}; }); function settingsLoad() { Array.from(document.getElementsByClassName("setting-tab")).forEach((tab) => { const contentToLoad = document.getElementById("content-" + tab.id); if (contentToLoad) { - window.loadedContentStorage[tab.id] = contentToLoad.innerHTML; + Alu.settings.loadedContentStorage[tab.id] = contentToLoad.innerHTML; contentToLoad.remove(); } @@ -18,13 +18,13 @@ function settingsLoad() { }); } function loadContent(tabID: string) { - if (window.currentlySelectedTab == tabID) return; - else window.currentlySelectedTab = tabID; + if (Alu.settings.currentTab == tabID) return; + else Alu.settings.currentTab = tabID; const currentContent = document.getElementById("current-content"); if (currentContent) { currentContent.style.opacity = "0"; setTimeout(() => { - currentContent.innerHTML = window.loadedContentStorage[tabID]; + currentContent.innerHTML = Alu.settings.loadedContentStorage[tabID]; currentContent.style.opacity = "1"; document.dispatchEvent(new CustomEvent("setting-tabLoad", { detail: tabID })); }, 250); @@ -84,7 +84,6 @@ function getLocalStorageValue(localStorageItem: Alu.ValidStoreKeys, dropdownID: const dropdownMenu = document.getElementById(dropdownID + "-menu") as HTMLElement; // Janky hack :D if (dropdownID == "dropdown__search-engine") { - console.log(localStorageItem, dropdownID) return Alu.store.get(localStorageItem).name; } diff --git a/src/pages/[lang]/games.astro b/src/pages/[lang]/games.astro index 972dde1..ed79909 100644 --- a/src/pages/[lang]/games.astro +++ b/src/pages/[lang]/games.astro @@ -45,7 +45,6 @@ export function getStaticPaths() { game.style.display = "none"; } } - console.log(results); if (results === 0) { const noResults = document.querySelector(".no-results") as HTMLDivElement; if (noResults) { diff --git a/src/pages/index.astro b/src/pages/index.astro index 92bab33..8ea22a6 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -27,6 +27,8 @@ gtag("config", "G-P1JX4G9KSF");