diff --git a/src/index.html b/src/index.html index e95c462..82742fb 100644 --- a/src/index.html +++ b/src/index.html @@ -89,6 +89,11 @@ color: white; text-align: center; } + #MUSIC_TOGGLE { + position: fixed; + right: 10px; + bottom: 10px; + } @@ -111,6 +116,7 @@

+ diff --git a/src/script.js b/src/script.js index 2ce26e4..917c703 100644 --- a/src/script.js +++ b/src/script.js @@ -27,6 +27,7 @@ const catch_me = document.getElementById("catch_me"), level_num = document.getElementById("level_num"), level_description = document.getElementById("level_description"), time_remaining = document.getElementById("time_remaining"); + toggle_button = document.getElementById("MUSIC_TOGGLE"); // Useful global values const catch_height = 50, @@ -95,6 +96,17 @@ diff_btns.forEach(el => { }) }); +toggle_button.addEventListener("click", e => { + source = document.getElementsByTagName("audio")[0]; + // if not muted then mute + if (!source.muted) { + source.muted = true; + } + else { + source.muted = false; + } +}); + const setTargets = () => { target_time = 60; // seconds