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

Side by Side Diff: options.js

Issue 4515985834901504: Issue 2664 - Remove ignoreHeaders argument from parseFilter(s) and move the logic to the UI (Closed)
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:
View unified diff | Download patch
« no previous file with comments | « lib/filterValidation.js ('k') | qunit/tests/filterValidation.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 for (var i = 0; i < userFiltersBox.length; i++) 530 for (var i = 0; i < userFiltersBox.length; i++)
531 text += userFiltersBox.options[i].value + "\n"; 531 text += userFiltersBox.options[i].value + "\n";
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, true); 540 var result = parseFilters(text);
541 541
542 if (result.error) 542 var errors = result.errors.filter(function(e)
543 { 543 {
544 alert(result.error); 544 return e.type != "unexpected-filter-list-header";
545 });
546
547 if (errors.length > 0)
548 {
549 alert(errors.join("\n"));
545 return; 550 return;
546 } 551 }
547 552
548 var seenFilter = Object.create(null); 553 var seenFilter = Object.create(null);
549 for (var i = 0; i < result.filters.length; i++) 554 for (var i = 0; i < result.filters.length; i++)
550 { 555 {
551 var filter = result.filters[i]; 556 var filter = result.filters[i];
552 FilterStorage.addFilter(filter); 557 FilterStorage.addFilter(filter);
553 seenFilter[filter.text] = null; 558 seenFilter[filter.text] = null;
554 } 559 }
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 links[i].href = arguments[i + 1]; 640 links[i].href = arguments[i + 1];
636 links[i].setAttribute("target", "_blank"); 641 links[i].setAttribute("target", "_blank");
637 } 642 }
638 else if (typeof arguments[i + 1] == "function") 643 else if (typeof arguments[i + 1] == "function")
639 { 644 {
640 links[i].href = "javascript:void(0);"; 645 links[i].href = "javascript:void(0);";
641 links[i].addEventListener("click", arguments[i + 1], false); 646 links[i].addEventListener("click", arguments[i + 1], false);
642 } 647 }
643 } 648 }
644 } 649 }
OLDNEW
« no previous file with comments | « lib/filterValidation.js ('k') | qunit/tests/filterValidation.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld