nelle-observer/astro/public/scripts/sound.js

28 lines
806 B
JavaScript
Raw Normal View History

2024-08-12 01:15:48 -06:00
// Sound effects
function PlaySound(soundobj) {
2024-08-12 01:17:24 -06:00
const thissound = document.getElementById(soundobj);
2024-08-12 01:15:48 -06:00
thissound.play();
}
function StopSound(soundobj) {
2024-08-12 01:17:24 -06:00
const thissound = document.getElementById(soundobj);
2024-08-12 01:15:48 -06:00
thissound.pause();
thissound.currentTime = 0;
}
const audio = new Audio("/assets/sounds/ui/zapsplat_multimedia_button_click_004_68776.mp3");
const buttons = document.querySelectorAll("button");
const links = document.querySelectorAll("a");
// 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();
});})