2020-04-02 22:14:53 +02:00
|
|
|
function getCookie(key) {
|
2021-03-31 02:48:13 +02:00
|
|
|
let match = new RegExp(`${key}=([^;]+);?`, "g").exec(document.cookie);
|
|
|
|
return match ? match[1] : undefined;
|
2020-04-02 22:14:53 +02:00
|
|
|
}
|
2019-10-04 22:15:03 +02:00
|
|
|
|
2020-04-02 22:14:53 +02:00
|
|
|
function setCookie(key, value, days) {
|
2021-03-19 07:55:18 +01:00
|
|
|
let date = new Date();
|
2020-04-02 22:14:53 +02:00
|
|
|
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
|
2021-03-19 07:59:36 +01:00
|
|
|
document.cookie = `${key}=${value}; expires=${date.toUTCString()}; path=/`;
|
2020-12-16 23:54:06 +01:00
|
|
|
}
|
|
|
|
|
2021-06-24 00:21:16 +02:00
|
|
|
function forceToAnchor(customAnchor) {
|
2021-10-11 14:07:57 +02:00
|
|
|
let anchor = customAnchor || location.hash;
|
2020-12-16 23:54:06 +01:00
|
|
|
// this is probably a terrible hack
|
2021-06-24 00:21:16 +02:00
|
|
|
if (anchor.startsWith("#")) {
|
|
|
|
let element = $(anchor);
|
|
|
|
if (element.length) {
|
2020-12-16 23:54:06 +01:00
|
|
|
$('html, body').animate({
|
2021-06-24 00:21:16 +02:00
|
|
|
scrollTop: element.offset().top
|
2020-12-16 23:54:06 +01:00
|
|
|
}, 0);
|
|
|
|
}
|
|
|
|
}
|
2021-03-19 11:42:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function addStyle(path) {
|
|
|
|
$('head').append($("<link/>", {
|
|
|
|
rel: "stylesheet",
|
|
|
|
href: path
|
|
|
|
}));
|
2019-10-04 22:15:03 +02:00
|
|
|
}
|