| 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 |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
| 13 * | 13 * |
| 14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
| 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
| 16 */ | 16 */ |
| 17 | 17 |
| 18 "use strict"; | 18 "use strict"; |
| 19 | 19 |
| 20 /** | 20 /** |
| 21 * @fileOverview Definition of Subscription class and its subclasses. | 21 * @fileOverview Definition of Subscription class and its subclasses. |
| 22 */ | 22 */ |
| 23 | 23 |
| 24 const {ActiveFilter, BlockingFilter, | 24 import {ActiveFilter, BlockingFilter, |
| 25 WhitelistFilter, ElemHideBase} = require("./filterClasses"); | 25 WhitelistFilter, ElemHideBase} from "./filterClasses"; |
| 26 const {FilterNotifier} = require("./filterNotifier"); | 26 import {FilterNotifier} from "./filterNotifier"; |
| 27 const {desc, extend} = require("./coreUtils"); | 27 import {desc, extend} from "./coreUtils"; |
| 28 | 28 |
| 29 /** | 29 /** |
| 30 * Abstract base class for filter subscriptions | 30 * Abstract base class for filter subscriptions |
| 31 * | 31 * |
| 32 * @param {string} url download location of the subscription | 32 * @param {string} url download location of the subscription |
| 33 * @param {string} [title] title of the filter subscription | 33 * @param {string} [title] title of the filter subscription |
| 34 * @constructor | 34 * @constructor |
| 35 */ | 35 */ |
| 36 function Subscription(url, title) | 36 export function Subscription(url, title) |
| 37 { | 37 { |
| 38 this.url = url; | 38 this.url = url; |
| 39 this.filters = []; | 39 this.filters = []; |
| 40 if (title) | 40 if (title) |
| 41 this._title = title; | 41 this._title = title; |
| 42 Subscription.knownSubscriptions[url] = this; | 42 Subscription.knownSubscriptions[url] = this; |
| 43 } | 43 } |
| 44 exports.Subscription = Subscription; | |
| 45 | 44 |
| 46 Subscription.prototype = | 45 Subscription.prototype = |
| 47 { | 46 { |
| 48 /** | 47 /** |
| 49 * Download location of the subscription | 48 * Download location of the subscription |
| 50 * @type {string} | 49 * @type {string} |
| 51 */ | 50 */ |
| 52 url: null, | 51 url: null, |
| 53 | 52 |
| 54 /** | 53 /** |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 return result; | 226 return result; |
| 228 }; | 227 }; |
| 229 | 228 |
| 230 /** | 229 /** |
| 231 * Class for special filter subscriptions (user's filters) | 230 * Class for special filter subscriptions (user's filters) |
| 232 * @param {string} url see Subscription() | 231 * @param {string} url see Subscription() |
| 233 * @param {string} [title] see Subscription() | 232 * @param {string} [title] see Subscription() |
| 234 * @constructor | 233 * @constructor |
| 235 * @augments Subscription | 234 * @augments Subscription |
| 236 */ | 235 */ |
| 237 function SpecialSubscription(url, title) | 236 export function SpecialSubscription(url, title) |
| 238 { | 237 { |
| 239 Subscription.call(this, url, title); | 238 Subscription.call(this, url, title); |
| 240 } | 239 } |
| 241 exports.SpecialSubscription = SpecialSubscription; | |
| 242 | 240 |
| 243 SpecialSubscription.prototype = extend(Subscription, { | 241 SpecialSubscription.prototype = extend(Subscription, { |
| 244 /** | 242 /** |
| 245 * Filter types that should be added to this subscription by default | 243 * Filter types that should be added to this subscription by default |
| 246 * (entries should correspond to keys in SpecialSubscription.defaultsMap). | 244 * (entries should correspond to keys in SpecialSubscription.defaultsMap). |
| 247 * @type {string[]} | 245 * @type {string[]} |
| 248 */ | 246 */ |
| 249 defaults: null, | 247 defaults: null, |
| 250 | 248 |
| 251 /** | 249 /** |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 }; | 329 }; |
| 332 | 330 |
| 333 /** | 331 /** |
| 334 * Abstract base class for regular filter subscriptions (both | 332 * Abstract base class for regular filter subscriptions (both |
| 335 * internally and externally updated) | 333 * internally and externally updated) |
| 336 * @param {string} url see Subscription() | 334 * @param {string} url see Subscription() |
| 337 * @param {string} [title] see Subscription() | 335 * @param {string} [title] see Subscription() |
| 338 * @constructor | 336 * @constructor |
| 339 * @augments Subscription | 337 * @augments Subscription |
| 340 */ | 338 */ |
| 341 function RegularSubscription(url, title) | 339 export function RegularSubscription(url, title) |
| 342 { | 340 { |
| 343 Subscription.call(this, url, title || url); | 341 Subscription.call(this, url, title || url); |
| 344 } | 342 } |
| 345 exports.RegularSubscription = RegularSubscription; | |
| 346 | 343 |
| 347 RegularSubscription.prototype = extend(Subscription, { | 344 RegularSubscription.prototype = extend(Subscription, { |
| 348 _homepage: null, | 345 _homepage: null, |
| 349 _lastDownload: 0, | 346 _lastDownload: 0, |
| 350 | 347 |
| 351 /** | 348 /** |
| 352 * Filter subscription homepage if known | 349 * Filter subscription homepage if known |
| 353 * @type {string} | 350 * @type {string} |
| 354 */ | 351 */ |
| 355 get homepage() | 352 get homepage() |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 } | 400 } |
| 404 }); | 401 }); |
| 405 | 402 |
| 406 /** | 403 /** |
| 407 * Class for filter subscriptions updated externally (by other extension) | 404 * Class for filter subscriptions updated externally (by other extension) |
| 408 * @param {string} url see Subscription() | 405 * @param {string} url see Subscription() |
| 409 * @param {string} [title] see Subscription() | 406 * @param {string} [title] see Subscription() |
| 410 * @constructor | 407 * @constructor |
| 411 * @augments RegularSubscription | 408 * @augments RegularSubscription |
| 412 */ | 409 */ |
| 413 function ExternalSubscription(url, title) | 410 export function ExternalSubscription(url, title) |
| 414 { | 411 { |
| 415 RegularSubscription.call(this, url, title); | 412 RegularSubscription.call(this, url, title); |
| 416 } | 413 } |
| 417 exports.ExternalSubscription = ExternalSubscription; | |
| 418 | 414 |
| 419 ExternalSubscription.prototype = extend(RegularSubscription, { | 415 ExternalSubscription.prototype = extend(RegularSubscription, { |
| 420 /** | 416 /** |
| 421 * See Subscription.serialize() | 417 * See Subscription.serialize() |
| 422 * @inheritdoc | 418 * @inheritdoc |
| 423 */ | 419 */ |
| 424 serialize(buffer) | 420 serialize(buffer) |
| 425 { | 421 { |
| 426 throw new Error( | 422 throw new Error( |
| 427 "Unexpected call, external subscriptions should not be serialized" | 423 "Unexpected call, external subscriptions should not be serialized" |
| 428 ); | 424 ); |
| 429 } | 425 } |
| 430 }); | 426 }); |
| 431 | 427 |
| 432 /** | 428 /** |
| 433 * Class for filter subscriptions updated externally (by other extension) | 429 * Class for filter subscriptions updated externally (by other extension) |
| 434 * @param {string} url see Subscription() | 430 * @param {string} url see Subscription() |
| 435 * @param {string} [title] see Subscription() | 431 * @param {string} [title] see Subscription() |
| 436 * @constructor | 432 * @constructor |
| 437 * @augments RegularSubscription | 433 * @augments RegularSubscription |
| 438 */ | 434 */ |
| 439 function DownloadableSubscription(url, title) | 435 export function DownloadableSubscription(url, title) |
| 440 { | 436 { |
| 441 RegularSubscription.call(this, url, title); | 437 RegularSubscription.call(this, url, title); |
| 442 } | 438 } |
| 443 exports.DownloadableSubscription = DownloadableSubscription; | |
| 444 | 439 |
| 445 DownloadableSubscription.prototype = extend(RegularSubscription, { | 440 DownloadableSubscription.prototype = extend(RegularSubscription, { |
| 446 _downloadStatus: null, | 441 _downloadStatus: null, |
| 447 _lastCheck: 0, | 442 _lastCheck: 0, |
| 448 _errors: 0, | 443 _errors: 0, |
| 449 | 444 |
| 450 /** | 445 /** |
| 451 * Status of the last download (ID of a string) | 446 * Status of the last download (ID of a string) |
| 452 * @type {string} | 447 * @type {string} |
| 453 */ | 448 */ |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 if (this.errors) | 560 if (this.errors) |
| 566 buffer.push("errors=" + this.errors); | 561 buffer.push("errors=" + this.errors); |
| 567 if (this.version) | 562 if (this.version) |
| 568 buffer.push("version=" + this.version); | 563 buffer.push("version=" + this.version); |
| 569 if (this.requiredVersion) | 564 if (this.requiredVersion) |
| 570 buffer.push("requiredVersion=" + this.requiredVersion); | 565 buffer.push("requiredVersion=" + this.requiredVersion); |
| 571 if (this.downloadCount) | 566 if (this.downloadCount) |
| 572 buffer.push("downloadCount=" + this.downloadCount); | 567 buffer.push("downloadCount=" + this.downloadCount); |
| 573 } | 568 } |
| 574 }); | 569 }); |
| OLD | NEW |