function Ticker(id){
var parEl = null;
if (!(parEl = document.getElementById(id))) {
window.alert("Konnte Ticker nicht initialisieren!");
return;
}
var msg = [];
while (parEl.getElementsByTagName("p").length > 0) {
msg.push(parEl.getElementsByTagName("p")[0].firstChild.nodeValue);
parEl.removeChild(parEl.getElementsByTagName("p")[0]);
}
this.respell = function(k,i) {
parEl.firstChild.nodeValue = msg[k].substring(0,i)+"_";
if (i++ == msg[k].length) {
i = 0;
window.setTimeout(function() { this.respell(k,i); }, 3000);
k = (k+1) == msg.length?0:k+1;
} else
window.setTimeout(function() { this.respell(k,i); }, 50);
}
window.respell = this.respell;
this.respell(0,0);
}
window.onload = function() {
new Ticker("derletztekick");
} |