Différences entre versions de « MediaWiki:Common.js »

De ɴon-ᴀ
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 = ["❄", "❅", "❆"]; // Unicode snowflakes
+
  const snowflakes = ["❄", "❅", "❆"];  
  
      function createSnowflake() {
+
  function createSnowflake() {
        const snowflake = document.createElement('div');
+
    const snowflake = document.createElement('div');
        snowflake.className = 'snowflake';
+
    snowflake.className = 'snowflake';
        snowflake.innerHTML = snowflakes[Math.floor(Math.random() * snowflakes.length)];
+
    snowflake.innerHTML = snowflakes[Math.floor(Math.random() * snowflakes.length)];
        snowflake.style.left = Math.random() * window.innerWidth + 'px';
+
    snowflake.style.left = Math.random() * window.innerWidth + 'px';
        snowflake.style.animationDuration = Math.random() * 3 + 2 + 's';
+
    snowflake.style.animationDuration = Math.random() * 3 + 2 + 's';
        document.body.appendChild(snowflake);
+
    document.body.appendChild(snowflake);
  
        setTimeout(() => {
+
    setTimeout(() => {
          document.body.removeChild(snowflake);
+
      document.body.removeChild(snowflake);
        }, 5000);
+
    }, 5000);
      }
+
  }
  
      function generateSnowflakes() {
+
  function generateSnowflakes() {
        setInterval(createSnowflake, 500); // Create a new snowflake every 500 milliseconds
+
    setInterval(createSnowflake, 500); // Create a new snowflake every 500 milliseconds
      }
+
  }
  
      generateSnowflakes();
+
  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();
});