mirror of
https://github.com/Ellpeck/TinyLifeWeb.git
synced 2024-11-22 19:28:35 +01:00
14 lines
514 B
JavaScript
14 lines
514 B
JavaScript
const darkStorage = localStorage.getItem("dark");
|
|
const darkTheme = darkStorage === null ? window.matchMedia("(prefers-color-scheme: dark)").matches : darkStorage === "true";
|
|
|
|
$(function () {
|
|
$(".navbar-collapse a").on("click", () => $(".navbar-collapse").collapse("hide"));
|
|
|
|
let mode = $("#dark-mode");
|
|
mode.prop("checked", darkTheme);
|
|
mode.on("click", function () {
|
|
localStorage.setItem("dark", $(this).prop("checked"));
|
|
location.hash = "";
|
|
location.reload();
|
|
});
|
|
});
|