'+stype+'
'+swhere+': '+svalue+'';
- });
+ sensorstd+='Temperatur';
+ $.each( data.sensors.temperature, function(s, sensorobj) {
+ 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+=' '+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="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="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+=' '+sensorobj.location+': '+sensorobj.value+sensorobj.unit+' | ';
+ });
+ sensorstd+='';
+
+ }
+ if (sensorstd != "")
+ {
+ sensorshtml='';
+ document.getElementById('sensor_status').innerHTML=sensorshtml;
}
- }
- if (sensorstd != "")
- {
- sensorshtml='';
- document.getElementById('sensor_status').innerHTML=sensorshtml;
}
}
@@ -79,29 +337,6 @@ function updateAnwesenheitStatus()
//req.send(null);
var jqxhr = $.getJSON(url, writeAnwesenheitStatus);
}
-var anwesenheit_timer = window.setInterval("updateAnwesenheitStatus()", 10000);
-
-function updateSensors()
-{
- //reloadImg(document.getElementById("tempsensor"));
- reloadImg(document.getElementById("movementsensor"));
- reloadImg(document.getElementById("lightsensor"));
-}
-
-var timer;
-var seconds = 0;
-var schedule = Array()
-
-$(document).ready(function()
-{
- updateDateClock(new Date());
- setInterval("clock()", 500);
- updateAnwesenheitStatus();
- loadCalendar();
- setInterval("updateAnwesenheitStatus()", 10000);
- setInterval("loadCalendar()", 100000);
- setInterval("updateSensors()", 50000);
-});
function updateDateClock(now)
{
@@ -121,14 +356,14 @@ 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);
}
}
-
+var seconds = 0;
function clock(now)
{
var now = new Date(new Date().valueOf() + 300);
@@ -139,25 +374,91 @@ function clock(now)
}
}
-//function updateSchedule()
-//{
-// $.ajax({type: "GET", url: "/export/schedules.php", data: "days=3&start=-1", dataType: "xml", error: showError, success: parseXml});
-//}
-
function showError(XMLHttpRequest, textStatus, errorThrown)
{
alert("Error: " + textStatus);
}
-function reloadImg(element)
+function updateSensors()
{
- //var image = document.getElementById("theText");
- if(element.complete) {
- var new_image = new Image();
- //set up the new image
- new_image.id = element.id;
- new_image.src = element.src;
+ reloadImg(document.getElementById("tempsensor"));
+ reloadImg(document.getElementById("movementsensor"));
+ reloadImg(document.getElementById("lightsensor"));
+}
+
+function IsImageOk(img) {
+ if (!img.complete)
+ {
+ return false;
+ }
+ if (typeof img.naturalWidth == "undefined" || (typeof img.naturalWidth == "number" && img.naturalWidth == 0))
+ {
+ return false;
+ }
+ return true;
+}
+
+var img_orig_src = {};
+function reloadImgAlt(element)
+{
+ if(element.complete)
+ {
+ var new_image = new Image();
+ //set up the new image
+ new_image.id = element.id;
+ new_image.className = element.className;
+ if (! img_orig_src[element.id])
+ {
+ img_orig_src[element.id] = element.src;
+ }
+ new_image.src = img_orig_src[element.id] + "?dt="+Math.floor(new Date().getTime() / 1000).toString();
+ if (IsImageOk(new_image))
+ {
element.parentNode.insertBefore(new_image,element);
element.parentNode.removeChild(element);
+ }
+ }
+}
+function reloadImg(element)
+{
+ if (! img_orig_src[element.id])
+ {
+ img_orig_src[element.id] = element.src;
}
+ 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") || document.getElementById("movementgooglegraph"))
+ {
+ loadAndDrawSensorData();
+ setInterval("loadAndDrawSensorData()",145*1000);
+ }
+ if (document.getElementById("gplusevents"))
+ {
+ loadGooglePlusEvents();
+ setInterval("loadGooglePlusEvents()", 1207*1000);
+ }
+});