Play audio on button press

This commit is contained in:
Kristofers Solo 2023-01-20 06:08:12 +02:00
parent cf4c205c5e
commit 78a9d3fd2c

View File

@ -1,11 +1,10 @@
let lightmode = localStorage.getItem("lightmode")
const HTML = document.documentElement
const AUDIO = document.getElementById("flashbang")
const ENABLE_LIGHT_MODE = () => {
const AUDIO = document.getElementById("flashbang")
HTML.setAttribute("data-color-mode", "light")
localStorage.setItem("lightmode", "enabled")
AUDIO.play()
}
const DISABLE_LIGHT_MODE = () => {
@ -21,6 +20,7 @@ document.querySelector("#color-mode-toggle").addEventListener("click", () => {
lightmode = localStorage.getItem("lightmode")
if (lightmode !== "enabled") {
ENABLE_LIGHT_MODE()
AUDIO.play()
} else {
DISABLE_LIGHT_MODE()
}