User:Bawolff/Sandbox/tick.js

/* I've noticed the tick function of the ticker is eating all my processing power, so I wanted to see if some other approach to it would make it faster. At the moment I'm just tryting random crap hoping something works.

This depends on the ticker code currently in use, and just replaces one of the functions. Must run after main ticker code Current Attempt:

replace any strings sent to setIntreval with function Use clip css instead of re-writing the inner html use onblur handlers to stop animation one not in focus (not done yet) ticker_tick_reset = function { return ticker_tick(true, false); } document.getElementById("ticker_start").style.position = "relative";

document.getElementById("ticker_content").style.position = "absolute"; var ticker_text_pos = 0; ticker_tick = function(reset, first) { var tick_content = document.getElementById("ticker_content"); if(reset){ tick_content.innerHTML = ("" + ticker_tl[ticker_index] + "").replace("\n", ""); } if(first){ ticker_index = Math.round(Math.random * ticker_tl.length-1); ticker_text_pos=0; ticker_str_length=ticker_tl[ticker_index].length;

tick_content.innerHTML = ("" + ticker_tl[ticker_index] + "").replace("\n", ""); } tick_content.style.clip = "rect(auto " + ticker_text_pos + "px auto auto)"; // must not have commas in it or IE won't like (although std prefers commas) ticker_text_pos += 1; ticker_contents=''; ticker_row=Math.max(0,ticker_index-7); //window.alert("TL: "+ticker_tl[ticker_index]);

//ticker_text_pos is now how many pixels displayed, not chars //for setInterval

if(ticker_text_pos++>= tick_content.offsetWidth) {   ticker_index++; if(ticker_index!=ticker_tl.length) {     ticker_text_pos=0; ticker_str_length=ticker_tl[ticker_index].length; if(first){ setTimeout(ticker_tick_reset,3); }else{ setTimeout(ticker_tick_reset,7000); }   }else{ ticker_index = Math.round(Math.random * ticker_tl.length-1); ticker_text_pos=ticker_tl[ticker_index].indexOf("\">");     ticker_str_length=ticker_tl[ticker_index].length;      setTimeout(ticker_tick_reset,3000);    }  } else    setTimeout((function  {ticker_tick(false, false);}),ticker_speed); }