better javascript updates
authorBernhard Tittelbach <xro@realraum.at>
Thu, 18 Apr 2013 21:45:36 +0000 (21:45 +0000)
committerBernhard Tittelbach <xro@realraum.at>
Thu, 18 Apr 2013 21:45:36 +0000 (21:45 +0000)
raspberry-kiosk/kiosk.html
raspberry-kiosk/kiosk.js

index 7bb2c11..333da4c 100644 (file)
@@ -4,7 +4,6 @@
   <title>Realraum Kiosk Seite</title>
   <script src="/jquery.min.js"></script>
   <!--script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script-->
-  <script type="text/javascript" src="gplusapikey.js"></script>
   <script type="text/javascript" src="kiosk.js"></script>
   <link rel="stylesheet" href="kiosk.css" type="text/css" />
  </head>
index 6d7c33e..d453cda 100644 (file)
@@ -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 ...<br/>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);
+       }
     }
 }