Simply theme JS

This commit is contained in:
Pk11 2021-10-22 21:16:34 -05:00
parent 549b90c341
commit c861048b22
2 changed files with 6 additions and 19 deletions

View File

@ -15,7 +15,7 @@
<link id="bootstrap-stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1" crossorigin="anonymous">
{% endif %}
<link rel="stylesheet" type="text/css" media="screen" href="/assets/css/style.css">
<link id="theme-css" rel="stylesheet" type="text/css" media="screen" href="/assets/css/style.css">
<script src="/assets/js/theme.js"></script>
{% include favicon.html %}

View File

@ -1,22 +1,9 @@
function loadTheme() {
const themeCSS = document.getElementById("themeCSS");
if(!localStorage.theme || localStorage.theme == "default") {
if(themeCSS)
themeCSS.remove();
} else {
if(themeCSS) {
themeCSS.href = "/assets/css/" + localStorage.theme +".css";
} else {
const l = document.createElement("link");
l.rel = "stylesheet";
l.type = "text/css";
l.media = "screen";
l.href = "/assets/css/" + localStorage.theme +".css"
l.id = "themeCSS";
document.head.appendChild(l);
}
}
const themeCSS = document.getElementById("theme-css");
if(!localStorage.theme || localStorage.theme == "default")
themeCSS.href = "/assets/css/style.css";
else
themeCSS.href = "/assets/css/" + localStorage.theme + ".css";
}
function setTheme(theme) {