| OLD | NEW | 
|---|
| (Empty) |  | 
|  | 1 /* | 
|  | 2  * This file is part of Adblock Plus <https://adblockplus.org/>, | 
|  | 3  * Copyright (C) 2006-2016 Eyeo GmbH | 
|  | 4  * | 
|  | 5  * Adblock Plus is free software: you can redistribute it and/or modify | 
|  | 6  * it under the terms of the GNU General Public License version 3 as | 
|  | 7  * published by the Free Software Foundation. | 
|  | 8  * | 
|  | 9  * Adblock Plus is distributed in the hope that it will be useful, | 
|  | 10  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|  | 11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|  | 12  * GNU General Public License for more details. | 
|  | 13  * | 
|  | 14  * You should have received a copy of the GNU General Public License | 
|  | 15  * along with Adblock Plus.  If not, see <http://www.gnu.org/licenses/>. | 
|  | 16  */ | 
|  | 17 | 
|  | 18 // | 
|  | 19 // This file has been generated automatically, relevant repositories: | 
|  | 20 // * https://hg.adblockplus.org/jshydra/ | 
|  | 21 // | 
|  | 22 | 
|  | 23 var Utils = exports.Utils = { | 
|  | 24   systemPrincipal: null, | 
|  | 25   getString: function(id) | 
|  | 26   { | 
|  | 27     if (typeof ext !== "undefined" && "i18n" in ext) | 
|  | 28     { | 
|  | 29       return ext.i18n.getMessage("global_" + id); | 
|  | 30     } | 
|  | 31     else | 
|  | 32     { | 
|  | 33       return id; | 
|  | 34     } | 
|  | 35   }, | 
|  | 36   runAsync: function(callback) | 
|  | 37   { | 
|  | 38     if (document.readyState == "loading") | 
|  | 39     { | 
|  | 40       var onDOMContentLoaded = function() | 
|  | 41       { | 
|  | 42         document.removeEventListener("DOMContentLoaded", onDOMContentLoaded); | 
|  | 43         callback(); | 
|  | 44       }; | 
|  | 45       document.addEventListener("DOMContentLoaded", onDOMContentLoaded); | 
|  | 46     } | 
|  | 47     else | 
|  | 48     { | 
|  | 49       setTimeout(callback, 0); | 
|  | 50     } | 
|  | 51   }, | 
|  | 52   get appLocale() | 
|  | 53   { | 
|  | 54     var locale = ext.i18n.getMessage("@@ui_locale").replace(/_/g, "-"); | 
|  | 55     Object.defineProperty(this, "appLocale", | 
|  | 56     { | 
|  | 57       value: locale, | 
|  | 58       enumerable: true | 
|  | 59     }); | 
|  | 60     return this.appLocale; | 
|  | 61   }, | 
|  | 62   generateChecksum: function(lines) | 
|  | 63   { | 
|  | 64     return null; | 
|  | 65   }, | 
|  | 66   makeURI: function(url) | 
|  | 67   { | 
|  | 68     return Services.io.newURI(url); | 
|  | 69   }, | 
|  | 70   checkLocalePrefixMatch: function(prefixes) | 
|  | 71   { | 
|  | 72     if (!prefixes) | 
|  | 73     { | 
|  | 74       return null; | 
|  | 75     } | 
|  | 76     var list = prefixes.split(","); | 
|  | 77     for (var i = 0; i < list.length; i++) | 
|  | 78     { | 
|  | 79       if ((new RegExp("^" + list[i] + "\\b")).test(this.appLocale)) | 
|  | 80       { | 
|  | 81         return list[i]; | 
|  | 82       } | 
|  | 83     } | 
|  | 84     return null; | 
|  | 85   }, | 
|  | 86   chooseFilterSubscription: function(subscriptions) | 
|  | 87   { | 
|  | 88     var selectedItem = null; | 
|  | 89     var selectedPrefix = null; | 
|  | 90     var matchCount = 0; | 
|  | 91     for (var i = 0; i < subscriptions.length; i++) | 
|  | 92     { | 
|  | 93       var subscription = subscriptions[i]; | 
|  | 94       if (!selectedItem) | 
|  | 95       { | 
|  | 96         selectedItem = subscription; | 
|  | 97       } | 
|  | 98       var prefix = require("utils").Utils.checkLocalePrefixMatch(subscription.ge
     tAttribute("prefixes")); | 
|  | 99       if (prefix) | 
|  | 100       { | 
|  | 101         if (!selectedPrefix || selectedPrefix.length < prefix.length) | 
|  | 102         { | 
|  | 103           selectedItem = subscription; | 
|  | 104           selectedPrefix = prefix; | 
|  | 105           matchCount = 1; | 
|  | 106         } | 
|  | 107         else if (selectedPrefix && selectedPrefix.length == prefix.length) | 
|  | 108         { | 
|  | 109           matchCount++; | 
|  | 110           if (Math.random() * matchCount < 1) | 
|  | 111           { | 
|  | 112             selectedItem = subscription; | 
|  | 113             selectedPrefix = prefix; | 
|  | 114           } | 
|  | 115         } | 
|  | 116       } | 
|  | 117     } | 
|  | 118     return selectedItem; | 
|  | 119   }, | 
|  | 120   getDocLink: function(linkID) | 
|  | 121   { | 
|  | 122     var Prefs = require("prefs").Prefs; | 
|  | 123     var docLink = Prefs.documentation_link; | 
|  | 124     return docLink.replace(/%LINK%/g, linkID).replace(/%LANG%/g, Utils.appLocale
     ); | 
|  | 125   }, | 
|  | 126   yield: function() | 
|  | 127   {} | 
|  | 128 }; | 
|  | 129 | 
| OLD | NEW | 
|---|