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: Rebase Created July 13, 2015, 2 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 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 ext.onMessage.addListener(function(message) 696 ext.onMessage.addListener(function(message)
700 { 697 {
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 }
706 else if (message.action == "error")
707 {
708 alert(message.args.join("\n"));
709 }
709 break; 710 break;
710 case "filters.listen": 711 case "filters.listen":
711 onFilterMessage(message.action, message.args[0]); 712 onFilterMessage(message.action, message.args[0]);
712 break; 713 break;
713 case "subscriptions.listen": 714 case "subscriptions.listen":
714 onSubscriptionMessage(message.action, message.args[0]); 715 onSubscriptionMessage(message.action, message.args[0]);
715 break; 716 break;
716 } 717 }
717 }); 718 });
718 719
719 ext.backgroundPage.sendMessage( 720 ext.backgroundPage.sendMessage(
720 { 721 {
721 type: "app.listen", 722 type: "app.listen",
722 filter: ["addSubscription"] 723 filter: ["addSubscription", "error"]
723 }); 724 });
724 ext.backgroundPage.sendMessage( 725 ext.backgroundPage.sendMessage(
725 { 726 {
726 type: "filters.listen", 727 type: "filters.listen",
727 filter: ["added", "loaded", "removed"] 728 filter: ["added", "loaded", "removed"]
728 }); 729 });
729 ext.backgroundPage.sendMessage( 730 ext.backgroundPage.sendMessage(
730 { 731 {
731 type: "subscriptions.listen", 732 type: "subscriptions.listen",
732 filter: ["added", "disabled", "homepage", "removed", "title"] 733 filter: ["added", "disabled", "homepage", "removed", "title"]
733 }); 734 });
734 735
735 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); 736 window.addEventListener("DOMContentLoaded", onDOMLoaded, false);
736 })(); 737 })();
LEFTRIGHT

Powered by Google App Engine
This is Rietveld