From 4612cba3d9c7c44a665f4d111ca9a230df14f2ae Mon Sep 17 00:00:00 2001 From: Physcik Date: Fri, 26 Dec 2025 15:40:32 +0500 Subject: theme persistance --- static/common.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'static/common.js') diff --git a/static/common.js b/static/common.js index e3566b1..a7dc3a5 100644 --- a/static/common.js +++ b/static/common.js @@ -1,7 +1,10 @@ -var isLightMode = false; +function setMode() { + if (localStorage.getItem("theme") == "light") + setLightMode(); +} function ToggleMode() { - if (isLightMode) + if (localStorage.getItem("theme") == "light") setDarkMode(); else setLightMode(); @@ -9,14 +12,14 @@ function ToggleMode() { function setLightMode() { swapClasses("dark", "light"); - isLightMode = true; + localStorage.setItem("theme", "light"); document.getElementById("toggleIcon").src = "static/toggle.svg" document.getElementById("homeIcon").src = "static/home_dark.svg" } function setDarkMode() { swapClasses("light", "dark"); - isLightMode = false; + localStorage.setItem("theme", "dark"); document.getElementById("toggleIcon").src = "static/toggle_dark.svg" document.getElementById("homeIcon").src = "static/home.svg" } -- cgit v1.3