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

Side by Side Diff: lib/utils.js

Issue 13077005: Fix first-run page in Opera (Closed)
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:
View unified diff | Download patch
« no previous file with comments | « lib/localstorage/io.js ('k') | metadata.opera » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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;
19
18 var Utils = exports.Utils = { 20 var Utils = exports.Utils = {
19 systemPrincipal: null, 21 systemPrincipal: null,
20 getString: function(id) 22 getString: function(id)
21 { 23 {
22 return id; 24 return id;
23 }, 25 },
24 runAsync: function(callback, thisPtr) 26
27 // This function can take additional parameters. Second paramater will be
28 // passed as this variable to the callback and any additional parameters as
29 // callback parameters.
30 runAsync: function(callback)
25 { 31 {
26 var params = Array.prototype.slice.call(arguments, 2); 32 callback = callback.bind.apply(callback, Array.prototype.slice.call(argument s, 1));
27 window.setTimeout(function() 33
34 if (typeof runAsyncQueue == "undefined")
28 { 35 {
29 callback.apply(thisPtr, params); 36 runAsyncQueue = (document.readyState == "loading" ? [] : null);
30 }, 0); 37 if (runAsyncQueue)
38 {
39 // Hack: Opera will happily run asynchronous actions while scripts are
40 // loading, queue them until the document is ready.
41 let loadHandler = function()
42 {
43 document.removeEventListener("DOMContentLoaded", loadHandler, false);
44
45 let queue = runAsyncQueue;
46 runAsyncQueue = null;
47 for each (let callback in queue)
48 {
49 try
50 {
51 callback();
52 }
53 catch(e)
54 {
55 Cu.reportError(e);
56 }
57 }
58 };
59 document.addEventListener("DOMContentLoaded", loadHandler, false);
60 }
61 }
62
63 if (runAsyncQueue)
64 runAsyncQueue.push(callback);
65 else
66 window.setTimeout(callback, 0);
31 }, 67 },
32 get appLocale() 68 get appLocale()
33 { 69 {
34 var locale = chrome.i18n.getMessage("@@ui_locale").replace(/_/g, "-"); 70 var locale = chrome.i18n.getMessage("@@ui_locale").replace(/_/g, "-");
35 this.__defineGetter__("appLocale", function() {return locale}); 71 this.__defineGetter__("appLocale", function() {return locale});
36 return this.appLocale; 72 return this.appLocale;
37 }, 73 },
38 generateChecksum: function(lines) 74 generateChecksum: function(lines)
39 { 75 {
40 // We cannot calculate MD5 checksums yet :-( 76 // We cannot calculate MD5 checksums yet :-(
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 return selectedItem; 133 return selectedItem;
98 }, 134 },
99 135
100 getDocLink: function(linkID) 136 getDocLink: function(linkID)
101 { 137 {
102 var Prefs = require("prefs").Prefs; 138 var Prefs = require("prefs").Prefs;
103 var docLink = Prefs.documentation_link; 139 var docLink = Prefs.documentation_link;
104 return docLink.replace(/%LINK%/g, linkID).replace(/%LANG%/g, Utils.appLocale ); 140 return docLink.replace(/%LINK%/g, linkID).replace(/%LANG%/g, Utils.appLocale );
105 } 141 }
106 }; 142 };
OLDNEW
« no previous file with comments | « lib/localstorage/io.js ('k') | metadata.opera » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld