Happy Holidays to all of you!
This is my first time posting. I'm working on a web project and trying to get this done before Christmas. The limitation is that I'm using an out of the box program and I don't have the skills to change it quickly, and it only outputs in a structured way... so I am not able to go dig into the code of the out-of-box program and solve it.
This it the first time I've really dug into JS. My JS knowledge is very limited and I could write very simple JS, that is about it. I have a form that I'm building that outputs data in between < script > .... </ script >. The data output begins at number 1 of the array. It is shown below
[CODE=javascript]
<!-- BEGIN OUTPUT FROM MY SITE ***
<script type="text/javascript">
var fadeimages=new Array()
fadeimages[1]=["../Portals/3/PropertiesImage s/thm_host_200712 09_035346.jpg", "http://www.google.com" , ""]
fadeimages[2]=["../Portals/3/PropertiesImage s/thm_host_200712 09_091810.jpg", "http://www.google.com" , ""]
fadeimages[3]=["../Portals/3/PropertiesImage s/thm_host_200712 09_094217.jpg", "http://www.google.com" , ""]
fadeimages[4]=["../Portals/3/PropertiesImage s/thm_host_200712 09_094947.jpg", "http://www.google.com" , ""]
fadeimages[5]=["../Portals/3/PropertiesImage s/thm_host_200712 09_095901.jpg", "http://www.google.com" , ""]
fadeimages[6]=["../Portals/3/PropertiesImage s/thm_host_200712 09_100204.jpg", "http://www.google.com" , ""]
fadeimages[7]=["../Portals/3/PropertiesImage s/thm_host_200712 09_111622.jpg", "http://www.google.com" , ""]
var fadebgcolor="wh ite"
</script>
<script type="text/javascript">
//new fadeshow(IMAGES _ARRAY_NAME, slideshow_width , slideshow_heigh t, borderwidth, delay, pause (0=no, 1=yes), optionalRandomO rder)
new fadeshow(fadeim ages, 140, 225, 0, 3000, 1, "R")
</script>
*** END OUTPUT FROM MY SITE-->
[/CODE]
I copied the JS from this site: http://www.dynamicdrive.com/dynamici...nslideshow.htm
I tried changing this piece of the code:
[CODE=javascript]
for (p=1;p<theimage s.length;p++){
this.postimages[p]=new Image()
this.postimages[p].src=theimages[p][0]
}
[/CODE]
Where p=0, but did not work when I changed to p=1.
Here is the full original source (sorry its long...)
[CODE=javascript]
////NO need to edit beyond here/////////////
var fadearray=new Array() //array to cache fadeshow instances
var fadeclear=new Array() //array to cache corresponding clearinterval pointers
var dom=(document.g etElementById) //modern dom browsers
var iebrowser=docum ent.all
function fadeshow(theima ges, fadewidth, fadeheight, borderwidth, delay, pause, displayorder){
this.pausecheck =pause
this.mouseoverc heck=0
this.delay=dela y
this.degree=10 //initial opacity degree (10%)
this.curimagein dex=0
this.nextimagei ndex=1
fadearray[fadearray.lengt h]=this
this.slideshowi d=fadearray.len gth-1
this.canvasbase ="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
this.imageborde r=parseInt(bord erwidth)
this.postimages =new Array() //preload images
for (p=0;p<theimage s.length;p++){
this.postimages[p]=new Image()
this.postimages[p].src=theimages[p][0]
}
var fadewidth=fadew idth+this.image border*2
var fadeheight=fade height+this.ima geborder*2
if (iebrowser&&dom ||dom) //if IE5+ or modern browsers (ie: Firefox)
document.write( '<div id="master'+thi s.slideshowid+' " style="position :relative;width :'+fadewidth+'p x;height:'+fade height+'px;over flow:hidden;"> <div id="'+this.canv asbase+'_0" style="position :absolute;width :'+fadewidth+'p x;height:'+fade height+'px;top: 0;left:0; filter:progid:D XImageTransform .Microsoft.alph a(opacity=10);o pacity:0.1;-moz-opacity:0.1;-khtml-opacity:0.1; background-color:'+fadebgc olor+'"></div> <div id="'+this.canv asbase+'_1" style="position :absolute;width :'+fadewidth+'p x;height:'+fade height+'px;top: 0;left:0; filter:progid:D XImageTransform .Microsoft.alph a(opacity=10);o pacity:0.1;-moz-opacity:0.1;-khtml-opacity:0.1; background-color:'+fadebgc olor+'"></div></div>')
else
document.write( '<div><img name="defaultsl ide'+this.slide showid+'" src="'+this.pos timages[0].src+'"></div>')
if (iebrowser&&dom ||dom) //if IE5+ or modern browsers such as Firefox
this.startit()
else{
this.curimagein dex++
setInterval("fa dearray["+this.slidesho wid+"].rotateimage()" , this.delay)
}
}
function fadepic(obj){
if (obj.degree<100 ){
obj.degree+=10
if (obj.tempobj.fi lters&&obj.temp obj.filters[0]){
if (typeof obj.tempobj.fil ters[0].opacity=="numb er") //if IE6+
obj.tempobj.fil ters[0].opacity=obj.de gree
else //else if IE5.5-
obj.tempobj.sty le.filter="alph a(opacity="+obj .degree+")"
}
else if (obj.tempobj.st yle.MozOpacity)
obj.tempobj.sty le.MozOpacity=o bj.degree/101
else if (obj.tempobj.st yle.KhtmlOpacit y)
obj.tempobj.sty le.KhtmlOpacity =obj.degree/100
else if (obj.tempobj.st yle.opacity&&!o bj.tempobj.filt ers)
obj.tempobj.sty le.opacity=obj. degree/101
}
else{
clearInterval(f adeclear[obj.slideshowid])
obj.nextcanvas= (obj.curcanvas= =obj.canvasbase +"_0")? obj.canvasbase+ "_0" : obj.canvasbase+ "_1"
obj.tempobj=ieb rowser? iebrowser[obj.nextcanvas] : document.getEle mentById(obj.ne xtcanvas)
obj.populatesli de(obj.tempobj, obj.nextimagein dex)
obj.nextimagein dex=(obj.nextim ageindex<obj.po stimages.length-1)? obj.nextimagein dex+1 : 0
setTimeout("fad earray["+obj.slideshow id+"].rotateimage()" , obj.delay)
}
}
fadeshow.protot ype.populatesli de=function(pic obj, picindex){
var slideHTML=""
if (this.theimages[picindex][1]!="") //if associated link exists for image
slideHTML='<a href="'+this.th eimages[picindex][1]+'" target="'+this. theimages[picindex][2]+'">'
slideHTML+='<im g src="'+this.pos timages[picindex].src+'" border="'+this. imageborder+'px ">'
if (this.theimages[picindex][1]!="") //if associated link exists for image
slideHTML+='</a>'
picobj.innerHTM L=slideHTML
}
fadeshow.protot ype.rotateimage =function(){
if (this.pausechec k==1) //if pause onMouseover enabled, cache object
var cacheobj=this
if (this.mouseover check==1)
setTimeout(func tion(){cacheobj .rotateimage()} , 100)
else if (iebrowser&&dom ||dom){
this.resetit()
var crossobj=this.t empobj=iebrowse r? iebrowser[this.curcanvas] : document.getEle mentById(this.c urcanvas)
crossobj.style. zIndex++
fadeclear[this.slideshowi d]=setInterval("f adepic(fadearra y["+this.slidesho wid+"])",50)
this.curcanvas= (this.curcanvas ==this.canvasba se+"_0")? this.canvasbase +"_1" : this.canvasbase +"_0"
}
else{
var ns4imgobj=docum ent.images['defaultslide'+ this.slideshowi d]
ns4imgobj.src=t his.postimages[this.curimagein dex].src
}
this.curimagein dex=(this.curim ageindex<this.p ostimages.lengt h-1)? this.curimagein dex+1 : 0
}
fadeshow.protot ype.resetit=fun ction(){
this.degree=10
var crossobj=iebrow ser? iebrowser[this.curcanvas] : document.getEle mentById(this.c urcanvas)
if (crossobj.filte rs&&crossobj.fi lters[0]){
if (typeof crossobj.filter s[0].opacity=="numb er") //if IE6+
crossobj.filter s(0).opacity=th is.degree
else //else if IE5.5-
crossobj.style. filter="alpha(o pacity="+this.d egree+")"
}
else if (crossobj.style .MozOpacity)
crossobj.style. MozOpacity=this .degree/101
else if (crossobj.style .KhtmlOpacity)
crossobj.style. KhtmlOpacity=th is.degree/100
else if (crossobj.style .opacity&&!cros sobj.filters)
crossobj.style. opacity=this.de gree/101
}
fadeshow.protot ype.startit=fun ction(){
var crossobj=iebrow ser? iebrowser[this.curcanvas] : document.getEle mentById(this.c urcanvas)
this.populatesl ide(crossobj, this.curimagein dex)
if (this.pausechec k==1){ //IF SLIDESHOW SHOULD PAUSE ONMOUSEOVER
var cacheobj=this
var crossobjcontain er=iebrowser? iebrowser["master"+this.s lideshowid] : document.getEle mentById("maste r"+this.slidesh owid)
crossobjcontain er.onmouseover= function(){cach eobj.mouseoverc heck=1}
crossobjcontain er.onmouseout=f unction(){cache obj.mouseoverch eck=0}
}
this.rotateimag e()
}
</script>
[/CODE]
I hope I'm making sense here.
-Eric
This is my first time posting. I'm working on a web project and trying to get this done before Christmas. The limitation is that I'm using an out of the box program and I don't have the skills to change it quickly, and it only outputs in a structured way... so I am not able to go dig into the code of the out-of-box program and solve it.
This it the first time I've really dug into JS. My JS knowledge is very limited and I could write very simple JS, that is about it. I have a form that I'm building that outputs data in between < script > .... </ script >. The data output begins at number 1 of the array. It is shown below
[CODE=javascript]
<!-- BEGIN OUTPUT FROM MY SITE ***
<script type="text/javascript">
var fadeimages=new Array()
fadeimages[1]=["../Portals/3/PropertiesImage s/thm_host_200712 09_035346.jpg", "http://www.google.com" , ""]
fadeimages[2]=["../Portals/3/PropertiesImage s/thm_host_200712 09_091810.jpg", "http://www.google.com" , ""]
fadeimages[3]=["../Portals/3/PropertiesImage s/thm_host_200712 09_094217.jpg", "http://www.google.com" , ""]
fadeimages[4]=["../Portals/3/PropertiesImage s/thm_host_200712 09_094947.jpg", "http://www.google.com" , ""]
fadeimages[5]=["../Portals/3/PropertiesImage s/thm_host_200712 09_095901.jpg", "http://www.google.com" , ""]
fadeimages[6]=["../Portals/3/PropertiesImage s/thm_host_200712 09_100204.jpg", "http://www.google.com" , ""]
fadeimages[7]=["../Portals/3/PropertiesImage s/thm_host_200712 09_111622.jpg", "http://www.google.com" , ""]
var fadebgcolor="wh ite"
</script>
<script type="text/javascript">
//new fadeshow(IMAGES _ARRAY_NAME, slideshow_width , slideshow_heigh t, borderwidth, delay, pause (0=no, 1=yes), optionalRandomO rder)
new fadeshow(fadeim ages, 140, 225, 0, 3000, 1, "R")
</script>
*** END OUTPUT FROM MY SITE-->
[/CODE]
I copied the JS from this site: http://www.dynamicdrive.com/dynamici...nslideshow.htm
I tried changing this piece of the code:
[CODE=javascript]
for (p=1;p<theimage s.length;p++){
this.postimages[p]=new Image()
this.postimages[p].src=theimages[p][0]
}
[/CODE]
Where p=0, but did not work when I changed to p=1.
Here is the full original source (sorry its long...)
[CODE=javascript]
////NO need to edit beyond here/////////////
var fadearray=new Array() //array to cache fadeshow instances
var fadeclear=new Array() //array to cache corresponding clearinterval pointers
var dom=(document.g etElementById) //modern dom browsers
var iebrowser=docum ent.all
function fadeshow(theima ges, fadewidth, fadeheight, borderwidth, delay, pause, displayorder){
this.pausecheck =pause
this.mouseoverc heck=0
this.delay=dela y
this.degree=10 //initial opacity degree (10%)
this.curimagein dex=0
this.nextimagei ndex=1
fadearray[fadearray.lengt h]=this
this.slideshowi d=fadearray.len gth-1
this.canvasbase ="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
this.imageborde r=parseInt(bord erwidth)
this.postimages =new Array() //preload images
for (p=0;p<theimage s.length;p++){
this.postimages[p]=new Image()
this.postimages[p].src=theimages[p][0]
}
var fadewidth=fadew idth+this.image border*2
var fadeheight=fade height+this.ima geborder*2
if (iebrowser&&dom ||dom) //if IE5+ or modern browsers (ie: Firefox)
document.write( '<div id="master'+thi s.slideshowid+' " style="position :relative;width :'+fadewidth+'p x;height:'+fade height+'px;over flow:hidden;"> <div id="'+this.canv asbase+'_0" style="position :absolute;width :'+fadewidth+'p x;height:'+fade height+'px;top: 0;left:0; filter:progid:D XImageTransform .Microsoft.alph a(opacity=10);o pacity:0.1;-moz-opacity:0.1;-khtml-opacity:0.1; background-color:'+fadebgc olor+'"></div> <div id="'+this.canv asbase+'_1" style="position :absolute;width :'+fadewidth+'p x;height:'+fade height+'px;top: 0;left:0; filter:progid:D XImageTransform .Microsoft.alph a(opacity=10);o pacity:0.1;-moz-opacity:0.1;-khtml-opacity:0.1; background-color:'+fadebgc olor+'"></div></div>')
else
document.write( '<div><img name="defaultsl ide'+this.slide showid+'" src="'+this.pos timages[0].src+'"></div>')
if (iebrowser&&dom ||dom) //if IE5+ or modern browsers such as Firefox
this.startit()
else{
this.curimagein dex++
setInterval("fa dearray["+this.slidesho wid+"].rotateimage()" , this.delay)
}
}
function fadepic(obj){
if (obj.degree<100 ){
obj.degree+=10
if (obj.tempobj.fi lters&&obj.temp obj.filters[0]){
if (typeof obj.tempobj.fil ters[0].opacity=="numb er") //if IE6+
obj.tempobj.fil ters[0].opacity=obj.de gree
else //else if IE5.5-
obj.tempobj.sty le.filter="alph a(opacity="+obj .degree+")"
}
else if (obj.tempobj.st yle.MozOpacity)
obj.tempobj.sty le.MozOpacity=o bj.degree/101
else if (obj.tempobj.st yle.KhtmlOpacit y)
obj.tempobj.sty le.KhtmlOpacity =obj.degree/100
else if (obj.tempobj.st yle.opacity&&!o bj.tempobj.filt ers)
obj.tempobj.sty le.opacity=obj. degree/101
}
else{
clearInterval(f adeclear[obj.slideshowid])
obj.nextcanvas= (obj.curcanvas= =obj.canvasbase +"_0")? obj.canvasbase+ "_0" : obj.canvasbase+ "_1"
obj.tempobj=ieb rowser? iebrowser[obj.nextcanvas] : document.getEle mentById(obj.ne xtcanvas)
obj.populatesli de(obj.tempobj, obj.nextimagein dex)
obj.nextimagein dex=(obj.nextim ageindex<obj.po stimages.length-1)? obj.nextimagein dex+1 : 0
setTimeout("fad earray["+obj.slideshow id+"].rotateimage()" , obj.delay)
}
}
fadeshow.protot ype.populatesli de=function(pic obj, picindex){
var slideHTML=""
if (this.theimages[picindex][1]!="") //if associated link exists for image
slideHTML='<a href="'+this.th eimages[picindex][1]+'" target="'+this. theimages[picindex][2]+'">'
slideHTML+='<im g src="'+this.pos timages[picindex].src+'" border="'+this. imageborder+'px ">'
if (this.theimages[picindex][1]!="") //if associated link exists for image
slideHTML+='</a>'
picobj.innerHTM L=slideHTML
}
fadeshow.protot ype.rotateimage =function(){
if (this.pausechec k==1) //if pause onMouseover enabled, cache object
var cacheobj=this
if (this.mouseover check==1)
setTimeout(func tion(){cacheobj .rotateimage()} , 100)
else if (iebrowser&&dom ||dom){
this.resetit()
var crossobj=this.t empobj=iebrowse r? iebrowser[this.curcanvas] : document.getEle mentById(this.c urcanvas)
crossobj.style. zIndex++
fadeclear[this.slideshowi d]=setInterval("f adepic(fadearra y["+this.slidesho wid+"])",50)
this.curcanvas= (this.curcanvas ==this.canvasba se+"_0")? this.canvasbase +"_1" : this.canvasbase +"_0"
}
else{
var ns4imgobj=docum ent.images['defaultslide'+ this.slideshowi d]
ns4imgobj.src=t his.postimages[this.curimagein dex].src
}
this.curimagein dex=(this.curim ageindex<this.p ostimages.lengt h-1)? this.curimagein dex+1 : 0
}
fadeshow.protot ype.resetit=fun ction(){
this.degree=10
var crossobj=iebrow ser? iebrowser[this.curcanvas] : document.getEle mentById(this.c urcanvas)
if (crossobj.filte rs&&crossobj.fi lters[0]){
if (typeof crossobj.filter s[0].opacity=="numb er") //if IE6+
crossobj.filter s(0).opacity=th is.degree
else //else if IE5.5-
crossobj.style. filter="alpha(o pacity="+this.d egree+")"
}
else if (crossobj.style .MozOpacity)
crossobj.style. MozOpacity=this .degree/101
else if (crossobj.style .KhtmlOpacity)
crossobj.style. KhtmlOpacity=th is.degree/100
else if (crossobj.style .opacity&&!cros sobj.filters)
crossobj.style. opacity=this.de gree/101
}
fadeshow.protot ype.startit=fun ction(){
var crossobj=iebrow ser? iebrowser[this.curcanvas] : document.getEle mentById(this.c urcanvas)
this.populatesl ide(crossobj, this.curimagein dex)
if (this.pausechec k==1){ //IF SLIDESHOW SHOULD PAUSE ONMOUSEOVER
var cacheobj=this
var crossobjcontain er=iebrowser? iebrowser["master"+this.s lideshowid] : document.getEle mentById("maste r"+this.slidesh owid)
crossobjcontain er.onmouseover= function(){cach eobj.mouseoverc heck=1}
crossobjcontain er.onmouseout=f unction(){cache obj.mouseoverch eck=0}
}
this.rotateimag e()
}
</script>
[/CODE]
I hope I'm making sense here.
-Eric
Comment