[Pkg-mozext-commits] [requestpolicy] 129/280: [refact] remove the third argument of `$str`
David Prévot
taffit at moszumanska.debian.org
Sat May 2 20:30:11 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository requestpolicy.
commit 6813cb319e6c354e68f6e18a04ee0160b4c84326
Author: Martin Kimmerle <dev at 256k.de>
Date: Tue Jan 6 17:48:54 2015 +0100
[refact] remove the third argument of `$str`
From now on the third argument of
`nsIStringBundle.formatStringFromName()`, i.e. the length of the
parameter list, is added by `$str` itself.
---
src/content/lib/utils/strings.jsm | 12 +++++++-----
src/content/settings/common.js | 9 +--------
src/content/ui/classicmenu.js | 12 ++++++------
src/content/ui/menu.js | 4 ++--
src/content/ui/overlay.js | 4 ++--
5 files changed, 18 insertions(+), 23 deletions(-)
diff --git a/src/content/lib/utils/strings.jsm b/src/content/lib/utils/strings.jsm
index 810c936..0a657b9 100644
--- a/src/content/lib/utils/strings.jsm
+++ b/src/content/lib/utils/strings.jsm
@@ -61,11 +61,13 @@ let StringUtils = (function() {
return Services.strings.createBundle(path + "?" + Math.random());
}
- self.$str = function() {
- let f = arguments.length > 1 ?
- self.strbundle.formatStringFromName :
- self.strbundle.GetStringFromName;
- return f.apply(null, arguments);
+ self.$str = function(aName, aParams) {
+ if (!!aParams) {
+ return self.strbundle.formatStringFromName(aName, aParams,
+ aParams.length);
+ } else {
+ return self.strbundle.GetStringFromName(aName);
+ }
};
return self;
diff --git a/src/content/settings/common.js b/src/content/settings/common.js
index 8a35eb3..016a575 100644
--- a/src/content/settings/common.js
+++ b/src/content/settings/common.js
@@ -36,14 +36,7 @@ var COMMON_STRINGS = [
];
-function _(msg, args) {
- if (args) {
- args = Array.prototype.slice.call(arguments, 1);
- return StringUtils.$str(msg, args, args.length);
- } else {
- return StringUtils.$str(msg);
- }
-}
+var _ = StringUtils.$str;
var common = {};
diff --git a/src/content/ui/classicmenu.js b/src/content/ui/classicmenu.js
index 06c1c0b..a6cc59d 100644
--- a/src/content/ui/classicmenu.js
+++ b/src/content/ui/classicmenu.js
@@ -72,7 +72,7 @@ requestpolicy.classicmenu = (function() {
self.addMenuItemTemporarilyAllowOrigin = function(menu, originHost) {
- var label = StringUtils.$str("allowOriginTemporarily", [originHost], 1);
+ var label = StringUtils.$str("allowOriginTemporarily", [originHost]);
var command = "requestpolicy.overlay.temporarilyAllowOrigin('"
+ requestpolicy.menu._sanitizeJsFunctionArg(originHost) + "');";
var item = self.addMenuItem(menu, label, command);
@@ -81,7 +81,7 @@ requestpolicy.classicmenu = (function() {
};
self.addMenuItemAllowOrigin = function(menu, originHost) {
- var label = StringUtils.$str("allowOrigin", [originHost], 1);
+ var label = StringUtils.$str("allowOrigin", [originHost]);
var command = "requestpolicy.overlay.allowOrigin('"
+ requestpolicy.menu._sanitizeJsFunctionArg(originHost) + "');";
return self.addMenuItem(menu, label, command);
@@ -91,7 +91,7 @@ requestpolicy.classicmenu = (function() {
self.addMenuItemTemporarilyAllowOriginToDest = function(menu, originHost,
destHost) {
var label = StringUtils.$str("allowOriginToDestinationTemporarily",
- [originHost, destHost], 2);
+ [originHost, destHost]);
var command = "requestpolicy.overlay.temporarilyAllowOriginToDestination('"
+ requestpolicy.menu._sanitizeJsFunctionArg(originHost) + "', '"
+ requestpolicy.menu._sanitizeJsFunctionArg(destHost) + "');";
@@ -102,7 +102,7 @@ requestpolicy.classicmenu = (function() {
self.addMenuItemAllowOriginToDest = function(menu, originHost, destHost) {
var label = StringUtils.$str("allowOriginToDestination",
- [originHost, destHost], 2);
+ [originHost, destHost]);
var command = "requestpolicy.overlay.allowOriginToDestination('"
+ requestpolicy.menu._sanitizeJsFunctionArg(originHost) + "', '"
+ requestpolicy.menu._sanitizeJsFunctionArg(destHost) + "');";
@@ -113,7 +113,7 @@ requestpolicy.classicmenu = (function() {
self.addMenuItemTemporarilyAllowDest = function(menu, destHost) {
- var label = StringUtils.$str("allowDestinationTemporarily", [destHost], 1);
+ var label = StringUtils.$str("allowDestinationTemporarily", [destHost]);
var command = "requestpolicy.overlay.temporarilyAllowDestination('"
+ requestpolicy.menu._sanitizeJsFunctionArg(destHost) + "');";
var item = self.addMenuItem(menu, label, command);
@@ -122,7 +122,7 @@ requestpolicy.classicmenu = (function() {
};
self.addMenuItemAllowDest = function(menu, destHost) {
- var label = StringUtils.$str("allowDestination", [destHost], 1);
+ var label = StringUtils.$str("allowDestination", [destHost]);
var command = "requestpolicy.overlay.allowDestination('"
+ requestpolicy.menu._sanitizeJsFunctionArg(destHost) + "');";
return self.addMenuItem(menu, label, command);
diff --git a/src/content/ui/menu.js b/src/content/ui/menu.js
index 48ba541..c56fd12 100644
--- a/src/content/ui/menu.js
+++ b/src/content/ui/menu.js
@@ -163,7 +163,7 @@ requestpolicy.menu = (function() {
//
// if (isChromeUri) {
// self._itemUnrestrictedOrigin.setAttribute("label",
- // StringUtils.$str("unrestrictedOrigin", ["chrome://"]), 1);
+ // StringUtils.$str("unrestrictedOrigin", ["chrome://"]));
// self._itemUnrestrictedOrigin.hidden = false;
// return;
// }
@@ -918,7 +918,7 @@ requestpolicy.menu = (function() {
self._addMenuItemHelper = function(list, ruleData, fmtStrName, fmtStrArgs,
ruleAction, cssClass) {
- var label = StringUtils.$str(fmtStrName, fmtStrArgs, fmtStrArgs.length);
+ var label = StringUtils.$str(fmtStrName, fmtStrArgs);
var item = self._addListItem(list, 'rp-od-item', label);
item.requestpolicyRuleData = ruleData;
item.requestpolicyRuleAction = ruleAction;
diff --git a/src/content/ui/overlay.js b/src/content/ui/overlay.js
index 5e8d7ef..1c5b938 100644
--- a/src/content/ui/overlay.js
+++ b/src/content/ui/overlay.js
@@ -474,10 +474,10 @@ requestpolicy.overlay = (function() {
let notificationLabel;
if (isOriginUndefined) {
notificationLabel = StringUtils.$str("redirectNotification",
- [cropUri(redirectTargetUri, 50)], 1);
+ [cropUri(redirectTargetUri, 50)]);
} else {
notificationLabel = StringUtils.$str("redirectNotificationWithOrigin",
- [cropUri(redirectOriginUri, 50), cropUri(redirectTargetUri, 50)], 2);
+ [cropUri(redirectOriginUri, 50), cropUri(redirectTargetUri, 50)]);
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/requestpolicy.git
More information about the Pkg-mozext-commits
mailing list