 Issue 5279235799252992:
  Issue 491 - Validate custom filters  (Closed)
    
  
    Issue 5279235799252992:
  Issue 491 - Validate custom filters  (Closed) 
  | Left: | ||
| Right: | 
| OLD | NEW | 
|---|---|
| 1 /* | 1 /* | 
| 2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 
| 3 * Copyright (C) 2006-2014 Eyeo GmbH | 3 * Copyright (C) 2006-2014 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 61 addFilters(); | 61 addFilters(); | 
| 62 } | 62 } | 
| 63 } | 63 } | 
| 64 | 64 | 
| 65 function addFilters() | 65 function addFilters() | 
| 66 { | 66 { | 
| 67 // Tell the background page to add the filters | 67 // Tell the background page to add the filters | 
| 68 var filters = document.getElementById("filters").value.split(/[\r\n]+/) | 68 var filters = document.getElementById("filters").value.split(/[\r\n]+/) | 
| 69 .map(function(f) {return f.replace(/^\s+/, "").replace(/ \s+$/, "");}) | 69 .map(function(f) {return f.replace(/^\s+/, "").replace(/ \s+$/, "");}) | 
| 70 .filter(function(f) {return f != "";}); | 70 .filter(function(f) {return f != "";}); | 
| 71 ext.backgroundPage.sendMessage({type: "add-filters", filters: filters}); | 71 | 
| 72 closeDialog(true); | 72 ext.backgroundPage.sendMessage( | 
| 73 { | |
| 74 type: "add-filters", | |
| 75 filters: filters | |
| 76 }, | |
| 77 | |
| 78 function(response) | |
| 79 { | |
| 80 if (response.status == "ok") | |
| 81 closeDialog(true); | |
| 82 else | |
| 83 alert(response.error); | |
| 
Wladimir Palant
2014/11/18 16:35:03
I don't think this message is helpful without indi
 
Sebastian Noack
2014/11/18 17:42:55
I decided to keep things as simple as possible for
 | |
| 84 } | |
| 85 ); | |
| 73 } | 86 } | 
| 74 | 87 | 
| 75 function closeDialog(success) | 88 function closeDialog(success) | 
| 76 { | 89 { | 
| 77 ext.backgroundPage.sendMessage( | 90 ext.backgroundPage.sendMessage( | 
| 78 { | 91 { | 
| 79 type: "forward", | 92 type: "forward", | 
| 80 payload: | 93 payload: | 
| 81 { | 94 { | 
| 82 type: "clickhide-close", | 95 type: "clickhide-close", | 
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 116 ); | 129 ); | 
| 117 dragCoords = [event.screenX, event.screenY]; | 130 dragCoords = [event.screenX, event.screenY]; | 
| 118 } | 131 } | 
| 119 } | 132 } | 
| 120 | 133 | 
| 121 function onDragEnd(event) | 134 function onDragEnd(event) | 
| 122 { | 135 { | 
| 123 onDrag(event); | 136 onDrag(event); | 
| 124 dragCoords = null; | 137 dragCoords = null; | 
| 125 } | 138 } | 
| OLD | NEW |