2024-09-23 12:51:49 -05:00
|
|
|
const storedStyle = localStorage.getItem('style');
|
|
|
|
if (!storedStyle) {
|
|
|
|
setTheme('green');
|
|
|
|
} else {
|
|
|
|
setTheme(storedStyle);
|
|
|
|
}
|
|
|
|
|
|
|
|
const switches = document.getElementsByClassName('switch');
|
|
|
|
for (const el of switches) {
|
|
|
|
el.addEventListener('click', () => {
|
|
|
|
setTheme(el.dataset.theme);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function setTheme(theme) {
|
|
|
|
if (theme === 'peach') {
|
2024-09-26 12:47:17 -05:00
|
|
|
document.getElementById('switcher-id').href = '/themes/peach.css';
|
2024-09-23 12:51:49 -05:00
|
|
|
} else if (theme === 'moon') {
|
2024-09-26 12:47:17 -05:00
|
|
|
document.getElementById('switcher-id').href = '/themes/moon.css';
|
2024-09-23 12:51:49 -05:00
|
|
|
} else if (theme === 'sakura') {
|
2024-09-26 12:47:17 -05:00
|
|
|
document.getElementById('switcher-id').href = '/themes/sakura.css';
|
2024-12-12 20:47:37 -06:00
|
|
|
} else if (theme === 'honey') {
|
|
|
|
document.getElementById('switcher-id').href = '/themes/honey.css';
|
|
|
|
} // when adding new themes, be sure to also add it to /includes/layout/sidebar.html and style.css under "switch" //
|
2024-09-23 12:51:49 -05:00
|
|
|
localStorage.setItem('style', theme);
|
|
|
|
}
|