Web/main/scripts/main.js
Ell 4aebe9542b
All checks were successful
Web/pipeline/head This commit looks good
default dark mode to the user's color scheme
2021-11-11 03:18:40 +01:00

28 lines
843 B
JavaScript

const darkCookie = getCookie("dark");
const dark = darkCookie == undefined ? window.matchMedia("(prefers-color-scheme: dark)").matches : darkCookie == "true";
if (dark)
addStyle("/style/dark.css");
// redirect legacy anchors
if (/^#privacy\/?$/.test(location.hash))
location.href = "/privacy";
if (/^#impressum\/?$/.test(location.hash))
location.href = "/impressum";
$(function () {
$('.navbar-collapse a').on('click', function () {
$('.navbar-collapse').collapse('hide');
});
$('#blobheart').on('click', function () {
$('#navbar-image').attr('src', 'res/heart.jpeg');
});
let mode = $('#dark-mode');
mode.prop('checked', dark);
mode.on('click', function () {
setCookie("dark", $(this).prop('checked'), 365);
location.hash = "";
location.reload();
});
});