|
1 | 1 | // Cuando se carga la página |
2 | 2 | window.addEventListener('load', function() { |
3 | 3 | // Llama a todas las funciones que quieres ejecutar cuando se carga la página |
4 | | - showNotification();openNav();closeNav(); |
| 4 | + createConfeti(); |
5 | 5 | flower();sol();leaf();nieve(); |
| 6 | + showNotification();openNav();closeNav(); |
6 | 7 | cookies();acceptCookies();declineCookies(); |
7 | 8 | jurassicworld();starwars();taylorswift();superheroes(); |
8 | 9 | }); |
| 10 | +function createConfeti() { |
| 11 | + var today = new Date(); |
| 12 | + var month = today.getMonth(); |
| 13 | + var day = today.getDate(); |
| 14 | + |
| 15 | + if ((month >= 6 && day >= 31) || (month == 7 && day <= 7)) { |
| 16 | + const confeti = document.createElement('div'); |
| 17 | + confeti.className = 'confeti'; |
| 18 | + confeti.style.left = Math.random() * window.innerWidth + 'px'; |
| 19 | + confeti.style.backgroundColor = getRandomColor(); |
| 20 | + document.body.appendChild(confeti); |
| 21 | + } |
| 22 | + } |
9 | 23 |
|
10 | | -function openNav() { |
11 | | - document.getElementById("mySidenav").style.width = "250px"; |
12 | | -} |
13 | | -function closeNav() { |
14 | | - document.getElementById("mySidenav").style.width = "0px"; |
15 | | -} |
16 | | -function showNotification() { |
17 | | - document.getElementById("notification").style.display = "block"; |
18 | | -} |
| 24 | + function getRandomColor() { |
| 25 | + const colors = ['#e74c3c', '#3498db', '#f1c40f', '#2ecc71', '#9b59b6']; |
| 26 | + return colors[Math.floor(Math.random() * colors.length)]; |
| 27 | + } |
19 | 28 |
|
| 29 | + setInterval(createConfeti, 500); // Agrega confeti cada 500 ms |
20 | 30 | function flower() { |
21 | 31 | var today = new Date(); |
22 | 32 | var month = today.getMonth(); |
@@ -94,6 +104,15 @@ function nieve() { |
94 | 104 | } |
95 | 105 | } |
96 | 106 | } |
| 107 | +function openNav() { |
| 108 | + document.getElementById("mySidenav").style.width = "250px"; |
| 109 | +} |
| 110 | +function closeNav() { |
| 111 | + document.getElementById("mySidenav").style.width = "0px"; |
| 112 | +} |
| 113 | +function showNotification() { |
| 114 | + document.getElementById("notification").style.display = "block"; |
| 115 | +} |
97 | 116 | function cookies() { |
98 | 117 | var acceptedCookies = localStorage.getItem('acceptedCookies'); |
99 | 118 | if (!acceptedCookies) { |
|
0 commit comments