mirror of
https://github.com/greflm13/StaticGalleryBuilder.git
synced 2026-04-17 11:30:08 +02:00
localStorage
This commit is contained in:
@@ -426,6 +426,7 @@ class PhotoGallery {
|
|||||||
darkMode() {
|
darkMode() {
|
||||||
const themeLink = document.getElementById("theme");
|
const themeLink = document.getElementById("theme");
|
||||||
const darkThemeLink = document.getElementById("darktheme");
|
const darkThemeLink = document.getElementById("darktheme");
|
||||||
|
localStorage.setItem("theme", "dark");
|
||||||
if (themeLink) themeLink.disabled = true;
|
if (themeLink) themeLink.disabled = true;
|
||||||
if (darkThemeLink) darkThemeLink.disabled = false;
|
if (darkThemeLink) darkThemeLink.disabled = false;
|
||||||
}
|
}
|
||||||
@@ -433,6 +434,7 @@ class PhotoGallery {
|
|||||||
lightMode() {
|
lightMode() {
|
||||||
const themeLink = document.getElementById("theme");
|
const themeLink = document.getElementById("theme");
|
||||||
const darkThemeLink = document.getElementById("darktheme");
|
const darkThemeLink = document.getElementById("darktheme");
|
||||||
|
localStorage.setItem("theme", "light");
|
||||||
if (themeLink) themeLink.disabled = false;
|
if (themeLink) themeLink.disabled = false;
|
||||||
if (darkThemeLink) darkThemeLink.disabled = true;
|
if (darkThemeLink) darkThemeLink.disabled = true;
|
||||||
}
|
}
|
||||||
@@ -462,9 +464,22 @@ class PhotoGallery {
|
|||||||
|
|
||||||
detectDarkMode() {
|
detectDarkMode() {
|
||||||
if (document.getElementById("darktheme")) {
|
if (document.getElementById("darktheme")) {
|
||||||
|
const switchState = document.getElementById("dark-mode-switch-check");
|
||||||
|
const localStorageTheme = localStorage.getItem("theme");
|
||||||
|
if (localStorageTheme === "dark") {
|
||||||
|
switchState.checked = true;
|
||||||
|
this.darkModeToggle("dark");
|
||||||
|
return;
|
||||||
|
} else if (localStorageTheme === "light") {
|
||||||
|
switchState.checked = true;
|
||||||
|
this.darkModeToggle("light");
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches) {
|
if (window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches) {
|
||||||
|
switchState.checked = true;
|
||||||
this.darkModeToggle("dark");
|
this.darkModeToggle("dark");
|
||||||
} else {
|
} else {
|
||||||
|
switchState.checked = false;
|
||||||
this.darkModeToggle("light");
|
this.darkModeToggle("light");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user