Différences entre versions de « MediaWiki:Common.js »
Sauter à la navigation
Sauter à la recherche
m |
m |
||
Ligne 2 : | Ligne 2 : | ||
document.addEventListener('DOMContentLoaded', function () { | document.addEventListener('DOMContentLoaded', function () { | ||
− | console.log('hello'); | + | console.log('hello'); |
− | + | const snowflakes = ["❄", "❅", "❆"]; | |
− | + | function createSnowflake() { | |
− | + | const snowflake = document.createElement('div'); | |
− | + | snowflake.className = 'snowflake'; | |
− | + | snowflake.innerHTML = snowflakes[Math.floor(Math.random() * snowflakes.length)]; | |
− | + | snowflake.style.left = Math.random() * window.innerWidth + 'px'; | |
− | + | snowflake.style.animationDuration = Math.random() * 3 + 2 + 's'; | |
− | + | document.body.appendChild(snowflake); | |
− | + | setTimeout(() => { | |
− | + | document.body.removeChild(snowflake); | |
− | + | }, 5000); | |
− | + | } | |
− | + | function generateSnowflakes() { | |
− | + | setInterval(createSnowflake, 500); // Create a new snowflake every 500 milliseconds | |
− | + | } | |
− | + | generateSnowflakes(); | |
− | + | }); |
Version du 21 janvier 2024 à 16:13
/* Tout JavaScript ici sera chargé avec chaque page accédée par n’importe quel utilisateur. */ document.addEventListener('DOMContentLoaded', function () { console.log('hello'); const snowflakes = ["❄", "❅", "❆"]; function createSnowflake() { const snowflake = document.createElement('div'); snowflake.className = 'snowflake'; snowflake.innerHTML = snowflakes[Math.floor(Math.random() * snowflakes.length)]; snowflake.style.left = Math.random() * window.innerWidth + 'px'; snowflake.style.animationDuration = Math.random() * 3 + 2 + 's'; document.body.appendChild(snowflake); setTimeout(() => { document.body.removeChild(snowflake); }, 5000); } function generateSnowflakes() { setInterval(createSnowflake, 500); // Create a new snowflake every 500 milliseconds } generateSnowflakes(); });