JSFiddle - React, Tailwind, and code Playground
by brasofilo
HTML
<div id="resultados">
</div>
<button id="refresh">Outro feed</button>
CSS
.paginaposts a{
font-size: 2em;
text-decoration: none
}
.paginaposts a:before {
content: "\0FCC\00a0\00a0";
}
JavaScript
/**
* https://gist.github.com/psynewave/4220821
*/
(function($){
$.extend({
jGFeed : function(url, fnk, num, key){
// Make sure url to get is defined
if(url == null) return false;
// Build Google Feed API URL
var gurl = "http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&callback=?&q="+url;
if(num != null) gurl += "&num="+num;
if(key != null) gurl += "&key="+key;
// AJAX request the API
$.getJSON(gurl, function(data){
if( !data.responseData ) {
console.log('Erro 400: Feed could not be loaded.');
return;
}
if( typeof fnk == 'function' )
fnk.call(this, data.responseData.feed);
else
console.log('Erro: Função de callback não definida.')
});
}
});
})(jQuery);
/**
* http://jquery-howto.blogspot.com.es/2009/05/google-feeds-api-jquery-plugin.html
*/
var paged = 1;
$.jGFeed(
'http://matheuspiscioneri.com.br/feed/?paged=' + paged,
parseFeed,
10
);
function parseFeed(feeds){
// Check for errors
if( !feeds ){
// there was an error
return false;
}
$('#resultados').html('');
// do whatever you want with feeds here
for(var i=0; i<feeds.entries.length; i++){
var salida = '';
var entry = feeds.entries[i];
salida += "<div class='paginaposts'>";
salida += "<h6><a href='" + entry.link + "' target='_blank'>" + entry.title + "</a></h6>";
salida += "</div>";
$('#resultados').append(salida);
}
}
$('#refresh').click(function(){
$(this).hide();
$.jGFeed(
'http://lorelle.wordpress.com/feed/?paged=' + paged,
parseFeed,
10
);
});