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

Side by Side Diff: lib/utils.js

Issue 29374674: Issue 4864 - Start using ESLint for adblockpluschrome (Closed)
Patch Set: Addressed more feedback Created March 31, 2017, 8:23 a.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/url.js ('k') | lib/whitelisting.js » ('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 <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2017 eyeo GmbH 3 * Copyright (C) 2006-2017 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
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 { 51 {
52 // We cannot calculate MD5 checksums yet :-( 52 // We cannot calculate MD5 checksums yet :-(
53 return null; 53 return null;
54 }, 54 },
55 checkLocalePrefixMatch(prefixes) 55 checkLocalePrefixMatch(prefixes)
56 { 56 {
57 if (!prefixes) 57 if (!prefixes)
58 return null; 58 return null;
59 59
60 for (let prefix of prefixes.split(",")) 60 for (let prefix of prefixes.split(","))
61 {
61 if (new RegExp("^" + prefix + "\\b").test(this.appLocale)) 62 if (new RegExp("^" + prefix + "\\b").test(this.appLocale))
62 return prefix; 63 return prefix;
64 }
63 65
64 return null; 66 return null;
65 }, 67 },
66 68
67 chooseFilterSubscription(subscriptions) 69 chooseFilterSubscription(subscriptions)
68 { 70 {
69 let selectedItem = null; 71 let selectedItem = null;
70 let selectedPrefix = null; 72 let selectedPrefix = null;
71 let matchCount = 0; 73 let matchCount = 0;
72 for (let subscription of subscriptions) 74 for (let subscription of subscriptions)
73 { 75 {
74 if (!selectedItem) 76 if (!selectedItem)
75 selectedItem = subscription; 77 selectedItem = subscription;
76 78
77 let prefix = Utils.checkLocalePrefixMatch(subscription.getAttribute("prefi xes")); 79 let prefix = Utils.checkLocalePrefixMatch(
80 subscription.getAttribute("prefixes")
81 );
78 if (prefix) 82 if (prefix)
79 { 83 {
80 if (!selectedPrefix || selectedPrefix.length < prefix.length) 84 if (!selectedPrefix || selectedPrefix.length < prefix.length)
81 { 85 {
82 selectedItem = subscription; 86 selectedItem = subscription;
83 selectedPrefix = prefix; 87 selectedPrefix = prefix;
84 matchCount = 1; 88 matchCount = 1;
85 } 89 }
86 else if (selectedPrefix && selectedPrefix.length == prefix.length) 90 else if (selectedPrefix && selectedPrefix.length == prefix.length)
87 { 91 {
(...skipping 10 matching lines...) Expand all
98 } 102 }
99 } 103 }
100 } 104 }
101 } 105 }
102 return selectedItem; 106 return selectedItem;
103 }, 107 },
104 108
105 getDocLink(linkID) 109 getDocLink(linkID)
106 { 110 {
107 let docLink = require("prefs").Prefs.documentation_link; 111 let docLink = require("prefs").Prefs.documentation_link;
108 return docLink.replace(/%LINK%/g, linkID).replace(/%LANG%/g, Utils.appLocale ); 112 return docLink.replace(/%LINK%/g, linkID)
113 .replace(/%LANG%/g, Utils.appLocale);
109 }, 114 },
110 115
111 yield() 116 yield()
112 { 117 {
113 } 118 }
114 }; 119 };
OLDNEW
« no previous file with comments | « lib/url.js ('k') | lib/whitelisting.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld