Web/main/scripts/main.js
Ell 6bde3c4ff8
Some checks failed
Web/pipeline/head There was a failure building this commit
silently convert the entire website to jekyll
2021-07-09 01:59:28 +02:00

34 lines
858 B
JavaScript

const dark = getCookie("dark") === "true";
if (dark)
addStyle("/style/dark.css");
$(function () {
openModals(window.location.hash);
$('a').on('click', function () {
openModals($(this).attr('href'));
});
$('.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);
window.location.hash = "";
location.reload();
});
});
function openModals(hash) {
if (hash && hash.startsWith("#")) {
let modal = $(`${hash}-modal`);
if (modal.length)
modal.modal('show');
}
}