persisted selection of child and time range when switching between pages. Also added automatic total sleep time scaling on vertical axis

This commit is contained in:
Brian Bjarke Jensen
2025-11-11 14:29:43 +01:00
parent b1fae46f28
commit dea3b5d3b5
3 changed files with 59 additions and 7 deletions
+9 -1
View File
@@ -267,9 +267,15 @@
let allDiaperChanges = [];
let allChildren = [];
let currentDaysRange = 7;
let currentDaysRange = parseInt(localStorage.getItem("lastDiaperTimeRange")) || 7;
let selectedChildId = null; // null means "All Children"
// Restore last selected child from localStorage
const lastChildId = localStorage.getItem("lastDiaperChildFilter");
if (lastChildId && lastChildId !== "all") {
selectedChildId = parseInt(lastChildId);
}
// Load diaper changes data
async function loadDiaperChanges() {
try {
@@ -311,12 +317,14 @@
function onDaysRangeChange(event) {
currentDaysRange = parseInt(event.target.value);
localStorage.setItem("lastDiaperTimeRange", currentDaysRange);
displayDiaperChanges(allDiaperChanges);
}
function onChildChange(event) {
selectedChildId =
event.target.value === "all" ? null : parseInt(event.target.value);
localStorage.setItem("lastDiaperChildFilter", event.target.value);
displayDiaperChanges(allDiaperChanges);
}