-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
34 lines (29 loc) · 1.15 KB
/
script.js
File metadata and controls
34 lines (29 loc) · 1.15 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
document.addEventListener("DOMContentLoaded", () => {
const dataManager = new DataManager();
const logButton = document.getElementById("logButton");
const clearButton = document.getElementById("clearButton");
const entryInput = document.getElementById("entryInput");
logButton.addEventListener("click", () => {
const value = parseInt(entryInput.value.trim(), 10);
const exercise = exerciseType.value;
if (!isNaN(value) && value > 0) {
const entry = { date: new Date().toISOString(), value: value };
dataManager.saveEntry(exercise, entry);
entryInput.value = ""; // Clear input field
updateCards();
} else {
alert("Please enter a valid number greater than zero.");
}
});
clearButton.addEventListener("click", () => {
if (confirm("Are you sure you want to clear all data?")) {
dataManager.clearEntries();
updateChart();
}
});
function updateCards() {
const entries = dataManager.getEntries();
updateProgressChart(entries);
}
updateCards(); // Load data on startup
});