A.T 0

At chrome.google.com/extensions, there is a "Today's top picks" thing that you can cycle through the different top rated extensions. Where can I get modifiable code for such a rotator, preferably with an CC license or free. Thanks.

2 answers


It would be pretty easy to build from scratch. If you have your data hosted somewhere (RSS, XML, JSON, etc.) you'd just pull it in with XMLHttpRequest. I think JSON works the easiest with the ease of parsing it.

You would load your data into an array and iterate it into a DIV as shown below

<script language="Javascript">
  var textArray = new Array();
  var currentTextIdx = 0;
  function loadText() {
    //perform XMLHttpRequest, load text as JSON, parse items into textArray, 
    //and call displayNextMsg('contentarea')
  function displayNextMsg(targetdiv) {
    var jsCommand = 'displayNextMsg(\'' + targetdiv + '\');';
    document.getElementById(targetdiv).innerHTML = textArray[currentTextIdx];
    if (currentTextIdx == textArray.length) {
      currentTextIdx = 0;

<body onLoad="loadText();">
  <div id="contentarea"></div>

Obviously, I left out some HTML elements but this is the basic idea. Load data into an array, use a function in conjunction with setTimeout to rerun the function at set intervals (in this case, every 6 seconds). If you're parsing out XML, you'd just use those functions but the logic would be exactly the same.

Answered almost 9 years ago by carlsontechnology




Answered about 9 years ago by Nathan Duran