Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title></title>
</head>
<body>
<a id="tst" style="font-Size:30px;" >
Welcome to Dynamic Drive!<br />
Welcome to Dynamic Drive!<br />
Welcome to Dynamic Drive!<br />
<span>nested text</span> Welcome to Dynamic Drive!
</a>
<div id="tst2" style="font-Size:30px;" >
Welcome to Dynamic Drive!<br />
Welcome to Dynamic Drive!<br />
Welcome to Dynamic Drive!<br />
<div>nested text <span>nested text</span></div> Welcome to Dynamic Drive!
</div>
<script type="text/javascript">
/*<![CDATA[*/
function NeonLights(o){
var obj=document.getElementById(o.ID),txtary=[],z0=0,txt,z0a,frag,z0a,span,colors=o.neoncolors;
this.txtnodes(obj,txtary);
this.ary=[];
for (;z0<txtary.length;z0++){
txt=txtary[z0].data;
frag=document.createDocumentFragment();
for (z0a=0;z0a<txt.length;z0a++){
span=document.createElement('SPAN');
span.style.color=colors[0];
span.appendChild(document.createTextNode(txt.charAt(z0a)));
frag.appendChild(span);
this.ary.push(span);
}
txtary[z0].parentNode.replaceChild(frag,txtary[z0]);
}
this.colors=colors;
this.ms=o.flashspeed;
this.cnt=0;
this.flash();
}
NeonLights.prototype={
flash:function(){
var oop=this,ary=this.ary,span=ary[this.cnt],z0=0;
if (span){
span.style.color=this.colors[1];
this.cnt++;
setTimeout(function(){ oop.flash(); },this.ms);
}
else {
for (var z0=0;z0<ary.length;z0++){
ary[z0].style.color=this.colors[0];
}
this.cnt=0;
oop.flash();
}
},
txtnodes:function(node,ary){
var num=node.childNodes.length,z0=0,txt,fc,z0a,sp;
for (;z0<num;z0++) {
fc=node.removeChild(node.firstChild);
if (fc.nodeType==3){
ary.push(fc);
node.appendChild(fc);
}
else {
node.appendChild(fc);
this.txtnodes(fc,ary);
}
}
}
}
new NeonLights({
ID:'tst',
neoncolors:['gray','yellow'],
flashspeed:100 //in milliseconds
});
new NeonLights({
ID:'tst2',
neoncolors:['red','blue'],
flashspeed:200 //in milliseconds
});
/*]]>*/
</script>
</body>
</html>
Bookmarks