fix theme.js ty lucidiot ;w;

This commit is contained in:
onomanapeia 2024-12-23 13:29:18 -06:00
parent 7367fd828b
commit 82f2ae984e

View file

@ -1,17 +1,20 @@
var DEFAULT_THEME = "peach";
var THEMES = [DEFAULT_THEME, "moon", "sakura", "honey"];
window.addEventListener('load', function() {
var prefersDarkScheme = window.matchMedia !== undefined && window.matchMedia("(prefers-color-scheme: dark)").matches;
var DEFAULT_THEME = prefersDarkScheme ? 'moon' : 'peach';
var THEMES = ["moon", "peach", "sakura", "honey"];
function setTheme(theme) {
function setTheme(theme) {
if (THEMES.indexOf(theme) < 0) theme = DEFAULT_THEME;
document.getElementById('switcher-id').href = '/themes/' + theme + '.css';
localStorage.setItem('style', theme);
}
}
setTheme(localStorage.getItem('style'));
setTheme(localStorage.getItem('style'));
const switches = document.getElementsByClassName('switch');
for (const el of switches) {
const switches = document.getElementsByClassName('switch');
for (const el of switches) {
el.addEventListener('click', () => {
setTheme(el.dataset.theme);
});
};
})