View Full Version : Slideshow from variable images

02-23-2003, 10:04 PM
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>");
// --></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.

02-24-2003, 05:00 PM
If you like you can use my slideshow (http://www.peterbailey.net/dhtml/oo_slideshow.htm), 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.

02-24-2003, 08:02 PM
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.

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("<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");


02-24-2003, 10:57 PM
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?

02-24-2003, 11:30 PM
Ok, so the slideshow would go from day to day with this? Like you'd see today, then yesterday, then the day before?

02-25-2003, 12:30 AM
I knew I made all my javascript classes (http://www.peterbailey.net/site/dev/jsclasses) 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 (http://www.peterbailey.net/dhtml/ss_test.htm). 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...) :D

02-25-2003, 01:56 AM
Thats awesome!!!! Thanks a lot man, I woulda spent 10 hours on that. Thanks again!