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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 /** | 64 /** |
65 * Title of the filter subscription | 65 * Title of the filter subscription |
66 * @type {string} | 66 * @type {string} |
67 */ | 67 */ |
68 get title() | 68 get title() |
69 { | 69 { |
70 return this._title; | 70 return this._title; |
71 }, | 71 }, |
72 set title(value) | 72 set title(value) |
73 { | 73 { |
74 if (value != this._title) | 74 if (value !== this._title) |
75 { | 75 { |
76 let oldValue = this._title; | 76 let oldValue = this._title; |
77 this._title = value; | 77 this._title = value; |
78 FilterNotifier.triggerListeners("subscription.title", | 78 FilterNotifier.triggerListeners("subscription.title", |
79 this, value, oldValue); | 79 this, value, oldValue); |
80 } | 80 } |
81 return this._title; | 81 return this._title; |
82 }, | 82 }, |
83 | 83 |
84 /** | 84 /** |
85 * Determines whether the title should be editable | 85 * Determines whether the title should be editable |
86 * @type {boolean} | 86 * @type {boolean} |
87 */ | 87 */ |
88 get fixedTitle() | 88 get fixedTitle() |
89 { | 89 { |
90 return this._fixedTitle; | 90 return this._fixedTitle; |
91 }, | 91 }, |
92 set fixedTitle(value) | 92 set fixedTitle(value) |
93 { | 93 { |
94 if (value != this._fixedTitle) | 94 if (value !== this._fixedTitle) |
95 { | 95 { |
96 let oldValue = this._fixedTitle; | 96 let oldValue = this._fixedTitle; |
97 this._fixedTitle = value; | 97 this._fixedTitle = value; |
98 FilterNotifier.triggerListeners("subscription.fixedTitle", | 98 FilterNotifier.triggerListeners("subscription.fixedTitle", |
99 this, value, oldValue); | 99 this, value, oldValue); |
100 } | 100 } |
101 return this._fixedTitle; | 101 return this._fixedTitle; |
102 }, | 102 }, |
103 | 103 |
104 /** | 104 /** |
105 * Defines whether the filters in the subscription should be disabled | 105 * Defines whether the filters in the subscription should be disabled |
106 * @type {boolean} | 106 * @type {boolean} |
107 */ | 107 */ |
108 get disabled() | 108 get disabled() |
109 { | 109 { |
110 return this._disabled; | 110 return this._disabled; |
111 }, | 111 }, |
112 set disabled(value) | 112 set disabled(value) |
113 { | 113 { |
114 if (value != this._disabled) | 114 if (value !== this._disabled) |
115 { | 115 { |
116 let oldValue = this._disabled; | 116 let oldValue = this._disabled; |
117 this._disabled = value; | 117 this._disabled = value; |
118 FilterNotifier.triggerListeners("subscription.disabled", | 118 FilterNotifier.triggerListeners("subscription.disabled", |
119 this, value, oldValue); | 119 this, value, oldValue); |
120 } | 120 } |
121 return this._disabled; | 121 return this._disabled; |
122 }, | 122 }, |
123 | 123 |
124 /** | 124 /** |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 * URL of the subscription | 164 * URL of the subscription |
165 * @return {Subscription} | 165 * @return {Subscription} |
166 * subscription or null if the subscription couldn't be created | 166 * subscription or null if the subscription couldn't be created |
167 */ | 167 */ |
168 Subscription.fromURL = function(url) | 168 Subscription.fromURL = function(url) |
169 { | 169 { |
170 let subscription = Subscription.knownSubscriptions.get(url); | 170 let subscription = Subscription.knownSubscriptions.get(url); |
171 if (subscription) | 171 if (subscription) |
172 return subscription; | 172 return subscription; |
173 | 173 |
174 if (url[0] != "~") | 174 if (url[0] !== "~") |
175 return new DownloadableSubscription(url, null); | 175 return new DownloadableSubscription(url, null); |
176 return new SpecialSubscription(url); | 176 return new SpecialSubscription(url); |
177 }; | 177 }; |
178 | 178 |
179 /** | 179 /** |
180 * Deserializes a subscription | 180 * Deserializes a subscription |
181 * | 181 * |
182 * @param {Object} obj | 182 * @param {Object} obj |
183 * map of serialized properties and their values | 183 * map of serialized properties and their values |
184 * @return {Subscription} | 184 * @return {Subscription} |
185 * subscription or null if the subscription couldn't be created | 185 * subscription or null if the subscription couldn't be created |
186 */ | 186 */ |
187 Subscription.fromObject = function(obj) | 187 Subscription.fromObject = function(obj) |
188 { | 188 { |
189 let result; | 189 let result; |
190 if (obj.url[0] != "~") | 190 if (obj.url[0] !== "~") |
191 { | 191 { |
192 // URL is valid - this is a downloadable subscription | 192 // URL is valid - this is a downloadable subscription |
193 result = new DownloadableSubscription(obj.url, obj.title); | 193 result = new DownloadableSubscription(obj.url, obj.title); |
194 if ("downloadStatus" in obj) | 194 if ("downloadStatus" in obj) |
195 result._downloadStatus = obj.downloadStatus; | 195 result._downloadStatus = obj.downloadStatus; |
196 if ("lastSuccess" in obj) | 196 if ("lastSuccess" in obj) |
197 result.lastSuccess = parseInt(obj.lastSuccess, 10) || 0; | 197 result.lastSuccess = parseInt(obj.lastSuccess, 10) || 0; |
198 if ("lastCheck" in obj) | 198 if ("lastCheck" in obj) |
199 result._lastCheck = parseInt(obj.lastCheck, 10) || 0; | 199 result._lastCheck = parseInt(obj.lastCheck, 10) || 0; |
200 if ("expires" in obj) | 200 if ("expires" in obj) |
(...skipping 13 matching lines...) Expand all Loading... |
214 if ("downloadCount" in obj) | 214 if ("downloadCount" in obj) |
215 result.downloadCount = parseInt(obj.downloadCount, 10) || 0; | 215 result.downloadCount = parseInt(obj.downloadCount, 10) || 0; |
216 } | 216 } |
217 else | 217 else |
218 { | 218 { |
219 result = new SpecialSubscription(obj.url, obj.title); | 219 result = new SpecialSubscription(obj.url, obj.title); |
220 if ("defaults" in obj) | 220 if ("defaults" in obj) |
221 result.defaults = obj.defaults.split(" "); | 221 result.defaults = obj.defaults.split(" "); |
222 } | 222 } |
223 if ("fixedTitle" in obj) | 223 if ("fixedTitle" in obj) |
224 result._fixedTitle = (obj.fixedTitle == "true"); | 224 result._fixedTitle = (obj.fixedTitle === "true"); |
225 if ("disabled" in obj) | 225 if ("disabled" in obj) |
226 result._disabled = (obj.disabled == "true"); | 226 result._disabled = (obj.disabled === "true"); |
227 | 227 |
228 return result; | 228 return result; |
229 }; | 229 }; |
230 | 230 |
231 /** | 231 /** |
232 * Class for special filter subscriptions (user's filters) | 232 * Class for special filter subscriptions (user's filters) |
233 * @param {string} url see {@link Subscription Subscription()} | 233 * @param {string} url see {@link Subscription Subscription()} |
234 * @param {string} [title] see {@link Subscription Subscription()} | 234 * @param {string} [title] see {@link Subscription Subscription()} |
235 * @constructor | 235 * @constructor |
236 * @augments Subscription | 236 * @augments Subscription |
(...skipping 18 matching lines...) Expand all Loading... |
255 * @return {boolean} | 255 * @return {boolean} |
256 */ | 256 */ |
257 isDefaultFor(filter) | 257 isDefaultFor(filter) |
258 { | 258 { |
259 if (this.defaults && this.defaults.length) | 259 if (this.defaults && this.defaults.length) |
260 { | 260 { |
261 for (let type of this.defaults) | 261 for (let type of this.defaults) |
262 { | 262 { |
263 if (filter instanceof SpecialSubscription.defaultsMap.get(type)) | 263 if (filter instanceof SpecialSubscription.defaultsMap.get(type)) |
264 return true; | 264 return true; |
265 if (!(filter instanceof ActiveFilter) && type == "blacklist") | 265 if (!(filter instanceof ActiveFilter) && type === "blacklist") |
266 return true; | 266 return true; |
267 } | 267 } |
268 } | 268 } |
269 | 269 |
270 return false; | 270 return false; |
271 }, | 271 }, |
272 | 272 |
273 /** | 273 /** |
274 * See Subscription.serialize() | 274 * See Subscription.serialize() |
275 * @inheritdoc | 275 * @inheritdoc |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 /** | 352 /** |
353 * Filter subscription homepage if known | 353 * Filter subscription homepage if known |
354 * @type {string} | 354 * @type {string} |
355 */ | 355 */ |
356 get homepage() | 356 get homepage() |
357 { | 357 { |
358 return this._homepage; | 358 return this._homepage; |
359 }, | 359 }, |
360 set homepage(value) | 360 set homepage(value) |
361 { | 361 { |
362 if (value != this._homepage) | 362 if (value !== this._homepage) |
363 { | 363 { |
364 let oldValue = this._homepage; | 364 let oldValue = this._homepage; |
365 this._homepage = value; | 365 this._homepage = value; |
366 FilterNotifier.triggerListeners("subscription.homepage", | 366 FilterNotifier.triggerListeners("subscription.homepage", |
367 this, value, oldValue); | 367 this, value, oldValue); |
368 } | 368 } |
369 return this._homepage; | 369 return this._homepage; |
370 }, | 370 }, |
371 | 371 |
372 /** | 372 /** |
373 * Time of the last subscription download (in seconds since the | 373 * Time of the last subscription download (in seconds since the |
374 * beginning of the epoch) | 374 * beginning of the epoch) |
375 * @type {number} | 375 * @type {number} |
376 */ | 376 */ |
377 get lastDownload() | 377 get lastDownload() |
378 { | 378 { |
379 return this._lastDownload; | 379 return this._lastDownload; |
380 }, | 380 }, |
381 set lastDownload(value) | 381 set lastDownload(value) |
382 { | 382 { |
383 if (value != this._lastDownload) | 383 if (value !== this._lastDownload) |
384 { | 384 { |
385 let oldValue = this._lastDownload; | 385 let oldValue = this._lastDownload; |
386 this._lastDownload = value; | 386 this._lastDownload = value; |
387 FilterNotifier.triggerListeners("subscription.lastDownload", | 387 FilterNotifier.triggerListeners("subscription.lastDownload", |
388 this, value, oldValue); | 388 this, value, oldValue); |
389 } | 389 } |
390 return this._lastDownload; | 390 return this._lastDownload; |
391 }, | 391 }, |
392 | 392 |
393 /** | 393 /** |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 * to increase softExpiration if the user doesn't use Adblock Plus | 477 * to increase softExpiration if the user doesn't use Adblock Plus |
478 * for some time. | 478 * for some time. |
479 * @type {number} | 479 * @type {number} |
480 */ | 480 */ |
481 get lastCheck() | 481 get lastCheck() |
482 { | 482 { |
483 return this._lastCheck; | 483 return this._lastCheck; |
484 }, | 484 }, |
485 set lastCheck(value) | 485 set lastCheck(value) |
486 { | 486 { |
487 if (value != this._lastCheck) | 487 if (value !== this._lastCheck) |
488 { | 488 { |
489 let oldValue = this._lastCheck; | 489 let oldValue = this._lastCheck; |
490 this._lastCheck = value; | 490 this._lastCheck = value; |
491 FilterNotifier.triggerListeners("subscription.lastCheck", | 491 FilterNotifier.triggerListeners("subscription.lastCheck", |
492 this, value, oldValue); | 492 this, value, oldValue); |
493 } | 493 } |
494 return this._lastCheck; | 494 return this._lastCheck; |
495 }, | 495 }, |
496 | 496 |
497 /** | 497 /** |
(...skipping 13 matching lines...) Expand all Loading... |
511 /** | 511 /** |
512 * Number of download failures since last success | 512 * Number of download failures since last success |
513 * @type {number} | 513 * @type {number} |
514 */ | 514 */ |
515 get errors() | 515 get errors() |
516 { | 516 { |
517 return this._errors; | 517 return this._errors; |
518 }, | 518 }, |
519 set errors(value) | 519 set errors(value) |
520 { | 520 { |
521 if (value != this._errors) | 521 if (value !== this._errors) |
522 { | 522 { |
523 let oldValue = this._errors; | 523 let oldValue = this._errors; |
524 this._errors = value; | 524 this._errors = value; |
525 FilterNotifier.triggerListeners("subscription.errors", this, | 525 FilterNotifier.triggerListeners("subscription.errors", this, |
526 value, oldValue); | 526 value, oldValue); |
527 } | 527 } |
528 return this._errors; | 528 return this._errors; |
529 }, | 529 }, |
530 | 530 |
531 /** | 531 /** |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
566 if (this.errors) | 566 if (this.errors) |
567 buffer.push("errors=" + this.errors); | 567 buffer.push("errors=" + this.errors); |
568 if (this.version) | 568 if (this.version) |
569 buffer.push("version=" + this.version); | 569 buffer.push("version=" + this.version); |
570 if (this.requiredVersion) | 570 if (this.requiredVersion) |
571 buffer.push("requiredVersion=" + this.requiredVersion); | 571 buffer.push("requiredVersion=" + this.requiredVersion); |
572 if (this.downloadCount) | 572 if (this.downloadCount) |
573 buffer.push("downloadCount=" + this.downloadCount); | 573 buffer.push("downloadCount=" + this.downloadCount); |
574 } | 574 } |
575 }); | 575 }); |
OLD | NEW |