From 42fc294800e3d71526c4a99ecfff6db0baa8142a Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Sat, 14 Jul 2018 10:20:47 -0400 Subject: [PATCH] Store date in packet as milliseconds in prep for storing in localStorage may wish to revert some of this later --- client.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/client.js b/client.js index 1f3cc12..e482006 100644 --- a/client.js +++ b/client.js @@ -95,7 +95,8 @@ function redrawTable() { else { let station = stations[callsign]; - let nowDelta = new Date(new Date() - station.lastHeard); + let lastHeard = new Date(station.lastHeard); + let nowDelta = new Date(new Date() - lastHeard); // TODO: should be set by same thing that sends alert if (nowDelta.getTime() > timeoutLength) { @@ -105,7 +106,7 @@ function redrawTable() { tr.classList.add('lowVoltage'); } tr.innerHTML += - `${station.lastHeard.toLocaleTimeString('en-GB')}` + + `${lastHeard.toLocaleTimeString('en-GB')}` + `${nowDelta.toLocaleTimeString('en-GB', {timeZone: "UTC"})}` + `${station.lastVoltage||''}` + `${station.lastTemperature||''}`; @@ -119,7 +120,7 @@ function notify(title, body) { function alertNotHeard(callsign) { notify(`${getTactical(callsign)} has not been heard for ${prettyDuration(timeoutLength)}!`, - `Last Heard: ${stations[callsign].lastHeard.toLocaleTimeString('en-GB')}`); + `Last Heard: ${new Date(stations[callsign].lastHeard).toLocaleTimeString('en-GB')}`); } function alertVoltage(callsign) { @@ -144,7 +145,7 @@ function handleMessage(message) { window.clearTimeout(stations[callsign].timeout); } - stations[callsign].lastHeard = date; + stations[callsign].lastHeard = date.getTime(); stations[callsign].delta = date - stations[callsign].lastHeard; stations[callsign].timeout = window.setTimeout( alertNotHeard, timeoutLength, callsign);