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: Error handling improvements Created July 14, 2015, 9:55 a.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 alert(message.args[0]); 708 alert(message.args.join("\n"));
712 } 709 }
713 break; 710 break;
714 case "filters.listen": 711 case "filters.listen":
715 onFilterMessage(message.action, message.args[0]); 712 onFilterMessage(message.action, message.args[0]);
716 break; 713 break;
717 case "subscriptions.listen": 714 case "subscriptions.listen":
718 onSubscriptionMessage(message.action, message.args[0]); 715 onSubscriptionMessage(message.action, message.args[0]);
719 break; 716 break;
720 } 717 }
721 }); 718 });
722 719
723 ext.backgroundPage.sendMessage( 720 ext.backgroundPage.sendMessage(
724 { 721 {
725 type: "app.listen", 722 type: "app.listen",
726 filter: ["addSubscription", "error"] 723 filter: ["addSubscription", "error"]
727 }); 724 });
728 ext.backgroundPage.sendMessage( 725 ext.backgroundPage.sendMessage(
729 { 726 {
730 type: "filters.listen", 727 type: "filters.listen",
731 filter: ["added", "loaded", "removed"] 728 filter: ["added", "loaded", "removed"]
732 }); 729 });
733 ext.backgroundPage.sendMessage( 730 ext.backgroundPage.sendMessage(
734 { 731 {
735 type: "subscriptions.listen", 732 type: "subscriptions.listen",
736 filter: ["added", "disabled", "homepage", "removed", "title"] 733 filter: ["added", "disabled", "homepage", "removed", "title"]
737 }); 734 });
738 735
739 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); 736 window.addEventListener("DOMContentLoaded", onDOMLoaded, false);
740 })(); 737 })();
LEFTRIGHT

Powered by Google App Engine
This is Rietveld