moving to custom swap engine
Signed-off-by: ari melody <ari@arimelody.me>
This commit is contained in:
parent
749f9bc8b7
commit
13d802d361
21 changed files with 4361 additions and 225 deletions
|
@ -1,44 +1,24 @@
|
|||
import "./main.js";
|
||||
|
||||
const bg = document.getElementById("background");
|
||||
bg.style.backgroundImage = `url(${bg.dataset.url})`;
|
||||
bg.removeAttribute("data-url");
|
||||
|
||||
const share_btn = document.getElementById("share");
|
||||
share_btn.onclick = (e) => {
|
||||
navigator.clipboard.writeText(window.location.href);
|
||||
share_btn.classList.remove('active');
|
||||
void share_btn.offsetWidth;
|
||||
share_btn.classList.add('active');
|
||||
}
|
||||
|
||||
const go_back_btn = document.getElementById("go-back")
|
||||
go_back_btn.innerText = "<";
|
||||
go_back_btn.addEventListener("click", () => {
|
||||
window.history.back();
|
||||
});
|
||||
|
||||
apply_funny_bob_to_upcoming_tags();
|
||||
|
||||
function apply_funny_bob_to_upcoming_tags() {
|
||||
const upcomingTags = document.querySelectorAll("#type.upcoming");
|
||||
for (var i = 0; i < upcomingTags.length; i++) {
|
||||
const tag = upcomingTags[i];
|
||||
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("");
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
function update_extras_buttons() {
|
||||
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);
|
||||
|
@ -52,57 +32,38 @@ function update_extras_buttons() {
|
|||
if (scroll_diff <= 0) current = pair;
|
||||
})
|
||||
current.button.classList.add("active");
|
||||
}
|
||||
update_extras_buttons();
|
||||
|
||||
document.querySelectorAll("div#extras ul li a[href]").forEach(link => {
|
||||
link.addEventListener("click", event => {
|
||||
event.preventDefault();
|
||||
location.replace(link.href);
|
||||
document.querySelectorAll("div#extras ul li a[href]").forEach(link => {
|
||||
link.addEventListener("click", event => {
|
||||
event.preventDefault();
|
||||
location.replace(link.href);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* handling track previews (currently not implemented)
|
||||
|
||||
const previews = document.querySelectorAll("[id^=preview-]");
|
||||
for (const preview of previews) {
|
||||
preview.addEventListener("click", (e) => {
|
||||
if (e.target.classList.contains('playing')) {
|
||||
stopPreview(e.target);
|
||||
} else {
|
||||
playPreview(e.target);
|
||||
}
|
||||
function bind_go_back_btn() {
|
||||
const go_back_btn = document.getElementById("go-back")
|
||||
go_back_btn.innerText = "<";
|
||||
go_back_btn.addEventListener("click", () => {
|
||||
window.history.back();
|
||||
});
|
||||
preview.querySelector('audio').addEventListener("ended", () => { stopPreview(preview); });
|
||||
}
|
||||
|
||||
var stupidsounds = false;
|
||||
|
||||
function stopPreviews() {
|
||||
for (const preview of previews) stopPreview(preview);
|
||||
function bind_share_btn() {
|
||||
const share_btn = document.getElementById("share");
|
||||
share_btn.onclick = (e) => {
|
||||
navigator.clipboard.writeText(window.location.href);
|
||||
share_btn.classList.remove('active');
|
||||
void share_btn.offsetWidth;
|
||||
share_btn.classList.add('active');
|
||||
}
|
||||
}
|
||||
|
||||
function playPreview(preview) {
|
||||
if (!stupidsounds) stopPreviews();
|
||||
const btn = preview.querySelector('i');
|
||||
btn.classList.remove("play", "fa-play");
|
||||
btn.classList.add("pause", "fa-pause");
|
||||
const audio = preview.querySelector('audio');
|
||||
audio.play();
|
||||
preview.classList.add('playing');
|
||||
function start() {
|
||||
bind_share_btn();
|
||||
bind_go_back_btn();
|
||||
apply_funny_bob_to_upcoming_tags();
|
||||
update_extras_buttons();
|
||||
}
|
||||
|
||||
function stopPreview(preview) {
|
||||
const btn = preview.querySelector('i');
|
||||
btn.classList.remove("pause", "fa-pause");
|
||||
btn.classList.add("play", "fa-play");
|
||||
const audio = preview.querySelector('audio');
|
||||
audio.pause();
|
||||
audio.currentTime = 0;
|
||||
preview.classList.remove('playing');
|
||||
}
|
||||
|
||||
stopPreviews();
|
||||
|
||||
*/
|
||||
start();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue