Common.js : Différence entre versions
De erg
(19 révisions intermédiaires par 4 utilisateurs non affichées) | |||
Ligne 1 : | Ligne 1 : | ||
console.log("it's tiiiiiime"); | console.log("it's tiiiiiime"); | ||
− | var snowflakes = ["❄", "❅", " | + | // Changer titre - ne MARCHE PAS pcq complexe iframe-svg |
+ | document.title = document.querySelector("h1").innerHTML; | ||
+ | console.log(document.querySelector("h1").innerHTML); | ||
+ | |||
+ | // Zoomout la carte une fois au moins pcq trop grande | ||
+ | map.zoom_out(); | ||
+ | |||
+ | |||
+ | var snowflakes = ["❄", "❅", "flocon2neige"]; | ||
+ | //var snowflakes = ["E", "R", "G"]; | ||
function createSnowflake() { | function createSnowflake() { | ||
Ligne 35 : | Ligne 44 : | ||
} | } | ||
− | var animationInterval = setInterval(animate, | + | var animationInterval = setInterval(animate, 500); // Reset the animation every 5000 milliseconds |
} | } | ||
function generateSnowflakes() { | function generateSnowflakes() { | ||
− | for (var i = 0; i < | + | for (var i = 0; i < 20; i++) { // Create initial snowflakes |
createSnowflake(); | createSnowflake(); | ||
} | } | ||
− | setInterval(createSnowflake, | + | setInterval(createSnowflake, 50); // Create a new snowflake every 500 milliseconds |
animateSnowflakes(); | animateSnowflakes(); | ||
} | } | ||
Ligne 49 : | Ligne 58 : | ||
generateSnowflakes(); | generateSnowflakes(); | ||
− | function findAndReplace(element) { | + | |
+ | function findAndReplaceInH1() { | ||
+ | var h1Elements = document.getElementsByTagName('h1'); | ||
+ | |||
+ | for (var i = 0; i < h1Elements.length; i++) { | ||
+ | var h1Element = h1Elements[i]; | ||
+ | |||
+ | if (h1Element.hasChildNodes()) { | ||
+ | findAndReplace(h1Element); | ||
+ | } else { | ||
+ | // Replace occurrences of "erg" with "eeeergggg" in text content | ||
+ | h1Element.innerText = h1Element.innerText.replace(/erg/g, 'eeeergggg'); | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | |||
+ | // Function to perform find and replace in a given element | ||
+ | function findAndReplace(element) { | ||
if (element.hasChildNodes()) { | if (element.hasChildNodes()) { | ||
element.childNodes.forEach(findAndReplace); | element.childNodes.forEach(findAndReplace); | ||
} else if (element.nodeType === Node.TEXT_NODE) { | } else if (element.nodeType === Node.TEXT_NODE) { | ||
− | + | // Replace occurrences of "erg" with "eeeergggg" in text content | |
element.nodeValue = element.nodeValue.replace(/eeerrrggg 🤮/g, 'eeerrrggg 🤮'); | element.nodeValue = element.nodeValue.replace(/eeerrrggg 🤮/g, 'eeerrrggg 🤮'); | ||
} | } | ||
} | } | ||
− | // | + | // Call the function to perform find and replace in h1 elements |
− | + | findAndReplaceInH1(); |
Version actuelle datée du 27 janvier 2024 à 23:48
console.log("it's tiiiiiime"); // Changer titre - ne MARCHE PAS pcq complexe iframe-svg document.title = document.querySelector("h1").innerHTML; console.log(document.querySelector("h1").innerHTML); // Zoomout la carte une fois au moins pcq trop grande map.zoom_out(); var snowflakes = ["❄", "❅", "flocon2neige"]; //var snowflakes = ["E", "R", "G"]; function createSnowflake() { var snowflake = document.createElement('div'); snowflake.className = 'snowflake'; snowflake.innerHTML = snowflakes[Math.floor(Math.random() * snowflakes.length)]; snowflake.style.left = Math.floor(Math.random() * (document.documentElement.clientWidth || document.body.clientWidth)) + 'px'; snowflake.style.top = '0'; document.body.appendChild(snowflake); setTimeout(function () { document.body.removeChild(snowflake); }, 5000); } function animateSnowflakes() { var snowflakes = document.getElementsByClassName('snowflake'); var iterationCount = 0; function animate() { for (var i = 0; i < snowflakes.length; i++) { var snowflake = snowflakes[i]; snowflake.style.top = '0'; void snowflake.offsetWidth; // Trigger reflow snowflake.style.top = '100vh'; // Set the end position } iterationCount++; if (iterationCount >= 20) { clearInterval(animationInterval); } } var animationInterval = setInterval(animate, 500); // Reset the animation every 5000 milliseconds } function generateSnowflakes() { for (var i = 0; i < 20; i++) { // Create initial snowflakes createSnowflake(); } setInterval(createSnowflake, 50); // Create a new snowflake every 500 milliseconds animateSnowflakes(); } generateSnowflakes(); function findAndReplaceInH1() { var h1Elements = document.getElementsByTagName('h1'); for (var i = 0; i < h1Elements.length; i++) { var h1Element = h1Elements[i]; if (h1Element.hasChildNodes()) { findAndReplace(h1Element); } else { // Replace occurrences of "erg" with "eeeergggg" in text content h1Element.innerText = h1Element.innerText.replace(/erg/g, 'eeeergggg'); } } } // Function to perform find and replace in a given element function findAndReplace(element) { if (element.hasChildNodes()) { element.childNodes.forEach(findAndReplace); } else if (element.nodeType === Node.TEXT_NODE) { // Replace occurrences of "erg" with "eeeergggg" in text content element.nodeValue = element.nodeValue.replace(/eeerrrggg 🤮/g, 'eeerrrggg 🤮'); } } // Call the function to perform find and replace in h1 elements findAndReplaceInH1();