diff --git a/main/_layouts/blog.html b/main/_layouts/blog.html index f9f4f83..1ce6855 100644 --- a/main/_layouts/blog.html +++ b/main/_layouts/blog.html @@ -22,7 +22,10 @@ nav: nav/blognav.html {% else %} {% endif %} diff --git a/main/_layouts/default.html b/main/_layouts/default.html index a5274ff..ce5d0a7 100644 --- a/main/_layouts/default.html +++ b/main/_layouts/default.html @@ -26,8 +26,6 @@ - - diff --git a/main/actaddmanual/index.html b/main/actaddmanual/index.html index fac9448..f56931c 100644 --- a/main/actaddmanual/index.html +++ b/main/actaddmanual/index.html @@ -12,8 +12,6 @@ - - diff --git a/main/actaddmanual/index.js b/main/actaddmanual/index.js index 411abb2..1903fb7 100644 --- a/main/actaddmanual/index.js +++ b/main/actaddmanual/index.js @@ -45,7 +45,16 @@ function populateManual(lang) { entries.append(t); } - forceToAnchor(); + let anchor = undefined || location.hash; + // this is probably a terrible hack + if (anchor.startsWith("#")) { + let element = $(anchor); + if (element.length) { + $('html, body').animate({ + scrollTop: element.offset().top + }, 0); + } + } } function replaceFormatting(text) { diff --git a/main/scripts/cookieinfo.js b/main/scripts/cookieinfo.js index 42cdfe2..85ca479 100644 --- a/main/scripts/cookieinfo.js +++ b/main/scripts/cookieinfo.js @@ -1,7 +1,7 @@ -if (getCookie("notification") !== "true") { +if (localStorage.getItem("notification") !== "true") { $('#cookieinfo').html( /*html*/ ` `); $("#notif-close").on("click", function () { - setCookie("notification", "true", 365); + localStorage.setItem("notification", "true"); }); -} \ No newline at end of file +} diff --git a/main/scripts/main.js b/main/scripts/main.js index d52c200..b981651 100644 --- a/main/scripts/main.js +++ b/main/scripts/main.js @@ -1,7 +1,10 @@ -const darkCookie = getCookie("dark"); -const dark = darkCookie == undefined ? window.matchMedia("(prefers-color-scheme: dark)").matches : darkCookie == "true"; +const darkCookie = localStorage.getItem("dark"); +const dark = darkCookie === null ? window.matchMedia("(prefers-color-scheme: dark)").matches : darkCookie === "true"; if (dark) - addStyle("/style/dark.css"); + $('head').append($("", { + rel: "stylesheet", + href: "/style/dark.css" + })); // redirect legacy anchors if (/^#privacy\/?$/.test(location.hash)) @@ -21,8 +24,8 @@ $(function () { let mode = $('#dark-mode'); mode.prop('checked', dark); mode.on('click', function () { - setCookie("dark", $(this).prop('checked'), 365); + localStorage.setItem("dark", $(this).prop('checked')); location.hash = ""; location.reload(); }); -}); \ No newline at end of file +}); diff --git a/main/scripts/util.js b/main/scripts/util.js deleted file mode 100644 index ee0b4ef..0000000 --- a/main/scripts/util.js +++ /dev/null @@ -1,30 +0,0 @@ -function getCookie(key) { - let match = new RegExp(`${key}=([^;]+);?`, "g").exec(document.cookie); - return match ? match[1] : undefined; -} - -function setCookie(key, value, days) { - let date = new Date(); - date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); - document.cookie = `${key}=${value}; expires=${date.toUTCString()}; path=/`; -} - -function forceToAnchor(customAnchor) { - let anchor = customAnchor || location.hash; - // this is probably a terrible hack - if (anchor.startsWith("#")) { - let element = $(anchor); - if (element.length) { - $('html, body').animate({ - scrollTop: element.offset().top - }, 0); - } - } -} - -function addStyle(path) { - $('head').append($("", { - rel: "stylesheet", - href: path - })); -} \ No newline at end of file