summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Unterkircher <unki@netshadow.at>2007-07-17 17:37:31 +0000
committerAndreas Unterkircher <unki@netshadow.at>2007-07-17 17:37:31 +0000
commit94bb73ca0d019247d4f08fb03a7f5afc2b5323ee (patch)
treea6f8adfe615fc5c8c64a6641191d6a64d485033c
parentba89e4f0f3526745c9332488d7e05038e33844c6 (diff)
issue45, first learning lessons with image preloading
git-svn-id: file:///var/lib/svn/phpfspot/trunk@218 fa6a889d-dae6-447d-9e79-4ba9a3039384
-rw-r--r--phpfspot.js49
-rw-r--r--templates/photo_index.tpl5
2 files changed, 54 insertions, 0 deletions
diff --git a/phpfspot.js b/phpfspot.js
index 068a96f..58e48de 100644
--- a/phpfspot.js
+++ b/phpfspot.js
@@ -226,6 +226,55 @@ function resetAll()
refreshPhotoIndex();
}
+function WSR_getElementsByClassName(oElm, strTagName, oClassNames){
+ var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
+ var arrReturnElements = new Array();
+ var arrRegExpClassNames = new Array();
+ if(typeof oClassNames == "object"){
+ for(var i=0; i<oClassNames.length; i++){
+ arrRegExpClassNames.push(new RegExp("(^|\s)" + oClassNames[i].replace(/-/g, "\-") + "(\s|$)"));
+ }
+ }
+ else{
+ arrRegExpClassNames.push(new RegExp("(^|\s)" + oClassNames.replace(/-/g, "\-") + "(\s|$)"));
+ }
+ var oElement;
+ var bMatchesAll;
+ for(var j=0; j<arrElements.length; j++){
+ oElement = arrElements[j];
+ bMatchesAll = true;
+ for(var k=0; k<arrRegExpClassNames.length; k++){
+ if(!arrRegExpClassNames[k].test(oElement.className)){
+ bMatchesAll = false;
+ break;
+ }
+ }
+ if(bMatchesAll){
+ arrReturnElements.push(oElement);
+ }
+ }
+ return (arrReturnElements)
+}
+
+
+function preloadPhotos(lbImg) {
+
+ var d=document;
+ if(d.images)
+ if(!d.photos)
+ d.photos=new Array();
+
+ var i, j=d.photos.length;
+
+ 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++;
+ }
+}
+
var startup = 1;
var calendar_shown = 0;
var calendar_mode = '';
+
diff --git a/templates/photo_index.tpl b/templates/photo_index.tpl
index e4ed521..2b4c827 100644
--- a/templates/photo_index.tpl
+++ b/templates/photo_index.tpl
@@ -102,4 +102,9 @@
</td>
</tr>
</table>
+<script type="text/javascript">
+<!--
+ preloadPhotos();
+-->
+</script>
<!-- /Photo Index -->