Google Ajax Feedサンプル
現段階のGoogle Ajax Feedサンプル最終形です。
<script src="http://www.google.com/jsapi?key=APIKEY"></script>
<div id="hadaka-news" class="rssblock">
<img src="/images/loading.gif" alt="loading" />
</div>
<script>
google.load("feeds", "1");
function initialize_news() {
var num = 5;
var site_title = "RSS";
var site = "http://a-hadaka.jp/modules/bulletin/";
var feed_url = "http://a-hadaka.jp/modules/bulletin/index.php?page=rss";
var feed = new google.feeds.Feed(feed_url);
feed.setNumEntries(num)
feed.load(function(result) {
if (!result.error) {
var container = document.getElementById("hadaka-news");
var mystr = '';
var mystr_h = '';
mystr_h += '<div class="alignleft"><a href="'+feed_url+
'"><img src="/images/rss20.png" alt="rsslogo" /></a></div>';
mystr_h += '<h6><a href="'+site+'">' + site_title + '</a></h6>';
for (var i = 0; i < result.feed.entries.length; i++) {
var entry = result.feed.entries[i];
var date = new Date(entry.publishedDate);
var yearNum = date.getYear();
if (yearNum < 2000) yearNum += 1900;
mystr += '<dt><img class="icon" src="http://favicon.hatena.ne.jp/?url='
+ site + ' "width="14" height="14" /> <a href="' + entry.link + '">'
+ entry.title + '</a> ('+yearNum+'年'+(date.getMonth()+1)+'月'
+date.getDate()+'日'+')</dt>';
mystr += '<dd>' + entry.contentSnippet + '</dd>';
}
container.innerHTML = mystr_h + '<dl>' + mystr + '</dl>';
}
});
}
google.setOnLoadCallback(initialize_news);
</script>