Brad
05-12-2006, 03:40 PM
Ultimate Fade-in Slideshow (v1.5)
http://www.dynamicdrive.com/dynamicindex14/fadeinslideshow.htm
-----(SEE POST #3 FOR AN UPDATED VERSION)-----
After reading some JavaScript tutorials and doing a lot of searches on Google, this is what I came up with to start the Ultimate Fade-in slideshow on command. It may not be the best way to do this but it works for me. (I am still learning about JavaScript.) Anyone is welcome to improve upon it or point out any errors or problems. I cannot post the entire code because it is too big for the size limit so I will just show what I changed.
THIS VERSION INCLUDES:
• Ability to start the slideshow by calling the function "startslideshow()"
• Optional "startdelay" for each slideshow. Set to "0" to disable.
• Note: More than 10 slideshows will require additional modification.
The first "IMAGES_ARRAY_NAME" must be "fadeimages" and continue with "fadeimages2" through "fadeimages10" in that order. Do not skip a number. Also do not use "fadeimages1"
Now you can decide how and when to start the slideshow
onload, onclick of something, etc.
REPLACE:
function fadeshow(theimages, fadewidth, fadeheight, borderwidth, delay, pause, displayorder){
WITH:
function fadeshow(theimages, fadewidth, fadeheight, borderwidth, delay, pause, startdelay, displayorder){
________________________________________
REPLACE:
if (iebrowser&&dom||dom) //if IE5+ or modern browsers such as Firefox
this.startit()
else{
this.curimageindex++
setInterval("fadearray["+this.slideshowid+"].rotateimage()", this.delay)
}
}
WITH:
if (this.theimages==fadeimages) //assigns each instance of "this" it's own global variable for use with "setTimeout"
theinstance=this
else if (this.theimages==fadeimages2)
theinstance2=this
else if (this.theimages==fadeimages3)
theinstance3=this
else if (this.theimages==fadeimages4)
theinstance4=this
else if (this.theimages==fadeimages5)
theinstance5=this
else if (this.theimages==fadeimages6)
theinstance6=this
else if (this.theimages==fadeimages7)
theinstance7=this
else if (this.theimages==fadeimages8)
theinstance8=this
else if (this.theimages==fadeimages9)
theinstance9=this
else if (this.theimages==fadeimages10)
theinstance10=this
else { //nothing
}
this.startdelay=startdelay
startsignal=null
this.waitforsignal()
}
function startslideshow(){ //CALL THIS FUNCTION TO START THE SLIDESHOW
startsignal=1 //changes value of "startsignal" global variable
}
fadeshow.prototype.waitforsignal=function(){ //function loops every 0.25 seconds until "startsignal" equals "1"
if (this.theimages==fadeimages){
if (startsignal==1)
setTimeout(function(){theinstance.beginslideshow()}, theinstance.startdelay)
else
setTimeout(function(){theinstance.waitforsignal()}, 250)
}
else if (this.theimages==fadeimages2){
if (startsignal==1)
setTimeout(function(){theinstance2.beginslideshow()}, theinstance2.startdelay)
else
setTimeout(function(){theinstance2.waitforsignal()}, 250)
}
else if (this.theimages==fadeimages3){
if (startsignal==1)
setTimeout(function(){theinstance3.beginslideshow()}, theinstance3.startdelay)
else
setTimeout(function(){theinstance3.waitforsignal()}, 250)
}
else if (this.theimages==fadeimages4){
if (startsignal==1)
setTimeout(function(){theinstance4.beginslideshow()}, theinstance4.startdelay)
else
setTimeout(function(){theinstance4.waitforsignal()}, 250)
}
else if (this.theimages==fadeimages5){
if (startsignal==1)
setTimeout(function(){theinstance5.beginslideshow()}, theinstance5.startdelay)
else
setTimeout(function(){theinstance5.waitforsignal()}, 250)
}
else if (this.theimages==fadeimages6){
if (startsignal==1)
setTimeout(function(){theinstance6.beginslideshow()}, theinstance6.startdelay)
else
setTimeout(function(){theinstance6.waitforsignal()}, 250)
}
else if (this.theimages==fadeimages7){
if (startsignal==1)
setTimeout(function(){theinstance7.beginslideshow()}, theinstance7.startdelay)
else
setTimeout(function(){theinstance7.waitforsignal()}, 250)
}
else if (this.theimages==fadeimages8){
if (startsignal==1)
setTimeout(function(){theinstance8.beginslideshow()}, theinstance8.startdelay)
else
setTimeout(function(){theinstance8.waitforsignal()}, 250)
}
else if (this.theimages==fadeimages9){
if (startsignal==1)
setTimeout(function(){theinstance9.beginslideshow()}, theinstance9.startdelay)
else
setTimeout(function(){theinstance9.waitforsignal()}, 250)
}
else if (this.theimages==fadeimages10){
if (startsignal==1)
setTimeout(function(){theinstance10.beginslideshow()}, theinstance10.startdelay)
else
setTimeout(function(){theinstance10.waitforsignal()}, 250)
}
else { //nothing
}
}
fadeshow.prototype.beginslideshow=function(){
if (iebrowser&&dom||dom) //if IE5+ or modern browsers such as Firefox
this.startit()
else{
this.curimageindex++
setInterval("fadearray["+this.slideshowid+"].rotateimage()", this.delay)
}
}
________________________________________
GOES IN THE BODY:
<script type="text/javascript">
/*
!!!IMPORTANT!!!
The first "IMAGES_ARRAY_NAME" must be "fadeimages"
and continue with "fadeimages2" through "fadeimages10"
in that order. Do not skip a number. Also do not use "fadeimages1"
Added optional "startdelay" for each slideshow. Set to "0" to disable.
Note: More than 10 slideshows will require additional modification.
*/
//new fadeshow(IMAGES_ARRAY_NAME, slideshow_width, slideshow_height, borderwidth, delay, pause, startdelay, optionalRandomOrder)
new fadeshow(fadeimages, 140, 225, 1, 3000, 1, 0, "R")
new fadeshow(fadeimages2, 140, 225, 0, 5000, 0, 1000)
</script>
<script type="text/javascript">
startslideshow() //STARTS THE SLIDESHOW
/*
Now you can decide how and when to start the slideshow
onload, onclick of something, etc.
*/
</script>
http://www.dynamicdrive.com/dynamicindex14/fadeinslideshow.htm
-----(SEE POST #3 FOR AN UPDATED VERSION)-----
After reading some JavaScript tutorials and doing a lot of searches on Google, this is what I came up with to start the Ultimate Fade-in slideshow on command. It may not be the best way to do this but it works for me. (I am still learning about JavaScript.) Anyone is welcome to improve upon it or point out any errors or problems. I cannot post the entire code because it is too big for the size limit so I will just show what I changed.
THIS VERSION INCLUDES:
• Ability to start the slideshow by calling the function "startslideshow()"
• Optional "startdelay" for each slideshow. Set to "0" to disable.
• Note: More than 10 slideshows will require additional modification.
The first "IMAGES_ARRAY_NAME" must be "fadeimages" and continue with "fadeimages2" through "fadeimages10" in that order. Do not skip a number. Also do not use "fadeimages1"
Now you can decide how and when to start the slideshow
onload, onclick of something, etc.
REPLACE:
function fadeshow(theimages, fadewidth, fadeheight, borderwidth, delay, pause, displayorder){
WITH:
function fadeshow(theimages, fadewidth, fadeheight, borderwidth, delay, pause, startdelay, displayorder){
________________________________________
REPLACE:
if (iebrowser&&dom||dom) //if IE5+ or modern browsers such as Firefox
this.startit()
else{
this.curimageindex++
setInterval("fadearray["+this.slideshowid+"].rotateimage()", this.delay)
}
}
WITH:
if (this.theimages==fadeimages) //assigns each instance of "this" it's own global variable for use with "setTimeout"
theinstance=this
else if (this.theimages==fadeimages2)
theinstance2=this
else if (this.theimages==fadeimages3)
theinstance3=this
else if (this.theimages==fadeimages4)
theinstance4=this
else if (this.theimages==fadeimages5)
theinstance5=this
else if (this.theimages==fadeimages6)
theinstance6=this
else if (this.theimages==fadeimages7)
theinstance7=this
else if (this.theimages==fadeimages8)
theinstance8=this
else if (this.theimages==fadeimages9)
theinstance9=this
else if (this.theimages==fadeimages10)
theinstance10=this
else { //nothing
}
this.startdelay=startdelay
startsignal=null
this.waitforsignal()
}
function startslideshow(){ //CALL THIS FUNCTION TO START THE SLIDESHOW
startsignal=1 //changes value of "startsignal" global variable
}
fadeshow.prototype.waitforsignal=function(){ //function loops every 0.25 seconds until "startsignal" equals "1"
if (this.theimages==fadeimages){
if (startsignal==1)
setTimeout(function(){theinstance.beginslideshow()}, theinstance.startdelay)
else
setTimeout(function(){theinstance.waitforsignal()}, 250)
}
else if (this.theimages==fadeimages2){
if (startsignal==1)
setTimeout(function(){theinstance2.beginslideshow()}, theinstance2.startdelay)
else
setTimeout(function(){theinstance2.waitforsignal()}, 250)
}
else if (this.theimages==fadeimages3){
if (startsignal==1)
setTimeout(function(){theinstance3.beginslideshow()}, theinstance3.startdelay)
else
setTimeout(function(){theinstance3.waitforsignal()}, 250)
}
else if (this.theimages==fadeimages4){
if (startsignal==1)
setTimeout(function(){theinstance4.beginslideshow()}, theinstance4.startdelay)
else
setTimeout(function(){theinstance4.waitforsignal()}, 250)
}
else if (this.theimages==fadeimages5){
if (startsignal==1)
setTimeout(function(){theinstance5.beginslideshow()}, theinstance5.startdelay)
else
setTimeout(function(){theinstance5.waitforsignal()}, 250)
}
else if (this.theimages==fadeimages6){
if (startsignal==1)
setTimeout(function(){theinstance6.beginslideshow()}, theinstance6.startdelay)
else
setTimeout(function(){theinstance6.waitforsignal()}, 250)
}
else if (this.theimages==fadeimages7){
if (startsignal==1)
setTimeout(function(){theinstance7.beginslideshow()}, theinstance7.startdelay)
else
setTimeout(function(){theinstance7.waitforsignal()}, 250)
}
else if (this.theimages==fadeimages8){
if (startsignal==1)
setTimeout(function(){theinstance8.beginslideshow()}, theinstance8.startdelay)
else
setTimeout(function(){theinstance8.waitforsignal()}, 250)
}
else if (this.theimages==fadeimages9){
if (startsignal==1)
setTimeout(function(){theinstance9.beginslideshow()}, theinstance9.startdelay)
else
setTimeout(function(){theinstance9.waitforsignal()}, 250)
}
else if (this.theimages==fadeimages10){
if (startsignal==1)
setTimeout(function(){theinstance10.beginslideshow()}, theinstance10.startdelay)
else
setTimeout(function(){theinstance10.waitforsignal()}, 250)
}
else { //nothing
}
}
fadeshow.prototype.beginslideshow=function(){
if (iebrowser&&dom||dom) //if IE5+ or modern browsers such as Firefox
this.startit()
else{
this.curimageindex++
setInterval("fadearray["+this.slideshowid+"].rotateimage()", this.delay)
}
}
________________________________________
GOES IN THE BODY:
<script type="text/javascript">
/*
!!!IMPORTANT!!!
The first "IMAGES_ARRAY_NAME" must be "fadeimages"
and continue with "fadeimages2" through "fadeimages10"
in that order. Do not skip a number. Also do not use "fadeimages1"
Added optional "startdelay" for each slideshow. Set to "0" to disable.
Note: More than 10 slideshows will require additional modification.
*/
//new fadeshow(IMAGES_ARRAY_NAME, slideshow_width, slideshow_height, borderwidth, delay, pause, startdelay, optionalRandomOrder)
new fadeshow(fadeimages, 140, 225, 1, 3000, 1, 0, "R")
new fadeshow(fadeimages2, 140, 225, 0, 5000, 0, 1000)
</script>
<script type="text/javascript">
startslideshow() //STARTS THE SLIDESHOW
/*
Now you can decide how and when to start the slideshow
onload, onclick of something, etc.
*/
</script>