Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: lib/utils.js

Issue 13077005: Fix first-run page in Opera (Closed)
Left Patch Set: Improved queuing of async actions Created Oct. 16, 2013, 1:13 p.m.
Right Patch Set: Fixed nits Created Oct. 16, 2013, 1:43 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « lib/localstorage/io.js ('k') | metadata.opera » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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-2013 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 return id;
25 }, 25 },
26 26
27 runAsync: function(callback, thisPtr) 27 // This function can take additional parameters. Second paramater will be
Thomas Greiner 2013/10/16 13:36:46 thisPtr is only implicitly used by callback.bind.a
Wladimir Palant 2013/10/16 13:44:41 That's mainly because this isn't the canonical imp
28 // passed as this variable to the callback and any additional parameters as
29 // callback parameters.
30 runAsync: function(callback)
28 { 31 {
29 callback = callback.bind.apply(callback, Array.prototype.slice.call(argument s, 1)); 32 callback = callback.bind.apply(callback, Array.prototype.slice.call(argument s, 1));
30 33
31 if (typeof runAsyncQueue == "undefined") 34 if (typeof runAsyncQueue == "undefined")
32 { 35 {
33 runAsyncQueue = (document.readyState == "loading" ? [] : null) 36 runAsyncQueue = (document.readyState == "loading" ? [] : null);
Thomas Greiner 2013/10/16 13:36:46 Nit: Semicolon at the end is missing.
Wladimir Palant 2013/10/16 13:44:41 Done.
34 if (runAsyncQueue) 37 if (runAsyncQueue)
35 { 38 {
36 // Hack: Opera will happily run asynchronous actions while scripts are 39 // Hack: Opera will happily run asynchronous actions while scripts are
37 // loading, queue them until the document is ready. 40 // loading, queue them until the document is ready.
38 let loadHandler = function() 41 let loadHandler = function()
39 { 42 {
40 document.removeEventListener("DOMContentLoaded", loadHandler, false); 43 document.removeEventListener("DOMContentLoaded", loadHandler, false);
41 44
42 let queue = runAsyncQueue; 45 let queue = runAsyncQueue;
43 runAsyncQueue = null; 46 runAsyncQueue = null;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 return selectedItem; 133 return selectedItem;
131 }, 134 },
132 135
133 getDocLink: function(linkID) 136 getDocLink: function(linkID)
134 { 137 {
135 var Prefs = require("prefs").Prefs; 138 var Prefs = require("prefs").Prefs;
136 var docLink = Prefs.documentation_link; 139 var docLink = Prefs.documentation_link;
137 return docLink.replace(/%LINK%/g, linkID).replace(/%LANG%/g, Utils.appLocale ); 140 return docLink.replace(/%LINK%/g, linkID).replace(/%LANG%/g, Utils.appLocale );
138 } 141 }
139 }; 142 };
LEFTRIGHT

Powered by Google App Engine
This is Rietveld