saufen/assets/javascript/modes.js
lubiana 91380c05a8
All checks were successful
/ ls (pull_request) Successful in 1m27s
/ ls (push) Successful in 1m24s
/ ls (release) Successful in 56s
besser mache
2025-06-18 18:39:30 +02:00

137 lines
5 KiB
JavaScript

// Bonkers mode functionality
function setEmojiLevelClass(mode) {
document.body.classList.remove('emoji-normal', 'emoji-enhanced', 'emoji-bonkers');
if (mode === 'bonkers') {
document.body.classList.add('emoji-bonkers');
} else if (mode === 'enhanced') {
document.body.classList.add('emoji-enhanced');
} else {
document.body.classList.add('emoji-normal');
}
}
function initBonkersMode() {
// Check if we're in bonkers mode
const currentMode = document.documentElement.getAttribute('data-website-mode');
setEmojiLevelClass(currentMode);
if (currentMode === 'bonkers') {
// Apply bonkers mode immediately
document.body.classList.add('bonkers-mode');
// Start the fabulous effects
createExtraSparkles();
createSlayEffects();
console.log('🌈✨ Bonkers mode activated! ✨🌈');
} else {
// Remove bonkers mode if it was active
document.body.classList.remove('bonkers-mode');
}
}
// Function to create extra sparkles during bonkers mode
function createExtraSparkles() {
const currentMode = document.documentElement.getAttribute('data-website-mode');
if (currentMode !== 'bonkers') return;
const extraEmojis = [
'💃', '🕺',
'🍑', '💦', '😏', '😈', '👅', '💋', '🥵', '😳', '🤤', '😍', '🥴',
'💕', '💖', '💗', '💘', '💝', '💞', '💟', '💌', '💏', '💑',
'🍆', '🥒', '🍌', '💦', '👀', '😉', '😌', '😍', '🥰', '😘',
'😚', '😋', '😏', '😫', '😩', '🥺', '🥵', '🥴',
'💖', '💗', '💕', '💞', '💓', '💗', '💖', '💘', '💝',
'💋', '💏', '💑'
];
const sparkle = document.createElement('div');
sparkle.className = 'emoji-footprint';
sparkle.textContent = extraEmojis[Math.floor(Math.random() * extraEmojis.length)];
sparkle.style.left = Math.random() * window.innerWidth + 'px';
sparkle.style.top = Math.random() * window.innerHeight + 'px';
document.body.appendChild(sparkle);
setTimeout(() => {
if (sparkle.parentNode) {
sparkle.remove();
}
}, 3000);
// Continue creating extra sparkles while in bonkers mode
const newMode = document.documentElement.getAttribute('data-website-mode');
if (newMode === 'bonkers') {
setTimeout(() => createExtraSparkles(), 75);
}
}
// Function to create slay effects
function createSlayEffects() {
const currentMode = document.documentElement.getAttribute('data-website-mode');
if (currentMode !== 'bonkers') return;
// Create floating "SLAY" text effects
const slayWords = [
'SLAY', 'QUEEN', 'FABULOUS', 'ICONIC', 'LEGENDARY', 'STUNNING', 'GORGEOUS', 'FLAWLESS',
'DAZZLING', 'RADIANT', 'BREATHTAKING', 'EXQUISITE', 'DIVINE', 'HOT', 'SEXY', 'SMOOTH',
'xoxo',
];
const slayElement = document.createElement('div');
slayElement.className = 'slay-text';
slayElement.textContent = slayWords[Math.floor(Math.random() * slayWords.length)];
slayElement.style.left = Math.random() * window.innerWidth + 'px';
slayElement.style.top = Math.random() * window.innerHeight + 'px';
document.body.appendChild(slayElement);
setTimeout(() => {
if (slayElement.parentNode) {
slayElement.remove();
}
}, 3000);
// Continue creating slay effects while in bonkers mode
const newMode = document.documentElement.getAttribute('data-website-mode');
if (newMode === 'bonkers') {
setTimeout(() => createSlayEffects(), 100);
}
}
// Watch for mode changes
function watchModeChanges() {
// Create a MutationObserver to watch for changes to the data-website-mode attribute
const observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
if (mutation.type === 'attributes' && mutation.attributeName === 'data-website-mode') {
const newMode = document.documentElement.getAttribute('data-website-mode');
if (newMode === 'bonkers') {
document.body.classList.add('bonkers-mode');
setEmojiLevelClass(newMode);
// Start the fabulous effects
createExtraSparkles();
createSlayEffects();
console.log('🌈✨ Switched to bonkers mode! ✨🌈');
} else {
document.body.classList.remove('bonkers-mode');
setEmojiLevelClass(newMode);
console.log(`😴 Switched to ${newMode} mode`);
}
}
});
});
// Start observing
observer.observe(document.documentElement, {
attributes: true,
attributeFilter: ['data-website-mode']
});
}
// Initialize when DOM is loaded
document.addEventListener('DOMContentLoaded', function() {
initBonkersMode();
watchModeChanges();
});
export { initBonkersMode, watchModeChanges };