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

88 lines
2 KiB
JavaScript
Raw Normal View History

2024-09-02 15:42:14 -06:00
const clickSound = new Audio(
2024-09-02 15:46:26 -06:00
"/assets/sounds/ui/zapsplat_button_click_2.mp3"
2024-09-02 15:42:14 -06:00
);
const hoverSound = new Audio(
2024-09-02 15:46:26 -06:00
"/assets/sounds/ui/zapsplat_button_click_bright_2.mp3"
2024-09-02 15:42:14 -06:00
);
2024-09-05 00:48:32 -06:00
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"
);
2024-09-02 15:42:14 -06:00
2024-08-12 01:15:48 -06:00
// Sound effects
function PlaySound(soundobj) {
2024-09-02 15:42:14 -06:00
const thisSound = document.getElementById(soundobj);
thisSound.play();
2024-08-18 01:12:47 -06:00
}
function StopSound(soundobj) {
2024-09-02 15:42:14 -06:00
const thisSound = document.getElementById(soundobj);
thisSound.pause();
thisSound.currentTime = 0;
2024-08-18 01:12:47 -06:00
}
const buttons = document.querySelectorAll("button");
const links = document.querySelectorAll("a");
const image = document.querySelectorAll("img");
2024-09-05 00:48:32 -06:00
const phonewave = document.getElementById("phonewave");
2024-08-18 01:12:47 -06:00
// biome-ignore lint/complexity/noForEach: <explanation>
links.forEach((a) => {
a.addEventListener("click", () => {
2024-09-02 15:42:14 -06:00
clickSound.play();
});
2024-09-02 15:46:26 -06:00
/*
2024-09-02 15:42:14 -06:00
a.addEventListener("mouseover", () => {
hoverSound.play();
2024-08-18 01:12:47 -06:00
});
2024-09-02 15:46:26 -06:00
*/
2024-08-18 01:12:47 -06:00
});
// biome-ignore lint/complexity/noForEach: <explanation>
buttons.forEach((button) => {
button.addEventListener("click", () => {
2024-09-02 15:42:14 -06:00
clickSound.play();
});
/*
button.addEventListener("mouseover", () => {
hoverSound.play();
});
button.addEventListener("momouseoutuseover", () => {
hoverSound.stop();
2024-08-18 01:12:47 -06:00
});
2024-09-02 15:42:14 -06:00
*/
2024-08-18 01:12:47 -06:00
});
// biome-ignore lint/complexity/noForEach: <explanation>
image.forEach((button) => {
button.addEventListener("click", () => {
2024-09-02 15:42:14 -06:00
clickSound.play();
});
/*
button.addEventListener("mouseover", () => {
hoverSound.play();
});
button.addEventListener("mouseout", () => {
hoverSound.stop();
2024-08-18 01:12:47 -06:00
});
2024-09-02 15:42:14 -06:00
*/
2024-08-18 01:12:47 -06:00
});
2024-09-05 00:48:32 -06:00
phonewave.addEventListener("click", () => {
phonewaveSound.play();
setTimeout(() => {
startLeapSound.play();
setTimeout(() => {
window.location.replace("https://applianceri.ng/next?host=nelle.observer");
return;
}, 8000);
return;
}, 10000);
});