source ⟩ hypertext ⟩ public ⟩ shrines ⟩ lights.js
const sounds = {
lightsOn: new Audio("/shrines/lightson.mp3"),
lightsOff: new Audio("/shrines/lightsoff.mp3")
};
function toggleLights() {
if (document.body.className == "dark") {
document.body.className = "light";
$("#toggle-lights").innerText = "☀️";
/* Play sound */
sounds.lightsOn.currentTime = -1;
sounds.lightsOn.play();
} else {
document.body.className = "dark";
$("#toggle-lights").innerText = "🌒";
/* Play sound */
sounds.lightsOff.currentTime = -1;
sounds.lightsOff.play();
}
}