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 * The number of subscriptions to which the filter belongs. |
| 81 * @type {number} |
| 82 */ |
| 83 get subscriptionCount() |
| 84 { |
| 85 return this._subscriptions.size; |
| 86 }, |
| 87 |
| 88 /** |
| 89 * Adds a subscription to the set of subscriptions to which the filter |
| 90 * belongs. |
| 91 * @param {Subscription} subscription |
| 92 */ |
| 93 addSubscription(subscription) |
| 94 { |
| 95 this._subscriptions.add(subscription); |
| 96 }, |
| 97 |
| 98 /** |
| 99 * Removes a subscription from the set of subscriptions to which the filter |
| 100 * belongs. |
| 101 * @param {Subscription} subscription |
| 102 */ |
| 103 removeSubscription(subscription) |
| 104 { |
| 105 this._subscriptions.delete(subscription); |
| 106 }, |
| 107 |
| 108 /** |
71 * Serializes the filter to an array of strings for writing out on the disk. | 109 * 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 | 110 * @param {string[]} buffer buffer to push the serialization results into |
73 */ | 111 */ |
74 serialize(buffer) | 112 serialize(buffer) |
75 { | 113 { |
76 buffer.push("[Filter]"); | 114 buffer.push("[Filter]"); |
77 buffer.push("text=" + this.text); | 115 buffer.push("text=" + this.text); |
78 }, | 116 }, |
79 | 117 |
80 toString() | 118 toString() |
(...skipping 1096 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1177 | 1215 |
1178 /** | 1216 /** |
1179 * Script that should be executed | 1217 * Script that should be executed |
1180 * @type {string} | 1218 * @type {string} |
1181 */ | 1219 */ |
1182 get script() | 1220 get script() |
1183 { | 1221 { |
1184 return this.body; | 1222 return this.body; |
1185 } | 1223 } |
1186 }); | 1224 }); |
OLD | NEW |