I am attempting to add an RSS feed section to my website. I want each story to be stored in a Bootstrap column of width 3. I am attempting to add a row at the start of every 4th element and then closing the row on the next 4th element. However at the moment I seem to be running into problems with it prematurely cutting off the rows and ruining the formatting.
Below is my JS and a screenshot of my problem.
var rssfeed = new google.feeds.Feed("http://www.residentadvisor.net/xml/rss_news.xml");
//rssfeed.setResultFormat(google.feeds.Feed.XML_FORMAT);
rssfeed.setNumEntries(10);
rssfeed.load(showEntries);
console.log(rssfeed);
function showEntries(result)
{
if (!result.error)
{
var feeds = result.feed.entries;
console.log(feeds);
var rssoutput = "";
for (var i=0; i<feeds.length; i++)
{
if (i%4 == 0) {
rssoutput += '<div class="row">';
}
rssoutput += '<div class="col-md-3">';
rssoutput += '<h3><a href="' + feeds[i].link + '">' + feeds[i].title + '</a></h3><br />';
rssoutput += '<p>' + feeds[i].content + '</p><br/>';
rssoutput += '<i><p>' + feeds[i].publishedDate + '</p></i><br />';
rssoutput += '</div>';
if (i != 0 && i%3 == 0) {
rssoutput += '</div>';
}
}
document.getElementById("latest-news").innerHTML = rssoutput;
}
}
