Jump to content

rotating text


otuatail

Recommended Posts

  • 2 weeks later...

Looking at the code it seems to be this:

// Convert news headlines into a news ticker
var newsHeadlines = [], newsLinks = [], newsRun = true, newsPosition = 0,
newsTimeout = -1, newsCurrent = 0, newsDelayStart = 1500, newsDelayLetter = 50,
newsDelayNext = 3000, newsSource = "news-headline", newsOutput = "news-headline-box",
newsElemAdd = "p", newsDivId = "newsTicker";

// Clear any timeout
function newsClear()
{
if (newsTimeout != -1) {
	clearTimeout(newsTimeout);
	newsTimeout = -1;
}
}

// Displays newsPosition characters of headline with index newsCurrent
function newsProcess()
{
if ((!newsRun) || newsHeadlines.length < 1) {
	return false;
}
newsClear();

// Saving CPU but not rewriting a, title every time
var writeFunc = newsPosition == 0 ? newsWrite : newsUpdate;
writeFunc(newsHeadlines[newsCurrent].substr(0, newsPosition + 1),
 newsLinks[newsCurrent]);

var curHead = newsHeadlines[newsCurrent];
if (newsPosition >= (newsHeadlines[newsCurrent].length - 1)) {
	newsTimeout = setTimeout(newsNext, newsDelayNext);
} else {
		++newsPosition;
	newsTimeout = setTimeout(newsProcess, newsDelayLetter);
}
}

// Progress to the next headline
function newsNext()
{
newsPosition = 0;
newsCurrent = (newsCurrent + 1) % newsHeadlines.length;
newsProcess();
}

BY THE WAY THIS IS NOT MINE NOR YOUR CODE IF YOU CHOOSE TO USE IT YOU DO SO ON YOUR OWN RESPONSIBILITY.

 

ALSO I HAVE NOT TESTED THIS CODE SO IT MAY NOT WORK

Link to comment
https://forums.phpfreaks.com/topic/194626-rotating-text/#findComment-1028026
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.