make sound play on image clicks too

This commit is contained in:
nelle 2024-08-18 01:12:47 -06:00
parent fbfef20c1a
commit 5f0bb3a02e

View file

@ -1,28 +1,39 @@
// 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 audio = new Audio(
const buttons = document.querySelectorAll("button"); "/assets/sounds/ui/zapsplat_multimedia_button_click_004_68776.mp3"
const links = document.querySelectorAll("a"); );
const buttons = document.querySelectorAll("button");
// biome-ignore lint/complexity/noForEach: <explanation> const links = document.querySelectorAll("a");
links.forEach(a => { const image = document.querySelectorAll("img");
a.addEventListener("click", () => {
audio.play(); // biome-ignore lint/complexity/noForEach: <explanation>
}) links.forEach((a) => {
}) a.addEventListener("click", () => {
audio.play();
// biome-ignore lint/complexity/noForEach: <explanation> });
buttons.forEach(button => { });
button.addEventListener("click", () => {
audio.play(); // biome-ignore lint/complexity/noForEach: <explanation>
});}) buttons.forEach((button) => {
button.addEventListener("click", () => {
audio.play();
});
});
// biome-ignore lint/complexity/noForEach: <explanation>
image.forEach((button) => {
button.addEventListener("click", () => {
audio.play();
});
});