OLD | NEW |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, |
3 * Copyright (C) 2006-2013 Eyeo GmbH | 3 * Copyright (C) 2006-2014 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 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 | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 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/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
16 */ | 16 */ |
17 | 17 |
18 let runAsyncQueue; | 18 let runAsyncQueue; |
19 | 19 |
20 var Utils = exports.Utils = { | 20 var Utils = exports.Utils = { |
21 systemPrincipal: null, | 21 systemPrincipal: null, |
22 getString: function(id) | 22 getString: function(id) |
23 { | 23 { |
24 return id; | 24 if (typeof ext !== "undefined" && "i18n" in ext) |
| 25 return ext.i18n.getMessage("global_" + id); |
| 26 else |
| 27 return id; |
25 }, | 28 }, |
26 | 29 |
27 // This function can take additional parameters. Second paramater will be | 30 // This function can take additional parameters. Second paramater will be |
28 // passed as this variable to the callback and any additional parameters as | 31 // passed as this variable to the callback and any additional parameters as |
29 // callback parameters. | 32 // callback parameters. |
30 runAsync: function(callback) | 33 runAsync: function(callback) |
31 { | 34 { |
32 callback = callback.bind.apply(callback, Array.prototype.slice.call(argument
s, 1)); | 35 callback = callback.bind.apply(callback, Array.prototype.slice.call(argument
s, 1)); |
33 | 36 |
34 if (typeof runAsyncQueue == "undefined") | 37 if (typeof runAsyncQueue == "undefined") |
35 { | 38 { |
36 runAsyncQueue = (document.readyState == "loading" ? [] : null); | 39 runAsyncQueue = (document.readyState == "loading" ? [] : null); |
37 if (runAsyncQueue) | 40 if (runAsyncQueue) |
38 { | 41 { |
39 // Hack: Opera will happily run asynchronous actions while scripts are | 42 // Hack: Opera will happily run asynchronous actions while scripts are |
40 // loading, queue them until the document is ready. | 43 // loading, queue them until the document is ready. |
41 let loadHandler = function() | 44 let loadHandler = function() |
42 { | 45 { |
43 document.removeEventListener("DOMContentLoaded", loadHandler, false); | 46 document.removeEventListener("DOMContentLoaded", loadHandler, false); |
44 | 47 |
45 let queue = runAsyncQueue; | 48 let queue = runAsyncQueue; |
46 runAsyncQueue = null; | 49 runAsyncQueue = null; |
47 for each (let callback in queue) | 50 for (let callback of queue) |
48 { | 51 { |
49 try | 52 try |
50 { | 53 { |
51 callback(); | 54 callback(); |
52 } | 55 } |
53 catch(e) | 56 catch(e) |
54 { | 57 { |
55 Cu.reportError(e); | 58 Cu.reportError(e); |
56 } | 59 } |
57 } | 60 } |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 } | 134 } |
132 } | 135 } |
133 return selectedItem; | 136 return selectedItem; |
134 }, | 137 }, |
135 | 138 |
136 getDocLink: function(linkID) | 139 getDocLink: function(linkID) |
137 { | 140 { |
138 var Prefs = require("prefs").Prefs; | 141 var Prefs = require("prefs").Prefs; |
139 var docLink = Prefs.documentation_link; | 142 var docLink = Prefs.documentation_link; |
140 return docLink.replace(/%LINK%/g, linkID).replace(/%LANG%/g, Utils.appLocale
); | 143 return docLink.replace(/%LINK%/g, linkID).replace(/%LANG%/g, Utils.appLocale
); |
| 144 }, |
| 145 |
| 146 yield: function() |
| 147 { |
141 } | 148 } |
142 }; | 149 }; |
OLD | NEW |