var feedsLoaded = [];
var totalFeeds = 30;
var feedsPerPage = 5;
var totalPages = 1;
var previousPage = 1;
var currentPage = 1;
var itemsOffset = 0;
var feedItemTemplate = $("#feed-item-template").html();
var feedItemCompiledTemplate = Handlebars.compile(feedItemTemplate);
var paginationTemplate = $("#pagination-items-template").html();
var paginationCompiledTemplate = Handlebars.compile(paginationTemplate);
/**
* Loads up to 30 posts from the feed URL. Function must return a Promise.
* @param {String} url - Feed URL
* @return {Promise<Array>} Promise resolves with the feed list, including a "thumbnail" property for the post thumbnail, if available
*/
function getFeed(url) {
// 1) Use https://cors-anywhere.herokuapp.com to enable cross-origin requests and load the feed using jFeed. See https://github.com/jfhovinne/jFeed to learn more about jFeed
// 2) Combine with the use of https://rss2json.com/ to retrieve any post thumbnails or if any error is encountered with jFeed. rss2json.com must only be used for post thumbnails and as a fallback system for processing errors from jFeed.
// 3) Each feed should only be loaded once until the page reloads
return new Promise((resolve, reject) => {
$.ajax({
url: 'https://api.rss2json.com/v1/api.json',
method: 'GET',
dataType: 'json',
data: {
rss_url: url,
api_key: 'e1y0txvwmerevbcru0oy2jm2dtmbsu1wvjujhrfh',
count: totalFeeds
},
success: function(feed) {
resolve(feed);
},
error: function(error) {
reject(error);
}
});
/*
jQuery.getFeed({
url: 'https://cors-anywhere.herokuapp.com/' + url,
success: function(feed) {
console.log(feed);
resolve(feed);
},
error: function(error) {
reject(error);
}
});
*/
});
}
function calculatePages() {
var feedURL = getActiveFeed();
var getNewFeed = getFeedLoaded(feedURL);
// Get the total number of pages...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.