﻿//document.write('<script src="https://www.google.com/jsapi?key=ABQIAAAAlFGPaTC_pOpbHdsYVJA4aBQ4H8G0BuAp1xOBthJy6qaPWOJouBR5EFLYJEZg1RDrFsm-i4gIntbisA" type="text/javascript"></script>');
google.load("feeds", "1");

function initialize() {
    var feed = new google.feeds.Feed("http://www.nihontechno.jp/?feed=rss2"); // 読み込むフィード
    feed.setNumEntries(5); // 最大5件読み込み
    feed.load(function(result) {
        if (!result.error) {
            var container = document.getElementById("recentposts");
            var ul = document.createElement("ul");
            for (var i = 0; i < result.feed.entries.length; i++) {
                var entry = result.feed.entries[i];
                var title = entry.title;
                var url = entry.link;
                var urlWithoutProtcol = url.replace("https://", "").replace("http://", "");

                ul.setAttribute("class", "posts");
                var li = document.createElement("li");
                var a = document.createElement("a");
                a.setAttribute("onclick", "_gaq.push(['_trackPageview', '/fromrecentposts/" + urlWithoutProtcol + "']);"); // GoogleAnalysticsトラッキング
                a.setAttribute("href", url);
                a.appendChild(document.createTextNode(title));
                li.appendChild(a);
                ul.appendChild(li);
            }
            container.appendChild(ul);
        }
    });
}
google.setOnLoadCallback(initialize);
