diff --git a/static/js/script.js b/static/js/script.js new file mode 100644 index 0000000..205d215 --- /dev/null +++ b/static/js/script.js @@ -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(); \ No newline at end of file diff --git a/templates/head.html b/templates/head.html index 4055b7f..179c11c 100644 --- a/templates/head.html +++ b/templates/head.html @@ -91,4 +91,5 @@ {% endif %} {% block css %} -{% endblock css %} \ No newline at end of file +{% endblock css %} + \ No newline at end of file diff --git a/templates/header.html b/templates/header.html index 0bda1b0..a65b254 100644 --- a/templates/header.html +++ b/templates/header.html @@ -24,27 +24,3 @@ {% endif %} - -