Show stations that were never heard, but exist in trackedStations

This commit is contained in:
Adam Goldsmith 2018-07-14 04:59:25 -04:00
parent a387cf449b
commit 648132aa2b
2 changed files with 30 additions and 16 deletions

View File

@ -69,11 +69,22 @@ function redrawTable() {
`<th>Time since Last Heard</th>` + `<th>Time since Last Heard</th>` +
`<th>Last Voltage</th>` + `<th>Last Voltage</th>` +
`<th>Last Temperature</th>`; `<th>Last Temperature</th>`;
for (let callsign in stations) { for (let callsign in trackedStations) {
let tr = table.appendChild(document.createElement('tr'));
tr.innerHTML = `<td>${getTactical(callsign)}</td>`;
if (!(callsign in stations)) {
tr.classList.add('neverHeard');
tr.innerHTML +=
'<td>Never Heard</td>' +
'<td>Never Heard</td>' +
'<td>Never Heard</td>' +
'<td>Never Heard</td>';
}
else {
let station = stations[callsign]; let station = stations[callsign];
let nowDelta = new Date(new Date() - station.lastHeard); let nowDelta = new Date(new Date() - station.lastHeard);
let tr = table.appendChild(document.createElement('tr'));
// TODO: should be set by same thing that sends alert // TODO: should be set by same thing that sends alert
if (nowDelta.getTime() > timeoutLength) { if (nowDelta.getTime() > timeoutLength) {
tr.classList.add('timedOut'); tr.classList.add('timedOut');
@ -81,13 +92,12 @@ function redrawTable() {
if (station.lastVoltage < lowVoltage) { if (station.lastVoltage < lowVoltage) {
tr.classList.add('lowVoltage'); tr.classList.add('lowVoltage');
} }
tr.innerHTML = tr.innerHTML +=
`<td>${getTactical(callsign)}</td>` +
`<td>${station.lastHeard.toLocaleTimeString('en-GB')}</td>` + `<td>${station.lastHeard.toLocaleTimeString('en-GB')}</td>` +
`<td>${nowDelta.toLocaleTimeString('en-GB', {timeZone: "UTC"})}</td>` + `<td>${nowDelta.toLocaleTimeString('en-GB', {timeZone: "UTC"})}</td>` +
`<td>${station.lastVoltage||''}</td>` + `<td>${station.lastVoltage||''}</td>` +
`<td>${station.lastTemperature||''}</td>`; `<td>${station.lastTemperature||''}</td>`;
}
} }
} }

View File

@ -18,6 +18,10 @@
table.stations tr.lowVoltage { table.stations tr.lowVoltage {
background-color: yellow; background-color: yellow;
} }
table.stations tr.neverHeard {
background-color: purple;
}
</style> </style>
</head> </head>
<body> <body>