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

Delta Between Two Patch Sets: options.js

Issue 29321198: Issue 2376 - Implement custom filters in new options page (Closed)
Left Patch Set: removed the console.log Created July 13, 2015, 2:08 p.m.
Right Patch Set: Nit fixes Created July 15, 2015, 2:35 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 | « options.html ('k') | skin/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-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
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 delete document.body.dataset.dialog; 428 delete document.body.dataset.dialog;
429 }, false); 429 }, false);
430 430
431 // Advanced tab 431 // Advanced tab
432 var filterTextbox = document.querySelector("#custom-filters-add input"); 432 var filterTextbox = document.querySelector("#custom-filters-add input");
433 placeholderValue = ext.i18n.getMessage("options_customFilters_textbox_placeh older"); 433 placeholderValue = ext.i18n.getMessage("options_customFilters_textbox_placeh older");
434 filterTextbox.setAttribute("placeholder", placeholderValue); 434 filterTextbox.setAttribute("placeholder", placeholderValue);
435 function addCustomFilters() 435 function addCustomFilters()
436 { 436 {
437 var filterText = filterTextbox.value; 437 var filterText = filterTextbox.value;
438 if (!filterText)
439 return;
440
441 ext.backgroundPage.sendMessage( 438 ext.backgroundPage.sendMessage(
442 { 439 {
443 type: "filters.parse", 440 type: "filters.add",
444 text: filterText 441 text: filterText
445 }); 442 });
446 filterTextbox.value = ""; 443 filterTextbox.value = "";
447 } 444 }
448 E("custom-filters-add").addEventListener("submit", function(e) 445 E("custom-filters-add").addEventListener("submit", function(e)
449 { 446 {
450 e.preventDefault(); 447 e.preventDefault();
451 addCustomFilters(); 448 addCustomFilters();
452 }, false); 449 }, false);
453 var customFilterEditButtons = document.querySelectorAll("#custom-filters-edi t-wrapper button"); 450 var customFilterEditButtons = document.querySelectorAll("#custom-filters-edi t-wrapper button");
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 switch (message.type) 698 switch (message.type)
702 { 699 {
703 case "app.listen": 700 case "app.listen":
704 if (message.action == "addSubscription") 701 if (message.action == "addSubscription")
705 { 702 {
706 E("blockingList-textbox").value = message.args[0].url; 703 E("blockingList-textbox").value = message.args[0].url;
707 openDialog("customlist"); 704 openDialog("customlist");
708 } 705 }
709 else if (message.action == "error") 706 else if (message.action == "error")
710 { 707 {
711 var error = message.args[0]; 708 alert(message.args.join("\n"));
712 //TODO handle error message
Thomas Greiner 2015/07/13 15:54:23 We're not going to have a dedicated UI element for
713 } 709 }
714 break; 710 break;
715 case "filters.listen": 711 case "filters.listen":
716 onFilterMessage(message.action, message.args[0]); 712 onFilterMessage(message.action, message.args[0]);
717 break; 713 break;
718 case "subscriptions.listen": 714 case "subscriptions.listen":
719 onSubscriptionMessage(message.action, message.args[0]); 715 onSubscriptionMessage(message.action, message.args[0]);
720 break; 716 break;
721 } 717 }
722 }); 718 });
723 719
724 ext.backgroundPage.sendMessage( 720 ext.backgroundPage.sendMessage(
725 { 721 {
726 type: "app.listen", 722 type: "app.listen",
727 filter: ["addSubscription"] 723 filter: ["addSubscription", "error"]
Thomas Greiner 2015/07/13 15:54:23 The "error" action also needs to be added here to
saroyanm 2015/07/14 10:20:59 I wander, shouldn't it only fire after it's regist
Thomas Greiner 2015/07/14 10:58:52 Exactly, that's why I asked you to make the change
saroyanm 2015/07/14 11:19:25 I think this question was remaining before We figu
728 }); 724 });
729 ext.backgroundPage.sendMessage( 725 ext.backgroundPage.sendMessage(
730 { 726 {
731 type: "filters.listen", 727 type: "filters.listen",
732 filter: ["added", "loaded", "removed"] 728 filter: ["added", "loaded", "removed"]
733 }); 729 });
734 ext.backgroundPage.sendMessage( 730 ext.backgroundPage.sendMessage(
735 { 731 {
736 type: "subscriptions.listen", 732 type: "subscriptions.listen",
737 filter: ["added", "disabled", "homepage", "removed", "title"] 733 filter: ["added", "disabled", "homepage", "removed", "title"]
738 }); 734 });
739 735
740 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); 736 window.addEventListener("DOMContentLoaded", onDOMLoaded, false);
741 })(); 737 })();
LEFTRIGHT

Powered by Google App Engine
This is Rietveld