google.load("feeds", "1"); 

function initialize() {
    getRssInfo("http://nextvision.exblog.jp/index.xml", "syacho");
    getRssInfo("http://feedblog.ameba.jp/rss/ameblo/nextvision-blog", "jomu");
    getRssInfo("http://freestyle.nvo.jp/feed", "freestyle");
}

function getRssInfo(url, div_id) {

    var DISP_CNT = 3
    var feed = new google.feeds.Feed(url); 
    feed.setNumEntries(5); 

    feed.load(function(result) {
        if (!result.error) {
            var container = document.getElementById(div_id);
            var ul_tag = document.createElement("ul"); 
            var cnt = 0;
            for (var i=0; i < result.feed.entries.length; i++) {
                var entry = result.feed.entries[i];

                if (entry.title.substring(0, 3) == "PR:") {
                    continue;
                }
                cnt++;

                var li_tag = document.createElement("li"); 
                var a_tag = document.createElement("a"); 

                var pubDate = new Date(entry.publishedDate);
                var itemYear = pubDate.getFullYear();
                var itemMonth = pubDate.getMonth() + 1;
                var itemDate = pubDate.getDate();

                pubDate = itemYear + "/" + itemMonth + "/" + itemDate;

                a_tag.setAttribute("href", entry.link); 
                a_tag.appendChild(document.createTextNode(entry.title + " (" + pubDate + ")"));

                li_tag.appendChild(a_tag); 
                ul_tag.appendChild(li_tag); 

                if (cnt >= DISP_CNT) {
                    break;
                }
            }
            //container.removeChild(container.childNodes.item(0)); 
            container.removeChild(container.lastChild);
            container.appendChild(ul_tag); 
        }
    });
}

google.setOnLoadCallback(initialize); 

