aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEinar Egilsson2011-09-04 22:53:16 +0200
committerEinar Egilsson2011-09-04 22:53:16 +0200
commit4b612baf4f29178214edec130856d83a40bf473d (patch)
tree20e36e3fcf7a24e829640c2fd605622f14af0edc
parent8fb65cf8aeaaf66636698310c0168929fc1a2ce0 (diff)
Total restructuring of files and deletion of old files
-rw-r--r--chrome.manifest7
-rw-r--r--chrome/browserOverlay.xul (renamed from chrome/ui/browserOverlay.xul)14
-rw-r--r--chrome/code/editRedirect.xul.js103
-rw-r--r--chrome/code/settings.xul.js276
-rw-r--r--chrome/css/redirector.css40
-rw-r--r--chrome/help.html (renamed from chrome/ui/help.html)0
-rw-r--r--chrome/images/redirector.png (renamed from chrome/ui/skin/redirector.png)bin1462 -> 1462 bytes
-rw-r--r--chrome/images/statusactive.png (renamed from chrome/ui/skin/statusactive.png)bin360 -> 360 bytes
-rw-r--r--chrome/images/statusinactive.png (renamed from chrome/ui/skin/statusinactive.png)bin396 -> 396 bytes
-rw-r--r--chrome/js/browserOverlay.js (renamed from chrome/code/browserOverlay.xul.js)26
-rw-r--r--chrome/js/component.js (renamed from chrome/code/component.js)2
-rw-r--r--chrome/js/proxyserver.js (renamed from chrome/code/proxyserver.js)2
-rw-r--r--chrome/js/redirect.js (renamed from chrome/code/redirect.js)0
-rw-r--r--chrome/js/redirector-ui.js (renamed from chrome/js/settings.js)55
-rw-r--r--chrome/js/redirector.js (renamed from chrome/code/redirector.js)8
-rw-r--r--chrome/js/redirectorprefs.js (renamed from chrome/code/redirectorprefs.js)0
-rw-r--r--chrome/js/xpcom.js (renamed from chrome/code/xpcom.js)0
-rw-r--r--chrome/redirector.html71
-rw-r--r--chrome/settings.html112
-rw-r--r--chrome/ui/editRedirect.xul58
-rw-r--r--chrome/ui/settings.xul119
-rw-r--r--chrome/ui/skin/movedown.pngbin294 -> 0 bytes
-rw-r--r--chrome/ui/skin/movedowndisabled.pngbin361 -> 0 bytes
-rw-r--r--chrome/ui/skin/moveup.pngbin360 -> 0 bytes
-rw-r--r--chrome/ui/skin/moveupdisabled.pngbin282 -> 0 bytes
-rw-r--r--chrome/ui/skin/redirector.css15
-rw-r--r--chrome/unittest/run.html (renamed from chrome/code/unittest/run.html)0
-rw-r--r--chrome/unittest/testcases.js (renamed from chrome/code/unittest/testcases.js)0
-rw-r--r--locale/en-US/browserOverlay.dtd (renamed from locale/en-US/browserOverlay.xul.dtd)0
29 files changed, 180 insertions, 728 deletions
diff --git a/chrome.manifest b/chrome.manifest
index e758bd7..5221095 100644
--- a/chrome.manifest
+++ b/chrome.manifest
@@ -1,12 +1,9 @@
-
content redirector file:chrome/
locale redirector en-US file:locale/en-US/
-skin redirector classic/1.0 file:chrome/ui/skin/
-overlay chrome://browser/content/browser.xul chrome://redirector/content/ui/browserOverlay.xul
+overlay chrome://browser/content/browser.xul chrome://redirector/content/browserOverlay.xul
-component {b7a7a54f-0581-47ff-b086-d6920cb7a3f7} chrome/code/component.js
+component {b7a7a54f-0581-47ff-b086-d6920cb7a3f7} chrome/js/component.js
contract @einaregilsson.com/redirector;1 {b7a7a54f-0581-47ff-b086-d6920cb7a3f7}
-category profile-after-change Redirector @einaregilsson.com/redirector;1
category content-policy Redirector @einaregilsson.com/redirector;1
category net-channel-event-sinks Redirector @einaregilsson.com/redirector;1 \ No newline at end of file
diff --git a/chrome/ui/browserOverlay.xul b/chrome/browserOverlay.xul
index 32bf1d5..a8dda3c 100644
--- a/chrome/ui/browserOverlay.xul
+++ b/chrome/browserOverlay.xul
@@ -1,11 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- $Id$ -->
-<!DOCTYPE overlay SYSTEM "chrome://redirector/locale/browserOverlay.xul.dtd">
+<!DOCTYPE overlay SYSTEM "chrome://redirector/locale/browserOverlay.dtd">
<overlay id="redirector-overlay"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
- <script src="../code/redirect.js"/>
- <script src="../code/redirectorprefs.js"/>
- <script src="../code/browserOverlay.xul.js"/>
+ <script src="chrome://redirector/content/js/browserOverlay.js"/>
<stringbundleset id="stringbundleset">
<stringbundle id="redirector-strings" src="chrome://redirector/locale/redirector.properties"/>
@@ -23,12 +20,11 @@
oncommand="RedirectorOverlay.onContextMenuCommand(event)"/>
</popup>
<statusbar id="status-bar">
- <statusbarpanel id="redirector-status">
- <image id="redirector-statusbar-img" src="chrome://redirector/skin/statusactive.png"
+ <statusbarpanel id="redirector-status">
+ <image id="redirector-statusbar-img" src="chrome://redirector/content/images/statusactive.png"
tooltiptext="Redirector is enabled;"
style="width:16px; height:16px;"
onclick="RedirectorOverlay.statusBarClick(event);" />
- </statusbarpanel>
+ </statusbarpanel>
</statusbar>
-
</overlay> \ No newline at end of file
diff --git a/chrome/code/editRedirect.xul.js b/chrome/code/editRedirect.xul.js
deleted file mode 100644
index 87f6533..0000000
--- a/chrome/code/editRedirect.xul.js
+++ /dev/null
@@ -1,103 +0,0 @@
-Components.utils.import("chrome://redirector/content/code/redirect.js");
-
-var EditRedirect = {
- txtExampleUrl : null,
- txtIncludePattern : null,
- txtRedirectUrl : null,
- txtExcludePattern : null,
- chkUnescapeMatches : null,
- rdoRegex : null,
- rdoWildcard : null,
-
- onLoad : function() {
- var args = window.arguments[0];
- var redirect = args.redirect;
- this.txtExampleUrl = document.getElementById('txtExampleUrl');
- this.txtIncludePattern = document.getElementById('txtIncludePattern');
- this.txtRedirectUrl= document.getElementById('txtRedirectUrl');
- this.txtExcludePattern= document.getElementById('txtExcludePattern');
- this.chkUnescapeMatches= document.getElementById('chkUnescapeMatches');
- this.rdoWildcard= document.getElementById('rdoWildcard');
- this.rdoRegex = document.getElementById('rdoRegex');
-
- this.txtExampleUrl.value = redirect.exampleUrl;
- this.txtIncludePattern.value = redirect.includePattern;
- this.txtExcludePattern.value = redirect.excludePattern;
- this.txtRedirectUrl.value = redirect.redirectUrl;
- this.chkUnescapeMatches.setAttribute('checked', redirect.unescapeMatches);
- this.rdoRegex.setAttribute('selected', redirect.isRegex());
- this.rdoWildcard.setAttribute('selected', redirect.isWildcard());
-
- this.txtIncludePattern.focus();
- this.strings = document.getElementById("redirector-strings");
- },
-
- onAccept : function() {
- var args = window.arguments[0];
- var msg, title;
- args.saved = true;
- this.saveValues(args.redirect);
-
- var oldDisabled = args.redirect.disabled;
- args.redirect.disabled = false;
- if (!/^\s*$/.test(args.redirect.exampleUrl)) {
- var result = args.redirect.getMatch(args.redirect.exampleUrl);
- if (!result.isMatch) {
- title = this.strings.getString('warningExampleUrlDoesntMatchPatternTitle');
- msg = this.strings.getString('warningExampleUrlDoesntMatchPattern');
- var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
- var rv = ps.confirmEx(window, title, msg, ps.STD_YES_NO_BUTTONS, ps.BUTTON_TITLE_YES, ps.BUTTON_TITLE_NO, null, null, {});
- return rv == 0;
- } else {
- var resultUrl = result.redirectTo;
- if (!resultUrl.match(/https?:/)) {
- var ioService = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
- var uri = ioService.newURI(args.redirect.exampleUrl, null, null);
- resultUrl = uri.resolve(resultUrl);
- }
-
- var secondResult = args.redirect.getMatch(resultUrl);
- if (secondResult.isMatch) {
- title = this.strings.getString('errorExampleUrlMatchesRecursiveTitle');
- msg = this.strings.getFormattedString('errorExampleUrlMatchesRecursive', [args.redirect.exampleUrl, resultUrl]);
- this.msgBox(title, msg);
- return false;
- }
- }
- }
- return true;
- },
-
- msgBox : function(title, text) {
- Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
- .getService(Components.interfaces.nsIPromptService)
- .alert(window, title, text);
- },
-
- saveValues : function(redirect) {
- redirect.exampleUrl = this.txtExampleUrl.value;
- redirect.includePattern = this.txtIncludePattern.value;
- redirect.excludePattern = this.txtExcludePattern.value;
- redirect.redirectUrl = this.txtRedirectUrl.value;
- redirect.patternType = this.rdoRegex.getAttribute('selected') == 'true' ? Redirect.REGEX : Redirect.WILDCARD;
- var val = this.chkUnescapeMatches.getAttribute('checked');
- redirect.unescapeMatches = val === 'true' || val === true;
- //Disabled cannot be set here
- },
-
- testPattern : function() {
- try {
- var redirect = new Redirect();
- this.saveValues(redirect);
- var extName = this.strings.getString('extensionName');
- var result = redirect.test();
- if (result.isMatch) {
- this.msgBox(extName, this.strings.getFormattedString('testPatternSuccess', [redirect.includePattern, redirect.exampleUrl, result.redirectTo]));
- } else if (result.isExcludeMatch) {
- this.msgBox(extName, this.strings.getFormattedString('testPatternExclude', [redirect.exampleUrl, redirect.excludePattern]));
- } else {
- this.msgBox(extName, this.strings.getFormattedString('testPatternFailure', [redirect.includePattern, redirect.exampleUrl]));
- }
- } catch(e) {alert(e);}
- }
-}; \ No newline at end of file
diff --git a/chrome/code/settings.xul.js b/chrome/code/settings.xul.js
deleted file mode 100644
index bee7817..0000000
--- a/chrome/code/settings.xul.js
+++ /dev/null
@@ -1,276 +0,0 @@
-Components.utils.import("chrome://redirector/content/code/redirector.js");
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-const nsLocalFile = Components.Constructor("@mozilla.org/file/local;1", "nsILocalFile", "initWithPath");
-
-var Settings = {
-
- lstRedirects: null,
- btnDelete : null,
- btnEdit : null,
- btnUp : null,
- btnDown : null,
- btnExport : null,
- btnImport : null,
- chkEnableRedirector : null,
- chkShowStatusBarIcon : null,
- chkShowContextMenu : null,
- chkEnableDebugOutput : null,
- prefs : null,
-
- onLoad : function() {
- try {
- //Get references to controls
- this.lstRedirects = document.getElementById('lstRedirects');
- this.btnDelete = document.getElementById('btnDelete');
- this.btnEdit = document.getElementById('btnEdit');
- this.btnUp = document.getElementById('btnUp');
- this.btnDown = document.getElementById('btnDown');
- this.btnExport = document.getElementById('btnExport');
- this.btnImport = document.getElementById('btnImport');
- this.chkEnableRedirector = document.getElementById('chkEnableRedirector');
- this.chkShowStatusBarIcon = document.getElementById('chkShowStatusBarIcon');
- this.chkShowContextMenu = document.getElementById('chkShowContextMenu');
- this.chkEnableDebugOutput = document.getElementById('chkEnableDebugOutput');
-
- this.prefs = new RedirectorPrefs();
- //Preferences
- this.changedPrefs(this.prefs);
- this.prefs.addListener(this);
-
- //Redirect list
- this.lstRedirects.selType = 'single';
- this.template = document.getElementsByTagName('richlistitem')[0];
- this.lstRedirects.removeChild(this.template);
- var list = [];
- for (var i = 0; i < Redirector.redirectCount; i++) {
- list.push(Redirector.getRedirectAt(i));
- }
- this.addItemsToListBox(list);
- this.selectionChange();
-
- this.strings = document.getElementById('redirector-strings');
- this.strings.getPluralized = function(id, number) {
- id += number == 1 ? 'Singular' : '';
- return this.getFormattedString(id, [number]);
- };
- } catch(e) {
- alert(e);
- }
- },
-
- onUnload : function() {
- this.prefs.dispose();
- },
-
- changedPrefs : function(prefs) {
- this.chkEnableRedirector.setAttribute('checked', prefs.enabled);
- this.chkShowStatusBarIcon.setAttribute('checked', prefs.showStatusBarIcon);
- this.chkShowContextMenu.setAttribute('checked', prefs.showContextMenu);
- this.chkEnableDebugOutput.setAttribute('checked', prefs.debugEnabled);
- },
-
- addItemsToListBox : function(items) {
-
- var item, row, value, newItem;
-
- for each (item in items) {
- newItem = this.template.cloneNode(true);
-
- newItem.getElementsByAttribute('name', 'dscrIncludePattern')[0].setAttribute('value', item.includePattern);
- newItem.getElementsByAttribute('name', 'dscrExcludePattern')[0].setAttribute('value', item.excludePattern);
- newItem.getElementsByAttribute('name', 'dscrRedirectTo')[0].setAttribute('value', item.redirectUrl);
- var checkEnabled = newItem.getElementsByAttribute('name', 'chkEnabled')[0];
- checkEnabled.setAttribute('checked', !item.disabled);
- newItem.setAttribute('class', item.disabled ? 'disabledRedirect' : '');
- newItem.item = item;
- this.lstRedirects.appendChild(newItem);
- newItem.setAttribute('selected', false)
- }
-
- //Enable, disable functionality
- this.lstRedirects.addEventListener('click', function(ev) {
- if (ev.originalTarget && ev.originalTarget.tagName == 'checkbox') {
- var parent = ev.originalTarget.parentNode;
- while (!parent.item) {
- parent = parent.parentNode;
- }
- parent.item.disabled = !ev.originalTarget.hasAttribute('checked');
- parent.setAttribute('class', parent.item.disabled ? 'disabledRedirect' : '');
- Redirector.save();
- }
- },false);
- },
-
- moveUp : function(){
- if (this.lstRedirects.selectedIndex <= 0) {
- return;
- }
- this.switchItems(this.lstRedirects.selectedIndex-1);
- },
-
- moveDown : function() {
- if (this.lstRedirects.selectedIndex == Redirector.redirectCount-1) {
- return;
- }
- this.switchItems(this.lstRedirects.selectedIndex);
- },
-
- switchItems : function(firstIndex) {
- Redirector.switchItems(firstIndex, firstIndex+1);
- var firstItem = this.lstRedirects.children[firstIndex];
- var secondItem = this.lstRedirects.children[firstIndex+1];
- this.lstRedirects.removeChild(secondItem);
- this.lstRedirects.insertBefore(secondItem, firstItem);
- this.selectionChange();
- },
-
- setListItemValues : function(listItem, item){
- listItem.getElementsByAttribute('name', 'dscrIncludePattern')[0].setAttribute('value', item.includePattern);
- listItem.getElementsByAttribute('name', 'dscrExcludePattern')[0].setAttribute('value', item.excludePattern);
- listItem.getElementsByAttribute('name', 'dscrRedirectTo')[0].setAttribute('value', item.redirectUrl);
- },
-
- preferenceChange : function(event) {
- this.prefs[event.originalTarget.getAttribute('preference')] = event.originalTarget.hasAttribute('checked');
- },
-
- addRedirect : function() {
- var args = { saved : false, redirect : new Redirect() };
- window.openDialog("chrome://redirector/content/ui/editRedirect.xul", "redirect", "chrome,dialog,modal,centerscreen", args);
- if (args.saved) {
- Redirector.addRedirect(args.redirect);
- //Get it from redirector since it has processed it and it's no longer the same
- //object as the one we added.
- this.addItemsToListBox([Redirector.getRedirectAt(Redirector.redirectCount-1)]);
- this.selectionChange();
- }
- },
-
- editRedirect : function() {
-
- if (this.lstRedirects.selectedIndex == -1) {
- return;
- }
- //.selectedItem is still there after it has been removed, that's why we have the .selectedIndex check above as well
- var listItem = this.lstRedirects.selectedItem;
- if (!listItem) {
- return;
- }
- var redirect = listItem.item;
- var args = { saved: false, "redirect":redirect.clone()};
- window.openDialog("chrome://redirector/content/ui/editRedirect.xul", "redirect", "chrome,dialog,modal,centerscreen", args);
-
- if (args.saved) {
- redirect.copyValues(args.redirect);
- this.setListItemValues(listItem, redirect);
- Redirector.save();
- this.selectionChange();
- }
- },
-
- deleteRedirect : function() {
- var index = this.lstRedirects.selectedIndex;
-
- if (index == -1) {
- return;
- }
-
- var text = this.strings.getString("deleteConfirmationText");
- var title = this.strings.getString("deleteConfirmationTitle");
- var reallyDelete = Cc["@mozilla.org/embedcomp/prompt-service;1"].getService(Ci.nsIPromptService).confirm(null, title, text);
- if (!reallyDelete) {
- return;
- }
-
- try {
- this.lstRedirects.removeChild(this.lstRedirects.children[index]);
- Redirector.deleteRedirectAt(index);
- this.selectionChange();
- } catch(e) {
- alert(e);
- }
- },
-
- listKeypress : function(event) {
- if (event.keyCode == 13) { //Enter button
- this.editRedirect();
- } else if (event.keyCode == 46) { //Del button
- this.deleteRedirect();
- }
- },
-
- selectionChange : function() {
- if (!this.lstRedirects) {
- return;
- }
- var index = this.lstRedirects.selectedIndex;
-
- this.btnEdit.disabled = (index == -1);
- this.btnDelete.disabled = (index == -1);
- this.btnUp.disabled = (index <= 0);
- this.btnDown.disabled = (index == -1 || index >= Redirector.redirectCount-1);
- this.btnExport.disabled = (Redirector.redirectCount== 0);
- },
-
- getFile : function(captionKey, mode) {
- //Mostly borrowed from Adblock Plus
- var picker = Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker);
- picker.init(window, this.strings.getString(captionKey), mode);
- picker.defaultExtension = ".rjson";
- var dir = this.prefs.defaultDir;
- if (dir) {
- picker.displayDirectory = new nsLocalFile(dir);
- }
- picker.appendFilter(this.strings.getString('redirectorFiles'), '*.rjson');
-
- if (picker.show() == picker.returnCancel) {
- return null;
- }
- this.prefs.defaultDir = picker.displayDirectory.path;
- return picker.file;
- },
-
- export : function() {
- var file = this.getFile('exportCaption', Ci.nsIFilePicker.modeSave);
- if (file) {
- Redirector.exportRedirects(file);
- }
- },
-
- import : function() {
- var file = this.getFile('importCaption', Ci.nsIFilePicker.modeOpen);
- var result;
- if (!file) {
- return;
- }
- result = Redirector.importRedirects(file);
- var msg, imported, existed;
- imported = result & 0xFFFF;
- existed = result >> 16;
-
- if (imported > 0) {
- msg = this.strings.getPluralized('importedMessage', imported);
- if (existed > 0) {
- msg += ', ' + this.strings.getPluralized('existedMessage',existed);
- } else {
- msg += '.';
- }
- } else if (imported == 0 && existed > 0) {
- msg = this.strings.getPluralized('allExistedMessage', existed);
- } else { //Both 0
- msg = this.strings.getString('importedNone');
- }
-
- var title = this.strings.getString("importResult");
- Cc["@mozilla.org/embedcomp/prompt-service;1"].getService(Ci.nsIPromptService).alert(null, title, msg);
-
- if (imported > 0) {
- var newlist = [];
- for (var i = Redirector.redirectCount-imported; i < Redirector.redirectCount; i++) {
- newlist.push(Redirector.getRedirectAt(i));
- }
- this.addItemsToListBox(newlist);
- }
- }
-};
diff --git a/chrome/css/redirector.css b/chrome/css/redirector.css
new file mode 100644
index 0000000..a9880d3
--- /dev/null
+++ b/chrome/css/redirector.css
@@ -0,0 +1,40 @@
+body {
+ font-family: Tahoma, Arial, sans-serif;
+ font-size:10pt;
+ min-height:100%;
+ background:-moz-linear-gradient(top, #bcd, #fff);
+ margin:0; padding:0;
+}
+html {
+ height:100%;
+ margin:0;
+ padding:0;
+}
+h1 { font-family: ; text-align:center; color:#555; text-shadow:0px 0px 15px white; font-size:34pt; padding:0px; margin:20px 0px 0px 0px; letter-spacing:2px; }
+label { display:table-cell; }
+input { display:table-cell; }
+li { margin:0; padding:5px; border-top: dotted 1px grey;}
+li:first-child { border-top:none;}
+#actions { width:600px; margin:10px auto; text-align:center; }
+#redirect-list {
+ -moz-user-select: -moz-none;
+
+ border:solid 1px grey;
+ margin:auto;
+ padding:0px;
+ width: 700px;
+ list-style-type:none;
+ list-style-position:outside;
+ border-radius:3px;
+ box-shadow: 0px 0px 2px grey;
+ text-shadow: 1px 1px 1px white;
+}
+#config { display:none; position:fixed; margin:auto;}
+button { border:solid 1px grey; border-radius:4px; background:-moz-linear-gradient(top, #ccc, #fff); cursor:pointer;}
+h5 { text-align:center; margin:0px; padding-left:130px; }
+.pattern, .redirectTo { color:blue; font-style:italic;}
+.exampleUrl, .redirectResult { color:blue; }
+#redirect-list li:nth-child(odd) { background:-moz-linear-gradient(top, #ddf, #cce); }
+#redirect-list li:nth-child(even) { background-color:#fff; }
+#redirect-form div { display:table-row; }
+#redirect-form { display:none; position:fixed; margin:0 auto; border:solid 1px black; }
diff --git a/chrome/ui/help.html b/chrome/help.html
index 4534d96..4534d96 100644
--- a/chrome/ui/help.html
+++ b/chrome/help.html
diff --git a/chrome/ui/skin/redirector.png b/chrome/images/redirector.png
index f8de12c..f8de12c 100644
--- a/chrome/ui/skin/redirector.png
+++ b/chrome/images/redirector.png
Binary files differ
diff --git a/chrome/ui/skin/statusactive.png b/chrome/images/statusactive.png
index 06ce766..06ce766 100644
--- a/chrome/ui/skin/statusactive.png
+++ b/chrome/images/statusactive.png
Binary files differ
diff --git a/chrome/ui/skin/statusinactive.png b/chrome/images/statusinactive.png
index 8b83562..8b83562 100644
--- a/chrome/ui/skin/statusinactive.png
+++ b/chrome/images/statusinactive.png
Binary files differ
diff --git a/chrome/code/browserOverlay.xul.js b/chrome/js/browserOverlay.js
index 20ff5c6..ed1ab73 100644
--- a/chrome/code/browserOverlay.xul.js
+++ b/chrome/js/browserOverlay.js
@@ -1,5 +1,5 @@
-
-Components.utils.import("chrome://redirector/content/code/redirector.js");
+Components.utils.import("chrome://redirector/content/js/redirectorprefs.js");
+Components.utils.import("chrome://redirector/content/js/redirector.js");
var RedirectorOverlay = {
@@ -40,10 +40,10 @@ var RedirectorOverlay = {
var statusImg = document.getElementById('redirector-statusbar-img');
if (prefs.enabled) {
- statusImg.src = 'chrome://redirector/skin/statusactive.png'
+ statusImg.src = 'chrome://redirector/content/images/statusactive.png'
statusImg.setAttribute('tooltiptext', this.strings.getString('enabledTooltip'));
} else {
- statusImg.src = 'chrome://redirector/skin/statusinactive.png'
+ statusImg.src = 'chrome://redirector/content/images/statusinactive.png'
statusImg.setAttribute('tooltiptext', this.strings.getString('disabledTooltip'));
}
@@ -65,11 +65,7 @@ var RedirectorOverlay = {
redirect.redirectUrl = gContextMenu.link.toString();
}
- var args = { saved : false, 'redirect' : redirect };
- window.openDialog("chrome://redirector/content/ui/editRedirect.xul", "redirect", "chrome,dialog,modal,centerscreen", args);
- if (args.saved) {
- Redirector.addRedirect(args.redirect);
- }
+ gBrowser.selectedTab = gBrowser.addTab("chrome://redirector/content/redirector.html");
},
onMenuItemCommand: function(event) {
@@ -81,17 +77,7 @@ var RedirectorOverlay = {
},
openSettings : function() {
- var windowName = "redirectorSettings";
- var windowsMediator = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator);
- var win = windowsMediator.getMostRecentWindow(windowName);
- if (win) {
- win.focus();
- } else {
- window.openDialog("chrome://redirector/content/ui/settings.xul",
- windowName,
- "chrome,dialog,resizable=yes,centerscreen", this);
- }
- gBrowser.selectedTab = gBrowser.addTab("chrome://redirector/content/settings.html");
+ gBrowser.selectedTab = gBrowser.addTab("chrome://redirector/content/redirector.html");
},
statusBarClick : function(event) {
diff --git a/chrome/code/component.js b/chrome/js/component.js
index 453d134..7b19109 100644
--- a/chrome/code/component.js
+++ b/chrome/js/component.js
@@ -2,7 +2,7 @@ Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
Ci = Components.interfaces;
Cr = Components.results;
-Components.utils.import("chrome://redirector/content/code/redirector.js");
+Components.utils.import("chrome://redirector/content/js/redirector.js");
function RedirectorComponent() { }
diff --git a/chrome/code/proxyserver.js b/chrome/js/proxyserver.js
index 5d4f1d6..4881f59 100644
--- a/chrome/code/proxyserver.js
+++ b/chrome/js/proxyserver.js
@@ -1,4 +1,4 @@
-Components.utils.import("chrome://redirector/content/code/xpcom.js");
+Components.utils.import("chrome://redirector/content/js/xpcom.js");
var EXPORTED_SYMBOLS = ['RedirectorProxy'];
diff --git a/chrome/code/redirect.js b/chrome/js/redirect.js
index 8b0b1d2..8b0b1d2 100644
--- a/chrome/code/redirect.js
+++ b/chrome/js/redirect.js
diff --git a/chrome/js/settings.js b/chrome/js/redirector-ui.js
index c12562b..e0a5d07 100644
--- a/chrome/js/settings.js
+++ b/chrome/js/redirector-ui.js
@@ -1,6 +1,6 @@
-Components.utils.import("chrome://redirector/content/code/redirector.js");
-Components.utils.import("chrome://redirector/content/code/redirectorprefs.js");
-Components.utils.import("chrome://redirector/content/code/xpcom.js");
+Components.utils.import("chrome://redirector/content/js/redirector.js");
+Components.utils.import("chrome://redirector/content/js/redirectorprefs.js");
+Components.utils.import("chrome://redirector/content/js/xpcom.js");
$(document).ready(function() {
var prefs = new RedirectorPrefs();
@@ -69,7 +69,6 @@ $(document).ready(function() {
for (var i = Redirector.redirectCount-imported; i < Redirector.redirectCount; i++) {
newlist.push(Redirector.getRedirectAt(i));
}
- //this.addItemsToListBox(newlist);
}
}
@@ -159,4 +158,50 @@ $(document).ready(function() {
var pref = $(this).attr('data-pref');
prefs[pref] = !!$(this).attr('checked');
});
-}); \ No newline at end of file
+});
+
+/*
+ testPattern : function() {
+ try {
+ var redirect = new Redirect();
+ this.saveValues(redirect);
+ var extName = this.strings.getString('extensionName');
+ var result = redirect.test();
+ if (result.isMatch) {
+ this.msgBox(extName, this.strings.getFormattedString('testPatternSuccess', [redirect.includePattern, redirect.exampleUrl, result.redirectTo]));
+ } else if (result.isExcludeMatch) {
+ this.msgBox(extName, this.strings.getFormattedString('testPatternExclude', [redirect.exampleUrl, redirect.excludePattern]));
+ } else {
+ this.msgBox(extName, this.strings.getFormattedString('testPatternFailure', [redirect.includePattern, redirect.exampleUrl]));
+ }
+ } catch(e) {alert(e);}
+ }
+
+ if (!/^\s*$/.test(args.redirect.exampleUrl)) {
+ var result = args.redirect.getMatch(args.redirect.exampleUrl);
+ if (!result.isMatch) {
+ title = this.strings.getString('warningExampleUrlDoesntMatchPatternTitle');
+ msg = this.strings.getString('warningExampleUrlDoesntMatchPattern');
+ var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
+ var rv = ps.confirmEx(window, title, msg, ps.STD_YES_NO_BUTTONS, ps.BUTTON_TITLE_YES, ps.BUTTON_TITLE_NO, null, null, {});
+ return rv == 0;
+ } else {
+ var resultUrl = result.redirectTo;
+ if (!resultUrl.match(/https?:/)) {
+ var ioService = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
+ var uri = ioService.newURI(args.redirect.exampleUrl, null, null);
+ resultUrl = uri.resolve(resultUrl);
+ }
+
+ var secondResult = args.redirect.getMatch(resultUrl);
+ if (secondResult.isMatch) {
+ title = this.strings.getString('errorExampleUrlMatchesRecursiveTitle');
+ msg = this.strings.getFormattedString('errorExampleUrlMatchesRecursive', [args.redirect.exampleUrl, resultUrl]);
+ this.msgBox(title, msg);
+ return false;
+ }
+ }
+ }
+
+
+*/ \ No newline at end of file
diff --git a/chrome/code/redirector.js b/chrome/js/redirector.js
index 9c7d769..21268e6 100644
--- a/chrome/code/redirector.js
+++ b/chrome/js/redirector.js
@@ -1,7 +1,7 @@
-Components.utils.import("chrome://redirector/content/code/xpcom.js");
-Components.utils.import("chrome://redirector/content/code/redirect.js");
-Components.utils.import("chrome://redirector/content/code/redirectorprefs.js");
-Components.utils.import("chrome://redirector/content/code/proxyserver.js");
+Components.utils.import("chrome://redirector/content/js/xpcom.js");
+Components.utils.import("chrome://redirector/content/js/redirect.js");
+Components.utils.import("chrome://redirector/content/js/redirectorprefs.js");
+Components.utils.import("chrome://redirector/content/js/proxyserver.js");
var EXPORTED_SYMBOLS = ['Redirector', 'rdump'];
diff --git a/chrome/code/redirectorprefs.js b/chrome/js/redirectorprefs.js
index 75ef936..75ef936 100644
--- a/chrome/code/redirectorprefs.js
+++ b/chrome/js/redirectorprefs.js
diff --git a/chrome/code/xpcom.js b/chrome/js/xpcom.js
index e81f58e..e81f58e 100644
--- a/chrome/code/xpcom.js
+++ b/chrome/js/xpcom.js
diff --git a/chrome/redirector.html b/chrome/redirector.html
new file mode 100644
index 0000000..9bb6cc7
--- /dev/null
+++ b/chrome/redirector.html
@@ -0,0 +1,71 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Redirector Extension Settings</title>
+ <link rel="stylesheet" href="css/redirector.css" />
+ <script type="text/javascript" src="js/jquery-1.6.2.min.js"></script>
+ <script type="text/javascript" src="js/redirector-ui.js"></script>
+ </head>
+ <body>
+ <h1>Redirector</h1>
+ <h5>Go where <em>YOU</em> want!</h5>
+ <div id="actions">
+ <button id="new-redirect">New Redirect...</button>
+ <button id="configure">Configure</button>
+ <button id="import">Import</button>
+ <button id="export">Export</button>
+ </div>
+ <ul id="redirect-list">
+ <li>
+ <div>Redirect: <span class="pattern">pattern</span> to <span class="redirectTo"></span></div>
+ <div>Example: <span class="exampleUrl"></span> becomes <span class="redirectResult"></span></div>
+ <div>
+ <a class="edit" href="#edit">Edit</a>
+ <a class="delete" href="#delete">Delete</a>
+ </div>
+ </li>
+ </ul>
+ <div id="config">
+ <h2>Configuration</h2>
+ <input type="checkbox" id="enable-redirector" data-pref="enabled" />Enabled
+ <input type="checkbox" id="show-status-bar-icon" data-pref="showStatusBarIcon"/> Statusbar icon
+ <input type="checkbox" id="show-context-menu" data-pref="showContextMenu"/> Context menu
+ <input type="checkbox" id="enable-debug-output" data-pref="debugEnabled"/> Debug output
+ </div>
+ <div id="redirect-form">
+ <div>
+ <label>Description</label>
+ <input type="text" id="description" />
+ </div>
+ <div>
+ <label>Example URL</label>
+ <input type="text" id="example-url" />
+ </div>
+ <div>
+ <label>Include Pattern</label>
+ <input type="text" id="include-pattern" />
+ </div>
+ <div>
+ <label>Exclude Pattern</label>
+ <input type="text" id="exclude-pattern" />
+ </div>
+ <div>
+ <label>Redirect To</label>
+ <input type="text" id="redirect-to" />
+ </div>
+ <div>
+ <label>Pattern Type</label>
+ <input type="radio" name="pattern-type" id="regex-pattern" /> Regular Expression
+ <input type="radio" name="pattern-type" id="wildcard-pattern" /> Wildcard