Index: node_modules/utils.js |
diff --git a/node_modules/utils.js b/node_modules/utils.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..3818829ad4cd958ab7569a640de4b764ba318584 |
--- /dev/null |
+++ b/node_modules/utils.js |
@@ -0,0 +1,129 @@ |
+/* |
+ * This file is part of Adblock Plus <https://adblockplus.org/>, |
+ * Copyright (C) 2006-2016 Eyeo GmbH |
+ * |
+ * Adblock Plus is free software: you can redistribute it and/or modify |
+ * it under the terms of the GNU General Public License version 3 as |
+ * published by the Free Software Foundation. |
+ * |
+ * Adblock Plus is distributed in the hope that it will be useful, |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
+ * GNU General Public License for more details. |
+ * |
+ * You should have received a copy of the GNU General Public License |
+ * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
+ */ |
+ |
+// |
+// This file has been generated automatically, relevant repositories: |
+// * https://hg.adblockplus.org/jshydra/ |
+// |
+ |
+var Utils = exports.Utils = { |
+ systemPrincipal: null, |
+ getString: function(id) |
+ { |
+ if (typeof ext !== "undefined" && "i18n" in ext) |
+ { |
+ return ext.i18n.getMessage("global_" + id); |
+ } |
+ else |
+ { |
+ return id; |
+ } |
+ }, |
+ runAsync: function(callback) |
+ { |
+ if (document.readyState == "loading") |
+ { |
+ var onDOMContentLoaded = function() |
+ { |
+ document.removeEventListener("DOMContentLoaded", onDOMContentLoaded); |
+ callback(); |
+ }; |
+ document.addEventListener("DOMContentLoaded", onDOMContentLoaded); |
+ } |
+ else |
+ { |
+ setTimeout(callback, 0); |
+ } |
+ }, |
+ get appLocale() |
+ { |
+ var locale = ext.i18n.getMessage("@@ui_locale").replace(/_/g, "-"); |
+ Object.defineProperty(this, "appLocale", |
+ { |
+ value: locale, |
+ enumerable: true |
+ }); |
+ return this.appLocale; |
+ }, |
+ generateChecksum: function(lines) |
+ { |
+ return null; |
+ }, |
+ makeURI: function(url) |
+ { |
+ return Services.io.newURI(url); |
+ }, |
+ checkLocalePrefixMatch: function(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]; |
+ } |
+ } |
+ return null; |
+ }, |
+ chooseFilterSubscription: function(subscriptions) |
+ { |
+ var selectedItem = null; |
+ var selectedPrefix = null; |
+ var matchCount = 0; |
+ for (var i = 0; i < subscriptions.length; i++) |
+ { |
+ var subscription = subscriptions[i]; |
+ if (!selectedItem) |
+ { |
+ selectedItem = subscription; |
+ } |
+ var prefix = require("utils").Utils.checkLocalePrefixMatch(subscription.getAttribute("prefixes")); |
+ if (prefix) |
+ { |
+ if (!selectedPrefix || selectedPrefix.length < prefix.length) |
+ { |
+ selectedItem = subscription; |
+ selectedPrefix = prefix; |
+ matchCount = 1; |
+ } |
+ else if (selectedPrefix && selectedPrefix.length == prefix.length) |
+ { |
+ matchCount++; |
+ if (Math.random() * matchCount < 1) |
+ { |
+ selectedItem = subscription; |
+ selectedPrefix = prefix; |
+ } |
+ } |
+ } |
+ } |
+ return selectedItem; |
+ }, |
+ getDocLink: function(linkID) |
+ { |
+ var Prefs = require("prefs").Prefs; |
+ var docLink = Prefs.documentation_link; |
+ return docLink.replace(/%LINK%/g, linkID).replace(/%LANG%/g, Utils.appLocale); |
+ }, |
+ yield: function() |
+ {} |
+}; |
+ |