nelle-observer/astro/public/scripts/sound.js
2024-09-05 00:48:32 -06:00

88 lines
No EOL
2 KiB
JavaScript

const clickSound = new Audio(
"/assets/sounds/ui/zapsplat_button_click_2.mp3"
);
const hoverSound = new Audio(
"/assets/sounds/ui/zapsplat_button_click_bright_2.mp3"
);
const phonewaveSound = new Audio(
"/assets/sounds/sciadv/phonewave/phonewave.ogg"
);
const startLeapSound = new Audio(
"/assets/sounds/sciadv/phonewave/begin-leap.ogg"
);
const stopLeapSound = new Audio(
"/assets/sounds/sciadv/phonewave/SE11_03.ogg"
);
// Sound effects
function PlaySound(soundobj) {
const thisSound = document.getElementById(soundobj);
thisSound.play();
}
function StopSound(soundobj) {
const thisSound = document.getElementById(soundobj);
thisSound.pause();
thisSound.currentTime = 0;
}
const buttons = document.querySelectorAll("button");
const links = document.querySelectorAll("a");
const image = document.querySelectorAll("img");
const phonewave = document.getElementById("phonewave");
// biome-ignore lint/complexity/noForEach: <explanation>
links.forEach((a) => {
a.addEventListener("click", () => {
clickSound.play();
});
/*
a.addEventListener("mouseover", () => {
hoverSound.play();
});
*/
});
// biome-ignore lint/complexity/noForEach: <explanation>
buttons.forEach((button) => {
button.addEventListener("click", () => {
clickSound.play();
});
/*
button.addEventListener("mouseover", () => {
hoverSound.play();
});
button.addEventListener("momouseoutuseover", () => {
hoverSound.stop();
});
*/
});
// biome-ignore lint/complexity/noForEach: <explanation>
image.forEach((button) => {
button.addEventListener("click", () => {
clickSound.play();
});
/*
button.addEventListener("mouseover", () => {
hoverSound.play();
});
button.addEventListener("mouseout", () => {
hoverSound.stop();
});
*/
});
phonewave.addEventListener("click", () => {
phonewaveSound.play();
setTimeout(() => {
startLeapSound.play();
setTimeout(() => {
window.location.replace("https://applianceri.ng/next?host=nelle.observer");
return;
}, 8000);
return;
}, 10000);
});