Left: | ||
Right: |
OLD | NEW |
---|---|
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-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 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 nodes = null; | 18 var nodes = null; |
19 let item = null; | 19 var item = null; |
20 let advancedMode = false; | 20 var advancedMode = false; |
Thomas Greiner
2015/11/02 18:54:36
How is this change related to the issue?
Wladimir Palant
2015/11/03 11:26:49
It is only related to testing here. We have an eve
Thomas Greiner
2015/11/03 11:54:54
I see. In that case fine to fix it separately.
Wladimir Palant
2015/11/04 09:30:41
Ok, I removed that change here and created https:/
| |
21 | 21 |
22 function init() | 22 function init() |
23 { | 23 { |
24 [nodes, item] = window.arguments; | 24 [nodes, item] = window.arguments; |
25 | 25 |
26 E("filterType").value = (!item.filter || item.filter.disabled || item.filter i nstanceof WhitelistFilter ? "filterlist" : "whitelist"); | 26 E("filterType").value = (!item.filter || item.filter.disabled || item.filter i nstanceof WhitelistFilter ? "filterlist" : "whitelist"); |
27 E("customPattern").value = item.location; | 27 E("customPattern").value = item.location; |
28 | 28 |
29 let insertionPoint = E("customPatternBox"); | 29 let insertionPoint = E("customPatternBox"); |
30 let addSuggestion = function(address) | 30 let addSuggestion = function(address) |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
112 // IOService returned nsIURI - not much we can do with it | 112 // IOService returned nsIURI - not much we can do with it |
113 addSuggestion(item.location); | 113 addSuggestion(item.location); |
114 E("patternGroup").value = ""; | 114 E("patternGroup").value = ""; |
115 } | 115 } |
116 if (Prefs.composer_default == 0) | 116 if (Prefs.composer_default == 0) |
117 E("customPattern").focus(); | 117 E("customPattern").focus(); |
118 else | 118 else |
119 E("patternGroup").focus(); | 119 E("patternGroup").focus(); |
120 | 120 |
121 let types = []; | 121 let types = []; |
122 for (let type in Policy.localizedDescr) | 122 for (let type of Policy.localizedDescr.keys()) |
123 { | 123 types.push(type); |
Thomas Greiner
2015/11/02 18:54:36
Detail: What about writing `let types = Array.from
Wladimir Palant
2015/11/03 11:26:49
Nice one, I didn't know about Array.from() yet. Ho
Thomas Greiner
2015/11/03 11:54:54
I agree that, with that change in mind, it's not n
| |
124 types.push(parseInt(type)); | 124 types.sort(); |
125 } | |
126 types.sort(function(a, b) { | |
127 if (a < b) | |
128 return -1; | |
129 else if (a > b) | |
130 return 1; | |
131 else | |
132 return 0; | |
133 }); | |
134 | 125 |
135 let docDomain = item.docDomain; | 126 let docDomain = item.docDomain; |
136 let thirdParty = item.thirdParty; | 127 let thirdParty = item.thirdParty; |
137 | 128 |
138 if (docDomain) | 129 if (docDomain) |
139 docDomain = docDomain.replace(/^www\./i, "").replace(/\.+$/, ""); | 130 docDomain = docDomain.replace(/^www\./i, "").replace(/\.+$/, ""); |
140 if (docDomain) | 131 if (docDomain) |
141 E("domainRestriction").value = docDomain; | 132 E("domainRestriction").value = docDomain; |
142 | 133 |
143 E("thirdParty").hidden = !thirdParty; | 134 E("thirdParty").hidden = !thirdParty; |
144 E("firstParty").hidden = thirdParty; | 135 E("firstParty").hidden = thirdParty; |
145 | 136 |
146 let typeGroup = E("typeGroup"); | 137 let typeGroup = E("typeGroup"); |
147 let defaultTypes = RegExpFilter.prototype.contentType & ~RegExpFilter.typeMap. DOCUMENT; | 138 let defaultTypes = RegExpFilter.prototype.contentType & ~RegExpFilter.typeMap. DOCUMENT; |
148 let isDefaultType = (RegExpFilter.typeMap[item.typeDescr] & defaultTypes) != 0 ; | 139 let isDefaultType = (RegExpFilter.typeMap[item.typeDescr] & defaultTypes) != 0 ; |
149 for (let type of types) | 140 for (let type of types) |
150 { | 141 { |
151 if (type == Policy.type.ELEMHIDE) | 142 if (type == "ELEMHIDE") |
152 continue; | 143 continue; |
153 | 144 |
154 let typeNode = document.createElement("checkbox"); | 145 let typeNode = document.createElement("checkbox"); |
155 typeNode.setAttribute("value", Policy.typeDescr[type].toLowerCase().replace( /\_/g, "-")); | 146 typeNode.setAttribute("value", type.toLowerCase().replace(/\_/g, "-")); |
156 typeNode.setAttribute("label", Policy.localizedDescr[type].toLowerCase()); | 147 typeNode.setAttribute("label", Policy.localizedDescr.get(type).toLowerCase() ); |
157 | 148 |
158 let typeMask = RegExpFilter.typeMap[Policy.typeDescr[type]]; | 149 let typeMask = RegExpFilter.typeMap[type]; |
159 typeNode._defaultType = (typeMask & defaultTypes) != 0; | 150 typeNode._defaultType = (typeMask & defaultTypes) != 0; |
160 if ((isDefaultType && typeNode._defaultType) || (!isDefaultType && item.type == type)) | 151 if ((isDefaultType && typeNode._defaultType) || (!isDefaultType && item.type == type)) |
161 typeNode.setAttribute("checked", "true"); | 152 typeNode.setAttribute("checked", "true"); |
162 | 153 |
163 if (item.type == type) | 154 if (item.type == type) |
164 typeNode.setAttribute("disabled", "true"); | 155 typeNode.setAttribute("disabled", "true"); |
165 typeNode.addEventListener("command", () => checkboxUpdated(typeNode), false) ; | 156 typeNode.addEventListener("command", () => checkboxUpdated(typeNode), false) ; |
166 typeGroup.appendChild(typeNode); | 157 typeGroup.appendChild(typeNode); |
167 } | 158 } |
168 | 159 |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
403 * Selects or unselects all type checkboxes except those | 394 * Selects or unselects all type checkboxes except those |
404 * that are disabled. | 395 * that are disabled. |
405 */ | 396 */ |
406 function selectAllTypes(/**Boolean*/ select) | 397 function selectAllTypes(/**Boolean*/ select) |
407 { | 398 { |
408 for (let typeNode = E("typeGroup").firstChild; typeNode; typeNode = typeNode.n extSibling) | 399 for (let typeNode = E("typeGroup").firstChild; typeNode; typeNode = typeNode.n extSibling) |
409 if (typeNode.getAttribute("disabled") != "true") | 400 if (typeNode.getAttribute("disabled") != "true") |
410 typeNode.checked = select; | 401 typeNode.checked = select; |
411 updateFilter(); | 402 updateFilter(); |
412 } | 403 } |
OLD | NEW |