OLD | NEW |
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-present eyeo GmbH | 3 * Copyright (C) 2006-present 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 22 matching lines...) Expand all Loading... |
33 | 33 |
34 /** | 34 /** |
35 * Abstract base class for filters | 35 * Abstract base class for filters |
36 * | 36 * |
37 * @param {string} text string representation of the filter | 37 * @param {string} text string representation of the filter |
38 * @constructor | 38 * @constructor |
39 */ | 39 */ |
40 function Filter(text) | 40 function Filter(text) |
41 { | 41 { |
42 this.text = text; | 42 this.text = text; |
43 this.subscriptions = new Set(); | 43 |
| 44 this._subscriptions = new Set(); |
44 } | 45 } |
45 exports.Filter = Filter; | 46 exports.Filter = Filter; |
46 | 47 |
47 Filter.prototype = | 48 Filter.prototype = |
48 { | 49 { |
49 /** | 50 /** |
50 * String representation of the filter | 51 * String representation of the filter |
51 * @type {string} | 52 * @type {string} |
52 */ | 53 */ |
53 text: null, | 54 text: null, |
54 | 55 |
55 /** | 56 /** |
56 * Filter subscriptions the filter belongs to | |
57 * @type {Set.<Subscription>} | |
58 */ | |
59 subscriptions: null, | |
60 | |
61 /** | |
62 * Filter type as a string, e.g. "blocking". | 57 * Filter type as a string, e.g. "blocking". |
63 * @type {string} | 58 * @type {string} |
64 */ | 59 */ |
65 get type() | 60 get type() |
66 { | 61 { |
67 throw new Error("Please define filter type in the subclass"); | 62 throw new Error("Please define filter type in the subclass"); |
68 }, | 63 }, |
69 | 64 |
70 /** | 65 /** |
| 66 * Yields filter subscriptions the filter belongs to |
| 67 * @yields {Subscription} |
| 68 */ |
| 69 *subscriptions() |
| 70 { |
| 71 yield* this._subscriptions; |
| 72 }, |
| 73 |
| 74 addSubscription(subscription) |
| 75 { |
| 76 this._subscriptions.add(subscription); |
| 77 }, |
| 78 |
| 79 removeSubscription(subscription) |
| 80 { |
| 81 this._subscriptions.delete(subscription); |
| 82 }, |
| 83 |
| 84 /** |
71 * Serializes the filter to an array of strings for writing out on the disk. | 85 * Serializes the filter to an array of strings for writing out on the disk. |
72 * @param {string[]} buffer buffer to push the serialization results into | 86 * @param {string[]} buffer buffer to push the serialization results into |
73 */ | 87 */ |
74 serialize(buffer) | 88 serialize(buffer) |
75 { | 89 { |
76 buffer.push("[Filter]"); | 90 buffer.push("[Filter]"); |
77 buffer.push("text=" + this.text); | 91 buffer.push("text=" + this.text); |
78 }, | 92 }, |
79 | 93 |
80 toString() | 94 toString() |
(...skipping 1096 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1177 | 1191 |
1178 /** | 1192 /** |
1179 * Script that should be executed | 1193 * Script that should be executed |
1180 * @type {string} | 1194 * @type {string} |
1181 */ | 1195 */ |
1182 get script() | 1196 get script() |
1183 { | 1197 { |
1184 return this.body; | 1198 return this.body; |
1185 } | 1199 } |
1186 }); | 1200 }); |
OLD | NEW |