diff options
author | Einar Egilsson | 2007-06-02 00:24:35 +0000 |
---|---|---|
committer | Einar Egilsson | 2007-06-02 00:24:35 +0000 |
commit | b0c6f7a2bff3d57f1c8d05a561dbd0bbca0228ca (patch) | |
tree | b9d11f284141f8aacd80e917bcd05877c3aee6e1 /chrome/content/overlay.js | |
parent | f77a93fe56b90c89d3a881d9af84d43e451efe8d (diff) |
Redirector: All main functionality except Regex working.
git-svn-id: http://einaregilsson.googlecode.com/svn/mozilla/redirector/trunk@57 119bf307-c92d-0410-89bd-8f53e6181181
Diffstat (limited to 'chrome/content/overlay.js')
-rw-r--r-- | chrome/content/overlay.js | 56 |
1 files changed, 50 insertions, 6 deletions
diff --git a/chrome/content/overlay.js b/chrome/content/overlay.js index 9092938..a230d23 100644 --- a/chrome/content/overlay.js +++ b/chrome/content/overlay.js @@ -32,6 +32,9 @@ var RedirectorOverlay = { } this.strings = document.getElementById("redirector-strings"); + this.prefObserver.register(); + this.setStatusBarImg(); + RedirLib.debug("Finished initialization"); this.initialized = true; @@ -74,17 +77,17 @@ var RedirectorOverlay = { onContextMenuCommand: function(event) { - params = { inn : { url : window.content.location.href}, out : {} }; + var item = { exampleUrl : window.content.location.href, pattern: window.content.location.href}; if (gContextMenu.onLink) { - params.inn.redirect = gContextMenu.link.toString(); + item.redirectUrl = gContextMenu.link.toString(); } window.openDialog("chrome://redirector/content/redirect.xul", "redirect", - "chrome,dialog,modal,centerscreen", params); + "chrome,dialog,modal,centerscreen", item); - if (params.out.pattern) { - Redirector.addRedirect(params.out); + if (item.saved) { + Redirector.addRedirect(item); } }, @@ -96,6 +99,47 @@ var RedirectorOverlay = { }, + toggleEnabled : function(event) { + RedirLib.setBoolPref('enabled', !RedirLib.getBoolPref('enabled')); + }, + + setStatusBarImg : function() { + var statusImg = $('redirector-statusbar-img'); + + if (RedirLib.getBoolPref('enabled')) { + statusImg.src = 'chrome://redirector/content/statusactive.png' + statusImg.setAttribute('tooltiptext', this.strings.getString('enabledTooltip')); + } else { + statusImg.src = 'chrome://redirector/content/statusinactive.png' + statusImg.setAttribute('tooltiptext', this.strings.getString('disabledTooltip')); + } + }, + + prefObserver : { + + getService : function() { + return Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranchInternal); + }, + + register: function() { + this.getService().addObserver('extensions.redirector', this, false); + }, + + unregister: function() { + this.getService().removeObserver('extensions.redirector', this); + }, + + observe : function(subject, topic, data) { + if (topic == 'nsPref:changed' && data == 'extensions.redirector.enabled') { + RedirectorOverlay.setStatusBarImg(); + } + } + + } + + }; window.addEventListener("load", function(event) { RedirectorOverlay.onLoad(event); }, false); -window.addEventListener("unload", function(event) { RedirectorOverlay.onUnload(event); }, false);
\ No newline at end of file +window.addEventListener("unload", function(event) { RedirectorOverlay.onUnload(event); }, false); + + |