2022-04-29 12:23:26 +02:00
|
|
|
import '/assets/scss/page.scss';
|
2021-08-06 09:51:41 +02:00
|
|
|
|
2024-02-07 16:15:43 +01:00
|
|
|
let eastereggsurl = '/assets/js/eastereggstrings.json'
|
2021-08-05 13:51:44 +02:00
|
|
|
document.addEventListener("readystatechange", event => {
|
|
|
|
if(event.target.readyState === 'complete') {
|
|
|
|
initExternalLinks();
|
2024-02-07 12:41:46 +01:00
|
|
|
initEasterEgg();
|
2021-08-05 13:51:44 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2021-08-06 09:51:41 +02:00
|
|
|
|
2021-08-05 13:51:44 +02:00
|
|
|
function initExternalLinks() {
|
|
|
|
document.querySelectorAll('a').forEach(elem => {
|
|
|
|
if(isExternalURL(elem.getAttribute('href'))) {
|
|
|
|
elem.setAttribute('target', '_blank');
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2024-02-07 12:41:46 +01:00
|
|
|
function initEasterEgg() {
|
2024-02-07 16:15:43 +01:00
|
|
|
document.body.addEventListener('click', evt => {
|
|
|
|
fetch(eastereggsurl)
|
|
|
|
.then((response) => {
|
|
|
|
if (!response.ok) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
return response.json();
|
|
|
|
}).then((eastereggstrings) => {
|
2024-02-07 12:41:46 +01:00
|
|
|
let randomstring = Math.floor(Math.random() * eastereggstrings.length);
|
|
|
|
document.querySelector('.easter-egg').innerHTML = eastereggstrings[randomstring];
|
2024-02-07 16:15:43 +01:00
|
|
|
})
|
2024-02-07 12:41:46 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function isInteractiveElement(element) {
|
|
|
|
// Check if the element is an interactive element or triggers an event
|
|
|
|
return (
|
|
|
|
element.tagName === 'A' ||
|
|
|
|
element.tagName === 'BUTTON' ||
|
|
|
|
element.tagName === 'INPUT' ||
|
|
|
|
element.tagName === 'SELECT' ||
|
|
|
|
element.tagName === 'TEXTAREA' ||
|
|
|
|
element.getAttribute('onclick') !== null ||
|
|
|
|
element.getAttribute('onmousedown') !== null ||
|
|
|
|
element.getAttribute('onmouseup') !== null ||
|
|
|
|
element.getAttribute('onmouseover') !== null ||
|
|
|
|
element.getAttribute('onmouseout') !== null ||
|
|
|
|
element.getAttribute('onmousemove') !== null ||
|
|
|
|
element.getAttribute('oncontextmenu') !== null
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-12-31 18:22:31 +01:00
|
|
|
const isExternalURL = (url) => {
|
|
|
|
if(url.startsWith('/')) return false;
|
|
|
|
return new URL(url).origin !== location.origin;
|
|
|
|
}
|