Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 XPCOMUtils.defineLazyModuleGetter(this, "Feeds",
7 "resource:///modules/Feeds.jsm");
9 function initFeedTab()
10 {
11 const feedTypes = {
12 "application/rss+xml": gBundle.getString("feedRss"),
13 "application/atom+xml": gBundle.getString("feedAtom"),
14 "text/xml": gBundle.getString("feedXML"),
15 "application/xml": gBundle.getString("feedXML"),
16 "application/rdf+xml": gBundle.getString("feedXML")
17 };
19 // get the feeds
20 var linkNodes = gDocument.getElementsByTagName("link");
21 var length = linkNodes.length;
22 for (var i = 0; i < length; i++) {
23 var link = linkNodes[i];
24 if (!link.href)
25 continue;
27 var rel = link.rel && link.rel.toLowerCase();
28 var rels = {};
29 if (rel) {
30 for each (let relVal in rel.split(/\s+/))
31 rels[relVal] = true;
32 }
34 if (rels.feed || (link.type && rels.alternate && !rels.stylesheet)) {
35 var type = Feeds.isValidFeed(link, gDocument.nodePrincipal, "feed" in rels);
36 if (type) {
37 type = feedTypes[type] || feedTypes["application/rss+xml"];
38 addRow(link.title, type, link.href);
39 }
40 }
41 }
43 var feedListbox = document.getElementById("feedListbox");
44 document.getElementById("feedTab").hidden = feedListbox.getRowCount() == 0;
45 }
47 function onSubscribeFeed()
48 {
49 var listbox = document.getElementById("feedListbox");
50 openUILinkIn(listbox.selectedItem.getAttribute("feedURL"), "current",
51 { ignoreAlt: true });
52 }
54 function addRow(name, type, url)
55 {
56 var item = document.createElement("richlistitem");
57 item.setAttribute("feed", "true");
58 item.setAttribute("name", name);
59 item.setAttribute("type", type);
60 item.setAttribute("feedURL", url);
61 document.getElementById("feedListbox").appendChild(item);
62 }