summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Unterkircher <unki@netshadow.at>2008-03-29 11:39:53 +0100
committerAndreas Unterkircher <unki@netshadow.at>2008-03-29 11:39:53 +0100
commit5a118f1db16afd22cb3c066f07cc6333fa0f96b6 (patch)
tree8866997e465fb29f9ee06c396d550a1d2d63dcdf
parent67f0eb35f6c3fe9bdda3cb585a0fe5e9ccb0e563 (diff)
issue112, enhanced preload functions for photo-index
Signed-off-by: Andreas Unterkircher <unki@netshadow.at>
-rw-r--r--phpfspot.js29
-rw-r--r--themes/default/templates/photo_index.tpl17
2 files changed, 33 insertions, 13 deletions
diff --git a/phpfspot.js b/phpfspot.js
index 89eacba..f9f9703 100644
--- a/phpfspot.js
+++ b/phpfspot.js
@@ -427,23 +427,32 @@ function WSR_getElementsByClassName(oElm, strTagName, oClassNames){
}
-function preloadPhotos(lbImg) {
+function preloadPhotos(image_url) {
- var d=document;
- if(d.images)
- if(!d.photos)
- d.photos=new Array();
-
- var i, j=d.photos.length;
+ var i;
+ var timeout = 1000;
+ var waiting = 100;
+ var counting;
lbImg=WSR_getElementsByClassName(document,"img","thumb");
for(i=0;i<lbImg.length;i++){
- d.photos[j]=new Image;
- d.photos[j].src=lbImg[i].src;
- j++;
+ 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;
+ }
+ }
}
}
+/* a function that does nothing */
+function noop() {}
+
function startSlideShow()
{
if(!sliding) {
diff --git a/themes/default/templates/photo_index.tpl b/themes/default/templates/photo_index.tpl
index 1a1a188..bf235d3 100644
--- a/themes/default/templates/photo_index.tpl
+++ b/themes/default/templates/photo_index.tpl
@@ -50,7 +50,7 @@
<div class="thumb" onmouseover="setBackGrdColor(this, 'mouseover');" onmouseout="setBackGrdColor(this, 'mouseout');" style="width: { $thumb_container_width }px; height: { $thumb_container_height }px;">
<a href="javascript:showImage({$images[thumb]}, 'scrollup');" id="thumblink{$images[thumb]}" name="image{$img_id[thumb]}" class="thumblink" onclick="click(this);" title="{$img_title[thumb]}">
- <img class="thumb" id="thumbimg{$images[thumb]}" src="phpfspot_img.php?idx={$images[thumb]}&amp;width={$width}" alt="thumb_{$images[thumb]}" width="{$img_width[thumb]}" height="{$img_height[thumb]}" />
+ <img class="thumb" id="thumbimg{$images[thumb]}" width="{$img_width[thumb]}" height="{$img_height[thumb]}" />
<br />
{$img_name[thumb]}
</a>
@@ -101,9 +101,20 @@
</div>
</div>
<br class="clearboth" />
-<script type="text/javascript">
+<script type="text/javascript" language="JavaScript">
<!--
- preloadPhotos();
+ { counter start=-1 }
+
+ var current;
+ var image_urls = new Array();
+
+ {section name="thumb" loop=$thumbs step=1}
+ {if $images[thumb] }
+ image_urls[{counter}] = 'phpfspot_img.php?idx={$images[thumb]}&width={$width}';
+ {/if}
+ {/section}
+
+ preloadPhotos(image_urls);
-->
</script>
<!-- /Photo Index -->