View Full Version : Resolved Ultimate Fade-in slideshow (v1.51) - date based image display

04-29-2009, 06:28 PM
1) Script Title: Ultimate Fade-in slideshow (v1.51)

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex14/fadeinslideshow.htm

3) Describe problem: No problem, rather a feature addition/modification

I absolutely LOVE this slideshow. I recently had someone ask me to figure out how to make a particular image in the show start and/or stop displaying as of a specific date.

I saw the thread on changing out the entire image set based on a particular date but do not know enough about JavaScript to make it work for just one of the images.

Is the following code a good starting point? If so, how can I complete the implementation? If not, what would work better?

function autoExpire(){

var expire_date=new Date('+this.theimages[picindex][3]+'); //adds the ability to put the desired date next to the target for each image
var currentTime = new Date();
var month = currentTime.getMonth() + 1;
var day = currentTime.getDate();
var year = currentTime.getFullYear();

var current_date = new Date(month +'/' + day + '/' + year);

if (current_date>=expire_date){
//what to do here???


04-30-2009, 02:17 PM
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:

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):

. . . asbase="canvas"+this.slideshowid
if (typeof displayorder!="undefined")
theimages.sort(function() {return 0.5 - Math.random();}) //thanks to Mike (aka Mwinter) :)
this.postimages=new Array() //preload images
for (p=0;p<theimages.length;p++){
this.postimages[p]=new Image()

var fadewidth=fadewidth+th . . .

04-30-2009, 06:43 PM
Thanks a ton. Sent a little PayPal love your way. It's not much but I really appreciated your help with this.