Mercurial > ambnews-firefox
view ambnews/content/blank.js @ 6:ec86d1e59d44
Ummm... Oops. When I converted AmbNews annotations to ambnews annotations, I missed a few.
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Thu, 21 Aug 2008 18:14:31 -0700 |
parents | 44bcb4975ead |
children | f07bf657f483 |
line wrap: on
line source
function loadNews() { var Cc = Components.classes; var Ci = Components.interfaces; var historyService = Cc["@mozilla.org/browser/nav-history-service;1"] .getService(Ci.nsINavHistoryService); // no query parameters will get all history // XXX default sorting is... ? var options = historyService.getNewQueryOptions(); options.resultType = options.RESULTS_AS_URI; options.sortingMode = options.SORT_BY_VISITCOUNT_DESCENDING; // no query parameters will return everything var query = historyService.getNewQuery(); query.annotation = "ambnews/feed"; // execute the query var result = historyService.executeQuery(query, options); var root = result.root; root.containerOpen = true; var childNum = 0; var childrenShown = 0; var maxChildrenToShow = 20; var shownFeeds = {}; function getNextFeed() { if (childrenShown == maxChildrenToShow || childNum == root.childCount) { root.containerOpen = false; } else { var annSvc = AmbNews.__getAnnSvc(); var child = root.getChild(childNum); var feedUri = annSvc.getPageAnnotation(AmbNews.url(child.uri), "ambnews/feed"); childNum++; if (feedUri in shownFeeds) { getNextFeed(); } else { shownFeeds[feedUri] = true; childrenShown++; AmbNews.getFeed(feedUri, onFeed); } } } function onFeed(feed) { var text = ""; if (feed) { var entriesToShow = 4; if (feed.entries.length < entriesToShow) entriesToShow = feed.entries.length; var feedLink = feed.link ? feed.link.spec : ""; text += ('<div class="feed"><div class="feed-title"><a ' + 'href="' + feedLink + '">' + feed.title.text + '</a></div><ul>'); for (var i = 0; i < entriesToShow; i++) { var entryTitle = feed.entries[i].title.text; if (entryTitle.length > 100) { entryTitle = entryTitle.slice(0, 100) + '\u2026'; } text += ('<li class="feed-entry"> \u00b7 <a href="' + feed.entries[i].link.spec + '">' + entryTitle + '</a></li>'); } text += '</ul></div>'; } else text = "An error occurred."; //$("#content").append(text); $(text).hide().fadeIn("slow", getNextFeed).appendTo("#content"); } getNextFeed(); } $(window).ready(loadNews);