2024-03-18 15:04:04 +00:00
|
|
|
import "./main.js";
|
|
|
|
|
2024-03-18 10:34:43 +00:00
|
|
|
function apply_funny_bob_to_upcoming_tags() {
|
2024-07-31 03:09:22 +00:00
|
|
|
const upcoming_tags = document.querySelectorAll("#type.upcoming");
|
|
|
|
for (var i = 0; i < upcoming_tags.length; i++) {
|
|
|
|
const tag = upcoming_tags[i];
|
|
|
|
const chars = tag.innerText.split("");
|
|
|
|
const result = chars.map((c, i) => `<span style="animation-delay: -${i * 100}ms;">${c}</span>`);
|
|
|
|
tag.innerHTML = result.join("");
|
|
|
|
}
|
2024-03-18 10:34:43 +00:00
|
|
|
}
|
|
|
|
|
2024-03-21 05:19:18 +00:00
|
|
|
function update_extras_buttons() {
|
2024-07-31 03:09:22 +00:00
|
|
|
const extras_pairs = Array.from(document.querySelectorAll("div#info > div").values()).map(container => {
|
|
|
|
return {
|
|
|
|
container,
|
|
|
|
button: document.getElementById("extras").querySelector(`ul li a[href="#${container.id}"]`)
|
|
|
|
};
|
|
|
|
});
|
|
|
|
const info_container = document.getElementById("info")
|
|
|
|
info_container.addEventListener("scroll", update_extras_buttons);
|
|
|
|
const info_rect = info_container.getBoundingClientRect();
|
|
|
|
const info_y = info_rect.y;
|
|
|
|
const font_size = parseFloat(getComputedStyle(document.documentElement).fontSize);
|
|
|
|
let current = extras_pairs[0];
|
|
|
|
extras_pairs.forEach(pair => {
|
|
|
|
pair.button.classList.remove("active");
|
|
|
|
const scroll_diff = pair.container.getBoundingClientRect().y -
|
|
|
|
info_rect.y -
|
|
|
|
info_rect.height / 2 +
|
|
|
|
4 * font_size;
|
|
|
|
if (scroll_diff <= 0) current = pair;
|
|
|
|
})
|
|
|
|
current.button.classList.add("active");
|
2024-03-21 05:19:18 +00:00
|
|
|
|
2024-07-31 03:09:22 +00:00
|
|
|
document.querySelectorAll("div#extras ul li a[href]").forEach(link => {
|
|
|
|
link.addEventListener("click", event => {
|
|
|
|
event.preventDefault();
|
|
|
|
const tag = link.href.split('#').slice(-1)[0];
|
|
|
|
document.getElementById(tag).scrollIntoView();
|
2024-03-20 03:17:34 +00:00
|
|
|
});
|
2024-07-31 03:09:22 +00:00
|
|
|
});
|
2024-03-18 10:34:43 +00:00
|
|
|
}
|
|
|
|
|
2024-04-16 16:53:24 +00:00
|
|
|
function bind_go_back_btn() {
|
2024-07-31 03:09:22 +00:00
|
|
|
const go_back_btn = document.getElementById("go-back")
|
|
|
|
go_back_btn.innerText = "<";
|
|
|
|
go_back_btn.addEventListener("click", () => {
|
|
|
|
window.history.back();
|
|
|
|
});
|
2024-03-18 10:34:43 +00:00
|
|
|
}
|
|
|
|
|
2024-04-16 16:53:24 +00:00
|
|
|
function bind_share_btn() {
|
2024-07-31 03:09:22 +00:00
|
|
|
const share_btn = document.getElementById("share");
|
|
|
|
if (navigator.clipboard === undefined) {
|
2024-04-17 17:29:39 +00:00
|
|
|
share_btn.onclick = event => {
|
2024-07-31 03:09:22 +00:00
|
|
|
console.error("clipboard is not supported by this browser!");
|
|
|
|
};
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
share_btn.onclick = event => {
|
|
|
|
event.preventDefault();
|
|
|
|
navigator.clipboard.writeText(window.location.href);
|
|
|
|
share_btn.classList.remove('active');
|
|
|
|
void share_btn.offsetWidth;
|
|
|
|
share_btn.classList.add('active');
|
|
|
|
}
|
2024-03-18 10:34:43 +00:00
|
|
|
}
|
|
|
|
|
2024-07-31 03:09:22 +00:00
|
|
|
bind_share_btn();
|
|
|
|
bind_go_back_btn();
|
|
|
|
apply_funny_bob_to_upcoming_tags();
|
|
|
|
update_extras_buttons();
|