-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
41 lines (34 loc) · 1.09 KB
/
script.js
File metadata and controls
41 lines (34 loc) · 1.09 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
import { initGame } from "./gameLogic.js";
const themeToggleButton = document.getElementById("theme-toggle");
// actualizar el tema y el ícono
function updateTheme() {
if (document.body.classList.contains("light-theme")) {
themeToggleButton.innerHTML = '<i class="fas fa-sun"></i>';
localStorage.setItem("theme", "light");
} else {
themeToggleButton.innerHTML = '<i class="fas fa-moon"></i>';
localStorage.setItem("theme", "dark");
}
}
function initkeyboardVisibility() {
const $virtualKeyboard = document.getElementById("virtual-keyboard");
if (window.innerWidth > 768) {
$virtualKeyboard.style.display = "flex";
} else {
$virtualKeyboard.style.display = "none";
}
}
// tema guardado en localStorage
if (localStorage.getItem("theme") === "light") {
document.body.classList.add("light-theme");
} else {
document.body.classList.remove("light-theme");
}
// ícono correcto al cargar la página
updateTheme();
themeToggleButton.addEventListener("click", () => {
document.body.classList.toggle("light-theme");
updateTheme();
});
initGame();
initkeyboardVisibility();