From 7f28f99ea30aae3aabedde34399fd463963fb74a Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Sat, 14 Jul 2018 10:24:33 -0400 Subject: [PATCH] Store stations list in localStorage for persistence across refresh --- client.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/client.js b/client.js index e482006..5ec62ae 100644 --- a/client.js +++ b/client.js @@ -159,6 +159,8 @@ function handleMessage(message) { } } + localStorage.setItem("stations", JSON.stringify(stations)); + redrawTable(); } } @@ -178,4 +180,7 @@ function connectToStream() { connectToStream(); window.addEventListener("load", redrawTable); +window.addEventListener("load", () => { + stations = JSON.parse(localStorage.getItem("stations") || '{}'); +}); window.setInterval(redrawTable, 1000);