var useWidth = "400px"; var speed = 250 // greater is slower; var message = "Now is the time for all good men to come to the aid of their country. That's one small step for man, one giant leap for mankind. Ask not what your country can do for you, ask what you can do for your country. | "; // be sure to include the vertical bar | at the end of the message(s);
var container = ""; var msgLength = 0; var circleMsg = ""; var prevMsg = "";
function updateMessage(){
if (circleMsg == ""){circleMsg = container.lastChild.data} else {circleMsg = prevMsg} var separatorIdx = circleMsg.lastIndexOf('|'); if (separatorIdx == -1){separatorIdx = msgLength} circleMsg = circleMsg.substring(1,separatorIdx); var spliceStr = message.substring(0,msgLength-separatorIdx-1); var dispMsg = circleMsg+spliceStr; container.removeChild(container.lastChild); container.appendChild(document.createTextNode(dispMsg)); prevMsg = circleMsg+'|'+spliceStr; setTimeout("updateMessage()",speed); }
function startCrawl(){
container.appendChild(document.createTextNode(message)) setTimeout("updateMessage()",3000); // delay before start crawl; }