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

0
points

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;
    }

    setTimeout(jsCommand,6000);
  }
</script>
<body onLoad="loadText();">
  <div id="contentarea"></div>
</body>

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 over 7 years ago by carlsontechnology
0
points

http://jqueryui.com/demos/tabs/

http://seanmonstar.github.com/MGFX.Tabs/

http://wiki.github.com/madrobby/scriptaculous/tabs

Answered over 7 years ago by Nathan Duran