JSFiddle - React, Tailwind, and code Playground
HTML
<div id="container">
</div>
JavaScript
(function($) {
var current = null;
$.fn.rssfeed = function(url, options) {
// Set pluign defaults
var defaults = {
limit: 10,
header: false,
titletag: 'h6',
date: false,
content: true,
snippet: false,
showerror: true,
errormsg: 'View our customer testimonials <a href="http://renownestates.com/blog/category/testimonials/">here</a>',
key: null
};
var options = $.extend(defaults, options);
// Functions
return this.each(function(i, e) {
var $e = $(e);
// Add feed class to user div
if (!$e.hasClass('rssFeed')) $e.addClass('rssFeed');
// Check for valid url
if (url == null) return false;
// Create Google Feed API address
var api = "http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&callback=?&q=" + url;
if (options.limit != null) api += "&num=" + options.limit;
if (options.key != null) api += "&key=" + options.key;
// Send request
$.getJSON(api, function(data) {
// Check for error
if (data.responseStatus == 200) {
// Process the feeds
_callback(e, data.responseData.feed, options);
} else {
// Handle error if required
if (options.showerror) if (options.errormsg != '') {
var msg = options.errormsg;
} else {
var msg = data.responseDetails;
};
$(e).html('<div class="rssError"><p>' + msg + '</p></div>');
};
});
});
};
// Callback function to create HTML result
var _callback = function(e, feeds, options) {
if (!feeds) {
return false;
}
var html = '';
...