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

var rssFeedUrl = "http://asakawakiyohito.blogspot.com/feeds/posts/default?alt=rss";

// gFeed plugin : via http://yas-hummingbird.blogspot.com/2009/05/jQuery-google-ajax-feed-api.html
jQuery.gFeed = function(url, options, callback){
	var opt = jQuery.extend({q: url, v: '1.0', num: 10}, options);
	if (!opt.q) return false;
	jQuery.getJSON('http://ajax.googleapis.com/ajax/services/feed/load?callback=?',
		opt,
		function(data){
			if (data) callback.call(this, data.responseData.feed);
		}
	);
};

function dateFormat(date) {
	var padding = function(num) {
		var temp = "0" + (num);
		return temp.substr(temp.length - 2, temp.length);
	};
	return date.getFullYear()+'.'+padding(date.getMonth()+1)+'.'+padding(date.getDate());
}

jQuery(function(){
	jQuery.gFeed(rssFeedUrl, {num:3},
		function(feed){
			var lst = [];
			var tempDate, date, link, title;
			jQuery(feed.entries).each(function() {
				tempDate = new Date(this.publishedDate);
				date = dateFormat(tempDate);
				link = this.link;
				title = this.title;
				lst.push('&gt;&nbsp;<span class="blog_date">'+date+'</span><br><span class="blog_title"><a href="'+link+'">'+title+'</a></span>');				
			});
			jQuery("div#blog_entry").append('<ul><li>' + lst.join('</li><li>') + '</li></ul>');
		}
	);
});
