Index: lib/utils.js |
diff --git a/lib/utils.js b/lib/utils.js |
index e965cad717e4cb7f2c19a8181a4edbebf322f14c..bb3fd5accda9f80ce6dd74cd52a08a0daa19c5a0 100644 |
--- a/lib/utils.js |
+++ b/lib/utils.js |
@@ -15,19 +15,21 @@ |
* along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
*/ |
-var Utils = exports.Utils = { |
+"use strict"; |
+ |
+let Utils = exports.Utils = { |
systemPrincipal: null, |
- getString: function(id) |
+ getString(id) |
{ |
return ext.i18n.getMessage("global_" + id); |
}, |
- runAsync: function(callback) |
+ runAsync(callback) |
{ |
if (document.readyState == "loading") |
{ |
// Make sure to not run asynchronous actions before all |
// scripts loaded. This caused issues on Opera in the past. |
- let onDOMContentLoaded = function() |
+ let onDOMContentLoaded = () => |
{ |
document.removeEventListener("DOMContentLoaded", onDOMContentLoaded); |
callback(); |
@@ -41,40 +43,38 @@ var Utils = exports.Utils = { |
}, |
get appLocale() |
{ |
- var locale = ext.i18n.getMessage("@@ui_locale").replace(/_/g, "-"); |
+ let locale = ext.i18n.getMessage("@@ui_locale").replace(/_/g, "-"); |
Object.defineProperty(this, "appLocale", {value: locale, enumerable: true}); |
return this.appLocale; |
}, |
- generateChecksum: function(lines) |
+ // We cannot calculate MD5 checksums yet :-( |
Sebastian Noack
2017/01/18 11:24:27
Moving the comment here seems unrelated.
kzar
2017/01/18 11:46:38
Whoops, well spotted. Done.
|
+ generateChecksum(lines) |
{ |
- // We cannot calculate MD5 checksums yet :-( |
return null; |
}, |
- checkLocalePrefixMatch: function(prefixes) |
+ checkLocalePrefixMatch(prefixes) |
{ |
if (!prefixes) |
return null; |
- var list = prefixes.split(","); |
- for (var i = 0; i < list.length; i++) |
- if (new RegExp("^" + list[i] + "\\b").test(this.appLocale)) |
- return list[i]; |
+ for (let prefix of prefixes.split(",")) |
+ if (new RegExp("^" + prefix + "\\b").test(this.appLocale)) |
+ return prefix; |
return null; |
}, |
- chooseFilterSubscription: function(subscriptions) |
+ chooseFilterSubscription(subscriptions) |
{ |
- var selectedItem = null; |
- var selectedPrefix = null; |
- var matchCount = 0; |
- for (var i = 0; i < subscriptions.length; i++) |
+ let selectedItem = null; |
+ let selectedPrefix = null; |
+ let matchCount = 0; |
+ for (let subscription of subscriptions) |
{ |
- var subscription = subscriptions[i]; |
if (!selectedItem) |
selectedItem = subscription; |
- var prefix = require("utils").Utils.checkLocalePrefixMatch(subscription.getAttribute("prefixes")); |
+ let prefix = require("utils").Utils.checkLocalePrefixMatch(subscription.getAttribute("prefixes")); |
Sebastian Noack
2017/01/18 11:24:27
Is require("utils") even necessary? Couldn't we ju
kzar
2017/01/18 11:46:37
Yes I can't see why not, Done.
|
if (prefix) |
{ |
if (!selectedPrefix || selectedPrefix.length < prefix.length) |
@@ -102,14 +102,14 @@ var Utils = exports.Utils = { |
return selectedItem; |
}, |
- getDocLink: function(linkID) |
+ getDocLink(linkID) |
{ |
- var Prefs = require("prefs").Prefs; |
- var docLink = Prefs.documentation_link; |
+ const {Prefs} = require("prefs"); |
Sebastian Noack
2017/01/18 11:24:28
In this case, perhaps just inline it:
let docLi
kzar
2017/01/18 11:46:38
Done.
|
+ let docLink = Prefs.documentation_link; |
return docLink.replace(/%LINK%/g, linkID).replace(/%LANG%/g, Utils.appLocale); |
}, |
- yield: function() |
+ yield() |
{ |
} |
}; |