yes
This commit is contained in:
@@ -919,6 +919,28 @@
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// Check if music is enabled
|
||||
const musicEnabled = getCookie('backgroundMusic') === 'true';
|
||||
const backgroundMusic = document.getElementById('backgroundMusic');
|
||||
|
||||
if (musicEnabled) {
|
||||
backgroundMusic.volume = 0.5; // Set volume to 50%
|
||||
backgroundMusic.play(); // Play the music
|
||||
} else {
|
||||
backgroundMusic.pause(); // Pause the music
|
||||
}
|
||||
|
||||
// Function to toggle music
|
||||
function toggleMusic() {
|
||||
const musicEnabled = getCookie('backgroundMusic') === 'true';
|
||||
setCookie('backgroundMusic', !musicEnabled, 30); // Toggle music state
|
||||
if (!musicEnabled) {
|
||||
backgroundMusic.play();
|
||||
} else {
|
||||
backgroundMusic.pause();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
+25
@@ -119,6 +119,9 @@
|
||||
<!-- Add a clock element to display date and time -->
|
||||
<div id="clock" style="opacity: 0; font-size: 1.5rem; margin-top: 20px;"></div>
|
||||
|
||||
<!-- Add background music -->
|
||||
<audio id="backgroundMusic" src="./videoplayback.mp3" loop></audio>
|
||||
|
||||
<script>
|
||||
// Utility function to set a cookie
|
||||
function setCookie(name, value, days) {
|
||||
@@ -245,8 +248,30 @@
|
||||
document.querySelector("button[onclick*='cal.html']").style.display = 'none'; // Calendar button
|
||||
document.querySelector("button[onclick*='gametoadd.html']").style.display = 'none'; // Coming Soon button
|
||||
}
|
||||
|
||||
// Check if music is enabled
|
||||
const musicEnabled = getCookie('backgroundMusic') === 'true';
|
||||
const backgroundMusic = document.getElementById('backgroundMusic');
|
||||
|
||||
if (musicEnabled) {
|
||||
backgroundMusic.volume = 0.5; // Set volume to 50%
|
||||
backgroundMusic.play(); // Play the music
|
||||
} else {
|
||||
backgroundMusic.pause(); // Pause the music
|
||||
}
|
||||
};
|
||||
|
||||
// Function to toggle music
|
||||
function toggleMusic() {
|
||||
const musicEnabled = getCookie('backgroundMusic') === 'true';
|
||||
setCookie('backgroundMusic', !musicEnabled, 30); // Toggle music state
|
||||
if (!musicEnabled) {
|
||||
backgroundMusic.play();
|
||||
} else {
|
||||
backgroundMusic.pause();
|
||||
}
|
||||
}
|
||||
|
||||
// Check if Date and Time is enabled
|
||||
const dateTimeEnabled = getCookie('dateTime') === 'true';
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user