X-Git-Url: https://git.realraum.at/?a=blobdiff_plain;f=raspberry-kiosk%2Fkiosk.js;h=0c90e4ed720ce0981dd838402519896e7c87f32b;hb=7867988775a7b6ec1604a863b665e46ac91e70ac;hp=29f7ba8f782c8fbaae5ab2c782582cb80ca123cc;hpb=7166321f6ab66c27e9d9275356db5f15a7f0ca4c;p=svn42.git
diff --git a/raspberry-kiosk/kiosk.js b/raspberry-kiosk/kiosk.js
index 29f7ba8..0c90e4e 100644
--- a/raspberry-kiosk/kiosk.js
+++ b/raspberry-kiosk/kiosk.js
@@ -1,6 +1,17 @@
+function min(a,b)
+{
+ if (a > b)
+ return b;
+ else
+ return a;
+}
+
function writeGooglePlusEvents(data, elem)
{
var ghtml = "";
+ //var gplusimgwidth = parseInt($('
').css("width"));
+ var gplusimgwidth = 495;
+ var minimgwidth=78;
for (var i=0; i< data.items.length; i++)
{
var item = data.items[i];
@@ -33,11 +44,33 @@ function writeGooglePlusEvents(data, elem)
ghtml += ''+item.updated.substring(0,16).replace("T"," ")+'
';
ghtml += ''+notetxt+'
';
if (noteimgs.length>0)
- {
+ {
+ var bigimglimit;
ghtml += '';
- for (var ni=0; ni 3)
{
- ghtml += ' | ';
+ var gplusimgmaxwidth = gplusimgwidth - (minimgwidth * ((noteimgs.length -1) / 3));
+ bigimglimit = "max-height:"+(minimgwidth*3)+"px; max-width:"+gplusimgmaxwidth+"px;"
+ ghtml += ' | ';
+ for (var ni=1; ni';
+ var niimax = min(noteimgs.length, ni+3);
+ for (var nii=ni; nii
';
+ }
+ ghtml += '';
+ }
+ }
+ else
+ {
+ var gplusimgmaxwidth = gplusimgwidth / noteimgs.length;
+ bigimglimit = "max-width:"+gplusimgmaxwidth+"px;"
+ for (var ni=0; ni';
+ }
}
ghtml += '
';
}
@@ -57,6 +90,22 @@ function loadGooglePlusEvents()
});
}
+function weekday2str(dow)
+{
+ var weekday=new Array(7);
+ weekday[0]="So";
+ weekday[1]="Mo";
+ weekday[2]="Di";
+ weekday[3]="Mi";
+ weekday[4]="Do";
+ weekday[5]="Fr";
+ weekday[6]="Sa";
+ weekday[7]="So";
+ if (dow >=0 && dow <=7)
+ return weekday[dow];
+ else
+ return "";
+}
function writeCalendar(data, elem)
{
@@ -71,13 +120,20 @@ function writeCalendar(data, elem)
}
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.length <= 2) { stime+="h"; }
- when = data[s].start.substring(8,10)+"."+data[s].start.substring(5,7) +", "+stime;
+ when = weekday + " " + dayofmonth+"."+month +", "+stime;
}
calhtml += ''+when+' - '+data[s].title+''+"\n";
}
@@ -112,20 +168,47 @@ function writeAnwesenheitStatus(data)
if (data.sensors)
{
- for (var s=0; s'+stype+'
'+swhere+': '+svalue+'';
- });
+ $.each( data.sensors.temperature, function(s, sensorobj) {
+ sensorstd+='Temperatur '+sensorobj.location+': '+sensorobj.value.toFixed(2)+sensorobj.unit+' | ';
});
}
- }
- if (sensorstd != "")
- {
- sensorshtml='';
- document.getElementById('sensor_status').innerHTML=sensorshtml;
- }
+ if (data.sensors.ext_illumination)
+ {
+ $.each( data.sensors.ext_illumination, function(s, sensorobj) {
+ sensorstd+='Licht '+sensorobj.location+': '+sensorobj.value+' | ';
+ });
+ }
+ if (data.sensors.door_locked)
+ {
+ $.each( data.sensors.door_locked, function(s, sensorobj) {
+ var lockstatus="Unlocked";
+ if (sensorobj.value) { lockstatus = "Locked"; }
+ sensorstd+='Türschloà '+sensorobj.location+': '+lockstatus+' | ';
+ });
+ }
+ if (data.sensors.ext_door_ajar)
+ {
+ $.each( data.sensors.ext_door_ajar, function(s, sensorobj) {
+ var lockstatus="Shut";
+ if (sensorobj.value) { lockstatus = "Ajar"; }
+ sensorstd+='Türkontakt '+sensorobj.location+': '+lockstatus+' | ';
+ });
+ }
+ if (data.sensors.ext_dust)
+ {
+ $.each( data.sensors.ext_dust, function(s, sensorobj) {
+ sensorstd+='Staub '+sensorobj.location+': '+sensorobj.value+sensorobj.unit+' | ';
+ });
+
+ }
+ if (sensorstd != "")
+ {
+ sensorshtml='';
+ document.getElementById('sensor_status').innerHTML=sensorshtml;
+ }
+ }
}
function updateAnwesenheitStatus()
@@ -213,7 +296,7 @@ function IsImageOk(img) {
}
var img_orig_src = {};
-function reloadImg(element)
+function reloadImgAlt(element)
{
if(element.complete)
{
@@ -225,7 +308,7 @@ function reloadImg(element)
{
img_orig_src[element.id] = element.src;
}
- new_image.src = img_orig_src[element.id] + "&dt="+Math.floor(new Date().getTime() / 1000).toString();
+ 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);
@@ -233,3 +316,11 @@ function reloadImg(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();
+}