This commit is contained in:
nelle 2024-09-02 15:42:14 -06:00
parent d77023ce97
commit 4103000463

View file

@ -1,18 +1,22 @@
const clickSound = new Audio(
"/assets/sounds/ui/zapsplat_multimedia_button_click_004_68776.mp3"
);
const hoverSound = new Audio(
"/assets/sounds/ui/zapsplat_multimedia_button_click_bright_002_92099.mp3"
);
// Sound effects // Sound effects
function PlaySound(soundobj) { function PlaySound(soundobj) {
const thissound = document.getElementById(soundobj); const thisSound = document.getElementById(soundobj);
thissound.play(); thisSound.play();
} }
function StopSound(soundobj) { function StopSound(soundobj) {
const thissound = document.getElementById(soundobj); const thisSound = document.getElementById(soundobj);
thissound.pause(); thisSound.pause();
thissound.currentTime = 0; thisSound.currentTime = 0;
} }
const audio = new Audio(
"/assets/sounds/ui/zapsplat_multimedia_button_click_004_68776.mp3"
);
const buttons = document.querySelectorAll("button"); const buttons = document.querySelectorAll("button");
const links = document.querySelectorAll("a"); const links = document.querySelectorAll("a");
const image = document.querySelectorAll("img"); const image = document.querySelectorAll("img");
@ -20,20 +24,39 @@ const image = document.querySelectorAll("img");
// biome-ignore lint/complexity/noForEach: <explanation> // biome-ignore lint/complexity/noForEach: <explanation>
links.forEach((a) => { links.forEach((a) => {
a.addEventListener("click", () => { a.addEventListener("click", () => {
audio.play(); clickSound.play();
});
a.addEventListener("mouseover", () => {
hoverSound.play();
}); });
}); });
// biome-ignore lint/complexity/noForEach: <explanation> // biome-ignore lint/complexity/noForEach: <explanation>
buttons.forEach((button) => { buttons.forEach((button) => {
button.addEventListener("click", () => { button.addEventListener("click", () => {
audio.play(); clickSound.play();
}); });
/*
button.addEventListener("mouseover", () => {
hoverSound.play();
});
button.addEventListener("momouseoutuseover", () => {
hoverSound.stop();
});
*/
}); });
// biome-ignore lint/complexity/noForEach: <explanation> // biome-ignore lint/complexity/noForEach: <explanation>
image.forEach((button) => { image.forEach((button) => {
button.addEventListener("click", () => { button.addEventListener("click", () => {
audio.play(); clickSound.play();
}); });
/*
button.addEventListener("mouseover", () => {
hoverSound.play();
});
button.addEventListener("mouseout", () => {
hoverSound.stop();
});
*/
}); });