From 648132aa2b07476c275d6904729863f521a8c6b1 Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Sat, 14 Jul 2018 04:59:25 -0400 Subject: [PATCH] Show stations that were never heard, but exist in trackedStations --- client.js | 42 ++++++++++++++++++++++++++---------------- index.html | 4 ++++ 2 files changed, 30 insertions(+), 16 deletions(-) diff --git a/client.js b/client.js index 1f4b423..31ef3a1 100644 --- a/client.js +++ b/client.js @@ -69,25 +69,35 @@ function redrawTable() { `Time since Last Heard` + `Last Voltage` + `Last Temperature`; - for (let callsign in stations) { - let station = stations[callsign]; - let nowDelta = new Date(new Date() - station.lastHeard); - + for (let callsign in trackedStations) { let tr = table.appendChild(document.createElement('tr')); - // TODO: should be set by same thing that sends alert - if (nowDelta.getTime() > timeoutLength) { - tr.classList.add('timedOut'); + tr.innerHTML = `${getTactical(callsign)}`; + if (!(callsign in stations)) { + tr.classList.add('neverHeard'); + tr.innerHTML += + 'Never Heard' + + 'Never Heard' + + 'Never Heard' + + 'Never Heard'; } - if (station.lastVoltage < lowVoltage) { - tr.classList.add('lowVoltage'); - } - tr.innerHTML = - `${getTactical(callsign)}` + - `${station.lastHeard.toLocaleTimeString('en-GB')}` + - `${nowDelta.toLocaleTimeString('en-GB', {timeZone: "UTC"})}` + - `${station.lastVoltage||''}` + - `${station.lastTemperature||''}`; + else { + let station = stations[callsign]; + let nowDelta = new Date(new Date() - station.lastHeard); + + // TODO: should be set by same thing that sends alert + if (nowDelta.getTime() > timeoutLength) { + tr.classList.add('timedOut'); + } + if (station.lastVoltage < lowVoltage) { + tr.classList.add('lowVoltage'); + } + tr.innerHTML += + `${station.lastHeard.toLocaleTimeString('en-GB')}` + + `${nowDelta.toLocaleTimeString('en-GB', {timeZone: "UTC"})}` + + `${station.lastVoltage||''}` + + `${station.lastTemperature||''}`; + } } } diff --git a/index.html b/index.html index d403060..0ca3b14 100644 --- a/index.html +++ b/index.html @@ -18,6 +18,10 @@ table.stations tr.lowVoltage { background-color: yellow; } + + table.stations tr.neverHeard { + background-color: purple; + }