Question

I'm trying increase the number of items that appear on this webpage using the Google Feed API to 25 instead of 4 items: http://ewh.ieee.org/reg/1/sac/news.php

Here is the JS:

<script src="//www.google.com/jsapi?key=AIzaSyA5m1Nc8ws2BbmPRwKu5gFradvD_hgq6G0" type="text/javascript"></script>
    <script type="text/javascript">

        google.load("feeds", "1");

        function feedLoaded(result) {
          if (!result.error) {
            var container = document.getElementById("content");
            container.innerHTML = '';

            for (var i = 0; i < result.feed.entries.length; i++) {
              var entry = result.feed.entries[i];
              var div = document.createElement("div");
              div.appendChild(document.createTextNode(i + ': ' + entry.title));
              container.appendChild(div);
            }
          }
        }

        function OnLoad() {
          var feedControl = new google.feeds.FeedControl();
          feedControl.addFeed("http://feeds.feedburner.com/IeeeSpectrum", "Latest IEEE Spectrum News:");
          feedControl.draw(document.getElementById("content"));
          feed.includeHistoricalEntries(); // tell the API we want to have old entries too
          feed.setNumEntries(25); // we want a maximum of 25 entries, if they exist

          feed.load(feedLoaded);
        }

        google.setOnLoadCallback(OnLoad);
    </script>

And the HTML:

        <body style="font-family: Arial;border: 0 none;">
            <div id="content">Loading IEEE Spectrum News...</div>
        </body>

I tried using feed.setNumEntries(), but it doesn't seem to work. I appreciate any help. Thank you.

Was it helpful?

Solution

I found the solution to my problem:

<script type="text/javascript">

google.load("feeds", "1");

function initialize() {
  var control = new google.feeds.FeedControl();
  control.setNumEntries(25);
  control.addFeed("http://feeds.feedburner.com/IeeeSpectrum", "Latest IEEE Spectrum News:");
  control.draw(document.getElementById("content"));
}

google.setOnLoadCallback(initialize);

</script>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top