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

Side by Side Diff: lib/utils.js

Issue 29545700: Issue 5685 - Pass ESLint (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Patch Set: Created Sept. 15, 2017, 7:38 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
« lib/init.js ('K') | « lib/updater.js ('k') | no next file » | 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 <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH 3 * Copyright (C) 2006-present 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 var Utils = exports.Utils = { 18 "use strict";
19
20 let Utils = {
19 systemPrincipal: null, 21 systemPrincipal: null,
20 getString: function(id) 22 getString(id)
21 { 23 {
22 return id; 24 return id;
23 }, 25 },
24 runAsync: function(callback, thisPtr) 26 runAsync(callback, thisPtr, ...params)
25 { 27 {
26 var params = Array.prototype.slice.call(arguments, 2); 28 setTimeout(() =>
27 window.setTimeout(function()
28 { 29 {
29 callback.apply(thisPtr, params); 30 callback.apply(thisPtr, params);
30 }, 0); 31 }, 0);
31 }, 32 },
32 get appLocale() 33 get appLocale()
33 { 34 {
34 return _appInfo.locale; 35 return _appInfo.locale;
35 }, 36 },
36 generateChecksum: function(lines) 37 generateChecksum(lines)
37 { 38 {
38 // We cannot calculate MD5 checksums yet :-( 39 // We cannot calculate MD5 checksums yet :-(
39 return null; 40 return null;
40 }, 41 },
41 42
42 checkLocalePrefixMatch: function(prefixes) 43 checkLocalePrefixMatch(prefixes)
43 { 44 {
44 if (!prefixes) 45 if (!prefixes)
45 return null; 46 return null;
46 47
47 let list = prefixes.split(","); 48 let list = prefixes.split(",");
48 for (let prefix of list) 49 for (let prefix of list)
49 if (new RegExp("^" + prefix + "\\b").test(this.appLocale)) 50 if (new RegExp("^" + prefix + "\\b").test(this.appLocale))
50 return prefix; 51 return prefix;
51 52
52 return null; 53 return null;
53 }, 54 },
54 55
55 chooseFilterSubscription: function(subscriptions) 56 chooseFilterSubscription(subscriptions)
56 { 57 {
57 let selectedItem = null; 58 let selectedItem = null;
58 let selectedPrefix = null; 59 let selectedPrefix = null;
59 let matchCount = 0; 60 let matchCount = 0;
60 for (let i = 0; i < subscriptions.length; i++) 61 for (let i = 0; i < subscriptions.length; i++)
61 { 62 {
62 let subscription = subscriptions[i]; 63 let subscription = subscriptions[i];
63 if (!selectedItem) 64 if (!selectedItem)
64 selectedItem = subscription; 65 selectedItem = subscription;
65 66
(...skipping 18 matching lines...) Expand all
84 { 85 {
85 selectedItem = subscription; 86 selectedItem = subscription;
86 selectedPrefix = prefix; 87 selectedPrefix = prefix;
87 } 88 }
88 } 89 }
89 } 90 }
90 } 91 }
91 return selectedItem; 92 return selectedItem;
92 } 93 }
93 }; 94 };
95
96 exports.Utils = Utils;
OLDNEW
« lib/init.js ('K') | « lib/updater.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld