anemone/static/js/script.js
2023-10-05 23:02:23 +01:00

21 lines
No EOL
454 B
JavaScript

const setTheme = (theme) => {
document.documentElement.className = theme;
localStorage.setItem('theme', theme);
}
const hasCodeRun = localStorage.getItem('hasCodeRun');
if (!hasCodeRun) {
const defaultTheme = "{{ config.extra.default_theme }}";
setTheme(defaultTheme);
localStorage.setItem('hasCodeRun', 'true');
}
const getTheme = () => {
const theme = localStorage.getItem('theme');
if (theme) {
setTheme(theme);
}
}
getTheme();