mirror of
https://github.com/Speyll/anemone.git
synced 2024-11-12 17:36:24 +00:00
moved js to its own static file
This commit is contained in:
parent
cff8b14efb
commit
3ae15e9ed8
3 changed files with 23 additions and 25 deletions
21
static/js/script.js
Normal file
21
static/js/script.js
Normal 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();
|
|
@ -91,4 +91,5 @@
|
|||
{% endif %}
|
||||
{% block css %}
|
||||
<link rel="stylesheet" href="{{ get_url(path='css/style.css', trailing_slash=false) | safe }}"/>
|
||||
{% endblock css %}
|
||||
{% endblock css %}
|
||||
<script src="{{ get_url(path='js/script.js', trailing_slash=false) | safe }}"></script>
|
|
@ -24,27 +24,3 @@
|
|||
</div>
|
||||
</nav>
|
||||
{% endif %}
|
||||
|
||||
<script>
|
||||
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();
|
||||
</script>
|
||||
|
|
Loading…
Reference in a new issue