312 lines
12 KiB
HTML
312 lines
12 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
|
|
<head>
|
|
<script defer src="https://chirpy.dev/bootstrapper.js" data-chirpy-domain="fun-miles-4jub.onrender.com"></script>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Settings</title>
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css"
|
|
integrity="sha512-z3gLpd7yknf1YoNbCzqRKc4qyor8gaKU1qmn+CShxbuBusANI9QpRohGBreCFkKxLhei6S9CQXFEbbKuqLg0DA=="
|
|
crossorigin="anonymous" referrerpolicy="no-referrer">
|
|
<link rel="stylesheet" href="settings.css">
|
|
<style>
|
|
:root {
|
|
/* Light mode variables */
|
|
--background-color: #ffffff;
|
|
--text-color: #000000;
|
|
--card-background-color: #f9f9f9;
|
|
|
|
/* Dark mode variables */
|
|
--background-color-dark: #121212;
|
|
--text-color-dark: #ffffff;
|
|
--card-background-color-dark: #1e1e1e;
|
|
}
|
|
|
|
body {
|
|
font-family: Arial, sans-serif;
|
|
margin: 0;
|
|
padding: 0;
|
|
background-color: var(--background-color);
|
|
color: var(--text-color);
|
|
transition: background-color 0.3s, color 0.3s;
|
|
}
|
|
|
|
.settings-container {
|
|
max-width: 600px;
|
|
margin: 50px auto;
|
|
padding: 20px;
|
|
border-radius: 10px;
|
|
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
|
|
background-color: var(--card-background-color);
|
|
}
|
|
|
|
h1 {
|
|
text-align: center;
|
|
}
|
|
|
|
.setting-item {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
margin: 20px 0;
|
|
}
|
|
|
|
.setting-item button {
|
|
padding: 10px 20px;
|
|
border: none;
|
|
border-radius: 5px;
|
|
cursor: pointer;
|
|
background-color: #007bff;
|
|
color: white;
|
|
font-size: 16px;
|
|
}
|
|
|
|
.setting-item button:hover {
|
|
background-color: #0056b3;
|
|
}
|
|
|
|
/* Red button for Clear Cookies */
|
|
.setting-item.clear-cookies button {
|
|
background-color: #ff4d4d;
|
|
}
|
|
|
|
.setting-item.clear-cookies button:hover {
|
|
background-color: #cc0000;
|
|
}
|
|
|
|
h1, .setting-item {
|
|
opacity: 0; /* Hide elements initially */
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body>
|
|
<div class="settings-container">
|
|
<h1>Settings</h1>
|
|
<div class="setting-item">
|
|
<span>Home</span>
|
|
<a href="index.html"><button id="homeButton">Go to Home</button></a>
|
|
</div>
|
|
<div class="setting-item">
|
|
<span>Dark Mode</span>
|
|
<button id="toggleDarkMode">Enable</button>
|
|
</div>
|
|
<div class="setting-item">
|
|
<span>Enable CloakJS (coming soon)</span>
|
|
<button id="toggleCloakJS">Enable</button>
|
|
</div>
|
|
<div class="setting-item">
|
|
<span>Show FPS Counter</span>
|
|
<button id="toggleFPSCounter">Enable</button>
|
|
</div>
|
|
<div class="setting-item">
|
|
<span>Enable Maturity Filter (coming soon)</span>
|
|
<button id="toggleMaturityFilter">Enable</button>
|
|
</div>
|
|
<div class="setting-item">
|
|
<span>Enable Text-to-Speech</span>
|
|
<button id="toggleTextToSpeech">Enable</button>
|
|
</div>
|
|
<div class="setting-item">
|
|
<span>Show Date and Time</span>
|
|
<button id="toggleDateTime">Enable</button>
|
|
</div>
|
|
<div class="setting-item">
|
|
<span>Save Search Input</span>
|
|
<button id="toggleSaveSearch">Enable</button>
|
|
</div>
|
|
<div class="setting-item">
|
|
<span>Enable More Animation</span>
|
|
<button id="toggleGameAnimation">Enable</button>
|
|
</div>
|
|
<div class="setting-item">
|
|
<span>Less Buttons</span>
|
|
<button id="toggleLessButtons">Enable</button>
|
|
</div>
|
|
<div class="setting-item">
|
|
<span>Background Music</span>
|
|
<button id="toggleMusicButton">Enable Background Music</button>
|
|
</div>
|
|
<div class="setting-item clear-cookies">
|
|
<span>Clear Cookies</span>
|
|
<button id="clearCookies">Clear</button>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Modal for confirmation -->
|
|
<div id="confirmationModal" style="display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.5); justify-content: center; align-items: center;">
|
|
<div style="background-color: white; padding: 20px; border-radius: 10px; text-align: center; max-width: 400px; width: 90%; color: black;">
|
|
<p>Are you sure you want to clear all cookies? This will reset all your preferences and saved data.</p>
|
|
<div style="display: flex; justify-content: space-around; margin-top: 20px;">
|
|
<button id="cancelClear" style="padding: 10px 20px; background-color: #ccc; border: none; border-radius: 5px; cursor: pointer;">Cancel</button>
|
|
<button id="confirmClear" style="padding: 10px 20px; background-color: #ff4d4d; color: white; border: none; border-radius: 5px; cursor: pointer;">OK</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<iframe src="music.html" style="display: none;" id="musicIframe"></iframe>
|
|
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/3.2.1/anime.min.js"></script>
|
|
<script>
|
|
// Utility function to set a cookie
|
|
function setCookie(name, value, days) {
|
|
const date = new Date();
|
|
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
|
|
document.cookie = `${name}=${value};expires=${date.toUTCString()};path=/`;
|
|
}
|
|
|
|
// Utility function to get a cookie
|
|
function getCookie(name) {
|
|
const cookies = document.cookie.split(';');
|
|
for (let i = 0; i < cookies.length; i++) {
|
|
const cookie = cookies[i].trim();
|
|
if (cookie.startsWith(name + '=')) {
|
|
return cookie.substring(name.length + 1);
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
// Function to apply dark mode
|
|
function applyDarkMode(enabled) {
|
|
if (enabled) {
|
|
document.body.style.setProperty('--background-color', 'var(--background-color-dark)');
|
|
document.body.style.setProperty('--text-color', 'var(--text-color-dark)');
|
|
document.body.style.setProperty('--card-background-color', 'var(--card-background-color-dark)');
|
|
} else {
|
|
document.body.style.setProperty('--background-color', 'var(--background-color)');
|
|
document.body.style.setProperty('--text-color', 'var(--text-color)');
|
|
document.body.style.setProperty('--card-background-color', 'var(--card-background-color)');
|
|
}
|
|
}
|
|
|
|
// Function to animate the title
|
|
function animateTitle() {
|
|
anime({
|
|
targets: 'h1',
|
|
opacity: [0, 1], // Fade in
|
|
translateY: [-50, 0], // Slide down
|
|
duration: 1000, // Animation duration
|
|
easing: 'easeOutExpo', // Smooth easing
|
|
});
|
|
}
|
|
|
|
// Function to animate the settings items
|
|
function animateSettingsItems() {
|
|
anime({
|
|
targets: '.setting-item',
|
|
opacity: [0, 1], // Fade in
|
|
translateY: [20, 0], // Slide up
|
|
delay: anime.stagger(150), // Stagger animation for each item
|
|
duration: 800, // Animation duration
|
|
easing: 'easeOutExpo', // Smooth easing
|
|
});
|
|
}
|
|
|
|
// Function to toggle animations
|
|
function toggleAnimations() {
|
|
const animationsEnabled = getCookie('gameAnimation') === 'true';
|
|
if (animationsEnabled) {
|
|
animateTitle();
|
|
animateSettingsItems();
|
|
} else {
|
|
// Make everything visible without animations
|
|
document.querySelector('h1').style.opacity = '1';
|
|
document.querySelector('h1').style.transform = 'none';
|
|
|
|
const settingsItems = document.querySelectorAll('.setting-item');
|
|
settingsItems.forEach(item => {
|
|
item.style.opacity = '1';
|
|
item.style.transform = 'none';
|
|
});
|
|
}
|
|
}
|
|
|
|
// Function to toggle a setting
|
|
function toggleSetting(buttonId, cookieName) {
|
|
const button = document.getElementById(buttonId);
|
|
const isEnabled = getCookie(cookieName) === 'true';
|
|
|
|
// Set initial button text
|
|
button.textContent = isEnabled ? 'Disable' : 'Enable';
|
|
|
|
// Apply dark mode if enabled
|
|
if (cookieName === 'darkMode') {
|
|
applyDarkMode(isEnabled);
|
|
}
|
|
|
|
// Add event listener to toggle the setting
|
|
button.addEventListener('click', () => {
|
|
const currentState = getCookie(cookieName) === 'true';
|
|
setCookie(cookieName, !currentState, 30); // Save preference for 30 days
|
|
button.textContent = currentState ? 'Enable' : 'Disable';
|
|
|
|
// Apply dark mode dynamically
|
|
if (cookieName === 'darkMode') {
|
|
applyDarkMode(!currentState);
|
|
}
|
|
|
|
// Trigger animations dynamically
|
|
if (cookieName === 'gameAnimation') {
|
|
toggleAnimations();
|
|
}
|
|
});
|
|
}
|
|
|
|
// Function to toggle background music
|
|
function toggleMusic() {
|
|
const musicEnabled = localStorage.getItem('backgroundMusicEnabled') === 'true';
|
|
localStorage.setItem('backgroundMusicEnabled', !musicEnabled); // Toggle music state
|
|
|
|
// Update the button text
|
|
const toggleMusicButton = document.getElementById('toggleMusicButton');
|
|
toggleMusicButton.textContent = !musicEnabled ? 'Disable Background Music' : 'Enable Background Music';
|
|
|
|
// Access the iframe's audio element
|
|
const musicIframe = document.getElementById('musicIframe');
|
|
const iframeWindow = musicIframe.contentWindow;
|
|
const backgroundMusic = iframeWindow.document.getElementById('backgroundMusic');
|
|
|
|
if (!musicEnabled) {
|
|
backgroundMusic.play();
|
|
} else {
|
|
backgroundMusic.pause();
|
|
}
|
|
}
|
|
|
|
// Set the initial state of the button
|
|
window.onload = () => {
|
|
const musicEnabled = localStorage.getItem('backgroundMusicEnabled') === 'true';
|
|
const toggleMusicButton = document.getElementById('toggleMusicButton');
|
|
toggleMusicButton.textContent = musicEnabled ? 'Disable Background Music' : 'Enable Background Music';
|
|
};
|
|
|
|
// Ensure animations are enabled by default
|
|
if (getCookie('gameAnimation') === null) {
|
|
setCookie('gameAnimation', 'true', 30); // Default to animations enabled
|
|
}
|
|
|
|
// Trigger animations on page load
|
|
window.onload = () => {
|
|
toggleAnimations();
|
|
};
|
|
|
|
// Apply toggle functionality to all buttons
|
|
toggleSetting('toggleDarkMode', 'darkMode');
|
|
toggleSetting('toggleCloakJS', 'cloakJS');
|
|
toggleSetting('toggleFPSCounter', 'fpsCounter');
|
|
toggleSetting('toggleMaturityFilter', 'maturityFilter');
|
|
toggleSetting('toggleTextToSpeech', 'textToSpeech');
|
|
toggleSetting('toggleDateTime', 'dateTime');
|
|
toggleSetting('toggleSaveSearch', 'saveSearch');
|
|
toggleSetting('toggleGameAnimation', 'gameAnimation');
|
|
toggleSetting('toggleLessButtons', 'lessButtons');
|
|
|
|
// Add event listener for background music toggle
|
|
const toggleMusicButton = document.getElementById('toggleMusicButton');
|
|
toggleMusicButton.addEventListener('click', toggleMusic);
|
|
</script>
|
|
</body>
|
|
|
|
</html> |