Store stations list in localStorage for persistence across refresh

This commit is contained in:
Adam Goldsmith 2018-07-14 10:24:33 -04:00
parent 3bfdec5b45
commit 7f28f99ea3

View File

@ -159,6 +159,8 @@ function handleMessage(message) {
} }
} }
localStorage.setItem("stations", JSON.stringify(stations));
redrawTable(); redrawTable();
} }
} }
@ -178,4 +180,7 @@ function connectToStream() {
connectToStream(); connectToStream();
window.addEventListener("load", redrawTable); window.addEventListener("load", redrawTable);
window.addEventListener("load", () => {
stations = JSON.parse(localStorage.getItem("stations") || '{}');
});
window.setInterval(redrawTable, 1000); window.setInterval(redrawTable, 1000);