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

Delta Between Two Patch Sets: options.js

Issue 4515985834901504: Issue 2664 - Remove ignoreHeaders argument from parseFilter(s) and move the logic to the UI (Closed)
Left Patch Set: Created June 8, 2015, 4:46 p.m.
Right Patch Set: Exclude filter list header errors using .forEach() Created June 8, 2015, 6:36 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 | « lib/filterValidation.js ('k') | qunit/tests/filterValidation.js » ('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 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 document.getElementById("rawFiltersText").value = text; 532 document.getElementById("rawFiltersText").value = text;
533 } 533 }
534 } 534 }
535 535
536 // Imports filters in the raw text box 536 // Imports filters in the raw text box
537 function importRawFiltersText() 537 function importRawFiltersText()
538 { 538 {
539 var text = document.getElementById("rawFiltersText").value; 539 var text = document.getElementById("rawFiltersText").value;
540 var result = parseFilters(text); 540 var result = parseFilters(text);
541 541
542 var errors = []; 542 var errors = result.errors.filter(function(e)
543 for (var i = 0; i < result.errors.length; i++) 543 {
544 { 544 return e.type != "unexpected-filter-list-header";
545 var error = result.errors[i]; 545 });
546 if (error.type != "unexpected-filter-list-header")
547 errors.push(error);
548 }
Wladimir Palant 2015/06/08 18:15:47 Why not: var errors = result.errors.filter(fun
Sebastian Noack 2015/06/08 18:36:46 Done.
549 546
550 if (errors.length > 0) 547 if (errors.length > 0)
551 { 548 {
552 alert(errors.join("\n")); 549 alert(errors.join("\n"));
553 return; 550 return;
554 } 551 }
555 552
556 var seenFilter = Object.create(null); 553 var seenFilter = Object.create(null);
557 for (var i = 0; i < result.filters.length; i++) 554 for (var i = 0; i < result.filters.length; i++)
558 { 555 {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 links[i].href = arguments[i + 1]; 640 links[i].href = arguments[i + 1];
644 links[i].setAttribute("target", "_blank"); 641 links[i].setAttribute("target", "_blank");
645 } 642 }
646 else if (typeof arguments[i + 1] == "function") 643 else if (typeof arguments[i + 1] == "function")
647 { 644 {
648 links[i].href = "javascript:void(0);"; 645 links[i].href = "javascript:void(0);";
649 links[i].addEventListener("click", arguments[i + 1], false); 646 links[i].addEventListener("click", arguments[i + 1], false);
650 } 647 }
651 } 648 }
652 } 649 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld