Results 1 to 3 of 3

Thread: Ultimate Fade-in slideshow (v1.51) - date based image display

  1. #1
    Join Date
    Apr 2009
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question Ultimate Fade-in slideshow (v1.51) - date based image display

    1) Script Title: Ultimate Fade-in slideshow (v1.51)

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...nslideshow.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?
    Code:
    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???
    Thanks!
    Last edited by Snookerman; 04-30-2009 at 06:52 PM. Reason: added “Resolved” prefix

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    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 . . .
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. The Following User Says Thank You to jscheuer1 For This Useful Post:

    dacia121 (04-30-2009)

  4. #3
    Join Date
    Apr 2009
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Thanks a ton. Sent a little PayPal love your way. It's not much but I really appreciated your help with this.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •