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 /** |
| 45 * Subscriptions to which this filter belongs. |
| 46 * @type {Set.<Subscription>} |
| 47 * @private |
| 48 */ |
| 49 this._subscriptions = new Set(); |
44 } | 50 } |
45 exports.Filter = Filter; | 51 exports.Filter = Filter; |
46 | 52 |
47 Filter.prototype = | 53 Filter.prototype = |
48 { | 54 { |
49 /** | 55 /** |
50 * String representation of the filter | 56 * String representation of the filter |
51 * @type {string} | 57 * @type {string} |
52 */ | 58 */ |
53 text: null, | 59 text: null, |
54 | 60 |
55 /** | 61 /** |
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". | 62 * Filter type as a string, e.g. "blocking". |
63 * @type {string} | 63 * @type {string} |
64 */ | 64 */ |
65 get type() | 65 get type() |
66 { | 66 { |
67 throw new Error("Please define filter type in the subclass"); | 67 throw new Error("Please define filter type in the subclass"); |
68 }, | 68 }, |
69 | 69 |
70 /** | 70 /** |
| 71 * Yields subscriptions to which the filter belongs. |
| 72 * @yields {Subscription} |
| 73 */ |
| 74 *subscriptions() |
| 75 { |
| 76 yield* this._subscriptions; |
| 77 }, |
| 78 |
| 79 /** |
| 80 * Adds a subscription to the set of subscriptions to which the filter |
| 81 * belongs. |
| 82 * @param {Subscription} subscription |
| 83 */ |
| 84 addSubscription(subscription) |
| 85 { |
| 86 this._subscriptions.add(subscription); |
| 87 }, |
| 88 |
| 89 /** |
| 90 * Removes a subscription from the set of subscriptions to which the filter |
| 91 * belongs. |
| 92 * @param {Subscription} subscription |
| 93 */ |
| 94 removeSubscription(subscription) |
| 95 { |
| 96 this._subscriptions.delete(subscription); |
| 97 }, |
| 98 |
| 99 /** |
71 * Serializes the filter to an array of strings for writing out on the disk. | 100 * 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 | 101 * @param {string[]} buffer buffer to push the serialization results into |
73 */ | 102 */ |
74 serialize(buffer) | 103 serialize(buffer) |
75 { | 104 { |
76 buffer.push("[Filter]"); | 105 buffer.push("[Filter]"); |
77 buffer.push("text=" + this.text); | 106 buffer.push("text=" + this.text); |
78 }, | 107 }, |
79 | 108 |
80 toString() | 109 toString() |
(...skipping 1096 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1177 | 1206 |
1178 /** | 1207 /** |
1179 * Script that should be executed | 1208 * Script that should be executed |
1180 * @type {string} | 1209 * @type {string} |
1181 */ | 1210 */ |
1182 get script() | 1211 get script() |
1183 { | 1212 { |
1184 return this.body; | 1213 return this.body; |
1185 } | 1214 } |
1186 }); | 1215 }); |
OLD | NEW |