localize prefwindow, remove obsolete OPML import code from prefwindow, and display message about not yet having any preferences

This commit is contained in:
Myk Melez 2008-08-04 15:55:18 -07:00
Родитель 7be3514624
Коммит 91b35f87d7
3 изменённых файлов: 7 добавлений и 65 удалений

Просмотреть файл

@ -38,64 +38,3 @@ const Cc = Components.classes;
const Ci = Components.interfaces;
const Cr = Components.results;
const Cu = Components.utils;
Cu.import("resource://snowl/modules/service.js");
Cu.import("resource://snowl/modules/datastore.js");
Cu.import("resource://snowl/modules/feed.js");
Cu.import("resource://snowl/modules/URI.js");
let SnowlPreferences = {
onImportOPML: function() {
let fp = Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker);
fp.init(window, "Import", Ci.nsIFilePicker.modeOpen);
fp.appendFilter("OPML Files", "*.opml");
fp.appendFilters(Ci.nsIFilePicker.filterXML);
fp.appendFilters(Ci.nsIFilePicker.filterAll);
let rv = fp.show();
if (rv != Ci.nsIFilePicker.returnOK)
return;
let request = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].
createInstance(Ci.nsIXMLHttpRequest);
request.open("GET", fp.fileURL.spec, false);
// Since the file probably ends in .opml, we have to force XHR to treat it
// as XML by overriding the MIME type it would otherwise select.
request.overrideMimeType("text/xml");
request.send(null);
let xmlDocument = request.responseXML;
let outline = xmlDocument.getElementsByTagName("body")[0];
this._importOutline(outline);
},
_importOutline: function(aOutline) {
// If this outline represents a feed, subscribe the user to the feed.
let uri = URI.get(aOutline.getAttribute("xmlUrl"));
if (uri) {
// FIXME: make sure the user isn't already subscribed to the feed
// before subscribing them.
let name = aOutline.getAttribute("title") || aOutline.getAttribute("text") || "untitled";
this._importItem(uri, name);
}
if (aOutline.hasChildNodes()) {
let children = aOutline.childNodes;
for (let i = 0; i < children.length; i++) {
let child = children[i];
// Only deal with "outline" elements; ignore text, etc. nodes.
if (child.nodeName != "outline")
continue;
this._importOutline(child);
}
}
},
_importItem: function(aURL, aName) {
let subscriber = new SnowlFeedSubscriber(aURL, aName);
subscriber.subscribe();
}
};

Просмотреть файл

@ -38,14 +38,15 @@
<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
<!DOCTYPE prefwindow SYSTEM "chrome://snowl/locale/preferences.dtd">
<prefwindow xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="Snowl Preferences"
buttons="none">
title="&prefwindow.title;">
<script type="application/x-javascript" src="chrome://snowl/content/preferences.js"/>
<prefpane label="Snowl Preferences">
<button label="Import OPML" oncommand="SnowlPreferences.onImportOPML(event);"/>
<prefpane>
&noPreferences.message;
</prefpane>
</prefwindow>

Просмотреть файл

@ -0,0 +1,2 @@
<!ENTITY prefwindow.title "Snowl Preferences">
<!ENTITY noPreferences.message "Snowl does not yet have preferences.">