From 14c86c9676cd02a61c0a2d1254ea1843d7713473 Mon Sep 17 00:00:00 2001 From: Einar Egilsson Date: Mon, 29 Aug 2011 15:40:18 +0200 Subject: Very rough draft of html settings --- chrome/code/browserOverlay.xul.js | 2 +- chrome/code/redirect.js | 27 ++------------------------- chrome/code/xpcom.js | 18 +++++++++++++----- 3 files changed, 16 insertions(+), 31 deletions(-) (limited to 'chrome/code') diff --git a/chrome/code/browserOverlay.xul.js b/chrome/code/browserOverlay.xul.js index d4df3b9..146e073 100644 --- a/chrome/code/browserOverlay.xul.js +++ b/chrome/code/browserOverlay.xul.js @@ -91,7 +91,7 @@ var RedirectorOverlay = { windowName, "chrome,dialog,resizable=yes,centerscreen", this); } - + gBrowser.selectedTab = gBrowser.addTab("chrome://redirector/content/settings.html"); }, statusBarClick : function(event) { diff --git a/chrome/code/redirect.js b/chrome/code/redirect.js index 5b977d0..8b0b1d2 100644 --- a/chrome/code/redirect.js +++ b/chrome/code/redirect.js @@ -41,10 +41,7 @@ Redirect.prototype = { //Functions clone : function() { - return new Redirect(this.exampleUrl, this.includePattern, - this.redirectUrl, this.patternType, - this.excludePattern, this.unescapeMatches, - this.disabled); + return new Redirect().fromObject(this.toObject()); }, compile : function() { @@ -68,6 +65,7 @@ Redirect.prototype = { for (var prop in o) { this[prop] = o[prop]; } + return this; }, copyValues : function(other) { @@ -80,17 +78,6 @@ Redirect.prototype = { this.disabled = other.disabled; }, - deserialize : function(str) { - if (!str || !str.split) { - throw Error("Invalid serialized redirect: " + str); - } - var parts = str.split(',,,'); - if (parts.length < 5) { - throw Error("Invalid serialized redirect, too few fields: " + str); - } - this._init.apply(this, parts); - }, - equals : function(redirect) { return this.exampleUrl == redirect.exampleUrl && this.includePattern == redirect.includePattern @@ -137,16 +124,6 @@ Redirect.prototype = { return this.patternType == Redirect.WILDCARD; }, - serialize : function() { - return [ this.exampleUrl - , this.includePattern - , this.redirectUrl - , this.patternType - , this.excludePattern - , this.unescapeMatches - , this.disabled ].join(',,,'); - }, - test : function() { return this.getMatch(this.exampleUrl); }, diff --git a/chrome/code/xpcom.js b/chrome/code/xpcom.js index a983433..e81f58e 100644 --- a/chrome/code/xpcom.js +++ b/chrome/code/xpcom.js @@ -1,7 +1,4 @@ -var EXPORTED_SYMBOLS = [ -'Ci', 'Cc', 'Cr', 'ServerSocket', 'ScriptableInputStream', 'FileInputStream', 'ConverterInputStream', 'LocalFile']; - Ci = Components.interfaces; Cc = Components.classes; Cr = Components.results; @@ -11,10 +8,21 @@ const ScriptableInputStream = Components.Constructor("@mozilla.org/scriptableinp const FileInputStream = Components.Constructor("@mozilla.org/network/file-input-stream;1", "nsIFileInputStream", "init"); const ConverterInputStream = Components.Constructor("@mozilla.org/intl/converter-input-stream;1", "nsIConverterInputStream", "init"); const LocalFile = Components.Constructor("@mozilla.org/file/local;1", "nsILocalFile", "initWithPath"); - -function Service(className, interfaceName) +const FilePicker = Components.Constructor("@mozilla.org/filepicker;1", "nsIFilePicker", "init"); +const FilePickerMode = { save : Ci.nsIFilePicker.modeSave, open : Ci.nsIFilePicker.modeOpen }; + +function Service(className, interfaceName) { return Cc[className].getService(Ci[interfaceName]); } const PromptService = Service("@mozilla.org/embedcomp/prompt-service;1","nsIPromptService"); const IOService = Service("@mozilla.org/network/io-service;1","nsIIOService"); +const LocaleService = Service("@mozilla.org/intl/nslocaleservice;1", "nsILocaleService"); +const StringBundleService = Service("@mozilla.org/intl/stringbundle;1", "nsIStringBundleService"); + +var EXPORTED_SYMBOLS = []; +for (var name in this) { + if (name != 'Service' && name != 'QueryInterface' && name != 'name' && name != 'EXPORTED_SYMBOLS') { + EXPORTED_SYMBOLS.push(name); + } +} -- cgit v1.2.3-70-g09d2