diff options
-rw-r--r-- | phpfspot.js | 49 | ||||
-rw-r--r-- | templates/photo_index.tpl | 5 |
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 --> |