Refactor christmas.js: reorganize christmasSymbols definition and streamline observer setup

This commit is contained in:
CodeDevMLH
2026-02-24 19:19:18 +01:00
parent e8effa7dfe
commit f4f472e6ec

View File

@@ -6,6 +6,8 @@ const randomChristmasMobile = config.EnableRandomChristmasMobile !== undefined ?
const enableDiffrentDuration = config.EnableDifferentDuration !== undefined ? config.EnableDifferentDuration : true; // enable different duration for the random Christmas symbols const enableDiffrentDuration = config.EnableDifferentDuration !== undefined ? config.EnableDifferentDuration : true; // enable different duration for the random Christmas symbols
const christmasCount = config.SymbolCount || 25; // count of random extra christmas const christmasCount = config.SymbolCount || 25; // count of random extra christmas
// Array of christmas characters
const christmasSymbols = ['❆', '🎁', '❄️', '🎁', '🎅', '🎊', '🎁', '🎉'];
let msgPrinted = false; // flag to prevent multiple console messages let msgPrinted = false; // flag to prevent multiple console messages
@@ -37,17 +39,12 @@ function toggleChristmas() {
// observe changes in the DOM // observe changes in the DOM
const observer = new MutationObserver(toggleChristmas); const observer = new MutationObserver(toggleChristmas);
// start observation
observer.observe(document.body, { observer.observe(document.body, {
childList: true, // observe adding/removing of child elements childList: true,
subtree: true, // observe all levels of the DOM tree subtree: true,
attributes: true // observe changes to attributes (e.g. class changes) attributes: true
}); });
// Array of christmas characters
const christmasSymbols = ['❆', '🎁', '❄️', '🎁', '🎅', '🎊', '🎁', '🎉'];
function addRandomChristmas(count) { function addRandomChristmas(count) {
const christmasContainer = document.querySelector('.christmas-container'); // get the christmas container const christmasContainer = document.querySelector('.christmas-container'); // get the christmas container
if (!christmasContainer) return; // exit if christmas container is not found if (!christmasContainer) return; // exit if christmas container is not found