diff --git a/client.js b/client.js index 0ce58dc..ee7377f 100644 --- a/client.js +++ b/client.js @@ -67,25 +67,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; + }