This commit is contained in:
Dean @ Skool
2023-10-17 20:09:29 -04:00
parent 7835da59ad
commit ff678c6eda
3 changed files with 59 additions and 32 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

-32
View File
@@ -52,38 +52,6 @@ if (location.pathname === '/') {
document.querySelector('.featuredimg').src = game.image;
}).catch(e => new PolarisError('Failed to load featured game.'));
}
// Define a variable to track whether the audio has been played
let audioPlayed = false;
// Function to play the audio
function playSmurfAudio() {
if (!audioPlayed) {
const audio = new Audio('/assets/misc/smurf.mp3');
audio.play();
audioPlayed = true;
}
}
// Event listener to check for the word "smurf"
document.addEventListener('keydown', (event) => {
if (event.key === 's' || event.key === 'm' || event.key === 'u' || event.key === 'r' || event.key === 'f') {
// Add the pressed key to a string and check if it matches "smurf"
if (event.key === 's') {
smurfString = 's';
} else {
smurfString += event.key;
}
if (smurfString === 'smurf') {
playSmurfAudio();
}
} else {
smurfString = ''; // Reset the string if a different key is pressed
}
});
// Variable to store the string as it's being typed
let smurfString = '';
const Polaris = { Settings, Games, Apps, Frame, PolarisError };
+59
View File
@@ -48,5 +48,64 @@ class Theme {
}
}
}
// Define a variable to track whether the audio has been played
let audioPlayed = false;
// Function to play the audio and display the image
function playSmurfAudio() {
if (!audioPlayed) {
const audio = new Audio('/assets/misc/smurf.mp3');
audio.play();
audioPlayed = true;
// Display the image
const imageElement = document.createElement('img');
imageElement.src = '/assets/img/smurf.jpg';
document.body.appendChild(imageElement);
// Delay theme change by 7 seconds
setTimeout(() => {
let themeToggleInterval = setInterval(() => {
// Toggle between light and dark themes
if (document.body.getAttribute('data-theme') === 'flamingo') {
document.body.setAttribute('data-theme', 'light');
} else {
document.body.setAttribute('data-theme', 'flamingo');
}
}, 300);
// Stop changing the theme when the audio ends
audio.onended = () => {
clearInterval(themeToggleInterval);
document.body.setAttribute('data-theme', 'dark');
// Remove the image when the audio ends
document.body.removeChild(imageElement);
};
}, 7000);
}
}
// Event listener to check for the word "smurf"
document.addEventListener('keydown', (event) => {
if (event.key === 's' || event.key === 'm' || event.key === 'u' || event.key === 'r' || event.key === 'f') {
// Add the pressed key to a string and check if it matches "smurf"
if (event.key === 's') {
smurfString = 's';
} else {
smurfString += event.key;
}
if (smurfString === 'smurf') {
playSmurfAudio();
}
} else {
smurfString = ''; // Reset the string if a different key is pressed
}
});
// Variable to store the string as it's being typed
let smurfString = '';
export default new Theme();