NewsTicker - JavaScript-QuelltextQuelltext von newsticker.js |
![]() ![]() ![]() |
Dies ist die Auflistung der Datei newsticker.js,
die die Funktionalität für den Newsticker bereitstellt.
Im folgenden Quelltext sind Prozedurdeklarationen rot und Kommentare grün markiert. |
![]() ![]() ![]() ![]() |
/* Droeppez Newsticker
* (c) 2002 Ulrich Kritzner
* Die Verwendung dieses Scripts in kommerziellen Seiten ist kostenpflichtig
*
* Der Newsticker erfordert die Einbindung von divcontent.js
*/
function DNT_SetContent(text,showlength)
{
var oldrunning=this.running,oldelapse=this.elapse;
this.Stop();
this.x=0;
this.text=text;
this.showlength=showlength;
if (oldrunning)
this.Run(oldelapse);
}
function DNT_SetAttributes(starttags,endtags)
{
var oldrunning=this.running,oldelapse=this.elapse;
this.Stop();
this.starttags=starttags;
this.endtags=endtags;
if (oldrunning)
this.Run(oldelapse);
}
function DNT_ContentHandler()
{
var i,len,rettext,c;
len=this.text.length;
rettext=this.starttags;
for (i=0;i<this.showlength;i++)
{
c=this.text.charAt((i+this.x)%len);
if (this.text.charCodeAt((i+this.x)%len)<=33)
c=" ";
rettext=rettext+c;
}
rettext=rettext+this.endtags;
this.x++;
if (this.x>=this.text.length)
this.x=0;
return rettext;
}
function NewsTicker(name,elementname)
{
this.x=0;
this.text="+++ +++ +++ Droeppez NewsTicker +++";
this.text+=" Der kompatibelste Newsticker im ganzen Netz ";
this.starttags="<tt style=\"color:#000000; background-color:#E0E0FF\">";
this.endtags="</tt>";
this.showlength=30;
this.Init=DivContent;
this.Init(name,elementname);
this.SetContent=DNT_SetContent;
this.SetAttributes=DNT_SetAttributes;
this.SetContentHandler(DNT_ContentHandler);
}
|
![]() ![]() ![]() |
Autor: Ulrich Kritzner |