diff options
Diffstat (limited to 'chrome/content')
-rw-r--r-- | chrome/content/code/editRedirect.xul.js | 3 | ||||
-rw-r--r-- | chrome/content/code/redirector.prototype.js | 11 | ||||
-rw-r--r-- | chrome/content/code/settings.xul.js | 16 | ||||
-rw-r--r-- | chrome/content/ui/settings.xul | 4 |
4 files changed, 28 insertions, 6 deletions
diff --git a/chrome/content/code/editRedirect.xul.js b/chrome/content/code/editRedirect.xul.js index e497245..100a7a0 100644 --- a/chrome/content/code/editRedirect.xul.js +++ b/chrome/content/code/editRedirect.xul.js @@ -53,7 +53,8 @@ var EditRedirect = { redirect.excludePattern = this.txtExcludePattern.value;
redirect.redirectUrl = this.txtRedirectUrl.value;
redirect.patternType = this.rdoRegex.getAttribute('selected') == 'true' ? Redirect.REGEX : Redirect.WILDCARD;
- redirect.unescapeMatches = this.chkUnescapeMatches.getAttribute('checked');
+ var val = this.chkUnescapeMatches.getAttribute('checked');
+ redirect.unescapeMatches = val === 'true' || val === true;
//Disabled cannot be set here
},
diff --git a/chrome/content/code/redirector.prototype.js b/chrome/content/code/redirector.prototype.js index 4e39fa6..b69a52f 100644 --- a/chrome/content/code/redirector.prototype.js +++ b/chrome/content/code/redirector.prototype.js @@ -166,7 +166,8 @@ Redirector.prototype = { var importCount = 0, existsCount = 0;
var lines = [];
var line = {value: null};
- while (stream.readLine(line)) {
+ stream.readLine(line);
+ while (line.value) {
var redirect = new Redirect();
redirect.deserialize(line.value.replace('\n', ''));
if (this.containsRedirect(redirect)) {
@@ -175,6 +176,7 @@ Redirector.prototype = { this.list.push(redirect);
importCount++;
}
+ stream.readLine(line);
}
stream.close();
this.save();
@@ -183,6 +185,12 @@ Redirector.prototype = { containsRedirect : function(redirect) {
for each (var existing in this.list) {
+ this.debug("EXAMPLEURL: " + (redirect.exampleUrl == existing.exampleUrl));
+ this.debug("INCLUDEPATTERN: " + (redirect.includePattern == existing.includePattern));
+ this.debug("EXCLUDEPATTERN: " + (redirect.excludePattern == existing.excludePattern));
+ this.debug("unescape: " + (redirect.unescapeMatches == existing.unescapeMatches));
+ this.debug("REDIRECTTO: " + (redirect.redirectUrl == existing.redirectUrl));
+ this.debug("PATTERNTYPE: " + (redirect.patternType == existing.patternType));
if (existing.equals(redirect)) {
return true;
}
@@ -207,7 +215,6 @@ Redirector.prototype = { }
var ioService = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
- //this.debug(currentUrl);
var uri = ioService.newURI(currentUrl, null, null);
return uri.resolve(relativeUrl);
diff --git a/chrome/content/code/settings.xul.js b/chrome/content/code/settings.xul.js index c7b375c..f85c1ee 100644 --- a/chrome/content/code/settings.xul.js +++ b/chrome/content/code/settings.xul.js @@ -12,6 +12,8 @@ var Settings = { btnEdit : null,
btnUp : null,
btnDown : null,
+ btnExport : null,
+ btnImport : null,
chkEnableRedirector : null,
chkShowStatusBarIcon : null,
chkShowContextMenu : null,
@@ -25,6 +27,8 @@ var Settings = { 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');
@@ -39,7 +43,8 @@ var Settings = { this.template = document.getElementsByTagName('richlistitem')[0];
this.lstRedirects.removeChild(this.template);
this.addItemsToListBox(Redirector.list);
-
+ this.selectionChange();
+
this.strings = document.getElementById('redirector-strings');
this.strings.getPluralized = function(id, number) {
id += number == 1 ? 'Singular' : '';
@@ -188,6 +193,14 @@ var Settings = { 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) {
@@ -199,6 +212,7 @@ var Settings = { this.btnDelete.disabled = (index == -1);
this.btnUp.disabled = (index <= 0);
this.btnDown.disabled = (index == -1 || index >= Redirector.list.length-1);
+ this.btnExport.disabled = (Redirector.list.length == 0);
},
importExport : function(mode, captionKey, func) {
diff --git a/chrome/content/ui/settings.xul b/chrome/content/ui/settings.xul index d61e893..141c5ef 100644 --- a/chrome/content/ui/settings.xul +++ b/chrome/content/ui/settings.xul @@ -31,7 +31,7 @@ <tabpanels flex="1">
<tabpanel flex="1">
<vbox flex="1">
- <richlistbox seltype="single" id="lstRedirects" flex="1" ondblclick="Settings.editRedirect();" onselect="Settings.selectionChange();">
+ <richlistbox seltype="single" id="lstRedirects" flex="1" onkeypress="Settings.listKeypress(event);" ondblclick="Settings.editRedirect();" onselect="Settings.selectionChange();">
<richlistitem class="SettingsItem" selected="false">
<grid>
<cols />
@@ -93,7 +93,7 @@ </vbox>
</tabpanel>
<tabpanel>
- <groupbox flex="1">
+ <groupbox flex="1" id="grpImportExport">
<vbox>
<hbox align="middle">
<button id="btnImport" accesskey="&btnImport.accesskey;" oncommand="Settings.import();" label="&btnImport.label;"/>
|