aboutsummaryrefslogtreecommitdiff
path: root/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'chrome')
-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
27 files changed, 178 insertions, 723 deletions
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
+ </div>
+ <div>
+ <label>Unescape matches</label>
+ <input type="checkbox" id="unescape-matches" />
+ </div>
+ <div>
+ <label>Enabled</label>
+ <input type="checkbox" id="redirect-enabled" />
+ </div>
+ </div>
+ </body>
+</html> \ No newline at end of file
diff --git a/chrome/settings.html b/chrome/settings.html
deleted file mode 100644
index 43318bf..0000000
--- a/chrome/settings.html
+++ /dev/null
@@ -1,112 +0,0 @@
-<!DOCTYPE html>
-<html>
- <head>
- <title>Redirector Extension Settings</title>
- <style type="text/css">
- 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; }
- </style>
- <script type="text/javascript" src="js/jquery-1.6.2.min.js"></script>
- <script type="text/javascript" src="js/settings.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" value="foo"/>
- </div>
- <div>
- <label>Example URL</label>
- <input type="text" value="foo"/>
- </div>
- <div>
- <label>Include Pattern</label>
- <input type="text" value="foo"/>
- </div>
- <div>
- <label>Exclude Pattern</label>
- <input type="text" value="foo"/>
- </div>
- <div>
- <label>Redirect To</label>
- <input type="text" value="foo"/>
- </div>
- <div>
- <label>Pattern Type</label>
- <input type="radio" /> Regular Expression
- <input type="radio" /> Wildcard
- </div>
- <div>
- <label>Unescape matches</label>
- <input type="checkbox"/>
- </div>
- <div>
- <label>Enabled</label>
- <input type="checkbox" />
- </div>
- </div>
- </body>
-</html> \ No newline at end of file
diff --git a/chrome/ui/editRedirect.xul b/chrome/ui/editRedirect.xul
deleted file mode 100644
index 6d7b133..0000000
--- a/chrome/ui/editRedirect.xul
+++ /dev/null
@@ -1,58 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- $Id$ -->
-<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
-<?xml-stylesheet href="chrome://redirector/skin/redirector.css" type="text/css"?>
-<!DOCTYPE dialog SYSTEM "chrome://redirector/locale/editRedirect.xul.dtd">
-<dialog title="&redirectWindow.title;"
- orient="vertical"
- autostretch="always"
- onload="EditRedirect.onLoad();"
- buttons="accept,cancel"
- ondialogaccept="return EditRedirect.onAccept();"
- xmlns:nc="http://home.netscape.com/NC-rdf#"
- xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
-
- <script type="application/x-javascript" src="../code/redirect.js"/>
- <script type="application/x-javascript" src="../code/editRedirect.xul.js"/>
- <stringbundleset id="stringbundleset">
- <stringbundle id="redirector-strings" src="chrome://redirector/locale/redirector.properties"/>
- </stringbundleset>
-
- <grid>
- <rows class="editRedirects">
- <row align="center">
- <text value="&txtExampleUrl.label;" />
- <textbox id="txtExampleUrl" />
- </row>
- <row align="center">
- <text value="&txtIncludePattern.label;" />
- <textbox id="txtIncludePattern" taborder="1"/>
- <button id="btnTestPattern" label="&btnTestPattern.label;" onclick="EditRedirect.testPattern();" taborder="2"/>
- </row>
- <row align="center">
- <text value="&txtExcludePattern.label;" />
- <textbox id="txtExcludePattern" taborder="3"/>
- </row>
- <row align="center">
- <text value="&txtRedirectUrl.label;" />
- <textbox id="txtRedirectUrl" taborder="4"/>
- </row>
- <row align="center">
- <text value="&rdoPatternTypes.label;"/>
- <radiogroup>
- <hbox>
- <radio id="rdoWildcard" label="&rdoWildcard.label;" accesskey="&rdoWildcard.accessKey;" selected="true" taborder="5"/>
- <radio id="rdoRegex" label="&rdoRegex.label;" accesskey="&rdoRegex.accessKey;" taborder="6"/>
- </hbox>
- </radiogroup>
- </row>
- <row align="center">
- <text value="&chkUnescapeMatches.label;" />
- <hbox>
- <checkbox id="chkUnescapeMatches" label="" taborder="7"/>
- <spacer flex="1" />
- </hbox>
- </row>
- </rows>
- </grid>
-</dialog>
diff --git a/chrome/ui/settings.xul b/chrome/ui/settings.xul
deleted file mode 100644
index 14d9de5..0000000
--- a/chrome/ui/settings.xul
+++ /dev/null
@@ -1,119 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- $Id$ -->
-<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
-<?xml-stylesheet href="chrome://redirector/skin/redirector.css" type="text/css"?>
-
-<!DOCTYPE dialog SYSTEM "chrome://redirector/locale/settings.xul.dtd">
-<window title="&window.title;"
- orient="vertical"
- onload="Settings.onLoad();"
- onunload="Settings.onUnload();"
- buttons="accept"
- width="650px"
- height="500px"
- id="redirectorSettings"
- windowtype="redirectorSettings"
- xmlns:nc="http://home.netscape.com/NC-rdf#"
- xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
-
- <script type="application/x-javascript" src="../code/redirectorprefs.js"/>
- <script type="application/x-javascript" src="../code/redirect.js"/>
- <script type="application/x-javascript" src="../code/settings.xul.js"/>
- <stringbundleset id="stringbundleset">
- <stringbundle id="redirector-strings" src="chrome://redirector/locale/redirector.properties"/>
- </stringbundleset>
- <tabbox flex="1" >
- <tabs>
- <tab label="&tabRedirects.label;" accesskey="&tabRedirects.accesskey;" />
- <tab label="&tabPreferences.label;" accesskey="&tabPreferences.accesskey;" />
- <tab label="&tabImportExport.label;" accesskey="&tabImportExport.accesskey;" />
- <tab label="&tabHelp.label;" accesskey="&tabHelp.accesskey;" />
- </tabs>
- <tabpanels flex="1">
- <tabpanel flex="1">
- <vbox flex="1">
- <richlistbox seltype="single" id="lstRedirects" flex="1" onkeypress="Settings.listKeypress(event);" ondblclick="Settings.editRedirect();" onselect="Settings.selectionChange();">
- <richlistitem class="SettingsItem" selected="false">
- <grid>
- <cols />
- <rows class="redirectRows">
- <row>
- <label value="&colIncludePattern.label;:" />
- <description name="dscrIncludePattern" />
- </row>
- <row>
- <label value="&colExcludePattern.label;:" />
- <description name="dscrExcludePattern" />
- </row>
- <row>
- <label value="&colRedirectTo.label;:" />
- <description name="dscrRedirectTo" />
- </row>
- <row>
- <label value="&colEnabled.label;:" />
- <hbox><checkbox checked="false" name="chkEnabled" label="" /> <spacer flex="1"/></hbox>
- </row>
- </rows>
- </grid>
- </richlistitem>
- </richlistbox>
- <hbox>
- <button id="btnAdd" oncommand="Settings.addRedirect();" accesskey="&btnAdd.accesskey;" label="&btnAdd.label;" tooltiptext="&btnAdd.tooltip;" disabled="false" />
- <button id="btnEdit" oncommand="Settings.editRedirect();" accesskey="&btnEdit.accesskey;" label="&btnEdit.label;" tooltiptext="&btnEdit.tooltip;" disabled="true" />
- <button id="btnDelete" oncommand="Settings.deleteRedirect();" accesskey="&btnDelete.accesskey;" label="&btnDelete.label;" tooltiptext="&btnDelete.tooltip;" disabled="true" />
- <button id="btnUp" oncommand="Settings.moveUp();" tooltiptext="&btnUp.tooltip;" disabled="true" />
- <button id="btnDown" oncommand="Settings.moveDown();" tooltiptext="&btnDown.tooltip;" disabled="true" />
- <button id="btnClose" oncommand="close();" tooltiptext="&btnClose.tooltip;" label="&btnClose.label;" accesskey="&btnClose.accesskey;" />
- </hbox>
- </vbox>
- </tabpanel>
- <tabpanel>
- <vbox flex="1">
- <groupbox>
- <caption label="&grpGeneralPreferences.label;" />
- <hbox>
- <checkbox id="chkEnableRedirector" label="&chkEnableRedirector.label;" oncommand="Settings.preferenceChange(event);" accesskey="&chkEnableRedirector.accesskey;" preference="enabled" />
- <spacer flex="1" />
- </hbox>
- <hbox>
- <checkbox id="chkShowStatusBarIcon" label="&chkShowStatusBarIcon.label;" oncommand="Settings.preferenceChange(event);" accesskey="&chkShowStatusBarIcon.accesskey;" preference="showStatusBarIcon" />
- <spacer flex="1" />
- </hbox>
- <hbox>
- <checkbox id="chkShowContextMenu" label="&chkShowContextMenu.label;" oncommand="Settings.preferenceChange(event);" accesskey="&chkShowContextMenu.accesskey;" preference="showContextMenu" />
- <spacer flex="1" />
- </hbox>
- </groupbox>
- <groupbox>
- <caption label="&grpDebuggingPreferences.label;" />
- <hbox>
- <checkbox id="chkEnableDebugOutput" label="&chkEnableDebugOutput.label;" oncommand="Settings.preferenceChange(event);" accesskey="&chkEnableDebugOutput.accesskey;" preference="debugEnabled" />
- <spacer flex="1" />
- </hbox>
- </groupbox>
- <spacer flex="1" />
- </vbox>
- </tabpanel>
- <tabpanel>
- <groupbox flex="1" id="grpImportExport">
- <vbox>
- <hbox align="middle">
- <button id="btnImport" accesskey="&btnImport.accesskey;" oncommand="Settings.import();" label="&btnImport.label;"/>
- <label id="lblImport" value="&lblImport.label;" />
- <spacer flex="1" />
- </hbox>
- <hbox>
- <button id="btnExport" accesskey="&btnExport.accesskey;" oncommand="Settings.export();" label="&btnExport.label;"/>
- <label id="lblExport" value="&lblExport.label;" />
- <spacer flex="1" />
- </hbox>
- <spacer flex="1" />
- </vbox>
- </groupbox>
- </tabpanel>
- <tabpanel>
- <browser type="content" src="chrome://redirector/content/ui/help.html" flex="1" />
- </tabpanel>
- </tabpanels>
- </tabbox>
-</window>
diff --git a/chrome/ui/skin/movedown.png b/chrome/ui/skin/movedown.png
deleted file mode 100644
index d32b79c..0000000
--- a/chrome/ui/skin/movedown.png
+++ /dev/null
Binary files differ
diff --git a/chrome/ui/skin/movedowndisabled.png b/chrome/ui/skin/movedowndisabled.png
deleted file mode 100644
index afd8fc6..0000000
--- a/chrome/ui/skin/movedowndisabled.png
+++ /dev/null
Binary files differ
diff --git a/chrome/ui/skin/moveup.png b/chrome/ui/skin/moveup.png
deleted file mode 100644
index 3025378..0000000
--- a/chrome/ui/skin/moveup.png
+++ /dev/null
Binary files differ
diff --git a/chrome/ui/skin/moveupdisabled.png b/chrome/ui/skin/moveupdisabled.png
deleted file mode 100644
index e526b29..0000000
--- a/chrome/ui/skin/moveupdisabled.png
+++ /dev/null
Binary files differ
diff --git a/chrome/ui/skin/redirector.css b/chrome/ui/skin/redirector.css
deleted file mode 100644
index ff9762e..0000000
--- a/chrome/ui/skin/redirector.css
+++ /dev/null
@@ -1,15 +0,0 @@
-/* $Id$ */
-
-.disabledRedirect { color:grey; }
-#lstRedirects richlistitem { border-bottom:dotted 1px grey; padding:3px; }
-.redirectRows > row > label { font-weight:bold;}
-.editRedirects > row > textbox { width: 350px; }
-#redirectorSettings > tabbox { margin:4px; }
-#btnUp { list-style-image: url('chrome://redirector/skin/moveup.png'); }
-#btnDown { list-style-image: url('chrome://redirector/skin/movedown.png'); }
-#btnUp[disabled=true] { list-style-image: url('chrome://redirector/skin/moveupdisabled.png'); }
-#btnDown[disabled=true] { list-style-image: url('chrome://redirector/skin/movedowndisabled.png'); }
-
-#btnUp, #btnDown { width:25px; min-width:25px; }
-#lblExport, #lblImport { padding-top:5px; }
-#grpImportExport { padding-top:10px; padding-left:5px;} \ No newline at end of file
diff --git a/chrome/code/unittest/run.html b/chrome/unittest/run.html
index cc178aa..cc178aa 100644
--- a/chrome/code/unittest/run.html
+++ b/chrome/unittest/run.html
diff --git a/chrome/code/unittest/testcases.js b/chrome/unittest/testcases.js
index 0c0c10c..0c0c10c 100644
--- a/chrome/code/unittest/testcases.js
+++ b/chrome/unittest/testcases.js