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
@@ -304,9 +304,15 @@
let allFeedings = [];
let allChildren = [];
let currentDaysRange = 7;
let currentDaysRange = parseInt(localStorage.getItem("lastFeedingTimeRange")) || 7;
let selectedChildId = null; // null means "All Children"
// Restore last selected child from localStorage
const lastChildId = localStorage.getItem("lastFeedingChildFilter");
if (lastChildId && lastChildId !== "all") {
selectedChildId = parseInt(lastChildId);
}
// Load feedings data
async function loadFeedings() {
try {
@@ -348,12 +354,14 @@
function onDaysRangeChange(event) {
currentDaysRange = parseInt(event.target.value);
localStorage.setItem("lastFeedingTimeRange", currentDaysRange);
displayFeedings(allFeedings);
}
function onChildChange(event) {
selectedChildId =
event.target.value === "all" ? null : parseInt(event.target.value);
localStorage.setItem("lastFeedingChildFilter", event.target.value);
displayFeedings(allFeedings);
}