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: Rebased Created March 17, 2017, 12:41 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/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-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 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 19 matching lines...) Expand all
30 // Make sure to not run asynchronous actions before all 30 // Make sure to not run asynchronous actions before all
31 // scripts loaded. This caused issues on Opera in the past. 31 // scripts loaded. This caused issues on Opera in the past.
32 let onDOMContentLoaded = () => 32 let onDOMContentLoaded = () =>
33 { 33 {
34 document.removeEventListener("DOMContentLoaded", onDOMContentLoaded); 34 document.removeEventListener("DOMContentLoaded", onDOMContentLoaded);
35 callback(); 35 callback();
36 }; 36 };
37 document.addEventListener("DOMContentLoaded", onDOMContentLoaded); 37 document.addEventListener("DOMContentLoaded", onDOMContentLoaded);
38 } 38 }
39 else 39 else
40 {
41 setTimeout(callback, 0); 40 setTimeout(callback, 0);
42 }
43 }, 41 },
44 get appLocale() 42 get appLocale()
45 { 43 {
46 let locale = ext.i18n.getMessage("@@ui_locale").replace(/_/g, "-"); 44 let locale = ext.i18n.getMessage("@@ui_locale").replace(/_/g, "-");
47 Object.defineProperty(this, "appLocale", {value: locale, enumerable: true}); 45 Object.defineProperty(this, "appLocale", {value: locale, enumerable: true});
48 return this.appLocale; 46 return this.appLocale;
49 }, 47 },
50 generateChecksum(lines) 48 generateChecksum(lines)
51 { 49 {
52 // We cannot calculate MD5 checksums yet :-( 50 // We cannot calculate MD5 checksums yet :-(
53 return null; 51 return null;
54 }, 52 },
55 checkLocalePrefixMatch(prefixes) 53 checkLocalePrefixMatch(prefixes)
56 { 54 {
57 if (!prefixes) 55 if (!prefixes)
58 return null; 56 return null;
59 57
60 for (let prefix of prefixes.split(",")) 58 for (let prefix of prefixes.split(","))
59 {
61 if (new RegExp("^" + prefix + "\\b").test(this.appLocale)) 60 if (new RegExp("^" + prefix + "\\b").test(this.appLocale))
62 return prefix; 61 return prefix;
62 }
63 63
64 return null; 64 return null;
65 }, 65 },
66 66
67 chooseFilterSubscription(subscriptions) 67 chooseFilterSubscription(subscriptions)
68 { 68 {
69 let selectedItem = null; 69 let selectedItem = null;
70 let selectedPrefix = null; 70 let selectedPrefix = null;
71 let matchCount = 0; 71 let matchCount = 0;
72 for (let subscription of subscriptions) 72 for (let subscription of subscriptions)
73 { 73 {
74 if (!selectedItem) 74 if (!selectedItem)
75 selectedItem = subscription; 75 selectedItem = subscription;
76 76
77 let prefix = Utils.checkLocalePrefixMatch(subscription.getAttribute("prefi xes")); 77 let prefix = Utils.checkLocalePrefixMatch(
78 subscription.getAttribute("prefixes")
79 );
78 if (prefix) 80 if (prefix)
79 { 81 {
80 if (!selectedPrefix || selectedPrefix.length < prefix.length) 82 if (!selectedPrefix || selectedPrefix.length < prefix.length)
81 { 83 {
82 selectedItem = subscription; 84 selectedItem = subscription;
83 selectedPrefix = prefix; 85 selectedPrefix = prefix;
84 matchCount = 1; 86 matchCount = 1;
85 } 87 }
86 else if (selectedPrefix && selectedPrefix.length == prefix.length) 88 else if (selectedPrefix && selectedPrefix.length == prefix.length)
87 { 89 {
(...skipping 10 matching lines...) Expand all
98 } 100 }
99 } 101 }
100 } 102 }
101 } 103 }
102 return selectedItem; 104 return selectedItem;
103 }, 105 },
104 106
105 getDocLink(linkID) 107 getDocLink(linkID)
106 { 108 {
107 let docLink = require("prefs").Prefs.documentation_link; 109 let docLink = require("prefs").Prefs.documentation_link;
108 return docLink.replace(/%LINK%/g, linkID).replace(/%LANG%/g, Utils.appLocale ); 110 return docLink.replace(/%LINK%/g, linkID)
111 .replace(/%LANG%/g, Utils.appLocale);
109 }, 112 },
110 113
111 yield() 114 yield()
112 { 115 {
113 } 116 }
114 }; 117 };
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