Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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-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 * |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
135 | 135 |
136 let tooltip = listItem.querySelector("[data-tooltip]"); | 136 let tooltip = listItem.querySelector("[data-tooltip]"); |
137 if (tooltip) | 137 if (tooltip) |
138 { | 138 { |
139 let tooltipId = tooltip.getAttribute("data-tooltip"); | 139 let tooltipId = tooltip.getAttribute("data-tooltip"); |
140 tooltipId = tooltipId.replace("%value%", item.recommended); | 140 tooltipId = tooltipId.replace("%value%", item.recommended); |
141 if (getMessage(tooltipId)) | 141 if (getMessage(tooltipId)) |
142 { | 142 { |
143 tooltip.setAttribute("data-tooltip", tooltipId); | 143 tooltip.setAttribute("data-tooltip", tooltipId); |
144 } | 144 } |
145 else | |
146 { | |
147 tooltip.parentNode.removeChild(tooltip); | |
148 } | |
149 } | 145 } |
150 | 146 |
151 for (let control of listItem.querySelectorAll(".control")) | 147 for (let control of listItem.querySelectorAll(".control")) |
152 { | 148 { |
153 if (control.hasAttribute("title")) | 149 if (control.hasAttribute("title")) |
154 { | 150 { |
155 let titleValue = getMessage(control.getAttribute("title")); | 151 let titleValue = getMessage(control.getAttribute("title")); |
156 control.setAttribute("title", titleValue); | 152 control.setAttribute("title", titleValue); |
157 } | 153 } |
158 } | 154 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
213 this._sortItems(); | 209 this._sortItems(); |
214 let access = (item.url || item.text).replace(/'/g, "\\'"); | 210 let access = (item.url || item.text).replace(/'/g, "\\'"); |
215 for (let i = 0; i < this.details.length; i++) | 211 for (let i = 0; i < this.details.length; i++) |
216 { | 212 { |
217 let table = E(this.details[i].id); | 213 let table = E(this.details[i].id); |
218 let element = table.querySelector("[data-access='" + access + "']"); | 214 let element = table.querySelector("[data-access='" + access + "']"); |
219 if (!element) | 215 if (!element) |
220 continue; | 216 continue; |
221 | 217 |
222 let title = this._getItemTitle(item, i); | 218 let title = this._getItemTitle(item, i); |
223 for (let displayElement of element.querySelectorAll(".display")) | 219 let displays = element.querySelectorAll(".display"); |
Thomas Greiner
2017/08/16 17:57:09
According to https://developer.mozilla.org/en-US/d
saroyanm
2017/08/17 11:21:17
well spotted.
saroyanm
2017/08/17 21:24:07
Done.
| |
224 displayElement.textContent = title; | 220 for (let j = 0; j < displays.length; j++) |
221 displays[j].textContent = title; | |
225 | 222 |
226 element.setAttribute("aria-label", title); | 223 element.setAttribute("aria-label", title); |
227 if (this.details[i].searchable) | 224 if (this.details[i].searchable) |
228 element.setAttribute("data-search", title.toLowerCase()); | 225 element.setAttribute("data-search", title.toLowerCase()); |
229 let control = element.querySelector(".control[role='checkbox']"); | 226 let control = element.querySelector(".control[role='checkbox']"); |
230 if (control) | 227 if (control) |
231 { | 228 { |
232 control.setAttribute("aria-checked", item.disabled == false); | 229 control.setAttribute("aria-checked", item.disabled == false); |
233 if (isAcceptableAds(item.url) && this == collections.filterLists) | 230 if (isAcceptableAds(item.url) && this == collections.filterLists) |
234 control.disabled = true; | 231 control.disabled = true; |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
331 index += (index == focusables.length - 1) ? -1 : 1; | 328 index += (index == focusables.length - 1) ? -1 : 1; |
332 | 329 |
333 let nextElement = focusables[index]; | 330 let nextElement = focusables[index]; |
334 if (!nextElement) | 331 if (!nextElement) |
335 return false; | 332 return false; |
336 | 333 |
337 nextElement.focus(); | 334 nextElement.focus(); |
338 return true; | 335 return true; |
339 } | 336 } |
340 | 337 |
341 collections.security = new Collection([ | 338 collections.protection = new Collection([ |
342 { | 339 { |
343 id: "recommend-security-list-table" | 340 id: "recommend-protection-list-table" |
344 } | 341 } |
345 ]); | 342 ]); |
346 collections.langs = new Collection([ | 343 collections.langs = new Collection([ |
347 { | 344 { |
348 id: "blocking-languages-table", | 345 id: "blocking-languages-table", |
349 emptyText: ["options_language_empty"] | 346 emptyText: ["options_language_empty"] |
350 } | 347 } |
351 ]); | 348 ]); |
352 collections.allLangs = new Collection([ | 349 collections.allLangs = new Collection([ |
353 { | 350 { |
(...skipping 17 matching lines...) Expand all Loading... | |
371 id: "all-filter-lists-table", | 368 id: "all-filter-lists-table", |
372 useOriginalTitle: true | 369 useOriginalTitle: true |
373 } | 370 } |
374 ]); | 371 ]); |
375 | 372 |
376 function addSubscription(subscription) | 373 function addSubscription(subscription) |
377 { | 374 { |
378 let collection = null; | 375 let collection = null; |
379 if (subscription.recommended) | 376 if (subscription.recommended) |
380 { | 377 { |
381 if (isProtection(subscription.recommended)) | 378 if (subscription.recommended == "ads") |
382 { | |
383 collection = collections.security; | |
Thomas Greiner
2017/08/16 17:57:10
Detail: The previous comments for this still appli
saroyanm
2017/08/17 21:24:07
Done.
| |
384 } | |
385 else if (subscription.recommended == "ads") | |
386 { | 379 { |
387 if (subscription.disabled == false) | 380 if (subscription.disabled == false) |
388 collection = collections.langs; | 381 collection = collections.langs; |
389 | 382 |
390 collections.allLangs.addItem(subscription); | 383 collections.allLangs.addItem(subscription); |
391 } | 384 } |
392 else if (subscription.disabled == false) | |
393 { | |
394 collection = collections.custom; | |
Thomas Greiner
2017/08/16 17:57:10
So we're still putting recommended subscriptions i
saroyanm
2017/08/17 11:21:19
Yes, because according to the subscription.xml "Ma
Thomas Greiner
2017/08/17 12:06:05
If they are in subscriptions.xml but are not suppo
saroyanm
2017/08/17 12:32:08
Is it the decision that we can make ?
If so I'm
Thomas Greiner
2017/08/17 12:49:06
We are the ones who added them in the first place
saroyanm
2017/08/17 14:06:18
Thanks for clarifying that, in this case whole log
saroyanm
2017/08/17 21:24:05
Done.
| |
395 } | |
396 else | 385 else |
Thomas Greiner
2017/08/16 17:57:09
This part of the if-statement is redundant because
saroyanm
2017/08/17 11:21:18
agree.
saroyanm
2017/08/17 21:24:05
Done.
| |
397 { | 386 { |
398 subscriptionsMap[subscription.url] = subscription; | 387 collection = collections.protection; |
399 return; | |
400 } | 388 } |
401 } | 389 } |
402 else if (!isAcceptableAds(subscription.url)) | 390 else if (!isAcceptableAds(subscription.url)) |
403 { | 391 { |
404 collection = collections.custom; | 392 collection = collections.custom; |
405 } | 393 } |
406 | 394 |
407 if (collection) | 395 if (collection) |
408 collection.addItem(subscription); | 396 collection.addItem(subscription); |
409 | 397 |
410 subscriptionsMap[subscription.url] = subscription; | 398 subscriptionsMap[subscription.url] = subscription; |
411 updateTooltips(); | 399 updateTooltips(); |
412 } | 400 } |
413 | 401 |
414 function updateSubscription(subscription) | 402 function updateSubscription(subscription) |
415 { | 403 { |
416 for (let name in collections) | 404 for (let name in collections) |
417 collections[name].updateItem(subscription); | 405 collections[name].updateItem(subscription); |
418 | 406 |
419 if (subscription.recommended == "ads") | 407 if (subscription.recommended == "ads") |
420 { | 408 { |
421 if (subscription.disabled) | 409 if (subscription.disabled) |
422 collections.langs.removeItem(subscription); | 410 collections.langs.removeItem(subscription); |
423 else | 411 else |
424 collections.langs.addItem(subscription); | 412 collections.langs.addItem(subscription); |
425 } | 413 } |
426 else if (!isProtection(subscription.recommended) && | 414 else if (!subscription.recommended && !isAcceptableAds(subscription.url)) |
427 !isAcceptableAds(subscription.url)) | |
428 { | 415 { |
429 if (subscription.disabled == false) | 416 if (subscription.disabled == false) |
430 { | 417 { |
431 collections.custom.addItem(subscription); | 418 collections.custom.addItem(subscription); |
Thomas Greiner
2017/08/16 17:57:09
Again, it seems like we're still putting recommend
saroyanm
2017/08/17 11:21:17
As, same as the comment above, the definition of t
saroyanm
2017/08/17 21:24:05
Done.
| |
432 updateTooltips(); | 419 updateTooltips(); |
433 } | 420 } |
434 else | 421 else |
435 { | 422 { |
436 collections.custom.removeItem(subscription); | 423 collections.custom.removeItem(subscription); |
437 } | 424 } |
438 } | 425 } |
439 } | 426 } |
440 | 427 |
441 function updateFilter(filter) | 428 function updateFilter(filter) |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
584 if (subscriptionType == "ads" && subscription.disabled == false) | 571 if (subscriptionType == "ads" && subscription.disabled == false) |
585 { | 572 { |
586 ext.backgroundPage.sendMessage({ | 573 ext.backgroundPage.sendMessage({ |
587 type: "subscriptions.remove", | 574 type: "subscriptions.remove", |
588 url: subscription.url | 575 url: subscription.url |
589 }); | 576 }); |
590 ext.backgroundPage.sendMessage({ | 577 ext.backgroundPage.sendMessage({ |
591 type: "subscriptions.add", | 578 type: "subscriptions.add", |
592 url: findParentData(element, "access", false) | 579 url: findParentData(element, "access", false) |
593 }); | 580 }); |
581 break; | |
594 } | 582 } |
Thomas Greiner
2017/08/16 17:57:10
Detail: Let's exit the loop as soon as we find the
saroyanm
2017/08/17 21:24:06
Done.
| |
595 } | 583 } |
596 break; | 584 break; |
597 case "close-dialog": | 585 case "close-dialog": |
598 closeDialog(); | 586 closeDialog(); |
599 break; | 587 break; |
600 case "edit-custom-filters": | 588 case "edit-custom-filters": |
601 setCustomFiltersView("write"); | 589 setCustomFiltersView("write"); |
602 break; | 590 break; |
603 case "import-subscription": { | 591 case "import-subscription": { |
604 let url = E("blockingList-textbox").value; | 592 let url = E("blockingList-textbox").value; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
638 sendMessageHandleErrors({ | 626 sendMessageHandleErrors({ |
639 type: "filters.importRaw", | 627 type: "filters.importRaw", |
640 text: E("custom-filters-raw").value, | 628 text: E("custom-filters-raw").value, |
641 removeExisting: true | 629 removeExisting: true |
642 }, | 630 }, |
643 () => | 631 () => |
644 { | 632 { |
645 setCustomFiltersView("read"); | 633 setCustomFiltersView("read"); |
646 }); | 634 }); |
647 break; | 635 break; |
648 case "switch-acceptable-ads": | 636 case "switch-acceptable-ads": |
Thomas Greiner
2017/08/16 17:57:10
It's great that the code has been made more consis
saroyanm
2017/08/17 11:21:18
I think I missed the part of combining them into o
Thomas Greiner
2017/08/17 12:06:05
Your proposal is perfectly fine. :)
saroyanm
2017/08/17 21:24:04
Done.
| |
637 let {value} = element; | |
649 ext.backgroundPage.sendMessage({ | 638 ext.backgroundPage.sendMessage({ |
650 type: "subscriptions.remove", | 639 type: value == "privacy" ? "subscriptions.add" : |
640 "subscriptions.remove", | |
651 url: acceptableAdsPrivacyUrl | 641 url: acceptableAdsPrivacyUrl |
652 }); | 642 }); |
653 ext.backgroundPage.sendMessage({ | 643 ext.backgroundPage.sendMessage({ |
654 type: "subscriptions.add", | 644 type: value == "ads" ? "subscriptions.add" : "subscriptions.remove", |
655 url: acceptableAdsUrl | |
656 }); | |
657 break; | |
658 case "switch-privacy-acceptable-ads": | |
659 ext.backgroundPage.sendMessage({ | |
660 type: "subscriptions.remove", | |
661 url: acceptableAdsUrl | |
662 }); | |
663 ext.backgroundPage.sendMessage({ | |
664 type: "subscriptions.add", | |
665 url: acceptableAdsPrivacyUrl | |
666 }); | |
667 break; | |
668 case "switch-no-acceptable-ads": | |
669 ext.backgroundPage.sendMessage({ | |
670 type: "subscriptions.remove", | |
671 url: acceptableAdsPrivacyUrl | |
672 }); | |
673 ext.backgroundPage.sendMessage({ | |
674 type: "subscriptions.remove", | |
675 url: acceptableAdsUrl | 645 url: acceptableAdsUrl |
676 }); | 646 }); |
677 break; | 647 break; |
678 case "switch-tab": | 648 case "switch-tab": |
679 let tabId = findParentData(element, "tab", false); | 649 let tabId = findParentData(element, "tab", false); |
680 switchTab(tabId); | 650 switchTab(tabId); |
681 break; | 651 break; |
682 case "toggle-disable-subscription": | 652 case "toggle-disable-subscription": |
683 ext.backgroundPage.sendMessage({ | 653 ext.backgroundPage.sendMessage({ |
684 type: "subscriptions.toggle", | 654 type: "subscriptions.toggle", |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1016 | 986 |
1017 function closeDialog() | 987 function closeDialog() |
1018 { | 988 { |
1019 let dialog = E("dialog"); | 989 let dialog = E("dialog"); |
1020 dialog.setAttribute("aria-hidden", true); | 990 dialog.setAttribute("aria-hidden", true); |
1021 dialog.removeAttribute("aria-labelledby"); | 991 dialog.removeAttribute("aria-labelledby"); |
1022 document.body.removeAttribute("data-dialog"); | 992 document.body.removeAttribute("data-dialog"); |
1023 focusedBeforeDialog.focus(); | 993 focusedBeforeDialog.focus(); |
1024 } | 994 } |
1025 | 995 |
1026 function setDntNotification(state) | 996 function setAcceptableAds() |
1027 { | 997 { |
1028 if (state) | 998 let option = "none"; |
1029 E("acceptable-ads").classList.add("show-dnt-notification"); | 999 document.forms["acceptable-ads"].classList.remove("show-dnt-notification"); |
1030 else | 1000 if (acceptableAdsUrl in subscriptionsMap) |
1031 E("acceptable-ads").classList.remove("show-dnt-notification"); | 1001 { |
1032 } | 1002 option = "ads"; |
1033 | 1003 } |
1034 function setAcceptableAds(option) | 1004 else if (acceptableAdsPrivacyUrl in subscriptionsMap) |
1035 { | 1005 { |
1036 let optionsContainer = E("acceptable-ads"); | 1006 option = "privacy"; |
1037 switch (option) | 1007 |
1038 { | 1008 if (!navigator.doNotTrack) |
1039 case "default": | 1009 document.forms["acceptable-ads"].classList.add("show-dnt-notification"); |
1040 optionsContainer.querySelector("[value='ads']").checked = true; | 1010 } |
1041 break; | 1011 document.forms["acceptable-ads"]["acceptable-ads"].value = option; |
1042 case "privacy": | |
1043 optionsContainer.querySelector("[value='ads,privacy']").checked = true; | |
1044 break; | |
1045 case "none": | |
1046 optionsContainer.querySelector("[value='none']").checked = true; | |
1047 break; | |
1048 } | |
1049 } | 1012 } |
1050 | 1013 |
1051 function isAcceptableAds(url) | 1014 function isAcceptableAds(url) |
1052 { | 1015 { |
1053 return url == acceptableAdsUrl || url == acceptableAdsPrivacyUrl; | 1016 return url == acceptableAdsUrl || url == acceptableAdsPrivacyUrl; |
1054 } | |
1055 | |
1056 function isProtection(type) | |
1057 { | |
1058 return type == "privacy" || type == "social"; | |
1059 } | 1017 } |
1060 | 1018 |
1061 function populateLists() | 1019 function populateLists() |
1062 { | 1020 { |
1063 subscriptionsMap = Object.create(null); | 1021 subscriptionsMap = Object.create(null); |
1064 filtersMap = Object.create(null); | 1022 filtersMap = Object.create(null); |
1065 | 1023 |
1066 // Empty collections and lists | 1024 // Empty collections and lists |
1067 for (let property in collections) | 1025 for (let property in collections) |
1068 collections[property].clearAll(); | 1026 collections[property].clearAll(); |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1221 case "lastDownload": | 1179 case "lastDownload": |
1222 case "title": | 1180 case "title": |
1223 updateSubscription(subscription); | 1181 updateSubscription(subscription); |
1224 break; | 1182 break; |
1225 case "added": | 1183 case "added": |
1226 if (subscription.url in subscriptionsMap) | 1184 if (subscription.url in subscriptionsMap) |
1227 updateSubscription(subscription); | 1185 updateSubscription(subscription); |
1228 else | 1186 else |
1229 addSubscription(subscription); | 1187 addSubscription(subscription); |
1230 | 1188 |
1231 if (subscription.url == acceptableAdsUrl) | 1189 if (isAcceptableAds(subscription.url)) |
1232 setAcceptableAds("default"); | 1190 setAcceptableAds(); |
Thomas Greiner
2017/08/16 17:57:10
We cannot determine the current state based on whi
saroyanm
2017/08/17 11:21:18
I agree. I'll update accordingly.
saroyanm
2017/08/17 21:24:04
Done.
| |
1233 | |
1234 if (subscription.url == acceptableAdsPrivacyUrl) | |
1235 { | |
1236 setAcceptableAds("privacy"); | |
1237 if (!navigator.doNotTrack) | |
1238 setDntNotification(true); | |
1239 } | |
1240 | 1191 |
1241 collections.filterLists.addItem(subscription); | 1192 collections.filterLists.addItem(subscription); |
1242 break; | 1193 break; |
1243 case "removed": | 1194 case "removed": |
1244 if (subscription.recommended == "ads" || | 1195 if (subscription.recommended) |
1245 isProtection(subscription.recommended)) | |
1246 { | 1196 { |
1247 subscription.disabled = true; | 1197 subscription.disabled = true; |
1248 onSubscriptionMessage("disabled", subscription); | 1198 onSubscriptionMessage("disabled", subscription); |
1249 } | 1199 } |
1250 if (isAcceptableAds(subscription.url)) | 1200 else |
1251 { | 1201 { |
1252 setAcceptableAds("none"); | 1202 delete subscriptionsMap[subscription.url]; |
1253 if (subscription.url == acceptableAdsPrivacyUrl) | 1203 if (isAcceptableAds(subscription.url)) |
1254 { | 1204 { |
1255 setDntNotification(false); | 1205 setAcceptableAds(); |
1256 } | 1206 } |
1257 } | 1207 else |
1258 else | 1208 { |
1259 { | 1209 collections.custom.removeItem(subscription); |
1260 collections.custom.removeItem(subscription); | 1210 } |
Thomas Greiner
2017/08/16 17:57:09
Detail: Recommended subscriptions should not be in
saroyanm
2017/08/17 21:24:06
Done.
| |
1261 delete subscriptionsMap[subscription.url]; | |
Thomas Greiner
2017/08/16 17:57:10
In `addSubscription()` we're adding Acceptable Ads
saroyanm
2017/08/17 11:21:17
I tried to be consistent with old implementation h
Thomas Greiner
2017/08/17 12:06:06
Sounds good.
saroyanm
2017/08/17 21:24:07
With current implementation is more understandable
Thomas Greiner
2017/08/22 16:08:57
I don't think not removing recommended subscriptio
| |
1262 } | 1211 } |
1263 collections.filterLists.removeItem(subscription); | 1212 collections.filterLists.removeItem(subscription); |
1264 break; | 1213 break; |
1265 } | 1214 } |
1266 | 1215 |
1267 updateShareLink(); | 1216 updateShareLink(); |
1268 } | 1217 } |
1269 | 1218 |
1270 function hidePref(key, value) | 1219 function hidePref(key, value) |
1271 { | 1220 { |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1418 }); | 1367 }); |
1419 ext.backgroundPage.sendMessage({ | 1368 ext.backgroundPage.sendMessage({ |
1420 type: "subscriptions.listen", | 1369 type: "subscriptions.listen", |
1421 filter: ["added", "disabled", "homepage", "lastDownload", "removed", | 1370 filter: ["added", "disabled", "homepage", "lastDownload", "removed", |
1422 "title", "downloadStatus", "downloading"] | 1371 "title", "downloadStatus", "downloading"] |
1423 }); | 1372 }); |
1424 | 1373 |
1425 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); | 1374 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); |
1426 window.addEventListener("hashchange", onHashChange, false); | 1375 window.addEventListener("hashchange", onHashChange, false); |
1427 } | 1376 } |
LEFT | RIGHT |