'+when+' - '+data[s].title+''+"\n";
+ data[s].when = when
}
- elem.innerHTML='';
+ return data
+}
+
+function loadCalendarKiosk()
+{
+ var calcontainer=document.getElementById("grical_upcoming_kiosk");
+ $.getJSON('/shmcache/grical_realraum.json', function(data){
+ var calhtml = "";
+ $.each(calendarItemEnhancer(data), function(index, itm) {
+ calhtml += ''+itm.when+' - '+itm.title+''+"\n";
+ });
+ calcontainer.innerHTML='';
+ });
}
-function loadCalendar()
+
+function loadCalendarMainPage()
{
//old URI: //grical.realraum.at/s/?query=!realraum&limit=9&view=json
var calcontainer=document.getElementById("grical_upcoming");
$.getJSON('/shmcache/grical_realraum.json', function(data){
- writeCalendar(data, calcontainer);
+ var calhtml = "";
+ $.each(calendarItemEnhancer(data), function(index, itm) {
+ calhtml += ''+"\n";
+ });
+ calcontainer.innerHTML='';
});
}
+
+function drawGauge(targetelem, label, temp, options) {
+ var data = google.visualization.arrayToDataTable([["Label", "Value"],[label,temp]]);
+ // Create and draw the visualization.
+ if (targetelem)
+ {
+ options["width"] = targetelem.getAttribute("width");
+ options["height"] = targetelem.getAttribute("height");
+ var chart = new google.visualization.Gauge(targetelem);
+ chart.draw(data, options);
+ }
+}
+
+function drawLineGraph(targetelem, dataarray, options) {
+ if (dataarray) {
+ var data = google.visualization.arrayToDataTable(dataarray);
+ // Create and draw the visualization.
+ if (targetelem)
+ {
+ options["width"]= targetelem.getAttribute("width");
+ options["height"]=targetelem.getAttribute("height");
+ new google.visualization.LineChart(targetelem).draw(data, options);
+ }
+ }
+}
+
+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"}} );
+ 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"}} );
+ drawLineGraph(document.getElementById('movementgooglegraph'), data["MovementSensorUpdate"],
+ {curveType: "none", title: 'Movement Sensors', vAxis: {maxValue: 10, minValue:0}, chartArea:{left:32,top:20,width:"88%",height:"83%"}, legend: {position: "none"}} );
+ });
+}
+
function writeAnwesenheitStatus(data)
{
var html="";
@@ -163,52 +216,72 @@ function writeAnwesenheitStatus(data)
iconuri=data.icon.closed;
statuscolor="red";
}
- html=' | | '+data.status+' |
';
- document.getElementById('anwesenheit_status').innerHTML=html;
+ var anwesenheit_status_kiosk = document.getElementById('anwesenheit_status_kiosk');
+ var anwesenheit_status_frontpage = document.getElementById('anwesenheit_status');
+ if (anwesenheit_status_kiosk)
+ {
+ anwesenheit_status_kiosk.innerHTML=' | | '+data.status+' |
';
+ }
+ if (anwesenheit_status_frontpage)
+ {
+ anwesenheit_status_frontpage.innerHTML=' | | '+data.status+' |
';
+ }
if (data.sensors)
{
if (data.sensors.temperature)
{
+ sensorstd+='Temperatur';
$.each( data.sensors.temperature, function(s, sensorobj) {
- sensorstd+=' | Temperatur '+sensorobj.location+': '+sensorobj.value.toFixed(2)+sensorobj.unit+' | ';
+ sensorstd+='
'+sensorobj.location+': '+sensorobj.value.toFixed(2)+sensorobj.unit;
+ drawGauge(document.getElementById('tempgauge'), "Temp "+sensorobj.location, sensorobj.value, {redFrom: 33, redTo: 40, yellowFrom:29, yellowTo: 33, minorTicks: 4, min:0, max:40});
});
+ sensorstd+='';
}
if (data.sensors.ext_illumination)
{
+ sensorstd+='Licht';
$.each( data.sensors.ext_illumination, function(s, sensorobj) {
- sensorstd+=' | Licht '+sensorobj.location+': '+sensorobj.value+' | ';
+ sensorstd+='
'+sensorobj.location+': '+sensorobj.value;
+ drawGauge(document.getElementById('lightgauge'), "Licht "+sensorobj.location, sensorobj.value, {redFrom: 950, redTo: 1024,yellowFrom:0, yellowTo: 200,minorTicks: 4, min:0, max:1024});
});
+ sensorstd+='';
}
if (data.sensors.door_locked)
{
+ sensorstd+='Eingangstür';
$.each( data.sensors.door_locked, function(s, sensorobj) {
- var lockstatus="Unlocked";
- if (sensorobj.value) { lockstatus = "Locked"; }
- sensorstd+=' | Türschloà '+sensorobj.location+': '+lockstatus+' | ';
+ var lockstatus="Auf";
+ if (sensorobj.value) { lockstatus = "Zu"; }
+ sensorstd+='
'+sensorobj.location+': '+lockstatus;
});
+ sensorstd+='';
}
if (data.sensors.ext_door_ajar)
{
+ sensorstd+='Türkontakt';
$.each( data.sensors.ext_door_ajar, function(s, sensorobj) {
- var lockstatus="Shut";
- if (sensorobj.value) { lockstatus = "Ajar"; }
- sensorstd+=' | Türkontakt '+sensorobj.location+': '+lockstatus+' | ';
+ var lockstatus="Auf";
+ if (sensorobj.value) { lockstatus = "Zu"; }
+ sensorstd+='
'+sensorobj.location+': '+lockstatus;
});
+ sensorstd+='';
}
if (data.sensors.ext_dust)
{
+ sensorstd+='Staub';
$.each( data.sensors.ext_dust, function(s, sensorobj) {
- sensorstd+=' | Staub '+sensorobj.location+': '+sensorobj.value+sensorobj.unit+' | ';
+ sensorstd+='
'+sensorobj.location+': '+sensorobj.value+sensorobj.unit+'';
});
+ sensorstd+='';
- }
+ }
if (sensorstd != "")
{
sensorshtml='';
document.getElementById('sensor_status').innerHTML=sensorshtml;
}
- }
+ }
}
function updateAnwesenheitStatus()
@@ -222,19 +295,6 @@ function updateAnwesenheitStatus()
var jqxhr = $.getJSON(url, writeAnwesenheitStatus);
}
-$(document).ready(function()
-{
- updateDateClock(new Date());
- setInterval("clock()", 500);
- updateAnwesenheitStatus();
- loadCalendar();
- loadGooglePlusEvents();
- setInterval("updateAnwesenheitStatus()", 10*1000);
- setInterval("loadCalendar()", 123*1000);
- setInterval("updateSensors()",145*1000);
- setInterval("loadGooglePlusEvents()", 1207*1000);
-});
-
function updateDateClock(now)
{
var daynames = new Array('So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa');
@@ -253,7 +313,7 @@ function highlightEntry(idx, color, value)
if(value == 0) {
if(idx%2 == 0)
$('#upnext' + idx).css('background-color', 'white');
- else
+ else
$('#upnext' + idx).css('background-color', '#E0E0E0');
} else {
$('#upnext' + idx).css('background-color', color);
@@ -324,3 +384,38 @@ function reloadImg(element)
}
element.src = img_orig_src[element.id] + "?dt="+Math.floor(new Date().getTime() / 1000).toString();
}
+
+$(document).ready(function()
+{
+ updateAnwesenheitStatus();
+ setInterval("updateAnwesenheitStatus()", 10*1000);
+ if (document.getElementById("dateclock"))
+ {
+ updateDateClock(new Date());
+ setInterval("clock()", 500);
+ }
+ if (document.getElementById("grical_upcoming_kiosk"))
+ {
+ loadCalendarKiosk();
+ setInterval("loadCalendarKiosk()", 123*1000);
+ }
+ if (document.getElementById("grical_upcoming"))
+ {
+ loadCalendarMainPage();
+ setInterval("loadCalendarMainPage()", 123*1000);
+ }
+ if (document.getElementById("sensorgraphs"))
+ {
+ setInterval("updateSensors()",145*1000);
+ }
+ if (document.getElementById("tempgooglegraph") || document.getElementById("lightgooglegraph"))
+ {
+ loadAndDrawSensorData();
+ setInterval("loadAndDrawSensorData()",145*1000);
+ }
+ if (document.getElementById("gplusevents"))
+ {
+ loadGooglePlusEvents();
+ setInterval("loadGooglePlusEvents()", 1207*1000);
+ }
+});