aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chrome.manifest1
-rw-r--r--chrome/code/browserOverlay.xul.js5
-rw-r--r--chrome/code/editRedirect.xul.js2
-rw-r--r--chrome/code/redirector.js59
-rw-r--r--chrome/code/redirectorprefs.js4
-rw-r--r--chrome/code/settings.xul.js4
-rw-r--r--chrome/ui/settings.xul1
-rw-r--r--defaults/preferences/redirector.preferences.js2
-rw-r--r--locale/en-US/redirector.properties2
-rw-r--r--locale/en-US/settings.xul.dtd5
-rw-r--r--locale/zh-CN/browserOverlay.xul.dtd9
-rw-r--r--locale/zh-CN/editRedirect.xul.dtd14
-rw-r--r--locale/zh-CN/redirector.properties33
-rw-r--r--locale/zh-CN/settings.xul.dtd65
14 files changed, 47 insertions, 159 deletions
diff --git a/chrome.manifest b/chrome.manifest
index 3ca72f2..e758bd7 100644
--- a/chrome.manifest
+++ b/chrome.manifest
@@ -1,7 +1,6 @@
content redirector file:chrome/
locale redirector en-US file:locale/en-US/
-locale redirector zh-CN file:locale/zh-CN/
skin redirector classic/1.0 file:chrome/ui/skin/
overlay chrome://browser/content/browser.xul chrome://redirector/content/ui/browserOverlay.xul
diff --git a/chrome/code/browserOverlay.xul.js b/chrome/code/browserOverlay.xul.js
index 0d2f46e..d4df3b9 100644
--- a/chrome/code/browserOverlay.xul.js
+++ b/chrome/code/browserOverlay.xul.js
@@ -17,6 +17,11 @@ var RedirectorOverlay = {
this.prefs = new RedirectorPrefs();
this.changedPrefs(this.prefs);
this.prefs.addListener(this);
+ document.addEventListener('keypress', function(event) {
+ if ((event.charCode == 114) && event.altKey) { //alt+r
+ RedirectorOverlay.toggleEnabled();
+ }
+ }, true);
} catch(e) {
if (this.strings) {
alert(this.strings.getString("initError") + "\n\n" + e);
diff --git a/chrome/code/editRedirect.xul.js b/chrome/code/editRedirect.xul.js
index 0c8f34b..87f6533 100644
--- a/chrome/code/editRedirect.xul.js
+++ b/chrome/code/editRedirect.xul.js
@@ -1,4 +1,4 @@
-//// $Id$
+Components.utils.import("chrome://redirector/content/code/redirect.js");
var EditRedirect = {
txtExampleUrl : null,
diff --git a/chrome/code/redirector.js b/chrome/code/redirector.js
index df2a25b..19b0f0c 100644
--- a/chrome/code/redirector.js
+++ b/chrome/code/redirector.js
@@ -12,7 +12,7 @@ Components.utils.import("chrome://redirector/content/code/redirect.js");
Components.utils.import("chrome://redirector/content/code/redirectorprefs.js");
function rdump(msg) {
- dump(msg + '\n');
+ //dump(msg + '\n');
}
Redirector = {
@@ -36,12 +36,7 @@ Redirector = {
},
addRedirect : function(redirect) {
- //This runaround is necessary because the redirect
- //that was created somewhere up in the GUI doesn't
- //have the Redirect function in scope.
- var rx = new Redirect();
- rx.copyValues(redirect);
- this._list.push(rx);
+ this._list.push(redirect);
this.save();
},
@@ -65,7 +60,7 @@ Redirector = {
fileStream.init(file, PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE, 0644, 0);
var stream = Cc["@mozilla.org/intl/converter-output-stream;1"].createInstance(Ci.nsIConverterOutputStream);
stream.init(fileStream, "UTF-8", 16384, Ci.nsIConverterInputStream.DEFAULT_REPLACEMENT_CHARACTER);
- var rjson = { globalExcludePattern : '', createdBy : 'Redirector v' + this._prefs.version, redirects :[]};
+ var rjson = { createdBy : 'Redirector v' + this._prefs.version, createdAt : new Date(), redirects :[]};
for each (var re in this._list) {
rjson.redirects.push(re.toObject());
}
@@ -124,30 +119,40 @@ Redirector = {
handleUpgrades : function(){
var currentVersion = '2.6';
+ this._list = [];
+ if (this._prefs.version == currentVersion) {
+ return;
+ }
//Here update checks are handled
- if (this._prefs.version != currentVersion) {
- var data = this._prefs.redirects;
- var arr;
- this._list = [];
- if (data != '') {
- for each (redirectString in data.split(':::')) {
- if (!redirectString || !redirectString.split) {
- continue;
- rdump('Invalid old redirect: ' + redirectString);
- }
- var parts = redirectString.split(',,,');
- if (parts.length < 5) {
- throw Error("Invalid serialized redirect, too few fields: " + redirectString);
- }
- var redirect = new Redirect();
- redirect._init.apply(parts);
- this._list.push(redirect);
+
+ try {
+ var branch = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefService).getBranch("extensions.redirector.");
+ var data = branch.getCharPref("redirects");
+ } catch(e) {
+ this._prefs.version = currentVersion;
+ return;
+ }
+ var arr;
+ this._list = [];
+ if (data != '') {
+ for each (redirectString in data.split(':::')) {
+ if (!redirectString || !redirectString.split) {
+ continue;
+ rdump('Invalid old redirect: ' + redirectString);
+ }
+ var parts = redirectString.split(',,,');
+ if (parts.length < 5) {
+ throw Error("Invalid serialized redirect, too few fields: " + redirectString);
}
- this.save();
- this._list = []; //Let the real loading start this properly
+ var redirect = new Redirect();
+ redirect._init.apply(redirect, parts);
+ this._list.push(redirect);
}
+ this.save();
+ this._list = []; //Let the real loading start this properly
}
+ branch.deleteBranch('redirects');
this._prefs.version = currentVersion;
},
diff --git a/chrome/code/redirectorprefs.js b/chrome/code/redirectorprefs.js
index 101a3f0..3920539 100644
--- a/chrome/code/redirectorprefs.js
+++ b/chrome/code/redirectorprefs.js
@@ -39,9 +39,6 @@ RedirectorPrefs.prototype = {
get defaultDir() { return this._defaultDir; },
set defaultDir(value) { this._prefBranch.setCharPref('defaultDir', value); },
- get redirects() { return this._redirects; },
- set redirects(value) { this._prefBranch.setCharPref('redirects', value); },
-
init : function() {
this._prefBranch = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch("extensions.redirector.");
this.reload();
@@ -61,7 +58,6 @@ RedirectorPrefs.prototype = {
this._showContextMenu = this._prefBranch.getBoolPref('showContextMenu');
this._debugEnabled = this._prefBranch.getBoolPref('debugEnabled');
this._defaultDir = this._prefBranch.getCharPref('defaultDir');
- this._redirects = this._prefBranch.getCharPref('redirects');
},
get service() {
diff --git a/chrome/code/settings.xul.js b/chrome/code/settings.xul.js
index c7f780a..bee7817 100644
--- a/chrome/code/settings.xul.js
+++ b/chrome/code/settings.xul.js
@@ -217,12 +217,12 @@ var Settings = {
//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 = ".rdx";
+ picker.defaultExtension = ".rjson";
var dir = this.prefs.defaultDir;
if (dir) {
picker.displayDirectory = new nsLocalFile(dir);
}
- picker.appendFilter(this.strings.getString('redirectorFiles'), '*.rdx');
+ picker.appendFilter(this.strings.getString('redirectorFiles'), '*.rjson');
if (picker.show() == picker.returnCancel) {
return null;
diff --git a/chrome/ui/settings.xul b/chrome/ui/settings.xul
index ccb9569..14d9de5 100644
--- a/chrome/ui/settings.xul
+++ b/chrome/ui/settings.xul
@@ -63,6 +63,7 @@
<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>
diff --git a/defaults/preferences/redirector.preferences.js b/defaults/preferences/redirector.preferences.js
index 1bac6b0..da9e642 100644
--- a/defaults/preferences/redirector.preferences.js
+++ b/defaults/preferences/redirector.preferences.js
@@ -1,10 +1,8 @@
-//// $Id$
pref("extensions.redirector.debugEnabled", false);
pref("extensions.redirector.enabled", true);
pref("extensions.redirector.showContextMenu", true);
pref("extensions.redirector.showStatusBarIcon", true);
-pref("extensions.redirector.redirects", '');
pref("extensions.redirector.version", 'undefined');
pref("extensions.redirector.defaultDir", '');
diff --git a/locale/en-US/redirector.properties b/locale/en-US/redirector.properties
index 128d08e..e0a05a5 100644
--- a/locale/en-US/redirector.properties
+++ b/locale/en-US/redirector.properties
@@ -12,7 +12,7 @@ testPatternFailure=The pattern %S does not match example URL %S
testPatternExclude=Example URL %S matches the exclude pattern %S and so would not be redirected
regexPatternError=The pattern '%S' is not a legal regular expression pattern. Details: %S
xpathDeprecated=XPath patterns are no longer supported as of version 1.5.1, please remove those redirects.
-redirectorFiles=Redirector files (*.rdx)
+redirectorFiles=Redirector files (*.rjson)
exportCaption=Export redirects...
importCaption=Import redirects...
deleteConfirmationText=Are you sure you want to permanently delete this redirect?
diff --git a/locale/en-US/settings.xul.dtd b/locale/en-US/settings.xul.dtd
index ff55b68..90d3f6f 100644
--- a/locale/en-US/settings.xul.dtd
+++ b/locale/en-US/settings.xul.dtd
@@ -32,6 +32,10 @@
<!ENTITY btnExport.accesskey "E">
<!ENTITY btnExport.tooltip "Export redirects to a file">
+<!ENTITY btnClose.label "Close">
+<!ENTITY btnClose.tooltip "Close this window">
+<!ENTITY btnClose.accesskey "C">
+
<!-- Tab headers -->
<!ENTITY tabRedirects.label "Redirects">
@@ -63,3 +67,4 @@
<!-- Import / Export -->
<!ENTITY lblExport.label "Export your redirects to a file">
<!ENTITY lblImport.label "Import new redirects from a file">
+
diff --git a/locale/zh-CN/browserOverlay.xul.dtd b/locale/zh-CN/browserOverlay.xul.dtd
deleted file mode 100644
index b0567f8..0000000
--- a/locale/zh-CN/browserOverlay.xul.dtd
+++ /dev/null
@@ -1,9 +0,0 @@
-<!-- $Id: browserOverlay.xul.dtd 249 2009-09-15 21:41:06Z einar@einaregilsson.com $ -->
-<!ENTITY RedirectorMenuItem.label "管理 URL 重定向">
-<!ENTITY RedirectorMenuItem.accesskey "R">
-<!ENTITY RedirectorContext.label "把 URL 添加到 Redirector 规则...">
-<!ENTITY RedirectorContext.accesskey "A">
-<!ENTITY RedirectorManageRedirects.label "管理规则">
-<!ENTITY RedirectorManageRedirects.accesskey "M">
-<!ENTITY RedirectorHelp.label "帮助">
-<!ENTITY RedirectorHelp.accesskey "H">
diff --git a/locale/zh-CN/editRedirect.xul.dtd b/locale/zh-CN/editRedirect.xul.dtd
deleted file mode 100644
index f0ab422..0000000
--- a/locale/zh-CN/editRedirect.xul.dtd
+++ /dev/null
@@ -1,14 +0,0 @@
-<!-- $Id: editRedirect.xul.dtd 253 2009-10-07 11:24:44Z einar@einaregilsson.com $ -->
-<!ENTITY redirectWindow.title "Redirector">
-<!ENTITY txtExampleUrl.label "用于测试的 URL">
-<!ENTITY txtIncludePattern.label "使用规则">
-<!ENTITY txtExcludePattern.label "例外规则">
-<!ENTITY txtRedirectUrl.label "重定向到">
-<!ENTITY btnTestPattern.label "测试">
-<!ENTITY rdoWildcard.label "通配符(*)">
-<!ENTITY rdoWildcard.accessKey "W">
-<!ENTITY rdoRegex.label "正则表达式">
-<!ENTITY rdoPatternTypes.label "规则类型">
-<!ENTITY rdoRegex.accessKey "R">
-<!ENTITY chkUnescapeMatches.label "Unescape 匹配部分">
-
diff --git a/locale/zh-CN/redirector.properties b/locale/zh-CN/redirector.properties
deleted file mode 100644
index 866ec1a..0000000
--- a/locale/zh-CN/redirector.properties
+++ /dev/null
@@ -1,33 +0,0 @@
-# $Id: redirector.properties 288 2009-10-26 08:13:15Z einar@einaregilsson.com $
-initError=Failed to initialize Redirector.
-extensions.redirector@einaregilsson.com.description=根据您设置的规则自动跳转网页。
-extensionName=Redirector
-addCurrentUrl=Add current url to Redirector
-addLinkUrl=为链接创建 Redirector 规则
-recursiveError=A redirect with the pattern %S matches %S and is trying to redirect to it again. You should change this rule so it won't work recursively.
-enabledTooltip=Redirector is enabled
-disabledTooltip=Redirector is disabled
-testPatternSuccess=The pattern %S matches example URL %S, and would redirect you to url: %S
-testPatternFailure=The pattern %S does not match example URL %S
-testPatternExclude=Example URL %S matches the exclude pattern %S and so would not be redirected
-regexPatternError=The pattern '%S' is not a legal regular expression pattern. Details: %S
-xpathDeprecated=XPath patterns are no longer supported as of version 1.5.1, please remove those redirects.
-redirectorFiles=Redirector files (*.rdx)
-exportCaption=Export redirects...
-importCaption=Import redirects...
-deleteConfirmationText=Are you sure you want to permanently delete this redirect?
-deleteConfirmationTitle=Delete redirect?
-importedMessage=%S redirects were imported
-importedMessageSingular=%S redirect was imported
-existedMessage=%S redirects were identical to existing redirects and were therefore not imported.
-existedMessageSingular=%S redirect was identical to an existing redirect and was therefore not imported.
-allExistedMessage=All %S redirects in the file were identical to existing redirects, no redirects were imported.
-allExistedMessageSingular=The single redirect in the file was identical to an existing redirect and was therefore not imported.
-importedNone=There were no usable redirects in the given file, no redirects were imported.
-importResult=Import results
-invalidRedirectTitle=Redirector Add-on: Invalid Redirect detected
-invalidRedirectText=The pattern "%S" redirected the url %S to %S which also matches the pattern. This will cause an endless loop and so the redirect has been disabled to prevent this from happening. You should edit this redirect to fix it.
-warningExampleUrlDoesntMatchPatternTitle=Warning: Example url does not match redirect
-warningExampleUrlDoesntMatchPattern=The example url does not match the redirect specified. Are you sure you want to save this redirect?
-errorExampleUrlMatchesRecursiveTitle=Error: Recursive match detected
-errorExampleUrlMatchesRecursive=The example url %S matches the redirect and would redirect you to %S, which also matches the redirect. This is not allowed as it can cause an endless loop of requests. \ No newline at end of file
diff --git a/locale/zh-CN/settings.xul.dtd b/locale/zh-CN/settings.xul.dtd
deleted file mode 100644
index 0facb3a..0000000
--- a/locale/zh-CN/settings.xul.dtd
+++ /dev/null
@@ -1,65 +0,0 @@
-<!-- $Id: settings.xul.dtd 266 2009-10-14 11:13:03Z einar@einaregilsson.com $ -->
-<!ENTITY window.title "Redirector">
-
-<!-- ListItems with redirects -->
-<!ENTITY colIncludePattern.label "使用规则">
-<!ENTITY colExcludePattern.label "例外规则">
-<!ENTITY colRedirectTo.label "重定向到">
-<!ENTITY colEnabled.label "启用">
-
-<!-- Buttons -->
-<!ENTITY btnAdd.label "增加规则...">
-<!ENTITY btnAdd.accesskey "A">
-<!ENTITY btnAdd.tooltip "新建一条规则">
-
-<!ENTITY btnEdit.label "编辑规则...">
-<!ENTITY btnEdit.accesskey "E">
-<!ENTITY btnEdit.tooltip "编辑选定的规则">
-
-<!ENTITY btnDelete.label "删除规则">
-<!ENTITY btnDelete.accesskey "D">
-<!ENTITY btnDelete.tooltip "删除选定的规则">
-
-<!ENTITY btnUp.tooltip "把规则向上移动一条位置">
-
-<!ENTITY btnDown.tooltip "把规则向下移动一条位置">
-
-<!ENTITY btnImport.label "导入...">
-<!ENTITY btnImport.accesskey "I">
-<!ENTITY btnImport.tooltip "从文件导入规则">
-
-<!ENTITY btnExport.label "导出...">
-<!ENTITY btnExport.accesskey "E">
-<!ENTITY btnExport.tooltip "导出规则到文件">
-
-
-<!-- Tab headers -->
-<!ENTITY tabRedirects.label "重定向规则">
-<!ENTITY tabRedirects.accesskey "R">
-<!ENTITY tabPreferences.label "选项">
-<!ENTITY tabPreferences.accesskey "P">
-<!ENTITY tabImportExport.label "导入/导出">
-<!ENTITY tabImportExport.accesskey "m">
-<!ENTITY tabHelp.label "帮助">
-<!ENTITY tabHelp.accesskey "H">
-
-<!-- Preferences -->
-<!ENTITY grpGeneralPreferences.label "一般">
-<!ENTITY grpDebuggingPreferences.label "调试">
-
-<!ENTITY chkEnableRedirector.label "启用 Redirector">
-<!ENTITY chkEnableRedirector.accesskey "E">
-
-<!ENTITY chkShowStatusBarIcon.label "在状态栏显示图标">
-<!ENTITY chkShowStatusBarIcon.accesskey "s">
-
-<!ENTITY chkShowContextMenu.label "在右键菜单中显示">
-<!ENTITY chkShowContextMenu.accesskey "c">
-
-<!ENTITY chkEnableDebugOutput.label "启用调试输出">
-<!ENTITY chkEnableDebugOutput.accesskey "d">
-
-
-<!-- Import / Export -->
-<!ENTITY lblExport.label "将规则导出到文件">
-<!ENTITY lblImport.label "从文件导入规则">