-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
47 lines (37 loc) · 1.58 KB
/
script.js
File metadata and controls
47 lines (37 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
const grid = document.getElementById("grid");
const cellSize = 45;
const gap = 4;
const totalSize = cellSize + gap;
// Crear celdas llenando la pantalla
const cols = Math.ceil(window.innerWidth / totalSize);
const rows = Math.ceil(window.innerHeight / totalSize);
for (let i = 0; i < cols * rows; i++) {
const cell = document.createElement("div");
cell.classList.add("cell");
grid.appendChild(cell);
}
const cells = document.querySelectorAll(".cell");
// Calcular las columnas reales que CSS generó
const computedStyle = getComputedStyle(grid);
const colCount = parseInt(
computedStyle.getPropertyValue("grid-template-columns").split(" ").length
);
document.addEventListener("mousemove", (e) => {
const x = Math.floor(e.clientX / totalSize);
const y = Math.floor(e.clientY / totalSize);
const index = y * colCount + x;
if (cells[index]) {
cells[index].classList.add("active");
setTimeout(() => cells[index].classList.remove("active"), 500);
}
});
window.addEventListener("resize", () => location.reload());
// 👁️ Mostrar / ocultar contraseña
const togglePassword = document.getElementById("togglePassword");
const passwordInput = document.getElementById("password");
togglePassword.addEventListener("click", () => {
const type =
passwordInput.getAttribute("type") === "password" ? "text" : "password";
passwordInput.setAttribute("type", type);
togglePassword.textContent = type === "password" ? "👁️" : "🙈";
});