-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfinishDay.js
34 lines (31 loc) · 1.45 KB
/
finishDay.js
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
document.addEventListener("DOMContentLoaded", () => {
const finalConclusion = Number(localStorage.getItem("finalProgress"));
const success = document.getElementById("successTasks");
const unsuccess = document.getElementById("unsuccessTasks");
const title = document.getElementById("final-title");
const conclusion = document.getElementById("conclusion");
const restartBtn = document.getElementById("restart-btn");
console.log("Final Progress:", finalConclusion);
console.log("Type of finalProgress:", typeof finalConclusion);
// Check if finalConclusion is a valid number
if (isNaN(finalConclusion)) {
console.log("Invalid final progress value");
} else if (finalConclusion === 100) {
success.removeAttribute("hidden");
title.innerHTML = "Doing good!";
conclusion.innerText = `Your final progress: ${Math.round(finalConclusion)}%`;
} else {
unsuccess.removeAttribute("hidden");
title.innerHTML = "Keep going!";
conclusion.innerText = `Your final progress: ${Math.round(finalConclusion)}%`;
}
// Ensure restart button exists before adding event listener
if (restartBtn) {
restartBtn.addEventListener("click", () => {
console.log("Botón BACK HOME clickeado"); // Mensaje para debug
window.electronAPI.loadPage("index.html");
});
} else {
console.error("Error: No se encontró el botón BACK HOME");
}
});