MediaWiki:Common.js

From Tony Chase
Revision as of 22:30, 4 December 2023 by Archtony (talk | contribs)
Jump to navigation Jump to search

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
/* Any JavaScript here will be loaded for all users on every page load. */
document.addEventListener("DOMContentLoaded", function () {
            const container = document.body;

            function createSnowflake() {
                const snowflake = document.createElement("div");
                snowflake.className = "snowflake";
                snowflake.innerHTML = "❄";
                container.appendChild(snowflake);

                const animationDuration = Math.random() * 3 + 2; // between 2 and 5 seconds
                snowflake.style.animation = `fall ${animationDuration}s linear infinite`;

                const startX = Math.random() * window.innerWidth;
                snowflake.style.left = `${startX}px`;

                const endX = Math.random() * window.innerWidth;
                const rotation = Math.random() * 360;
                snowflake.style.transform = `translate(${endX}px, ${window.innerHeight}px) rotate(${rotation}deg)`;
            }

            function createSnowflakes(quantity) {
                for (let i = 0; i < quantity; i++) {
                    createSnowflake();
                }
            }

            createSnowflakes(50); // Adjust the quantity of snowflakes as needed
        });