diff --git a/static/poopGraph.js b/static/poopGraph.js index c39c13a..df00804 100644 --- a/static/poopGraph.js +++ b/static/poopGraph.js @@ -2,6 +2,16 @@ const startInput = document.getElementById('startDate'); const endInput = document.getElementById('endDate'); const cutSpikesInput = document.getElementById('cutSpikes'); +const initialParamString = window.location.hash.substring(1); +if (initialParamString) { + window.localStorage.setItem("params", initialParamString); +} else { + const savedParamString = window.localStorage.getItem("params"); + if (savedParamString) { + window.location.hash = savedParamString; + } +} + const hashParams = new URLSearchParams(window.location.hash.substring(1)); startInput.value = hashParams.get('start'); endInput.value = hashParams.get('end'); @@ -306,7 +316,9 @@ function plot(data) { if (!cutSpikesInput.checked) { params.set('cutSpikes', 'false'); } - window.location.hash = params.toString(); + const updatedParamString = params.toString(); + window.localStorage.setItem("params", updatedParamString); + window.location.hash = updatedParamString; }; startInput.addEventListener('input', (e) => {