first commit! 🎉
Signed-off-by: ari melody <ari@arimelody.me>
This commit is contained in:
commit
27d6e4f011
97 changed files with 2957 additions and 0 deletions
67
public/script/music-gateway.js
Normal file
67
public/script/music-gateway.js
Normal file
|
@ -0,0 +1,67 @@
|
|||
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');
|
||||
}
|
||||
|
||||
document.getElementById("go-back").addEventListener("click", () => {
|
||||
window.history.back();
|
||||
});
|
||||
|
||||
apply_funny_bob_to_upcoming_tags();
|
||||
|
||||
function apply_funny_bob_to_upcoming_tags() {
|
||||
upcomingTags = document.querySelectorAll("#type.upcoming");
|
||||
for (var i = 0; i < upcomingTags.length; i++) {
|
||||
const tag = upcomingTags[i];
|
||||
chars = tag.innerText.split("");
|
||||
result = chars.map((c, i) => `<span style="animation-delay: -${i * 100}ms;">${c}</span>`);
|
||||
tag.innerHTML = result.join("");
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
});
|
||||
preview.querySelector('audio').addEventListener("ended", () => { stopPreview(preview); });
|
||||
}
|
||||
|
||||
var stupidsounds = false;
|
||||
|
||||
function stopPreviews() {
|
||||
for (const preview of previews) stopPreview(preview);
|
||||
}
|
||||
|
||||
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 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();
|
Loading…
Add table
Add a link
Reference in a new issue