let dark = getCookie("dark") === "true"; let cookieNotification = getCookie("notification") !== "true"; let pride = new Date().getMonth() == 5; if (dark) { document.write('') document.write('') } if (pride) document.write('') $(function () { let openModals = function (hash) { if (hash && hash.length > 1) { if (hash === '#impressum') { $('#impressum-modal').modal('show'); } else if (hash === "#commissions") { $('#commissions-modal').modal('show'); } } } openModals(window.location.hash); $('a').on('click', function () { openModals($(this).attr('href')); }); updateMeta(window.location.hash); $(window).on("hashchange", function () { updateMeta(window.location.hash); }); $('.navbar-collapse a').on('click', function () { $('.navbar-collapse').collapse('hide'); }); $('#blobheart').on('click', function () { $('#navbar-image').attr('src', 'res/heart.png'); }); let mode = $('#dark-mode'); mode.prop('checked', dark); mode.on('click', function () { setCookie("dark", $(this).prop('checked'), 365); window.location.hash = ""; location.reload(); }); PR.prettyPrint(); }); function updateMeta(hash) { var title; if (hash === "#projects") { title = "Projects"; } else if (hash === "#social") { title = "Social"; } else if (hash === "#about") { title = "About" } else if (hash === "#blog") { title = "Blog" } setTitleAndDesc(title, "Ellpeck's little internet place"); } function setTitleAndDesc(title, desc) { let fullTitle = "Ellpeck.de" + (title ? " - " + title : ""); $('meta[property="og:title"]').attr("content", fullTitle); document.title = fullTitle; $('meta[property="og:description"]').attr("content", desc); $('meta[name="description"]').attr("content", desc); } function getCookie(key) { let c = document.cookie; if (!c) return undefined; let start = c.indexOf(key + "=") + key.length + 1; let end = c.indexOf(";", start); return c.substring(start, end < 0 ? c.length : end); } function setCookie(key, value, days) { var date = new Date(); date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); document.cookie = key + "=" + value + "; expires=" + date.toUTCString(); }