| 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-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 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 /** | 18 /** |
| 19 * @fileOverview Handles notifications. | 19 * @fileOverview Handles notifications. |
| 20 */ | 20 */ |
| 21 | 21 |
| 22 Cu.import("resource://gre/modules/Services.jsm"); | 22 Cu.import("resource://gre/modules/Services.jsm"); |
| 23 | 23 |
| 24 let {Prefs} = require("prefs"); | 24 var {Prefs} = require("prefs"); |
| 25 let {Downloader, Downloadable, MILLIS_IN_MINUTE, MILLIS_IN_HOUR, MILLIS_IN_DAY}
= require("downloader"); | 25 var {Downloader, Downloadable, MILLIS_IN_MINUTE, MILLIS_IN_HOUR, MILLIS_IN_DAY}
= require("downloader"); |
| 26 let {Utils} = require("utils"); | 26 var {Utils} = require("utils"); |
| 27 let {Matcher, defaultMatcher} = require("matcher"); | 27 var {Matcher, defaultMatcher} = require("matcher"); |
| 28 let {Filter, RegExpFilter, WhitelistFilter} = require("filterClasses"); | 28 var {Filter, RegExpFilter, WhitelistFilter} = require("filterClasses"); |
| 29 | 29 |
| 30 let INITIAL_DELAY = 1 * MILLIS_IN_MINUTE; | 30 var INITIAL_DELAY = 1 * MILLIS_IN_MINUTE; |
| 31 let CHECK_INTERVAL = 1 * MILLIS_IN_HOUR; | 31 var CHECK_INTERVAL = 1 * MILLIS_IN_HOUR; |
| 32 let EXPIRATION_INTERVAL = 1 * MILLIS_IN_DAY; | 32 var EXPIRATION_INTERVAL = 1 * MILLIS_IN_DAY; |
| 33 let TYPE = { | 33 var TYPE = { |
| 34 information: 0, | 34 information: 0, |
| 35 question: 1, | 35 question: 1, |
| 36 critical: 2 | 36 critical: 2 |
| 37 }; | 37 }; |
| 38 | 38 |
| 39 let showListeners = []; | 39 var showListeners = []; |
| 40 let questionListeners = {}; | 40 var questionListeners = {}; |
| 41 | 41 |
| 42 function getNumericalSeverity(notification) | 42 function getNumericalSeverity(notification) |
| 43 { | 43 { |
| 44 return (notification.type in TYPE ? TYPE[notification.type] : TYPE.information
); | 44 return (notification.type in TYPE ? TYPE[notification.type] : TYPE.information
); |
| 45 } | 45 } |
| 46 | 46 |
| 47 function saveNotificationData() | 47 function saveNotificationData() |
| 48 { | 48 { |
| 49 // HACK: JSON values aren't saved unless they are assigned a different object. | 49 // HACK: JSON values aren't saved unless they are assigned a different object. |
| 50 Prefs.notificationdata = JSON.parse(JSON.stringify(Prefs.notificationdata)); | 50 Prefs.notificationdata = JSON.parse(JSON.stringify(Prefs.notificationdata)); |
| 51 } | 51 } |
| 52 | 52 |
| 53 function localize(translations, locale) | 53 function localize(translations, locale) |
| 54 { | 54 { |
| 55 if (locale in translations) | 55 if (locale in translations) |
| 56 return translations[locale]; | 56 return translations[locale]; |
| 57 | 57 |
| 58 let languagePart = locale.substring(0, locale.indexOf("-")); | 58 let languagePart = locale.substring(0, locale.indexOf("-")); |
| 59 if (languagePart && languagePart in translations) | 59 if (languagePart && languagePart in translations) |
| 60 return translations[languagePart]; | 60 return translations[languagePart]; |
| 61 | 61 |
| 62 let defaultLocale = "en-US"; | 62 let defaultLocale = "en-US"; |
| 63 return translations[defaultLocale]; | 63 return translations[defaultLocale]; |
| 64 } | 64 } |
| 65 | 65 |
| 66 /** | 66 /** |
| 67 * The object providing actual downloading functionality. | 67 * The object providing actual downloading functionality. |
| 68 * @type Downloader | 68 * @type Downloader |
| 69 */ | 69 */ |
| 70 let downloader = null; | 70 var downloader = null; |
| 71 let localData = []; | 71 var localData = []; |
| 72 | 72 |
| 73 /** | 73 /** |
| 74 * Regularly fetches notifications and decides which to show. | 74 * Regularly fetches notifications and decides which to show. |
| 75 * @class | 75 * @class |
| 76 */ | 76 */ |
| 77 let Notification = exports.Notification = | 77 var Notification = exports.Notification = |
| 78 { | 78 { |
| 79 /** | 79 /** |
| 80 * Called on module startup. | 80 * Called on module startup. |
| 81 */ | 81 */ |
| 82 init: function() | 82 init: function() |
| 83 { | 83 { |
| 84 downloader = new Downloader(this._getDownloadables.bind(this), INITIAL_DELAY
, CHECK_INTERVAL); | 84 downloader = new Downloader(this._getDownloadables.bind(this), INITIAL_DELAY
, CHECK_INTERVAL); |
| 85 downloader.onExpirationChange = this._onExpirationChange.bind(this); | 85 downloader.onExpirationChange = this._onExpirationChange.bind(this); |
| 86 downloader.onDownloadSuccess = this._onDownloadSuccess.bind(this); | 86 downloader.onDownloadSuccess = this._onDownloadSuccess.bind(this); |
| 87 downloader.onDownloadError = this._onDownloadError.bind(this); | 87 downloader.onDownloadError = this._onDownloadError.bind(this); |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 Prefs.notifications_showui = true; | 403 Prefs.notifications_showui = true; |
| 404 } | 404 } |
| 405 else if (index != -1 && forceValue !== true) | 405 else if (index != -1 && forceValue !== true) |
| 406 categories.splice(index, 1); | 406 categories.splice(index, 1); |
| 407 | 407 |
| 408 // HACK: JSON values aren't saved unless they are assigned a different objec
t. | 408 // HACK: JSON values aren't saved unless they are assigned a different objec
t. |
| 409 Prefs.notifications_ignoredcategories = JSON.parse(JSON.stringify(categories
)); | 409 Prefs.notifications_ignoredcategories = JSON.parse(JSON.stringify(categories
)); |
| 410 } | 410 } |
| 411 }; | 411 }; |
| 412 Notification.init(); | 412 Notification.init(); |
| OLD | NEW |