K
kidders
Below is a script i need to modify to work and its driving me nuts.
Essentially it fades the content of an array. The original script
specified the object name, I tried to modify it to allow an object to
be passed instead as there are two fading areas on the page code
below, to be honest I could see absolutely no reason why but im not
that offay with javascript so this could be down to me.
Deadlines are getting tight on this one so not bothered how its done
but i need to be able to have fading content on the two specified
areas, one statscroller the other newscroller. The second content
array has been setup, news_fcontent, but it not used.
Any help is greatly appreciated.
<script type="text/javascript">
/***********************************************
* Fading Scroller- © Dynamic Drive DHTML code library
(www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source
code
************************************************/
var statsdelay = 3000; //set statsdelay between message change
(in miliseconds)
var statsmaxsteps=30; // number of steps to take to change from start
color to endcolor
var stepstatsdelay=50; // time in miliseconds of a single step
//**Note: statsmaxsteps*stepstatsdelay will be total time in
miliseconds of fading effect
var startcolor= new Array(148,189,235); // start color (red, green,
blue)
var endcolor=new Array(0,0,0); // end color (red, green, blue)
var stats_fcontent=new Array();
stats_fcontent[0]='<div class="fading_banner1"><span class="title">'
+ <%= _totalValue %> + '</span><br/><span class="body">of jewellery
valued so far!</span></div>';
stats_fcontent[1]='<div class="fading_banner1"><span class="title">'
+ <%= _totalCustomers %> + '</span><br/><span class="body">customers
now protected!</span></div>';
stats_fcontent[2]='<div class="fading_banner2"><span
class="title">Working in association with</span><br /><br /><img
src="../images/national_association_gsmiths.jpg" alt="National
Association of Goldsmiths" /></div>';
var news_fcontent=new Array();
news_fcontent[0]='<div class="news_item"><div class="news_text">' + <
%= _header1 %> + '<br />' + <%= _body1 %> + '<br /><a href="' + <%=
_href1 %> + '">More....</a></div><span class="image"><img src="' + <%=
_imgSrc1 %> + '" /></span></div>';
news_fcontent[1]='<div class="news_item"><div class="news_text">' + <
%= _header2 %> + '<br />' + <%= _body2 %> + '<br /><a href="' + <%=
_href2 %> + '">More....</a></div><span class="image"><img src="' + <%=
_imgSrc2 %> + '" /></span></div>';
news_fcontent[2]='<div class="news_item"><div class="news_text">' + <
%= _header3 %> + '<br />' + <%= _body3 %> + '<br /><a href="' + <%=
_href3 %> + '">More....</a></div><span class="image"><img src="' + <%=
_imgSrc3 %> + '" /></span></div>';
var _fade_links=1; //should links inside scroller content also fade
like text? 0 for no, 1 for yes.
var _ie4=document.all&&!document.getElementById;
var _DOM2=document.getElementById;
var faderstatsdelay=0;
var _index=0;
stats_changecontent;
/*Rafael Raposo edited function*/
//function to change content
function stats_changecontent(){
if (_index>=stats_fcontent.length)
_index=0
if (_DOM2){
document.getElementById("statscroller").style.color="rgb("+startcolor[0]+",
"+startcolor[1]+", "+startcolor[2]+")";
document.getElementById("statscroller").innerHTML=stats_fcontent[_index];
if (_fade_links)
stats_linkcolorchange(1);
stats_colorfade(1, 15);
}
else if (_ie4)
document.all.statscroller.innerHTML=stats_fcontent[_index]
_index++
}
// stats_colorfade() partially by Marcio Galli for Netscape
Communications. ////////////
// Modified by Dynamicdrive.com
function stats_linkcolorchange(step){
var
obj=document.getElementById("statscroller").getElementsByTagName("A");
if (obj.length>0){
for (i=0;i<obj.length;i++)
obj.style.color=stats_getstepcolor(step);
}
}
/*Rafael Raposo edited function*/
var _fadecounter;
function stats_colorfade(step) {
if(step<=statsmaxsteps) {
document.getElementById("statscroller").style.color=stats_getstepcolor(step);
if (_fade_links)
stats_linkcolorchange(step);
step++;
_fadecounter=setTimeout("stats_colorfade("+step+")",stepstatsdelay);
}else{
clearTimeout(_fadecounter);
document.getElementById("statscroller").style.color="rgb("+endcolor[0]+",
"+endcolor[1]+", "+endcolor[2]+")";
setTimeout("stats_changecontent()", statsdelay);
}
}
/*Rafael Raposo's new function*/
function stats_getstepcolor(step) {
var diff
var newcolor=new Array(3);
for(var i=0;i<3;i++) {
diff = (startcolor-endcolor);
if(diff > 0) {
newcolor = startcolor-(Math.round((diff/
statsmaxsteps))*step);
} else {
newcolor = startcolor+(Math.round((Math.abs(diff)/
statsmaxsteps))*step);
}
}
return ("rgb(" + newcolor[0] + ", " + newcolor[1] + ", " +
newcolor[2] + ")");
}
if (window.addEventListener)
window.addEventListener("load", stats_changecontent, false)
else if (window.attachEvent)
window.attachEvent("onload", stats_changecontent)
else if (document.getElementById)
window.onload=stats_changecontent
</script>
<div class="header">LATEST NEWS....</div>
<div id="newscroller" class="news_item"/>
Essentially it fades the content of an array. The original script
specified the object name, I tried to modify it to allow an object to
be passed instead as there are two fading areas on the page code
below, to be honest I could see absolutely no reason why but im not
that offay with javascript so this could be down to me.
Deadlines are getting tight on this one so not bothered how its done
but i need to be able to have fading content on the two specified
areas, one statscroller the other newscroller. The second content
array has been setup, news_fcontent, but it not used.
Any help is greatly appreciated.
<script type="text/javascript">
/***********************************************
* Fading Scroller- © Dynamic Drive DHTML code library
(www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source
code
************************************************/
var statsdelay = 3000; //set statsdelay between message change
(in miliseconds)
var statsmaxsteps=30; // number of steps to take to change from start
color to endcolor
var stepstatsdelay=50; // time in miliseconds of a single step
//**Note: statsmaxsteps*stepstatsdelay will be total time in
miliseconds of fading effect
var startcolor= new Array(148,189,235); // start color (red, green,
blue)
var endcolor=new Array(0,0,0); // end color (red, green, blue)
var stats_fcontent=new Array();
stats_fcontent[0]='<div class="fading_banner1"><span class="title">'
+ <%= _totalValue %> + '</span><br/><span class="body">of jewellery
valued so far!</span></div>';
stats_fcontent[1]='<div class="fading_banner1"><span class="title">'
+ <%= _totalCustomers %> + '</span><br/><span class="body">customers
now protected!</span></div>';
stats_fcontent[2]='<div class="fading_banner2"><span
class="title">Working in association with</span><br /><br /><img
src="../images/national_association_gsmiths.jpg" alt="National
Association of Goldsmiths" /></div>';
var news_fcontent=new Array();
news_fcontent[0]='<div class="news_item"><div class="news_text">' + <
%= _header1 %> + '<br />' + <%= _body1 %> + '<br /><a href="' + <%=
_href1 %> + '">More....</a></div><span class="image"><img src="' + <%=
_imgSrc1 %> + '" /></span></div>';
news_fcontent[1]='<div class="news_item"><div class="news_text">' + <
%= _header2 %> + '<br />' + <%= _body2 %> + '<br /><a href="' + <%=
_href2 %> + '">More....</a></div><span class="image"><img src="' + <%=
_imgSrc2 %> + '" /></span></div>';
news_fcontent[2]='<div class="news_item"><div class="news_text">' + <
%= _header3 %> + '<br />' + <%= _body3 %> + '<br /><a href="' + <%=
_href3 %> + '">More....</a></div><span class="image"><img src="' + <%=
_imgSrc3 %> + '" /></span></div>';
var _fade_links=1; //should links inside scroller content also fade
like text? 0 for no, 1 for yes.
var _ie4=document.all&&!document.getElementById;
var _DOM2=document.getElementById;
var faderstatsdelay=0;
var _index=0;
stats_changecontent;
/*Rafael Raposo edited function*/
//function to change content
function stats_changecontent(){
if (_index>=stats_fcontent.length)
_index=0
if (_DOM2){
document.getElementById("statscroller").style.color="rgb("+startcolor[0]+",
"+startcolor[1]+", "+startcolor[2]+")";
document.getElementById("statscroller").innerHTML=stats_fcontent[_index];
if (_fade_links)
stats_linkcolorchange(1);
stats_colorfade(1, 15);
}
else if (_ie4)
document.all.statscroller.innerHTML=stats_fcontent[_index]
_index++
}
// stats_colorfade() partially by Marcio Galli for Netscape
Communications. ////////////
// Modified by Dynamicdrive.com
function stats_linkcolorchange(step){
var
obj=document.getElementById("statscroller").getElementsByTagName("A");
if (obj.length>0){
for (i=0;i<obj.length;i++)
obj.style.color=stats_getstepcolor(step);
}
}
/*Rafael Raposo edited function*/
var _fadecounter;
function stats_colorfade(step) {
if(step<=statsmaxsteps) {
document.getElementById("statscroller").style.color=stats_getstepcolor(step);
if (_fade_links)
stats_linkcolorchange(step);
step++;
_fadecounter=setTimeout("stats_colorfade("+step+")",stepstatsdelay);
}else{
clearTimeout(_fadecounter);
document.getElementById("statscroller").style.color="rgb("+endcolor[0]+",
"+endcolor[1]+", "+endcolor[2]+")";
setTimeout("stats_changecontent()", statsdelay);
}
}
/*Rafael Raposo's new function*/
function stats_getstepcolor(step) {
var diff
var newcolor=new Array(3);
for(var i=0;i<3;i++) {
diff = (startcolor-endcolor);
if(diff > 0) {
newcolor = startcolor-(Math.round((diff/
statsmaxsteps))*step);
} else {
newcolor = startcolor+(Math.round((Math.abs(diff)/
statsmaxsteps))*step);
}
}
return ("rgb(" + newcolor[0] + ", " + newcolor[1] + ", " +
newcolor[2] + ")");
}
if (window.addEventListener)
window.addEventListener("load", stats_changecontent, false)
else if (window.attachEvent)
window.attachEvent("onload", stats_changecontent)
else if (document.getElementById)
window.onload=stats_changecontent
</script>
<div class="header">LATEST NEWS....</div>
<div id="newscroller" class="news_item"/>
<br />
<div id="statscroller" /><br />