From c4177abaaf62f11ccd94cebcee612e97c34c995e Mon Sep 17 00:00:00 2001 From: Cryptkeeper Date: Mon, 1 Feb 2016 05:20:25 -0600 Subject: [PATCH] Start work on saving graph controls --- assets/js/site.js | 4 ++++ assets/js/util.js | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/assets/js/site.js b/assets/js/site.js index 12093b6..10d2f5a 100644 --- a/assets/js/site.js +++ b/assets/js/site.js @@ -460,9 +460,13 @@ $(document).ready(function() { delete hiddenGraphData[serverIp]; } + // Redraw the graph historyPlot.setData(convertGraphData(displayedGraphData)); historyPlot.setupGrid(); historyPlot.draw(); + + // Update our localStorage + saveGraphControls(); }); }); diff --git a/assets/js/util.js b/assets/js/util.js index af6420b..5b83b60 100644 --- a/assets/js/util.js +++ b/assets/js/util.js @@ -2,6 +2,24 @@ var MISSING_FAVICON_BASE64 = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAA var tooltip = $('#tooltip'); +function saveGraphControls(displayedServers) { + if (typeof(localStorage) !== undefined) { + var json = JSON.stringify(displayedServers); + + localStorage.setItem('displayedServers', json); + } +} + +function loadGraphControls() { + if (typeof(localStorage) !== undefined) { + var item = localStorage.getItem('displayedServers'); + + if (item) { + return JSON.parse(item); + } + } +} + function getTimestamp(ms, timeOnly) { var date = new Date(0);