X-Git-Url: https://git.realraum.at/?a=blobdiff_plain;f=raspberry-kiosk%2Fkiosk.js;h=778ed47cff532f25350d5ca55c9c2cd2b4995efe;hb=c775b5528f8f96e75c28264b9cea8525c6da9298;hp=d506e1e27aa920fb92f50b78436914de45879f5e;hpb=9148b190d80a15e5393f7ef8c5bd6997c4b40bb2;p=svn42.git diff --git a/raspberry-kiosk/kiosk.js b/raspberry-kiosk/kiosk.js index d506e1e..778ed47 100644 --- a/raspberry-kiosk/kiosk.js +++ b/raspberry-kiosk/kiosk.js @@ -112,27 +112,36 @@ function calendarItemEnhancer(data) for (var s=0; s dt) + var stime = data[s].starttime; + var dt; + if (stime) { + dt = Date.parse(data[s].start+'T'+data[s].starttime); + } else { + dt = Date.parse(data[s].start); + } + if (stime && Date.now() > dt) { when = "JETZT"; } else { var weekday = weekday2str((new Date(dt)).getDay()); - var stime = data[s].starttime; var month = data[s].start.substring(5,7); if (month[0] == '0') month = month[1]; var dayofmonth = data[s].start.substring(8,10); if (dayofmonth[0] == '0') dayofmonth = dayofmonth[1]; - while (stime.substring(stime.length-3,stime.length) == ":00") - { - stime=stime.substring(0,stime.length-3); + if (stime) { + while (stime.substring(stime.length-3,stime.length) == ":00") + { + stime=stime.substring(0,stime.length-3); + } + if (stime.length <= 2) { stime+="h"; } + when = weekday + " " + dayofmonth+"."+month +", "+stime; + } else { + when = weekday + " " + dayofmonth+"."+month; } - if (stime.length <= 2) { stime+="h"; } - when = weekday + " " + dayofmonth+"."+month +", "+stime; } data[s].when = when } @@ -207,14 +216,26 @@ function drawLineGraph(targetelem, dataarray, options, x_is_epochdate) { function loadAndDrawSensorData() { $.getJSON("https://realraum.at/shmcache/r3sensors.json", function(data){ drawLineGraph(document.getElementById('tempgooglegraph'), data["TempSensorUpdate"], - {curveType: "function", title: 'Temperature Sensors', colors: ['#FF0000','#CC0033','#660000','#CC3333'], chartArea:{left:32,top:20,width:"88%",height:"83%"}, legend: {position: "none"}} ,true); + {curveType: "function", title: 'Temperature Sensors', colors: ['#FF0000','#CC0033','#660000','#CC3333'], vAxis:{viewWindow:{min:15,max:26}, viewWindowMode:"explicit"}, chartArea:{left:32,top:20,width:"88%",height:"78%"}, legend: {position: "none"}} ,true); drawLineGraph(document.getElementById('lightgooglegraph'), data["IlluminationSensorUpdate"], - {curveType: "none", title: 'Illumination Sensors', vAxis: {maxValue: 1024, minValue:5}, chartArea:{left:32,top:20,width:"88%",height:"83%"}, legend: {position: "none"}} ,true); + {curveType: "none", title: 'Illumination Sensors', vAxis: {maxValue: 1024, minValue:5}, chartArea:{left:32,top:20,width:"88%",height:"78%"}, legend: {position: "none"}} ,true); drawLineGraph(document.getElementById('movementgooglegraph'), data["MovementSensorUpdate"], - {curveType: "function", title: 'Movement Sensors', vAxis: {maxValue: 10, minValue:0}, chartArea:{left:32,top:20,width:"88%",height:"83%"}, legend: {position: "none"}} ,true); + {curveType: "function", title: 'Movement Sensors', vAxis: {maxValue: 10, minValue:0,viewWindowMode:"maximized"}, chartArea:{left:32,top:20,width:"88%",height:"78%"}, legend: {position: "none"}} ,true); }); } +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=""; @@ -232,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)