Mercurial > planet-ubiquity-redesign
changeset 26:0ea70c7a4591
processFeed functions are now asynchronous.
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Mon, 02 Mar 2009 21:54:05 -0800 |
parents | 987ff147ea02 |
children | 43da06d64c2d |
files | about-mozilla.js |
diffstat | 1 files changed, 27 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/about-mozilla.js Mon Mar 02 21:14:09 2009 -0800 +++ b/about-mozilla.js Mon Mar 02 21:54:05 2009 -0800 @@ -1,4 +1,4 @@ -function processBlogFeed(feed, content) { +function processBlogFeed(feed, content, cb) { jQuery.each( feed.entries, function(i) { @@ -27,6 +27,7 @@ $(item).attr("published", this.publishedDate); content.append(item); }); + cb(); } var FEEDS = [ @@ -72,6 +73,23 @@ $(document.body).width(entries.outerWidth() * entries.length); } +function splitByDate(rawContent, content) { + var now = new Date(); + $(".blog-item", rawContent).each( + function(i) { + var pub = new Date($(this).attr("published")); + var msAgo = now - pub; + var hoursAgo = msAgo / (1000 * 60 * 60); + var daysAgo = Math.floor(hoursAgo / 8); + if (daysAgo < 0) + daysAgo = 0; + if (daysAgo > 9) + daysAgo = 9; + var div = $(".days-ago-" + daysAgo, content); + div.append(this); + }); +} + function showFeed(feedInfo, cb) { var entry = $('<div class="entry"></div>'); var headline = $('<div class="headline"></div>'); @@ -89,26 +107,14 @@ for (var i = 0; i < 10; i++) content.append('<div class="days-ago-' + i + '"></div>'); - feedInfo.processFeed(result.feed, rawContent); - - var now = new Date(); - $(".blog-item", rawContent).each( - function(i) { - var pub = new Date($(this).attr("published")); - var msAgo = now - pub; - var hoursAgo = msAgo / (1000 * 60 * 60); - var daysAgo = Math.floor(hoursAgo / 8); - if (daysAgo < 0) - daysAgo = 0; - if (daysAgo > 9) - daysAgo = 9; - var div = $(".days-ago-" + daysAgo, content); - div.append(this); - } - ); - - entry.append(content); - cb(); + feedInfo.processFeed( + result.feed, + rawContent, + function() { + splitByDate(rawContent, content); + entry.append(content); + cb(); + }); }); }