mirror of
https://github.com/LukeHagar/jims-blog.git
synced 2025-12-06 04:20:07 +00:00
64 lines
1.9 KiB
HTML
64 lines
1.9 KiB
HTML
{{- if (eq .Site.Params.theme.defaultTheme "light") }}
|
|
<script>
|
|
if (document.body.className.includes("dark")) {
|
|
document.body.classList.remove('dark');
|
|
localStorage.setItem("pref-theme", 'light');
|
|
}
|
|
</script>
|
|
|
|
{{ else if (eq .Site.Params.theme.defaultTheme "dark") }}
|
|
{{- /* theme is dark */}}
|
|
<script>
|
|
if (document.body.className.includes("light")) {
|
|
document.body.classList.add('dark');
|
|
localStorage.setItem("pref-theme", 'dark');
|
|
}
|
|
</script>
|
|
|
|
{{- else }}
|
|
{{- /* theme is auto */}}
|
|
<script>
|
|
if (localStorage.getItem("pref-theme") === "dark") {
|
|
document.body.classList.add('dark');
|
|
} else if (localStorage.getItem("pref-theme") === "light") {
|
|
document.body.classList.remove('dark')
|
|
} else if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
|
document.body.classList.add('dark');
|
|
}
|
|
|
|
</script>
|
|
{{- end }}
|
|
|
|
{{- if (not .Site.Params.theme.disableThemeToggle) }}
|
|
<script>
|
|
document.getElementById("theme-toggle").addEventListener("click", () => {
|
|
if (document.body.className.includes("dark")) {
|
|
document.body.classList.remove('dark');
|
|
localStorage.setItem("pref-theme", 'light');
|
|
} else {
|
|
document.body.classList.add('dark');
|
|
localStorage.setItem("pref-theme", 'dark');
|
|
}
|
|
})
|
|
|
|
var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
|
|
var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
|
|
return new bootstrap.Tooltip(tooltipTriggerEl)
|
|
})
|
|
|
|
</script>
|
|
{{- end }}
|
|
|
|
<script>
|
|
let loadingIcons;
|
|
|
|
function loading() {
|
|
myVar = setTimeout(showPage, 100);
|
|
}
|
|
|
|
function showPage() {
|
|
try{
|
|
document.getElementById("loading-icons").style.display = "block";
|
|
} catch(err) {}
|
|
}
|
|
</script> |