-
-

正在加载⋯⋯

+
+ +

+
+
+ +
+ +

@@ -32,31 +38,43 @@ google.load("feeds", 1); var entries = []; var lastIndex = 0; - $(function(){ - var feed = new google.feeds.Feed("http://cn.engadget.com/rss.xml"); - feed.setNumEntries(250); + var lastShow = "#a0"; + + function loadFeeds() { + loadFeed("http://cn.engadget.com/rss.xml"); + loadFeed("http://news.ycombinator.com/rss"); + } + + function loadFeed(url) { + var feed = new google.feeds.Feed(url); + feed.setNumEntries(50); feed.includeHistoricalEntries(); feed.load(function(result) { if (!result.error) { - entries = result.feed.entries; - /* var container = $("#feed"); - for (var i = 0; i < result.feed.entries.length; i++) { - var entry = result.feed.entries[i]; - $(container).append("
"+entry.title+"
"); - $(container).append("
"+entry.content.substring(0, 100)+"...
"); - - }*/ + es = result.feed.entries; + for (var i = 0; i < es.length; i++) { + entries.push(es[i]); + } } }); + } + + $(function(){ + loadFeeds(); }) + setInterval(function() { if (entries.length > 0) { if (lastIndex >= entries.length) { lastIndex = 0; } var e = entries[lastIndex++]; - $("article").children("h2").text(e.title); - $(".content").html(e.content); + $(lastShow).addClass("hide"); + var thisShow = (lastShow == "#a1" ? "#a2" : "#a1"); + $(thisShow).children("h2").text(e.title); + $(thisShow).children(".content").html(e.content.substring(0, 250) + "..."); + $(thisShow).removeClass("hide"); + lastShow = thisShow; } }, 1000*5)