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: Created June 8, 2015, 4:46 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
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 = [];
543 for (var i = 0; i < result.errors.length; i++)
543 { 544 {
544 alert(result.error); 545 var error = result.errors[i];
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
550 if (errors.length > 0)
551 {
552 alert(errors.join("\n"));
545 return; 553 return;
546 } 554 }
547 555
548 var seenFilter = Object.create(null); 556 var seenFilter = Object.create(null);
549 for (var i = 0; i < result.filters.length; i++) 557 for (var i = 0; i < result.filters.length; i++)
550 { 558 {
551 var filter = result.filters[i]; 559 var filter = result.filters[i];
552 FilterStorage.addFilter(filter); 560 FilterStorage.addFilter(filter);
553 seenFilter[filter.text] = null; 561 seenFilter[filter.text] = null;
554 } 562 }
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 links[i].href = arguments[i + 1]; 643 links[i].href = arguments[i + 1];
636 links[i].setAttribute("target", "_blank"); 644 links[i].setAttribute("target", "_blank");
637 } 645 }
638 else if (typeof arguments[i + 1] == "function") 646 else if (typeof arguments[i + 1] == "function")
639 { 647 {
640 links[i].href = "javascript:void(0);"; 648 links[i].href = "javascript:void(0);";
641 links[i].addEventListener("click", arguments[i + 1], false); 649 links[i].addEventListener("click", arguments[i + 1], false);
642 } 650 }
643 } 651 }
644 } 652 }
OLDNEW

Powered by Google App Engine
This is Rietveld