annotate ambnews/content/ambnews.js @ 15:07d3a1ab689e

Incremented version number.
author Atul Varma <varmaa@toolness.com>
date Sat, 23 Aug 2008 09:19:17 -0700
parents 2f58ecd38d7a
children 9d0dac426ba8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11
f259d52d361e Added tri-license headers to JS files.
Atul Varma <varmaa@toolness.com>
parents: 10
diff changeset
1 /* ***** BEGIN LICENSE BLOCK *****
f259d52d361e Added tri-license headers to JS files.
Atul Varma <varmaa@toolness.com>
parents: 10
diff changeset
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
f259d52d361e Added tri-license headers to JS files.
Atul Varma <varmaa@toolness.com>
parents: 10
diff changeset
3 *
f259d52d361e Added tri-license headers to JS files.
Atul Varma <varmaa@toolness.com>
parents: 10
diff changeset
4 * The contents of this file are subject to the Mozilla Public License Version
f259d52d361e Added tri-license headers to JS files.
Atul Varma <varmaa@toolness.com>
parents: 10
diff changeset
5 * 1.1 (the "License"); you may not use this file except in compliance with
f259d52d361e Added tri-license headers to JS files.
Atul Varma <varmaa@toolness.com>
parents: 10
diff changeset
6 * the License. You may obtain a copy of the License at
f259d52d361e Added tri-license headers to JS files.
Atul Varma <varmaa@toolness.com>
parents: 10
diff changeset
7 * http://www.mozilla.org/MPL/
f259d52d361e Added tri-license headers to JS files.
Atul Varma <varmaa@toolness.com>
parents: 10
diff changeset
8 *
f259d52d361e Added tri-license headers to JS files.
Atul Varma <varmaa@toolness.com>
parents: 10
diff changeset
9 * Software distributed under the License is distributed on an "AS IS" basis,
f259d52d361e Added tri-license headers to JS files.
Atul Varma <varmaa@toolness.com>
parents: 10
diff changeset
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
f259d52d361e Added tri-license headers to JS files.
Atul Varma <varmaa@toolness.com>
parents: 10
diff changeset
11 * for the specific language governing rights and limitations under the
f259d52d361e Added tri-license headers to JS files.
Atul Varma <varmaa@toolness.com>
parents: 10
diff changeset
12 * License.
f259d52d361e Added tri-license headers to JS files.
Atul Varma <varmaa@toolness.com>
parents: 10
diff changeset
13 *
f259d52d361e Added tri-license headers to JS files.
Atul Varma <varmaa@toolness.com>
parents: 10
diff changeset
14 * The Original Code is Ambient News.
f259d52d361e Added tri-license headers to JS files.
Atul Varma <varmaa@toolness.com>
parents: 10
diff changeset
15 *
f259d52d361e Added tri-license headers to JS files.
Atul Varma <varmaa@toolness.com>
parents: 10
diff changeset
16 * The Initial Developer of the Original Code is Mozilla.
f259d52d361e Added tri-license headers to JS files.
Atul Varma <varmaa@toolness.com>
parents: 10
diff changeset
17 * Portions created by the Initial Developer are Copyright (C) 2007
f259d52d361e Added tri-license headers to JS files.
Atul Varma <varmaa@toolness.com>
parents: 10
diff changeset
18 * the Initial Developer. All Rights Reserved.
f259d52d361e Added tri-license headers to JS files.
Atul Varma <varmaa@toolness.com>
parents: 10
diff changeset
19 *
f259d52d361e Added tri-license headers to JS files.
Atul Varma <varmaa@toolness.com>
parents: 10
diff changeset
20 * Contributor(s):
f259d52d361e Added tri-license headers to JS files.
Atul Varma <varmaa@toolness.com>
parents: 10
diff changeset
21 * Atul Varma <avarma@mozilla.com>
14
2f58ecd38d7a Added Ben Basson as a contributor, since I used his code for the new tab override behavior.
Atul Varma <varmaa@toolness.com>
parents: 13
diff changeset
22 * Ben Basson <ben@basson.at>
11
f259d52d361e Added tri-license headers to JS files.
Atul Varma <varmaa@toolness.com>
parents: 10
diff changeset
23 *
f259d52d361e Added tri-license headers to JS files.
Atul Varma <varmaa@toolness.com>
parents: 10
diff changeset
24 * Alternatively, the contents of this file may be used under the terms of
f259d52d361e Added tri-license headers to JS files.
Atul Varma <varmaa@toolness.com>
parents: 10
diff changeset
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
f259d52d361e Added tri-license headers to JS files.
Atul Varma <varmaa@toolness.com>
parents: 10
diff changeset
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
f259d52d361e Added tri-license headers to JS files.
Atul Varma <varmaa@toolness.com>
parents: 10
diff changeset
27 * in which case the provisions of the GPL or the LGPL are applicable instead
f259d52d361e Added tri-license headers to JS files.
Atul Varma <varmaa@toolness.com>
parents: 10
diff changeset
28 * of those above. If you wish to allow use of your version of this file only
f259d52d361e Added tri-license headers to JS files.
Atul Varma <varmaa@toolness.com>
parents: 10
diff changeset
29 * under the terms of either the GPL or the LGPL, and not to allow others to
f259d52d361e Added tri-license headers to JS files.
Atul Varma <varmaa@toolness.com>
parents: 10
diff changeset
30 * use your version of this file under the terms of the MPL, indicate your
f259d52d361e Added tri-license headers to JS files.
Atul Varma <varmaa@toolness.com>
parents: 10
diff changeset
31 * decision by deleting the provisions above and replace them with the notice
f259d52d361e Added tri-license headers to JS files.
Atul Varma <varmaa@toolness.com>
parents: 10
diff changeset
32 * and other provisions required by the GPL or the LGPL. If you do not delete
f259d52d361e Added tri-license headers to JS files.
Atul Varma <varmaa@toolness.com>
parents: 10
diff changeset
33 * the provisions above, a recipient may use your version of this file under
f259d52d361e Added tri-license headers to JS files.
Atul Varma <varmaa@toolness.com>
parents: 10
diff changeset
34 * the terms of any one of the MPL, the GPL or the LGPL.
f259d52d361e Added tri-license headers to JS files.
Atul Varma <varmaa@toolness.com>
parents: 10
diff changeset
35 *
f259d52d361e Added tri-license headers to JS files.
Atul Varma <varmaa@toolness.com>
parents: 10
diff changeset
36 * ***** END LICENSE BLOCK ***** */
f259d52d361e Added tri-license headers to JS files.
Atul Varma <varmaa@toolness.com>
parents: 10
diff changeset
37
1
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
38 var AmbNews = {
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
39 url: function url(spec) {
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
40 if (typeof(spec) != "string")
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
41 // Assume that a URI object was passed in, so just return it back.
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
42 return spec;
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
43 var classObj = Components.classes["@mozilla.org/network/io-service;1"];
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
44 var ios = classObj.getService(Components.interfaces.nsIIOService);
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
45 return ios.newURI(spec, null, null);
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
46 },
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
47 getFeed: function AmbNews_getFeed(url, callback) {
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
48 function onXml(text) {
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
49 var feed = null;
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
50 if (text) {
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
51 var resultListener = {
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
52 handleResult: function resultListener_handleResult(aResult) {
10
f07bf657f483 Display of Vanilla forum threads is better now; fixed some display bugs; updated TODOs; documented more code.
Atul Varma <varmaa@toolness.com>
parents: 5
diff changeset
53 var nsIFeed = aResult.doc;
f07bf657f483 Display of Vanilla forum threads is better now; fixed some display bugs; updated TODOs; documented more code.
Atul Varma <varmaa@toolness.com>
parents: 5
diff changeset
54 if (!nsIFeed)
f07bf657f483 Display of Vanilla forum threads is better now; fixed some display bugs; updated TODOs; documented more code.
Atul Varma <varmaa@toolness.com>
parents: 5
diff changeset
55 return;
1
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
56 feed = {};
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
57 var Ci = Components.interfaces;
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
58 nsIFeed.QueryInterface(Ci.nsIFeed);
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
59 feed.link = nsIFeed.link;
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
60 feed.title = nsIFeed.title;
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
61 feed.entries = [];
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
62 for (var i = 0; i < nsIFeed.items.length; i++) {
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
63 var item = nsIFeed.items.queryElementAt(i, Ci.nsIFeedEntry);
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
64 feed.entries.push(item);
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
65 }
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
66 }
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
67 };
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
68 var fp = AmbNews.__getFeedProcessor();
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
69 fp.listener = resultListener;
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
70 fp.parseFromString(text, AmbNews.url(url));
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
71 }
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
72 callback(feed);
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
73 }
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
74 AmbNews.__getXml(url, onXml);
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
75 },
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
76 __getXml: function AmbNews_getXml(url, callback) {
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
77 var feedUrl = AmbNews.url(url);
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
78 var annSvc = AmbNews.__getAnnSvc();
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
79
5
8cafc4c42c29 Changed page annotations from AmbNews/something to ambnews/something to match the way other paths are done, but it appears that page annotations are case-insensitive anyways, which is cool I guess.
Atul Varma <varmaa@toolness.com>
parents: 4
diff changeset
80 if (annSvc.pageHasAnnotation(feedUrl, "ambnews/feed-xml")) {
8cafc4c42c29 Changed page annotations from AmbNews/something to ambnews/something to match the way other paths are done, but it appears that page annotations are case-insensitive anyways, which is cool I guess.
Atul Varma <varmaa@toolness.com>
parents: 4
diff changeset
81 var xml = annSvc.getPageAnnotation(feedUrl, "ambnews/feed-xml");
1
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
82 // TODO: Perhaps re-enable this, but only let it live for a
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
83 // few minutes?
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
84 //callback(xml);
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
85 //return;
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
86 }
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
87
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
88 var request = new XMLHttpRequest();
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
89 request.open("GET", url, true);
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
90
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
91 var onRscFunc = function getXml_onReadyStateChange() {
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
92 if (request.readyState == 4) {
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
93 if (request.status == 200) {
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
94 if (request.responseText) {
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
95 annSvc.setPageAnnotation(feedUrl,
5
8cafc4c42c29 Changed page annotations from AmbNews/something to ambnews/something to match the way other paths are done, but it appears that page annotations are case-insensitive anyways, which is cool I guess.
Atul Varma <varmaa@toolness.com>
parents: 4
diff changeset
96 "ambnews/feed-xml",
1
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
97 request.responseText,
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
98 0,
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
99 annSvc.EXPIRE_DAYS);
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
100 callback(request.responseText);
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
101 } else
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
102 callback("");
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
103 } else
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
104 callback("");
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
105 }
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
106 };
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
107
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
108 request.onreadystatechange = onRscFunc;
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
109 request.send(null);
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
110 },
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
111 __getFeedProcessor: function AmbNews_getFeedProcessor() {
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
112 var Cc = Components.classes;
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
113 var Ci = Components.interfaces;
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
114 var fp = Cc["@mozilla.org/feed-processor;1"]
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
115 .createInstance(Ci.nsIFeedProcessor);
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
116 return fp;
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
117 },
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
118 __getAnnSvc: function AmbNews_getAnnSvc() {
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
119 var Cc = Components.classes;
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
120 var annSvc = Cc["@mozilla.org/browser/annotation-service;1"]
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
121 .getService(Components.interfaces.nsIAnnotationService);
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
122 return annSvc;
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
123 },
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
124 onLinkAdded: function AmbNews_onLinkAdded(aEvent) {
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
125 if (aEvent.target.rel == "alternate" &&
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
126 (aEvent.target.type == "application/rss+xml" ||
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
127 aEvent.target.type == "application/atom+xml")) {
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
128 var annSvc = AmbNews.__getAnnSvc();
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
129 var page = AmbNews.url(aEvent.target.baseURI);
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
130 var feed = AmbNews.url(aEvent.target.href);
5
8cafc4c42c29 Changed page annotations from AmbNews/something to ambnews/something to match the way other paths are done, but it appears that page annotations are case-insensitive anyways, which is cool I guess.
Atul Varma <varmaa@toolness.com>
parents: 4
diff changeset
131 annSvc.setPageAnnotation(page, "ambnews/feed",
1
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
132 feed.spec, 0, annSvc.EXPIRE_WEEKS);
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
133 }
2
88b12596346d Added an about:news handler and made the default page for new tabs about:news.
Atul Varma <varmaa@toolness.com>
parents: 1
diff changeset
134 },
13
fe30d1d71ee5 Fixed the race-condition bug for selecting the about:news URL text, and also probably prevented about:news from loading in places that it wasn't supposed to.
Atul Varma <varmaa@toolness.com>
parents: 11
diff changeset
135 initBrowser: function AmbNews_initBrowser() {
fe30d1d71ee5 Fixed the race-condition bug for selecting the about:news URL text, and also probably prevented about:news from loading in places that it wasn't supposed to.
Atul Varma <varmaa@toolness.com>
parents: 11
diff changeset
136 // Listen for the addition of new <link> elements on pages.
fe30d1d71ee5 Fixed the race-condition bug for selecting the about:news URL text, and also probably prevented about:news from loading in places that it wasn't supposed to.
Atul Varma <varmaa@toolness.com>
parents: 11
diff changeset
137 window.addEventListener("DOMLinkAdded", AmbNews.onLinkAdded, false);
fe30d1d71ee5 Fixed the race-condition bug for selecting the about:news URL text, and also probably prevented about:news from loading in places that it wasn't supposed to.
Atul Varma <varmaa@toolness.com>
parents: 11
diff changeset
138
fe30d1d71ee5 Fixed the race-condition bug for selecting the about:news URL text, and also probably prevented about:news from loading in places that it wasn't supposed to.
Atul Varma <varmaa@toolness.com>
parents: 11
diff changeset
139 // Whenever the user opens a new tab, have it point to
fe30d1d71ee5 Fixed the race-condition bug for selecting the about:news URL text, and also probably prevented about:news from loading in places that it wasn't supposed to.
Atul Varma <varmaa@toolness.com>
parents: 11
diff changeset
140 // about:news by default, and select the URL.
fe30d1d71ee5 Fixed the race-condition bug for selecting the about:news URL text, and also probably prevented about:news from loading in places that it wasn't supposed to.
Atul Varma <varmaa@toolness.com>
parents: 11
diff changeset
141
fe30d1d71ee5 Fixed the race-condition bug for selecting the about:news URL text, and also probably prevented about:news from loading in places that it wasn't supposed to.
Atul Varma <varmaa@toolness.com>
parents: 11
diff changeset
142 // The following code was taken from the "New Tab Homepage 0.4"
fe30d1d71ee5 Fixed the race-condition bug for selecting the about:news URL text, and also probably prevented about:news from loading in places that it wasn't supposed to.
Atul Varma <varmaa@toolness.com>
parents: 11
diff changeset
143 // extension's 'chrome/content/tabhomepage.js' file. Thanks,
fe30d1d71ee5 Fixed the race-condition bug for selecting the about:news URL text, and also probably prevented about:news from loading in places that it wasn't supposed to.
Atul Varma <varmaa@toolness.com>
parents: 11
diff changeset
144 // Ben Basson, for figuring this out for me.
fe30d1d71ee5 Fixed the race-condition bug for selecting the about:news URL text, and also probably prevented about:news from loading in places that it wasn't supposed to.
Atul Varma <varmaa@toolness.com>
parents: 11
diff changeset
145 gBrowser.removeEventListener("NewTab", BrowserOpenTab, false);
fe30d1d71ee5 Fixed the race-condition bug for selecting the about:news URL text, and also probably prevented about:news from loading in places that it wasn't supposed to.
Atul Varma <varmaa@toolness.com>
parents: 11
diff changeset
146 function onOpenTab(aEvent) {
fe30d1d71ee5 Fixed the race-condition bug for selecting the about:news URL text, and also probably prevented about:news from loading in places that it wasn't supposed to.
Atul Varma <varmaa@toolness.com>
parents: 11
diff changeset
147 var newTab = gBrowser.addTab("about:news");
fe30d1d71ee5 Fixed the race-condition bug for selecting the about:news URL text, and also probably prevented about:news from loading in places that it wasn't supposed to.
Atul Varma <varmaa@toolness.com>
parents: 11
diff changeset
148 gBrowser.selectedTab = newTab;
fe30d1d71ee5 Fixed the race-condition bug for selecting the about:news URL text, and also probably prevented about:news from loading in places that it wasn't supposed to.
Atul Varma <varmaa@toolness.com>
parents: 11
diff changeset
149 if (gURLBar)
fe30d1d71ee5 Fixed the race-condition bug for selecting the about:news URL text, and also probably prevented about:news from loading in places that it wasn't supposed to.
Atul Varma <varmaa@toolness.com>
parents: 11
diff changeset
150 setTimeout(function() { gURLBar.select(); }, 0);
fe30d1d71ee5 Fixed the race-condition bug for selecting the about:news URL text, and also probably prevented about:news from loading in places that it wasn't supposed to.
Atul Varma <varmaa@toolness.com>
parents: 11
diff changeset
151 if (aEvent)
fe30d1d71ee5 Fixed the race-condition bug for selecting the about:news URL text, and also probably prevented about:news from loading in places that it wasn't supposed to.
Atul Varma <varmaa@toolness.com>
parents: 11
diff changeset
152 aEvent.stopPropagation();
fe30d1d71ee5 Fixed the race-condition bug for selecting the about:news URL text, and also probably prevented about:news from loading in places that it wasn't supposed to.
Atul Varma <varmaa@toolness.com>
parents: 11
diff changeset
153
fe30d1d71ee5 Fixed the race-condition bug for selecting the about:news URL text, and also probably prevented about:news from loading in places that it wasn't supposed to.
Atul Varma <varmaa@toolness.com>
parents: 11
diff changeset
154 return newTab;
2
88b12596346d Added an about:news handler and made the default page for new tabs about:news.
Atul Varma <varmaa@toolness.com>
parents: 1
diff changeset
155 }
13
fe30d1d71ee5 Fixed the race-condition bug for selecting the about:news URL text, and also probably prevented about:news from loading in places that it wasn't supposed to.
Atul Varma <varmaa@toolness.com>
parents: 11
diff changeset
156 window.BrowserOpenTab = onOpenTab;
fe30d1d71ee5 Fixed the race-condition bug for selecting the about:news URL text, and also probably prevented about:news from loading in places that it wasn't supposed to.
Atul Varma <varmaa@toolness.com>
parents: 11
diff changeset
157 gBrowser.addEventListener("NewTab", onOpenTab, false);
1
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
158 }
44bcb4975ead Added more files.
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
159 };