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

Delta Between Two Patch Sets: desktop-options.js

Issue 29674584: Issue 5549 - Implement missing error handlings for custom filter lists (Closed)
Left Patch Set: applied changes Created Feb. 2, 2018, 5:20 p.m.
Right Patch Set: changed custom-filters-edit-area to custom-filters-control as suggested Created Feb. 5, 2018, 9:05 a.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') | locale/en_US/desktop-options.json » ('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 643 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 const filters = E("custom-filters-raw").value; 654 const filters = E("custom-filters-raw").value;
655 sendMessageHandleErrors({ 655 sendMessageHandleErrors({
656 type: "filters.importRaw", 656 type: "filters.importRaw",
657 text: filters, 657 text: filters,
658 removeExisting: true 658 removeExisting: true
659 }, 659 },
660 (errors) => 660 (errors) =>
661 { 661 {
662 if (errors) 662 if (errors)
663 { 663 {
664 E("custom-filters").classList.add("warning");
664 const customFiltersError = clearAndGetCustomFiltersError(); 665 const customFiltersError = clearAndGetCustomFiltersError();
665 E("custom-filters").classList.add("warning");
666 666
667 // The current error does not contain info about the line 667 // The current error does not contain info about the line
668 // that generated such error. 668 // that generated such error.
669 // Whenever the error object will pass the bad filter 669 // Whenever the error object will pass the bad filter
670 // within its properties, this split should be removed. 670 // within its properties, this split should be removed.
671 const lines = filters.split("\n"); 671 const lines = filters.split("\n");
672 const messages = errors.map(error => lines[error.lineno - 1]); 672 const messages = errors.map(error => lines[error.lineno - 1]);
673 for (const message of messages) 673 for (const message of messages)
674 { 674 {
675 const li = document.createElement("li"); 675 const li = document.createElement("li");
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 else 770 else
771 { 771 {
772 form.querySelector(":invalid").focus(); 772 form.querySelector(":invalid").focus();
773 } 773 }
774 break; 774 break;
775 } 775 }
776 } 776 }
777 777
778 function clearAndGetCustomFiltersError() 778 function clearAndGetCustomFiltersError()
779 { 779 {
780 E("custom-filters").classList.remove("warning");
781 const customFiltersError = E("custom-filters-error"); 780 const customFiltersError = E("custom-filters-error");
782 customFiltersError.textContent = ""; 781 customFiltersError.textContent = "";
783 customFiltersError.classList.remove("many"); 782 customFiltersError.classList.remove("many");
784 return customFiltersError; 783 return customFiltersError;
785 } 784 }
786 785
787 function setCustomFiltersView(mode) 786 function setCustomFiltersView(mode)
788 { 787 {
789 let customFiltersElement = E("custom-filters-raw"); 788 let customFiltersElement = E("custom-filters-raw");
790 updateCustomFiltersUi(); 789 updateCustomFiltersUi();
791 if (mode == "read") 790 if (mode == "read")
792 { 791 {
792 E("custom-filters").classList.remove("warning");
793 clearAndGetCustomFiltersError(); 793 clearAndGetCustomFiltersError();
794 customFiltersElement.disabled = true; 794 customFiltersElement.disabled = true;
795 if (!customFiltersElement.value) 795 if (!customFiltersElement.value)
796 { 796 {
797 setCustomFiltersView("empty"); 797 setCustomFiltersView("empty");
798 return; 798 return;
799 } 799 }
800 } 800 }
801 else if (mode == "write") 801 else if (mode == "write")
802 { 802 {
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after
1502 }); 1502 });
1503 browser.runtime.sendMessage({ 1503 browser.runtime.sendMessage({
1504 type: "subscriptions.listen", 1504 type: "subscriptions.listen",
1505 filter: ["added", "disabled", "homepage", "lastDownload", "removed", 1505 filter: ["added", "disabled", "homepage", "lastDownload", "removed",
1506 "title", "downloadStatus", "downloading"] 1506 "title", "downloadStatus", "downloading"]
1507 }); 1507 });
1508 1508
1509 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); 1509 window.addEventListener("DOMContentLoaded", onDOMLoaded, false);
1510 window.addEventListener("hashchange", onHashChange, false); 1510 window.addEventListener("hashchange", onHashChange, false);
1511 } 1511 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld