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

Delta Between Two Patch Sets: desktop-options.js

Issue 29578574: Issue 5632 - Use checkboxes for toggling acceptable ads (Closed)
Left Patch Set: Addressed Ire's comments Created Oct. 19, 2017, 8:40 p.m.
Right Patch Set: Fixed the duplication Created Oct. 20, 2017, 6:56 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « desktop-options.html ('k') | skin/desktop-options.css » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 }); 552 });
553 } 553 }
554 554
555 function switchTab(id) 555 function switchTab(id)
556 { 556 {
557 location.hash = id; 557 location.hash = id;
558 } 558 }
559 559
560 function execAction(action, element) 560 function execAction(action, element)
561 { 561 {
562 if (element.getAttribute("aria-disabled") == "true") 562 if (element.getAttribute("aria-disabled") == "true")
Thomas Greiner 2017/10/20 15:35:03 Detail: No need to check for "true" or "false" whe
saroyanm 2017/10/20 16:42:06 In our code in some places we do set attribute lik
Thomas Greiner 2017/10/20 17:59:57 I'm fine with working on this in a separate ticket
saroyanm 2017/10/20 19:06:46 Ticket: https://issues.adblockplus.org/ticket/5900
563 return; 563 return;
564 564
565 switch (action) 565 switch (action)
566 { 566 {
567 case "add-domain-exception": 567 case "add-domain-exception":
568 addWhitelistedDomain(); 568 addWhitelistedDomain();
569 break; 569 break;
570 case "add-language-subscription": 570 case "add-language-subscription":
571 addEnableSubscription(findParentData(element, "access", false)); 571 addEnableSubscription(findParentData(element, "access", false));
572 break; 572 break;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 }, 649 },
650 () => 650 () =>
651 { 651 {
652 setCustomFiltersView("read"); 652 setCustomFiltersView("read");
653 }); 653 });
654 break; 654 break;
655 case "show-more-filters-section": 655 case "show-more-filters-section":
656 E("more-filters").setAttribute("aria-hidden", false); 656 E("more-filters").setAttribute("aria-hidden", false);
657 break; 657 break;
658 case "switch-acceptable-ads": 658 case "switch-acceptable-ads":
659 let isChecked = element.getAttribute("aria-checked") == "true";
660 let value = element.value || element.dataset.value; 659 let value = element.value || element.dataset.value;
661 let isRegularAcceptableAds = value == "ads"; 660 // User check the checkbox
661 let shouldCheck = element.getAttribute("aria-checked") != "true";
662 let installAcceptableAds = false;
663 let installAcceptableAdsPrivacy = false;
664 // Acceptable Ads checkbox clicked
665 if (value == "ads")
666 {
667 installAcceptableAds = shouldCheck;
668 }
669 // Privacy Friendly Acceptable Ads checkbox clicked
670 else
671 {
672 installAcceptableAdsPrivacy = shouldCheck;
673 installAcceptableAds = !shouldCheck;
674 }
662 675
663 browser.runtime.sendMessage({ 676 browser.runtime.sendMessage({
664 type: isRegularAcceptableAds != isChecked ? "subscriptions.add" : 677 type: installAcceptableAds ? "subscriptions.add" :
665 "subscriptions.remove", 678 "subscriptions.remove",
666 url: acceptableAdsUrl 679 url: acceptableAdsUrl
667 }); 680 });
668 browser.runtime.sendMessage({ 681 browser.runtime.sendMessage({
669 type: isRegularAcceptableAds || isChecked ? "subscriptions.remove" : 682 type: installAcceptableAdsPrivacy ? "subscriptions.add" :
670 "subscriptions.add", 683 "subscriptions.remove",
671 url: acceptableAdsPrivacyUrl 684 url: acceptableAdsPrivacyUrl
672 }); 685 });
Thomas Greiner 2017/10/20 15:35:03 This is very hard to read so for the sake of maint
saroyanm 2017/10/20 16:42:06 I agree with you, I made it hopefully simpler now.
Thomas Greiner 2017/10/20 17:59:57 It's better. As mentioned in person, I'd avoid dup
saroyanm 2017/10/20 19:06:46 Done.
673 break; 686 break;
674 case "switch-tab": 687 case "switch-tab":
675 switchTab(element.getAttribute("href").substr(1)); 688 switchTab(element.getAttribute("href").substr(1));
676 break; 689 break;
677 case "toggle-disable-subscription": 690 case "toggle-disable-subscription":
678 browser.runtime.sendMessage({ 691 browser.runtime.sendMessage({
679 type: "subscriptions.toggle", 692 type: "subscriptions.toggle",
680 keepInstalled: true, 693 keepInstalled: true,
681 url: findParentData(element, "access", false) 694 url: findParentData(element, "access", false)
682 }); 695 });
(...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after
1404 }); 1417 });
1405 browser.runtime.sendMessage({ 1418 browser.runtime.sendMessage({
1406 type: "subscriptions.listen", 1419 type: "subscriptions.listen",
1407 filter: ["added", "disabled", "homepage", "lastDownload", "removed", 1420 filter: ["added", "disabled", "homepage", "lastDownload", "removed",
1408 "title", "downloadStatus", "downloading"] 1421 "title", "downloadStatus", "downloading"]
1409 }); 1422 });
1410 1423
1411 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); 1424 window.addEventListener("DOMContentLoaded", onDOMLoaded, false);
1412 window.addEventListener("hashchange", onHashChange, false); 1425 window.addEventListener("hashchange", onHashChange, false);
1413 } 1426 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld