X-Git-Url: https://git.realraum.at/?a=blobdiff_plain;f=raspberry-kiosk%2Fkiosk.js;h=e9d4b6c65b8397434bb1f1b74c8bbd08daac92dd;hb=39a41339d2ce0cc3bbbe4d270377e4e698631c1e;hp=0c90e4ed720ce0981dd838402519896e7c87f32b;hpb=7867988775a7b6ec1604a863b665e46ac91e70ac;p=svn42.git diff --git a/raspberry-kiosk/kiosk.js b/raspberry-kiosk/kiosk.js index 0c90e4e..e9d4b6c 100644 --- a/raspberry-kiosk/kiosk.js +++ b/raspberry-kiosk/kiosk.js @@ -30,7 +30,7 @@ function writeGooglePlusEvents(data, elem) noteimgs.push(attach[a].thumbnails[t].image.url); } } - else if ( attach[a].objectType == "photo") + else if ( attach[a].objectType == "photo" || attach[a].objectType == "video") { noteimgs.push(attach[a].image.url); } @@ -107,9 +107,8 @@ function weekday2str(dow) return ""; } -function writeCalendar(data, elem) +function calendarItemEnhancer(data) { - var calhtml = ""; for (var s=0; s'+data[s].title+''+"\n"; + data[s].when = when } - elem.innerHTML=''; + return data } -function loadCalendar() + +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 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 += '
  • '+itm.when+' - '+itm.title+'
  • '+"\n"; + }); + calcontainer.innerHTML=''; }); } + function writeAnwesenheitStatus(data) { var html=""; @@ -163,44 +180,62 @@ 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; }); + 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; }); + 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 != "") @@ -208,7 +243,7 @@ function writeAnwesenheitStatus(data) sensorshtml=''+sensorstd+'
    '; document.getElementById('sensor_status').innerHTML=sensorshtml; } - } + } } function updateAnwesenheitStatus() @@ -222,19 +257,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'); @@ -324,3 +346,33 @@ 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("gplusevents")) + { + loadGooglePlusEvents(); + setInterval("loadGooglePlusEvents()", 1207*1000); + } +});