Spaces:
Running
Running
Update index.html
Browse files- index.html +12 -4
index.html
CHANGED
|
@@ -258,14 +258,23 @@
|
|
| 258 |
render();
|
| 259 |
});
|
| 260 |
|
| 261 |
-
|
| 262 |
const grid = document.getElementById('examsGrid');
|
| 263 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 264 |
const now = new Date(); now.setHours(0,0,0,0);
|
| 265 |
const target = new Date(e.date); target.setHours(0,0,0,0);
|
| 266 |
const diff = Math.ceil((target - now) / 86400000);
|
| 267 |
|
| 268 |
-
// Since auto-delete removes negatives, we just handle 0 (Today) and positives
|
| 269 |
let val = diff === 0 ? 'NOW' : diff;
|
| 270 |
let label = diff === 0 ? 'CRITICAL_EVENT' : (diff === 1 ? 'CYCLE_REMAINING' : 'CYCLES_REMAINING');
|
| 271 |
|
|
@@ -283,7 +292,6 @@
|
|
| 283 |
</div>`;
|
| 284 |
}).join('');
|
| 285 |
}
|
| 286 |
-
|
| 287 |
window.tilt = (e, card) => {
|
| 288 |
const rect = card.getBoundingClientRect();
|
| 289 |
const x = e.clientX - rect.left;
|
|
|
|
| 258 |
render();
|
| 259 |
});
|
| 260 |
|
| 261 |
+
function render() {
|
| 262 |
const grid = document.getElementById('examsGrid');
|
| 263 |
+
|
| 264 |
+
// 1. Create a safe copy of the data using [...dataStore]
|
| 265 |
+
// 2. Sort explicitly by converting everything to a timestamp first
|
| 266 |
+
const sortedExams = [...dataStore].sort((a, b) => {
|
| 267 |
+
const dateA = new Date(a.date).getTime();
|
| 268 |
+
const dateB = new Date(b.date).getTime();
|
| 269 |
+
return dateA - dateB;
|
| 270 |
+
});
|
| 271 |
+
|
| 272 |
+
// 3. Map over the NEW sortedExams array instead of dataStore
|
| 273 |
+
grid.innerHTML = sortedExams.map(e => {
|
| 274 |
const now = new Date(); now.setHours(0,0,0,0);
|
| 275 |
const target = new Date(e.date); target.setHours(0,0,0,0);
|
| 276 |
const diff = Math.ceil((target - now) / 86400000);
|
| 277 |
|
|
|
|
| 278 |
let val = diff === 0 ? 'NOW' : diff;
|
| 279 |
let label = diff === 0 ? 'CRITICAL_EVENT' : (diff === 1 ? 'CYCLE_REMAINING' : 'CYCLES_REMAINING');
|
| 280 |
|
|
|
|
| 292 |
</div>`;
|
| 293 |
}).join('');
|
| 294 |
}
|
|
|
|
| 295 |
window.tilt = (e, card) => {
|
| 296 |
const rect = card.getBoundingClientRect();
|
| 297 |
const x = e.clientX - rect.left;
|