This commit is contained in:
2025-04-14 13:26:09 +00:00
parent 41d4199450
commit 4f845a0c5a
4 changed files with 72 additions and 0 deletions
+25
View File
@@ -124,6 +124,10 @@
<span>Less Buttons</span>
<button id="toggleLessButtons">Enable</button>
</div>
<div class="setting-item">
<span>Background Music</span>
<button id="toggleMusicButton">Toggle Background Music</button>
</div>
<div class="setting-item clear-cookies">
<span>Clear Cookies</span>
<button id="clearCookies">Clear</button>
@@ -248,6 +252,27 @@
});
}
// Function to toggle background music
function toggleBackgroundMusic() {
const musicEnabled = getCookie('backgroundMusic') === 'true';
setCookie('backgroundMusic', !musicEnabled, 30); // Toggle the cookie value
const toggleMusicButton = document.getElementById('toggleMusicButton');
if (!musicEnabled) {
toggleMusicButton.textContent = 'Disable Background Music';
} else {
toggleMusicButton.textContent = 'Enable Background Music';
}
}
// Set the initial state of the button
const musicEnabled = getCookie('backgroundMusic') === 'true';
const toggleMusicButton = document.getElementById('toggleMusicButton');
toggleMusicButton.textContent = musicEnabled ? 'Disable Background Music' : 'Enable Background Music';
// Add event listener
toggleMusicButton.addEventListener('click', toggleBackgroundMusic);
// Ensure animations are enabled by default
if (getCookie('gameAnimation') === null) {
setCookie('gameAnimation', 'true', 30); // Default to animations enabled