It's a good beginning. It should be a prototype function though (in order to fit in with the structure of the script), and should iterate over the array:
Code:
fadeshow.prototype.autoExpire = function(){
var current_date = new Date();
for (var i = this.theimages.length - 1; i > -1; --i){
if (current_date >= new Date(this.theimages[i][3])){
this.theimages.splice(i, 1);
}
}
}
Now where to use it? I mean the code itself can go at the end of the main script, but where in the main script should it be invoked? Obviously before the image preload array is created, otherwise the images will not synchronise with the rest of the array if any have expired.
In the fadeshow function here should be good (addition highlighted):
Code:
. . . asbase="canvas"+this.slideshowid
this.curcanvas=this.canvasbase+"_0"
if (typeof displayorder!="undefined")
theimages.sort(function() {return 0.5 - Math.random();}) //thanks to Mike (aka Mwinter) :)
this.theimages=theimages
if([].splice)
this.autoExpire();
this.imageborder=parseInt(borderwidth)
this.postimages=new Array() //preload images
for (p=0;p<theimages.length;p++){
this.postimages[p]=new Image()
this.postimages[p].src=theimages[p][0]
}
var fadewidth=fadewidth+th . . .
Bookmarks