diff --git a/add_to_index_html.html b/add_to_index_html.html index b0ca41f..327df90 100644 --- a/add_to_index_html.html +++ b/add_to_index_html.html @@ -1,16 +1,3 @@ -
\ No newline at end of file + \ No newline at end of file diff --git a/snowflakes.js b/snowflakes.js index 8f9f42f..5b25299 100644 --- a/snowflakes.js +++ b/snowflakes.js @@ -1,5 +1,6 @@ const snowflakes = true; // enable/disable snowflakes const randomSnowflakes = true; // enable random Snowflakes +const randomSnowflakesMobile = false; // enable random Snowflakes on mobile devices const enableColoredSnowflakes = true; // enable colored snowflakes on mobile devices const snowflakeCount = 25; // count of random extra snowflakes @@ -45,7 +46,7 @@ observer.observe(document.body, { function addRandomSnowflakes(count) { const snowflakeContainer = document.querySelector('.snowflakes'); // get the snowflake container if (!snowflakeContainer) return; // exit if snowflake container is not found - + console.log('Adding random snowflakes'); const snowflakeSymbols = ['❅', '❆']; // some snowflake symbols @@ -80,13 +81,31 @@ function addRandomSnowflakes(count) { console.log('Random snowflakes added'); } +// initialize standard snowflakes +function initSnowflakes() { + const snowflakesContainer = document.querySelector('.snowflakes'); + + // Array of snowflake characters + const snowflakeSymbols = ['❅', '❆']; + + // create the 12 standard snowflakes + for (let i = 0; i < 12; i++) { + const snowflake = document.createElement('div'); + snowflake.className = 'snowflake'; + snowflake.textContent = snowflakeSymbols[i % 2]; // change between ❅ and ❆ + + snowflakesContainer.appendChild(snowflake); + } +} + // initialize snowflakes and add random snowflakes after the DOM is loaded document.addEventListener('DOMContentLoaded', () => { if (!snowflakes) return; // exit if snowflakes are disabled + initSnowflakes(); toggleSnowflakes(); const screenWidth = window.innerWidth; // get the screen width to detect mobile devices - if (randomSnowflakes && screenWidth > 768) { // add random snowflakes only on larger screens - addRandomSnowflakes(snowflakeCount); + if (randomSnowflakes && screenWidth > 768 && randomSnowflakesMobile) { // add random snowflakes only on larger screens, unless enabled for mobile devices + addRandomSnowflakes(snowflakeCount); } }); \ No newline at end of file