MediaWiki:Common.js: Difference between revisions
Jump to navigation
Jump to search
(Replaced content with "→Any JavaScript here will be loaded for all users on every page load.: ") Tag: Replaced |
No edit summary Tag: Reverted |
||
Line 1: | Line 1: | ||
/* Any JavaScript here will be loaded for all users on every page load. */ | /* 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 | |||
}); |
Revision as of 22:30, 4 December 2023
/* 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 });