diff options
author | Andreas Unterkircher <unki@netshadow.at> | 2008-05-25 09:46:49 +0200 |
---|---|---|
committer | Andreas Unterkircher <unki@netshadow.at> | 2008-05-25 10:02:09 +0200 |
commit | 57a136513d1e5ef86acf49b934ea3e6eff26dbfd (patch) | |
tree | 6d0a20176f8b4e9055a4784e6ff649ea571377f8 | |
parent | dcc26041d1dd86d47516e143fd5e475e588180cf (diff) |
added some comments to image-preloading code
Signed-off-by: Andreas Unterkircher <unki@netshadow.at>
-rw-r--r-- | phpfspot.js | 24 | ||||
-rw-r--r-- | themes/default/templates/photo_index.tpl | 8 |
2 files changed, 20 insertions, 12 deletions
diff --git a/phpfspot.js b/phpfspot.js index ebe1242..75d0ed7 100644 --- a/phpfspot.js +++ b/phpfspot.js @@ -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; + } } } } diff --git a/themes/default/templates/photo_index.tpl b/themes/default/templates/photo_index.tpl index 7fe04ab..fa63b31 100644 --- a/themes/default/templates/photo_index.tpl +++ b/themes/default/templates/photo_index.tpl @@ -135,7 +135,13 @@ <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; |