Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function NewsTicker()
- {
- this.container = null;
- this.text = "";
- this.index = 0;
- this.count = 0;
- this.othercolor = false;
- }
- NewsTicker.prototype.init = function()
- {
- div = document.getElementById("newstickertext");
- if(div)
- {
- textWidth = div.offsetWidth;
- this.text = div.innerHTML;
- div = document.getElementById("newsticker");
- this.container = div;
- containerWidth = div.offsetWidth;
- this.count = Math.ceil(containerWidth/textWidth);
- }
- }
- NewsTicker.prototype.loop = function()
- {
- if(this.container == null)
- this.init();
- else
- {
- this.index++;
- if(this.index>=this.text.length)
- {
- this.index = 0;
- this.othercolor = !this.othercolor;
- }
- oc = this.othercolor;
- txt = "<span class='newsticker"+(oc?"2":"1")+"'>"+this.text.substring(this.index)+"</span>";
- for(i=1;i<this.count;i++)
- {
- oc = !oc;
- txt += "<span class='newsticker"+(oc?"2":"1")+"'>"+this.text+"</span>";
- }
- oc = !oc;
- txt += "<span class='newsticker"+(oc?"2":"1")+"'>"+this.text.substring(0,this.index)+"</span>";
- this.container.innerHTML = txt;
- }
- window.setTimeout("newsticker.loop()","75");
- }
- NewsTicker.prototype.updateCheck = function()
- {
- /** update routine **/
- //window.setTimeout("newsticker.updateCheck()","60000");
- }
- NewsTicker.prototype.start = function()
- {
- this.loop();
- this.updateCheck();
- }
- window.newsticker = new NewsTicker();
- window.newsticker.start();
Advertisement
Add Comment
Please, Sign In to add comment