User:Bawolff/Sandbox/tick-fade.js

/* http://en.wikinews.org/w/index.php?title=User:Bawolff/Sandbox/tick.js modified to fade. Not cross-browser at moment, but can be fixed. (however relies on css3 and an IE work arroudn, so how cross-browser is questionable) 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.opacity = ticker_text_pos; // must not have commas in it or IE won't like (although std prefers commas) ticker_text_pos += 0.07; ticker_contents=''; ticker_row=Math.max(0,ticker_index-7); //window.alert("TL: "+ticker_tl[ticker_index]);

//ticker_text_pos is opacity, not chars //for setInterval

if(ticker_text_pos >= 1) {   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); }