2024-02-16 15:31:30 +01:00
|
|
|
const controls = document.querySelector(".controls");
|
|
|
|
const song = document.querySelector("iframe.song").contentWindow;
|
|
|
|
|
2024-02-17 15:53:36 +01:00
|
|
|
// Autoscroll
|
2024-02-16 15:31:30 +01:00
|
|
|
var scroll;
|
|
|
|
function pageScroll() {
|
|
|
|
song.scrollBy(0, 1);
|
|
|
|
scroll = setTimeout(pageScroll, 80);
|
|
|
|
}
|
|
|
|
|
|
|
|
document.querySelector("#autoscroll").addEventListener("click", function() {
|
|
|
|
if (this.classList.contains("active")) {
|
|
|
|
clearTimeout(scroll);
|
|
|
|
} else {
|
|
|
|
pageScroll();
|
|
|
|
}
|
|
|
|
this.classList.toggle("active");
|
|
|
|
});
|
|
|
|
|
2024-02-17 15:53:36 +01:00
|
|
|
// Scaling
|
|
|
|
function pageScale(value) {
|
|
|
|
if (value === 0) {
|
|
|
|
song.document.body.style.transform = "scale(1)";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const currentScale = parseFloat(song.document.body.style.transform.split("scale(")[1]) || 1;
|
|
|
|
song.document.body.style.transform = "scale(" + (currentScale + value) + ")";
|
|
|
|
}
|
|
|
|
|
|
|
|
controls.querySelector("#font-size-increase").addEventListener("click", () => pageScale(0.1));
|
|
|
|
controls.querySelector("#font-size-decrease").addEventListener("click", () => pageScale(-0.1));
|
|
|
|
controls.querySelector("#font-size-reset").addEventListener("click", () => pageScale(0));
|
|
|
|
|
2024-02-16 15:31:30 +01:00
|
|
|
// Display the controls on JS-enabled browsers
|
|
|
|
window.addEventListener("load", () => controls.classList.remove = "hidden");
|