From c3500ebce143983fccca65e8c592759945b8603d Mon Sep 17 00:00:00 2001 From: CodeDevMLH Date: Tue, 26 Nov 2024 16:24:56 +0100 Subject: [PATCH] enable/disable colored snowflakes --- add_to_index_html.html | 8 ++++---- snowflakes.js | 10 ++++++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/add_to_index_html.html b/add_to_index_html.html index 764f535..b0ca41f 100644 --- a/add_to_index_html.html +++ b/add_to_index_html.html @@ -3,14 +3,14 @@ \ No newline at end of file diff --git a/snowflakes.js b/snowflakes.js index 9b5369d..8f9f42f 100644 --- a/snowflakes.js +++ b/snowflakes.js @@ -1,5 +1,6 @@ const snowflakes = true; // enable/disable snowflakes const randomSnowflakes = true; // enable random Snowflakes +const enableColoredSnowflakes = true; // enable colored snowflakes on mobile devices const snowflakeCount = 25; // count of random extra snowflakes @@ -47,7 +48,8 @@ function addRandomSnowflakes(count) { console.log('Adding random snowflakes'); - const snowflakeSymbols = ['❅', '❆', '❄']; // some snowflake symbols + const snowflakeSymbols = ['❅', '❆']; // some snowflake symbols + const snowflakeSymbolsMobile = ['❅', '❆', '❄']; // some snowflake symbols mobile version for (let i = 0; i < count; i++) { // create a new snowflake element @@ -55,7 +57,11 @@ function addRandomSnowflakes(count) { snowflake.classList.add('snowflake'); // pick a random snowflake symbol - snowflake.textContent = snowflakeSymbols[Math.floor(Math.random() * snowflakeSymbols.length)]; + if (enableColoredSnowflakes) { + snowflake.textContent = snowflakeSymbolsMobile[Math.floor(Math.random() * snowflakeSymbolsMobile.length)]; + } else { + snowflake.textContent = snowflakeSymbols[Math.floor(Math.random() * snowflakeSymbols.length)]; + } // set random horizontal position, animation delay and size(uncomment lines to enable) const randomLeft = Math.random() * 100; // position (0% to 100%)