From 72ed9bcd6ca284096d47c607d7272ea3907c4291 Mon Sep 17 00:00:00 2001 From: Bernhard Tittelbach Date: Sat, 15 Feb 2014 15:41:12 +0000 Subject: [PATCH] show warning if status older than 600s --- raspberry-kiosk/kiosk.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/raspberry-kiosk/kiosk.js b/raspberry-kiosk/kiosk.js index 52d84da..778ed47 100644 --- a/raspberry-kiosk/kiosk.js +++ b/raspberry-kiosk/kiosk.js @@ -224,6 +224,18 @@ function loadAndDrawSensorData() { }); } +function siNumberString(num,unit) +{ + var siid="" + var sisize=new Array([1e9,"G"],[1e6,"M"],[1e3,"K"]); + for (i=0; i= sisize[i][0]) { siid=sisize[i][1]; num=num/sisize[i][0]; break;} + + } + return (Math.round(num*10)/10)+siid+unit; +} + function writeAnwesenheitStatus(data) { var html=""; @@ -241,13 +253,21 @@ function writeAnwesenheitStatus(data) } var anwesenheit_status_kiosk = document.getElementById('anwesenheit_status_kiosk'); var anwesenheit_status_frontpage = document.getElementById('anwesenheit_status'); + var statusage = parseInt((new Date()).getTime()/1000) - data.lastchange; + var statusagestatus = ""; + if (statusage > 600) + { + //var statusagestatus = 'Status older than ' + siNumberString(statusage,"s") + ''; + var statusagestatus = '
Status older than ' + siNumberString(statusage,"s") + '
'; + } if (anwesenheit_status_kiosk) { anwesenheit_status_kiosk.innerHTML='
'+data.status+'
'; } if (anwesenheit_status_frontpage) { - anwesenheit_status_frontpage.innerHTML='
'+data.status+'
'; + //anwesenheit_status_frontpage.innerHTML=''+statusagestatus+'
'+data.status+'
'; + anwesenheit_status_frontpage.innerHTML='
'+data.status+statusagestatus+'
'; } if (data.sensors) -- 1.7.10.4