Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Feb 2003
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Slideshow from variable images

    I have some code for displaying the day's comics. Here it is:

    <script language="JavaScript"><!--
    var today=new Date();var thismonth=today.getMonth()+1;var thisyear=today.getYear();var thisday=today.getDate();
    function comicwrite(year,month,day,name) {
    var tempmonth;var shortyear;
    if(year<1900) {year=year+1900;}
    if(year>2000) {shortyear ="0"+(year-2000);}
    else {shortyear=""+(year-1900);}
    var montharray=new Array(31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
    if(month>1) {tempmonth=month-1;} else {tempmonth=12;}
    var maxdays=montharray[tempmonth-1];
    if(tempmonth==2) {if(year % 100 == 0) {if(year % 400 == 0) { maxdays=29; }}
    else {if((year%4)==0) {maxdays=29;}}}
    if(day>1) {day--;}
    else {if(month>1) {month--;day=maxdays;} else {month=12;year--;day=maxdays;}}
    if(day < 10) {day ="0"+day;}
    else {day = ""+day;}
    if(month < 10) {month="0"+month;}
    else {month = ""+month;}
    document.write("<p><a href=http://images.ucomics.com/comics/"+name+"/"+year+"/"+name+shortyear+month+day+".gif target=_blank><img src=http://images.ucomics.com/comics/"+name+"/"+year+"/"+name+shortyear+month+day+".gif border=0></a></p>");
    }
    comicwrite(thisyear,thismonth,thisday,"ga");
    comicwrite(thisyear,thismonth,thisday,"zi");
    // --></script>

    What I want to do is, take those comic strips, and add them to a slideshow on the same page. I'm having a little trouble doing that, but I found a good slideshow script at dynamic drive: http://dynamicdrive.com/dynamicindex14/image4.htm

    Any slideshow script is fine but I need it to work with the comic script above. If you decide to show me how to do it with another script, please make sure its nothing fancy, either like the one at the link or one where it just simply changes.
    AgaBoogaBoo
    _____________________
    ankygupta@hotmail.com

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If you like you can use my slideshow, it can be comlpicated or simple, as the 4 examples show, you have a lot of control over displaying it and allowing the user to interact with it.
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Location
    Atlanta, GA.
    Posts
    313
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Maybe this code will help. It displays all the cartoons from a given date up to today. Now all you need to do is incorperate it into a slideshow script. Just replace the document.writes with the code to add images to a slideshow. One thing though, when I ran this I noticed not all the images are the same size. Might be a problem with some slide shows.

    Code:
    <HTML>
    <HEAD>
    <TITLE>Test</TITLE>
    </HEAD>
    <BODY>
    <script>
    function twoDigit(n)
    {
    	return (n > 9) ? n : "0" + n;
    }
    function displayImages(d, name)
    {
    	var today = new Date();
    	for(var x = d.getTime(); x<today.getTime() ; x+=86400000)
    	{
    		var dt = new Date(x);
    		var year  = dt.getYear();
    		var month 	= twoDigit(dt.getMonth() + 1);
    		var day   	= twoDigit(dt.getDate());
    		var shortyear	= twoDigit(year % 100);
    
    		document.write(month + "/" +day + "/" + year + " => ");
    		document.write("src=http://images.ucomics.com/comics/"+name+"/"+year+"/"+name+shortyear+month+day+".gif<br>"); 
    		document.write("<img src=http://images.ucomics.com/comics/"+name+"/"+year+"/"+name+shortyear+month+day+".gif><br>"); 
    	}
    }
    //displayImages(new Date(YYYY, MM, DD), name)
    //Note Month = 0 to 11 for Jan to Dec
    displayImages(new Date(2003,0,1), "ga");
    displayImages(new Date(2003,1,10), "zi");
    
    </script>
    </BODY>
    </HTML>
    The answer does not come from thinking outside the box, it comes from realizing the truth :-
    "There Is No Box". [JavaScript Gadgets'n'Gizmos][JavaScript-FX]

  • #4
    New Coder
    Join Date
    Feb 2003
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Can you give me an example or show me what you mean? I'm a little confused as to how it would work, would I make the address of the image a variable and then use a variable inside a variable in the slideshow script?

    If so, can you show me how to combine those two scripts working?
    AgaBoogaBoo
    _____________________
    ankygupta@hotmail.com

  • #5
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ok, so the slideshow would go from day to day with this? Like you'd see today, then yesterday, then the day before?
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”

  • #6
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I knew I made all my javascript classes for a reason! they sure made this easy. Using my Date class and my Slideshow class, I wrote a quick interface accessing both to create this page. Took me 10 minutes

    What do you think?

    Do you have permission from Ucomics to leech err, syndicate their content? (which is probably syndicated by somebody else...)
    Last edited by beetle; 02-24-2003 at 11:45 PM.
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”

  • #7
    New Coder
    Join Date
    Feb 2003
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cool

    Thats awesome!!!! Thanks a lot man, I woulda spent 10 hours on that. Thanks again!
    AgaBoogaBoo
    _____________________
    ankygupta@hotmail.com


  •  

    Posting Permissions

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