diff options
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/code/browserOverlay.xul.js | 2 | ||||
-rw-r--r-- | chrome/code/redirectorprefs.js | 72 | ||||
-rw-r--r-- | chrome/js/settings.js | 2 |
3 files changed, 30 insertions, 46 deletions
diff --git a/chrome/code/browserOverlay.xul.js b/chrome/code/browserOverlay.xul.js index 146e073..20ff5c6 100644 --- a/chrome/code/browserOverlay.xul.js +++ b/chrome/code/browserOverlay.xul.js @@ -16,7 +16,7 @@ var RedirectorOverlay = { this.strings = document.getElementById("redirector-strings"); this.prefs = new RedirectorPrefs(); this.changedPrefs(this.prefs); - this.prefs.addListener(this); + this.prefs.addListener(this); document.addEventListener('keypress', function(event) { if ((event.charCode == 114) && event.altKey) { //alt+r RedirectorOverlay.toggleEnabled(); diff --git a/chrome/code/redirectorprefs.js b/chrome/code/redirectorprefs.js index 40e8737..75ef936 100644 --- a/chrome/code/redirectorprefs.js +++ b/chrome/code/redirectorprefs.js @@ -6,42 +6,7 @@ function RedirectorPrefs() { RedirectorPrefs.prototype = { - //Preferences: - _version : null, - _enabled : null, - _showStatusBarIcon : null, - _showContextMenu : null, - _debugEnabled : null, - _defaultDir : null, - _redirects : null, - _proxyServerPort : null, - _prefBranch : null, - _listeners : null, - - //Preferences props - - get version() { return this._version; }, - set version(value) { this._prefBranch.setCharPref('version', value); }, - - get enabled() { return this._enabled; }, - set enabled(value) { this._prefBranch.setBoolPref('enabled', value); }, - - get showStatusBarIcon() { return this._showStatusBarIcon; }, - set showStatusBarIcon(value) { this._prefBranch.setBoolPref('showStatusBarIcon', value); }, - - get showContextMenu() { return this._showContextMenu; }, - set showContextMenu(value) { this._prefBranch.setBoolPref('showContextMenu', value); }, - - get debugEnabled() { return this._debugEnabled; }, - set debugEnabled(value) { this._prefBranch.setBoolPref('debugEnabled', value); }, - - get proxyServerPort() { return this._proxyServerPort; }, - set proxyServerPort(value) { this._prefBranch.setIntPref('proxyServerPort', value); }, - - get defaultDir() { return this._defaultDir; }, - set defaultDir(value) { this._prefBranch.setCharPref('defaultDir', value); }, - init : function() { this._prefBranch = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch("extensions.redirector."); this.reload(); @@ -54,13 +19,32 @@ RedirectorPrefs.prototype = { this.service.removeObserver('extensions.redirector', this); }, - reload : function() { - this._version = this._prefBranch.getCharPref('version'); - this._enabled = this._prefBranch.getBoolPref('enabled'); - this._showStatusBarIcon = this._prefBranch.getBoolPref('showStatusBarIcon'); - this._showContextMenu = this._prefBranch.getBoolPref('showContextMenu'); - this._debugEnabled = this._prefBranch.getBoolPref('debugEnabled'); - this._defaultDir = this._prefBranch.getCharPref('defaultDir'); + reload : function(addWatch) { + var b = this._prefBranch; + for each (var name in b.getChildList('')){ + this.unwatch(name); + var type = b.getPrefType(name); + if (type == b.PREF_STRING) { + this[name] = b.getCharPref(name); + } else if (type == b.PREF_INT) { + this[name] = b.getIntPref(name); + } else if (type == b.PREF_BOOL) { + this[name] = b.getBoolPref(name); + } + + this.watch(name, function(id,oldval,newval) { + var type = b.getPrefType(id); + if (type == b.PREF_STRING) { + b.setCharPref(id,newval); + } else if (type == b.PREF_INT) { + b.setIntPref(id, newval); + } else if (type == b.PREF_BOOL) { + dump(id+ ' ' + newval) + b.setBoolPref(id, newval); + } + return newval; + }); + } }, get service() { @@ -71,7 +55,7 @@ RedirectorPrefs.prototype = { if (topic != 'nsPref:changed') { return; } - this.reload(); + this.reload(false); for each (var listener in this._listeners) { listener && listener.changedPrefs && listener.changedPrefs(this); } @@ -83,8 +67,8 @@ RedirectorPrefs.prototype = { removeListener : function(listener) { for (var i = 0; i < this._listeners.length; i++) { - if (this._listeners[i] == listener) { this._listeners.splice(i,1); + if (this._listeners[i] == listener) { return; } } diff --git a/chrome/js/settings.js b/chrome/js/settings.js index 1a190ff..c12562b 100644 --- a/chrome/js/settings.js +++ b/chrome/js/settings.js @@ -93,7 +93,7 @@ $(document).ready(function() { var redirect = $(this.parentNode.parentNode).data('redirect'); if (PromptService.confirm(null, tr("deleteConfirmationTitle"), tr("deleteConfirmationText"))) { Redirector.deleteRedirect(redirect); - $(this.parentNode.parentNode).remove(); + $(this.parentNode.parentNode).fadeOut(function() { $(this).remove(); }); } ev.preventDefault(); }); |