Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
57 } | 57 } |
58 else if (event.keyCode == 13 && !event.shiftKey && !event.ctrlKey) | 58 else if (event.keyCode == 13 && !event.shiftKey && !event.ctrlKey) |
59 { | 59 { |
60 event.preventDefault(); | 60 event.preventDefault(); |
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 | |
68 var filters = document.getElementById("filters").value.split(/[\r\n]+/) | |
69 .map(function(f) {return f.replace(/^\s+/, "").replace(/ \s+$/, "");}) | |
70 .filter(function(f) {return f != "";}); | |
71 | |
72 ext.backgroundPage.sendMessage( | 67 ext.backgroundPage.sendMessage( |
73 { | 68 { |
74 type: "add-filters", | 69 type: "add-filters", |
75 filters: filters | 70 text: document.getElementById("filters").value |
76 }, | 71 }, |
77 | 72 |
78 function(response) | 73 function(response) |
79 { | 74 { |
80 if (response.status == "ok") | 75 if (response.status == "ok") |
81 closeDialog(true); | 76 closeDialog(true); |
82 else | 77 else |
83 alert(response.error); | 78 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 } | 79 } |
85 ); | 80 ); |
86 } | 81 } |
87 | 82 |
88 function closeDialog(success) | 83 function closeDialog(success) |
89 { | 84 { |
90 ext.backgroundPage.sendMessage( | 85 ext.backgroundPage.sendMessage( |
91 { | 86 { |
92 type: "forward", | 87 type: "forward", |
93 payload: | 88 payload: |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
129 ); | 124 ); |
130 dragCoords = [event.screenX, event.screenY]; | 125 dragCoords = [event.screenX, event.screenY]; |
131 } | 126 } |
132 } | 127 } |
133 | 128 |
134 function onDragEnd(event) | 129 function onDragEnd(event) |
135 { | 130 { |
136 onDrag(event); | 131 onDrag(event); |
137 dragCoords = null; | 132 dragCoords = null; |
138 } | 133 } |
LEFT | RIGHT |