moved js to its own static file

This commit is contained in:
Speyll
2023-10-05 23:02:23 +01:00
parent cff8b14efb
commit 3ae15e9ed8
3 changed files with 23 additions and 25 deletions

21
static/js/script.js Normal file
View File

@@ -0,0 +1,21 @@
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();