Refactor snowflake symbol definitions: move symbol arrays to the top for better organization and remove redundant declarations

This commit is contained in:
CodeDevMLH
2026-02-24 19:24:25 +01:00
parent 6cc344e0db
commit 306b0c5e6e

View File

@@ -7,6 +7,8 @@ const enableColoredSnowflakes = config.EnableColoredSnowflakes !== undefined ? c
const enableDiffrentDuration = config.EnableDifferentDuration !== undefined ? config.EnableDifferentDuration : true; // enable different animation duration
const snowflakeCount = config.SnowflakeCount || 25; // count of random extra snowflakes
const snowflakeSymbols = ['❅', '❆']; // some snowflake symbols
const snowflakeSymbolsMobile = ['❅', '❆', '❄']; // some snowflake symbols mobile version
let msgPrinted = false; // flag to prevent multiple console messages
@@ -19,7 +21,7 @@ function toggleSnowflakes() {
const trailerPlayer = document.querySelector('.youtubePlayerContainer');
const isDashboard = document.body.classList.contains('dashboardDocument');
const hasUserMenu = document.querySelector('#app-user-menu');
// hide snowflakes if video/trailer player is active or dashboard is visible
if (videoPlayer || trailerPlayer || isDashboard || hasUserMenu) {
snowflakeContainer.style.display = 'none'; // hide snowflakes
@@ -38,12 +40,10 @@ function toggleSnowflakes() {
// observe changes in the DOM
const observer = new MutationObserver(toggleSnowflakes);
// start observation
observer.observe(document.body, {
childList: true, // observe adding/removing of child elements
subtree: true, // observe all levels of the DOM tree
attributes: true // observe changes to attributes (e.g. class changes)
childList: true,
subtree: true,
attributes: true
});
function addRandomSnowflakes(count) {
@@ -52,9 +52,6 @@ function addRandomSnowflakes(count) {
console.log('Adding random snowflakes');
const snowflakeSymbols = ['❅', '❆']; // some snowflake symbols
const snowflakeSymbolsMobile = ['❅', '❆', '❄']; // some snowflake symbols mobile version
for (let i = 0; i < count; i++) {
// create a new snowflake element
const snowflake = document.createElement('div');
@@ -70,7 +67,7 @@ function addRandomSnowflakes(count) {
// set random horizontal position, animation delay and size(uncomment lines to enable)
const randomLeft = Math.random() * 100; // position (0% to 100%)
const randomAnimationDelay = Math.random() * 8; // delay (0s to 8s)
const randomAnimationDelay2 = Math.random() * 5; // delay (0s to 5s)
const randomAnimationDelay2 = -(Math.random() * 5); // delay (-5s to 0s)
// apply styles
snowflake.style.left = `${randomLeft}%`;