Skip to content

Commit 0aaaa94

Browse files
committed
auto-update UI only show updated values
1 parent 97f7be6 commit 0aaaa94

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

data/index.js

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@
294294
.then(json => {
295295
console.log("then(json => ..)");
296296
//console.log("parsed .., data is ["+ JSON.stringify(json)+"]");
297+
needReload = false;
297298
data = json.otmonitor;
298299
for( let i in data )
299300
{
@@ -306,6 +307,14 @@
306307
rowDiv.setAttribute("class", "otmonrow");
307308
//rowDiv.setAttribute("id", "otmon_"+data[i].name);
308309
rowDiv.style.background = "lightblue";
310+
rowDiv.style.visibility = ((data[i].epoch==0)?"collapse":"visible");
311+
// rowDiv.style.display = ((data[i].epoch==0)?"none":"table-row");
312+
var epoch = document.createElement("INPUT");
313+
epoch.setAttribute("type", "hidden");
314+
epoch.setAttribute("id", "otmon_epoch_"+data[i].name);
315+
epoch.name = data[i].name;
316+
epoch.value = data[i].epoch;
317+
rowDiv.appendChild(epoch);
309318
//--- field Name ---
310319
var fldDiv = document.createElement("div");
311320
fldDiv.setAttribute("class", "otmoncolumn1");
@@ -326,10 +335,19 @@
326335
}
327336
else
328337
{ //if the element exists, then update the value
329-
document.getElementById("otmon_"+data[i].name).textContent = data[i].value;
338+
var update = document.getElementById("otmon_"+data[i].name);
339+
var epoch = document.getElementById("otmon_epoch_"+data[i].name);
340+
if ((Number(epoch.value)==0) && (Number(data[i].epoch)>0)) {
341+
//console.log ("unhide based on epoch");
342+
//setTimeout(function () { update.style.visibility = 'visible';}, 0);
343+
needReload = true;
344+
}
345+
epoch.value = data[i].epoch;
346+
//if (update.style.visibility == 'visible') update.textContent = data[i].value;
347+
330348
}
331349
}
332-
350+
if (needReload) window.location.reload(true);
333351
})
334352
.catch(function(error) {
335353
var p = document.createElement('p');

0 commit comments

Comments
 (0)