From: Bernhard Tittelbach Date: Thu, 18 Apr 2013 21:45:36 +0000 (+0000) Subject: better javascript updates X-Git-Url: https://git.realraum.at/?a=commitdiff_plain;h=d305767f69ed6aebf3cd1ccc8e2bf9746a63d822;p=svn42.git better javascript updates --- diff --git a/raspberry-kiosk/kiosk.html b/raspberry-kiosk/kiosk.html index 7bb2c11..333da4c 100644 --- a/raspberry-kiosk/kiosk.html +++ b/raspberry-kiosk/kiosk.html @@ -4,7 +4,6 @@ Realraum Kiosk Seite - diff --git a/raspberry-kiosk/kiosk.js b/raspberry-kiosk/kiosk.js index 6d7c33e..d453cda 100644 --- a/raspberry-kiosk/kiosk.js +++ b/raspberry-kiosk/kiosk.js @@ -44,7 +44,6 @@ function loadGooglePlusEvents() var gpak = "AIzaSyD9xBFM-KWwSYBgZ8VzftJ5wYYvurOxEHg"; var gplusuri = "https://www.googleapis.com/plus/v1/people/113737596421797426873/activities/public?maxResults=4&key="+gpak; var gpluscontainer=document.getElementById("gplusevents"); - gpluscontainer.innerHTML="Plus loading ..."; $.getJSON(gplusuri, function(data){ writeGooglePlusEvents(data, gpluscontainer); }); @@ -80,7 +79,6 @@ function loadCalendar() { //old URI: //grical.realraum.at/s/?query=!realraum&limit=9&view=json var calcontainer=document.getElementById("grical_upcoming"); - calcontainer.innerHTML="Calendar loading ...
please wait a second or two"; $.getJSON('/shmcache/grical_realraum.json', function(data){ writeCalendar(data, calcontainer); }); @@ -204,6 +202,16 @@ function showError(XMLHttpRequest, textStatus, errorThrown) alert("Error: " + textStatus); } +function IsImageOk(img) { + if (!img.complete) { + return false; + } + if (typeof img.naturalWidth != "undefined" && img.naturalWidth == 0) { + return false; + } + return true; +} + function reloadImg(element) { //var image = document.getElementById("theText"); @@ -213,7 +221,10 @@ function reloadImg(element) new_image.id = element.id; new_image.className = element.className; new_image.src = element.src; - element.parentNode.insertBefore(new_image,element); - element.parentNode.removeChild(element); + if (IsImageOk(new_image)) + { + element.parentNode.insertBefore(new_image,element); + element.parentNode.removeChild(element); + } } }