save poop graph settings in local storage
This commit is contained in:
parent
7941a6f7fc
commit
d2eacd6a12
|
@ -2,6 +2,16 @@ const startInput = document.getElementById('startDate');
|
||||||
const endInput = document.getElementById('endDate');
|
const endInput = document.getElementById('endDate');
|
||||||
const cutSpikesInput = document.getElementById('cutSpikes');
|
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));
|
const hashParams = new URLSearchParams(window.location.hash.substring(1));
|
||||||
startInput.value = hashParams.get('start');
|
startInput.value = hashParams.get('start');
|
||||||
endInput.value = hashParams.get('end');
|
endInput.value = hashParams.get('end');
|
||||||
|
@ -306,7 +316,9 @@ function plot(data) {
|
||||||
if (!cutSpikesInput.checked) {
|
if (!cutSpikesInput.checked) {
|
||||||
params.set('cutSpikes', 'false');
|
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) => {
|
startInput.addEventListener('input', (e) => {
|
||||||
|
|
Loading…
Reference in a new issue