| Left: | ||
| Right: |
| LEFT | RIGHT |
|---|---|
| 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-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 202 let notifications = localData.concat(remoteData); | 202 let notifications = localData.concat(remoteData); |
| 203 if (notifications.length === 0) | 203 if (notifications.length === 0) |
| 204 return null; | 204 return null; |
| 205 | 205 |
| 206 let {addonName, addonVersion, application, applicationVersion, platform, pla tformVersion} = require("info"); | 206 let {addonName, addonVersion, application, applicationVersion, platform, pla tformVersion} = require("info"); |
| 207 let notificationToShow = null; | 207 let notificationToShow = null; |
| 208 for (let notification of notifications) | 208 for (let notification of notifications) |
| 209 { | 209 { |
| 210 if (typeof notification.type === "undefined" || notification.type !== "cri tical") | 210 if (typeof notification.type === "undefined" || notification.type !== "cri tical") |
| 211 { | 211 { |
| 212 let shown = undefined; | 212 let shown; |
|
Sebastian Noack
2017/01/06 11:21:08
Initializing a variable with undefined is equivale
wspee
2017/01/06 14:08:51
Done.
| |
| 213 if (Prefs.notificationdata.shown instanceof Object) | 213 if (typeof Prefs.notificationdata.shown == "object") |
|
Sebastian Noack
2017/01/06 11:21:08
Checking for the prototype seems unnecessary here.
wspee
2017/01/06 14:08:51
Done.
| |
| 214 shown = Prefs.notificationdata.shown[notification.id]; | 214 shown = Prefs.notificationdata.shown[notification.id]; |
| 215 | 215 |
| 216 if (typeof shown !== "undefined") | 216 if (typeof shown != "undefined") |
|
Sebastian Noack
2017/01/06 11:21:08
As per the Mozilla coding style guide (https://dev
wspee
2017/01/06 14:08:51
Done.
| |
| 217 { | 217 { |
| 218 if (typeof notification.interval === "number") | 218 if (typeof notification.interval == "number") |
|
Sebastian Noack
2017/01/06 11:21:07
Same here, use == instead of ===.
wspee
2017/01/06 14:08:51
Done.
| |
| 219 { | 219 { |
| 220 if (shown + notification.interval > Date.now()) | 220 if (shown + notification.interval > Date.now()) |
| 221 continue | 221 continue; |
|
Sebastian Noack
2017/01/06 11:21:08
For consistency, please add the optional semicolon
wspee
2017/01/06 14:08:51
Done.
| |
| 222 } | 222 } |
| 223 else if (shown) | 223 else if (shown) |
| 224 continue | 224 continue; |
|
Sebastian Noack
2017/01/06 11:21:07
For consistency, please add the optional semicolon
wspee
2017/01/06 14:08:51
Done.
| |
| 225 } | 225 } |
| 226 | 226 |
| 227 if (Prefs.notifications_ignoredcategories.indexOf("*") != -1) | 227 if (notification.type !== "relentless" && Prefs.notifications_ignoredcat egories.indexOf("*") != -1) |
| 228 continue; | 228 continue; |
| 229 } | 229 } |
| 230 | 230 |
| 231 if (typeof url === "string" || notification.urlFilters instanceof Array) | 231 if (typeof url === "string" || notification.urlFilters instanceof Array) |
| 232 { | 232 { |
| 233 if (Prefs.enabled && typeof url === "string" && notification.urlFilters instanceof Array) | 233 if (Prefs.enabled && typeof url === "string" && notification.urlFilters instanceof Array) |
| 234 { | 234 { |
| 235 let host; | 235 let host; |
| 236 try | 236 try |
| 237 { | 237 { |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 298 * Marks a notification as shown. | 298 * Marks a notification as shown. |
| 299 * @param {String} id ID of the notification to be marked as shown | 299 * @param {String} id ID of the notification to be marked as shown |
| 300 */ | 300 */ |
| 301 markAsShown: function(id) | 301 markAsShown: function(id) |
| 302 { | 302 { |
| 303 let now = Date.now(); | 303 let now = Date.now(); |
| 304 let data = Prefs.notificationdata; | 304 let data = Prefs.notificationdata; |
| 305 | 305 |
| 306 if (data.shown instanceof Array) | 306 if (data.shown instanceof Array) |
| 307 { | 307 { |
| 308 let newShown = {} | 308 let newShown = {}; |
|
Sebastian Noack
2017/01/06 11:21:08
For consistency, please add the optional semicolon
wspee
2017/01/06 14:08:51
Done.
| |
| 309 for (let old_id of data.shown) | 309 for (let oldId of data.shown) |
| 310 newShown[old_id] = now; | 310 newShown[oldId] = now; |
| 311 data.shown = newShown; | 311 data.shown = newShown; |
| 312 } | 312 } |
| 313 | 313 |
| 314 if (!(data.shown instanceof Object)) | 314 if (typeof data.shown != "object") |
|
Sebastian Noack
2017/01/06 11:21:08
See above, you should probably use typeof here.
wspee
2017/01/06 14:08:51
Done.
| |
| 315 data.shown = {}; | 315 data.shown = {}; |
| 316 | 316 |
| 317 data.shown[id] = Date.now(); | 317 data.shown[id] = now; |
|
Sebastian Noack
2017/01/06 11:21:08
I suppose, we should use the "now" variable here a
wspee
2017/01/06 14:08:51
Done.
| |
| 318 | 318 |
| 319 saveNotificationData(); | 319 saveNotificationData(); |
| 320 }, | 320 }, |
| 321 | 321 |
| 322 /** | 322 /** |
| 323 * Localizes the texts of the supplied notification. | 323 * Localizes the texts of the supplied notification. |
| 324 * @param {Object} notification notification to translate | 324 * @param {Object} notification notification to translate |
| 325 * @param {String} locale the target locale (optional, defaults to the | 325 * @param {String} locale the target locale (optional, defaults to the |
| 326 * application locale) | 326 * application locale) |
| 327 * @return {Object} the translated texts | 327 * @return {Object} the translated texts |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 419 Prefs.notifications_showui = true; | 419 Prefs.notifications_showui = true; |
| 420 } | 420 } |
| 421 else if (index != -1 && forceValue !== true) | 421 else if (index != -1 && forceValue !== true) |
| 422 categories.splice(index, 1); | 422 categories.splice(index, 1); |
| 423 | 423 |
| 424 // HACK: JSON values aren't saved unless they are assigned a different objec t. | 424 // HACK: JSON values aren't saved unless they are assigned a different objec t. |
| 425 Prefs.notifications_ignoredcategories = JSON.parse(JSON.stringify(categories )); | 425 Prefs.notifications_ignoredcategories = JSON.parse(JSON.stringify(categories )); |
| 426 } | 426 } |
| 427 }; | 427 }; |
| 428 Notification.init(); | 428 Notification.init(); |
| LEFT | RIGHT |