added some comments to image-preloading code
authorAndreas Unterkircher <unki@netshadow.at>
Sun, 25 May 2008 07:46:49 +0000 (09:46 +0200)
committerAndreas Unterkircher <unki@netshadow.at>
Sun, 25 May 2008 08:02:09 +0000 (10:02 +0200)
Signed-off-by: Andreas Unterkircher <unki@netshadow.at>
phpfspot.js
themes/default/templates/photo_index.tpl

index ebe124225f169a182530acda770bdccc46c22f72..75d0ed73a72c0a0700b3200cf8122bf28735c414 100644 (file)
@@ -660,17 +660,19 @@ function preloadPhotos(image_url) {
    var waiting = 100;
    var counting;
 
-   lbImg=WSR_getElementsByClassName(document,"img","thumb");
-   for(i=0;i<lbImg.length;i++){
-      lbImg[i].src=image_url[i];
-      // to not bomb the server with requests, give the page some time
-      // to load the images one by one. if a image exceeds the timeout,
-      // the next image will be loaded.
-      if(lbImg[i].complete != undefined && lbImg[i].complete != true) {
-         counting = 0;
-         while(lbImg[i].complete != true && counting < timeout) {
-            window.setTimeout("noop()", waiting);
-            counting+=waiting;
+   lbImg = WSR_getElementsByClassName(document,"img","thumb");
+   if(lbImg != undefined) {
+      for(i=0;i<lbImg.length;i++){
+         lbImg[i].src=image_url[i];
+         // to not bomb the server with requests, give the page some time
+         // to load the images one by one. if a image exceeds the timeout,
+         // the next image will be loaded.
+         if(lbImg[i].complete != undefined && lbImg[i].complete != true) {
+            counting = 0;
+            while(lbImg[i].complete != true && counting < timeout) {
+               window.setTimeout("noop()", waiting);
+               counting+=waiting;
+            }
          }
       }
    }
index 7fe04ab053e00c788340269aa0ab6c88b256cf55..fa63b31aa043e47886bd031394beb04482eea044 100644 (file)
 <br class="cb" />
 <script type="text/javascript" language="JavaScript">
 <!--
-   /*** image preloading ***/
+   // image preloading
+   //
+   // these few javascript lines will try to speed up loading all the photo
+   // thumbnails. An array of all photos to display will be built written
+   // by the smarty-template. The js-code will then loop through this array
+   // and invoke loading of each photo. Sadly this does not work good on all
+   // browsers.
    { counter start=-1 }
 
    var current;