-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhistory.js
More file actions
41 lines (39 loc) · 1.67 KB
/
history.js
File metadata and controls
41 lines (39 loc) · 1.67 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
const progressBody = document.getElementById('progress-body');
function displayProgress() {
console.log('displayProgress called');
try {
if (!progressBody) {
console.error('Progress table body not found');
return;
}
const history = JSON.parse(localStorage.getItem('typingHistory')) || [];
console.log('History data loaded:', history);
progressBody.innerHTML = '';
if (history.length === 0) {
console.log('No history data available');
progressBody.innerHTML = '<tr><td colspan="3">No history data available</td></tr>';
return;
}
history.forEach((entry, index) => {
console.log('Adding history entry:', entry);
const tr = document.createElement('tr');
tr.innerHTML = `<td>${new Date(entry.date).toLocaleString()}</td><td>${entry.wpm}</td><td>${entry.accuracy}%</td>`;
progressBody.appendChild(tr);
});
console.log('Progress history updated, rows:', history.length);
} catch (error) {
console.error('Error displaying progress history:', error);
if (progressBody) {
progressBody.innerHTML = '<tr><td colspan="3">Error loading history</td></tr>';
}
}
}
document.addEventListener('DOMContentLoaded', () => {
console.log('DOM fully loaded for history.js');
if (!document.getElementById('progress-body')) {
console.error('Progress body element not found on DOM load');
} else {
console.log('Progress body element found, ID:', document.getElementById('progress-body').id);
}
displayProgress();
});