summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Unterkircher <unki@netshadow.at>2008-03-29 12:11:33 +0100
committerAndreas Unterkircher <unki@netshadow.at>2008-03-29 12:11:33 +0100
commitb7a43526958fc12ce7d0e42b8023db52cb25f140 (patch)
tree1badbdc3ad3e1588faf0c5e0b43738cbb7007fcd
parent38b33998a89dc05f4fc7c90ba6eabb29301f131a (diff)
parent072aed3d53445a6b09edabf1551706de4c3f1cb1 (diff)
Merge branch 'master' into nefformat
-rw-r--r--phpfspot.class.php1
-rw-r--r--phpfspot.js29
-rw-r--r--themes/default/templates/photo_index.tpl17
-rw-r--r--themes/default/templates/single_photo.tpl7
4 files changed, 41 insertions, 13 deletions
diff --git a/phpfspot.class.php b/phpfspot.class.php
index 8260cc9..b5034e7 100644
--- a/phpfspot.class.php
+++ b/phpfspot.class.php
@@ -546,6 +546,7 @@ class PHPFSPOT {
$this->tmpl->assign('next_img', $next_img);
}
$this->tmpl->assign('mini_width', $this->cfg->mini_width);
+ $this->tmpl->assign('photo_width', $this->cfg->photo_width);
$this->tmpl->assign('photo_number', $i);
$this->tmpl->assign('photo_count', count($all_photos));
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 -->
diff --git a/themes/default/templates/single_photo.tpl b/themes/default/templates/single_photo.tpl
index ea513d9..a16776e 100644
--- a/themes/default/templates/single_photo.tpl
+++ b/themes/default/templates/single_photo.tpl
@@ -103,6 +103,13 @@
<!--
if(autobrowse && document.getElementById("autobrowse_ico"))
document.getElementById("autobrowse_ico").src = 'resources/32_pause.png';
+
+ /* lets preload to previous and the next image to speedup */
+ var image_next = new Image();
+ image_next.src = "phpfspot_img.php?idx={$next_img}&width={$photo_width}";
+ var image_prev = new Image();
+ image_prev.src = "phpfspot_img.php?idx={$prev_img}&width={$photo_width}";
+
-->
</script>
<!-- /Single photo -->