Skip to content

Commit 9541756

Browse files
authored
Update index.js
Signed-off-by: Grouvex <168425996+Grouvex@users.noreply.github.com>
1 parent 04d3ed4 commit 9541756

File tree

1 file changed

+29
-10
lines changed

1 file changed

+29
-10
lines changed

index.js

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,32 @@
11
// Cuando se carga la página
22
window.addEventListener('load', function() {
33
// Llama a todas las funciones que quieres ejecutar cuando se carga la página
4-
showNotification();openNav();closeNav();
4+
createConfeti();
55
flower();sol();leaf();nieve();
6+
showNotification();openNav();closeNav();
67
cookies();acceptCookies();declineCookies();
78
jurassicworld();starwars();taylorswift();superheroes();
89
});
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+
}
923

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+
}
1928

29+
setInterval(createConfeti, 500); // Agrega confeti cada 500 ms
2030
function flower() {
2131
var today = new Date();
2232
var month = today.getMonth();
@@ -94,6 +104,15 @@ function nieve() {
94104
}
95105
}
96106
}
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+
}
97116
function cookies() {
98117
var acceptedCookies = localStorage.getItem('acceptedCookies');
99118
if (!acceptedCookies) {

0 commit comments

Comments
 (0)