const foreground = document.querySelector("#foreground");
const releases = document.querySelectorAll(".index li a");

const title = document.querySelector(".meta.release .title");
const date = document.querySelector(".meta.release .date");

fetch("releases.json")
	.then((res) => res.json())
	.then((data) => {
		for (const release of releases) {
			release.addEventListener("mouseenter", () => {
				foreground.src = `img/${release.dataset.bg}.png`;
				meta(data.releases[parseInt(release.dataset.bg)]);
			});
		}
	});

const meta = function (release) {
	title.innerHTML = release.title;
	title.classList.remove("hidden");
	date.innerHTML = release.date;
	date.classList.remove("hidden");
};

const intro = document.querySelector("#intro");
let introOutro = new Audio("https://hub.xpub.nl/soupboat/SI18/08/si18-8-intro-outro-final.mp3");
intro.addEventListener("click", () => {
	if (introOutro.paused) introOutro.play();
	else introOutro.pause();
});
