From 78a9d3fd2c1a84a950fb6193f779285a6fae4d58 Mon Sep 17 00:00:00 2001 From: Kristofers Solo Date: Fri, 20 Jan 2023 06:08:12 +0200 Subject: [PATCH] Play audio on button press --- static/main/js/lightmode.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/static/main/js/lightmode.js b/static/main/js/lightmode.js index ac84052..11e5a52 100644 --- a/static/main/js/lightmode.js +++ b/static/main/js/lightmode.js @@ -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() }