Index: lib/notification.js |
=================================================================== |
--- a/lib/notification.js |
+++ b/lib/notification.js |
@@ -65,17 +65,17 @@ |
return translations[languagePart]; |
let defaultLocale = "en-US"; |
return translations[defaultLocale]; |
} |
function parseVersionComponent(comp) |
{ |
- if (comp == "*") |
+ if (comp === "*") |
return Infinity; |
return parseInt(comp, 10) || 0; |
} |
function compareVersion(v1, v2) |
{ |
let regexp = /^(.*?)([a-z].*)?$/i; |
let [, head1, tail1] = regexp.exec(v1); |
@@ -84,17 +84,17 @@ |
let components2 = head2.split("."); |
for (let i = 0; i < components1.length || |
i < components2.length; i++) |
{ |
let result = parseVersionComponent(components1[i]) - |
parseVersionComponent(components2[i]) || 0; |
- if (result != 0) |
+ if (result !== 0) |
return result; |
} |
// Compare version suffix (e.g. 0.1alpha < 0.1b1 < 01.b2 < 0.1). |
// However, note that this is a simple string comparision, meaning: b10 < b2 |
if (tail1 == tail2) |
return 0; |
if (!tail1 || tail2 && tail1 > tail2) |
@@ -206,64 +206,64 @@ |
/** |
* Adds a listener for notifications to be shown. |
* @param {Function} listener Listener to be invoked when a notification is |
* to be shown |
*/ |
addShowListener(listener) |
{ |
- if (showListeners.indexOf(listener) == -1) |
+ if (showListeners.indexOf(listener) === -1) |
showListeners.push(listener); |
}, |
/** |
* Removes the supplied listener. |
* @param {Function} listener Listener that was added via addShowListener() |
*/ |
removeShowListener(listener) |
{ |
let index = showListeners.indexOf(listener); |
- if (index != -1) |
+ if (index !== -1) |
showListeners.splice(index, 1); |
}, |
/** |
* Determines which notification is to be shown next. |
* @param {string} url URL to match notifications to (optional) |
* @return {Object} notification to be shown, or null if there is none |
*/ |
_getNextToShow(url) |
{ |
let remoteData = []; |
- if (typeof Prefs.notificationdata.data == "object" && |
+ if (typeof Prefs.notificationdata.data === "object" && |
Prefs.notificationdata.data.notifications instanceof Array) |
{ |
remoteData = Prefs.notificationdata.data.notifications; |
} |
let notifications = localData.concat(remoteData); |
if (notifications.length === 0) |
return null; |
const {addonName, addonVersion, application, |
applicationVersion, platform, platformVersion} = require("info"); |
let targetChecks = { |
- extension: v => v == addonName, |
+ extension: v => v === addonName, |
extensionMinVersion: |
v => compareVersion(addonVersion, v) >= 0, |
extensionMaxVersion: |
v => compareVersion(addonVersion, v) <= 0, |
- application: v => v == application, |
+ application: v => v === application, |
applicationMinVersion: |
v => compareVersion(applicationVersion, v) >= 0, |
applicationMaxVersion: |
v => compareVersion(applicationVersion, v) <= 0, |
- platform: v => v == platform, |
+ platform: v => v === platform, |
platformMinVersion: |
v => compareVersion(platformVersion, v) >= 0, |
platformMaxVersion: |
v => compareVersion(platformVersion, v) <= 0, |
blockedTotalMin: v => Prefs.show_statsinpopup && |
Prefs.blocked_total >= v, |
blockedTotalMax: v => Prefs.show_statsinpopup && |
Prefs.blocked_total <= v, |
@@ -272,32 +272,32 @@ |
let notificationToShow = null; |
for (let notification of notifications) |
{ |
if (typeof notification.type === "undefined" || |
notification.type !== "critical") |
{ |
let shown; |
- if (typeof Prefs.notificationdata.shown == "object") |
+ if (typeof Prefs.notificationdata.shown === "object") |
shown = Prefs.notificationdata.shown[notification.id]; |
- if (typeof shown != "undefined") |
+ if (typeof shown !== "undefined") |
{ |
- if (typeof notification.interval == "number") |
+ if (typeof notification.interval === "number") |
{ |
if (shown + notification.interval > Date.now()) |
continue; |
} |
else if (shown) |
continue; |
} |
if (notification.type !== "relentless" && |
- Prefs.notifications_ignoredcategories.indexOf("*") != -1) |
+ Prefs.notifications_ignoredcategories.indexOf("*") !== -1) |
{ |
continue; |
} |
} |
if (typeof url === "string" || notification.urlFilters instanceof Array) |
{ |
if (Prefs.enabled && typeof url === "string" && |
@@ -388,17 +388,17 @@ |
if (data.shown instanceof Array) |
{ |
let newShown = {}; |
for (let oldId of data.shown) |
newShown[oldId] = now; |
data.shown = newShown; |
} |
- if (typeof data.shown != "object") |
+ if (typeof data.shown !== "object") |
data.shown = {}; |
data.shown[id] = now; |
saveNotificationData(); |
}, |
/** |
@@ -409,32 +409,32 @@ |
getLocalizedTexts(notification) |
{ |
let textKeys = ["title", "message"]; |
let localizedTexts = {}; |
for (let key of textKeys) |
{ |
if (key in notification) |
{ |
- if (typeof notification[key] == "string") |
+ if (typeof notification[key] === "string") |
localizedTexts[key] = notification[key]; |
else |
localizedTexts[key] = localize(notification[key], Utils.appLocale); |
} |
} |
return localizedTexts; |
}, |
/** |
* Adds a local notification. |
* @param {Object} notification notification to add |
*/ |
addNotification(notification) |
{ |
- if (localData.indexOf(notification) == -1) |
+ if (localData.indexOf(notification) === -1) |
localData.push(notification); |
}, |
/** |
* Removes an existing local notification. |
* @param {Object} notification notification to remove |
*/ |
removeNotification(notification) |
@@ -498,22 +498,22 @@ |
* Toggles whether notifications of a specific category should be ignored |
* @param {string} category notification category identifier |
* @param {boolean} [forceValue] force specified value |
*/ |
toggleIgnoreCategory(category, forceValue) |
{ |
let categories = Prefs.notifications_ignoredcategories; |
let index = categories.indexOf(category); |
- if (index == -1 && forceValue !== false) |
+ if (index === -1 && forceValue !== false) |
{ |
categories.push(category); |
Prefs.notifications_showui = true; |
} |
- else if (index != -1 && forceValue !== true) |
+ else if (index !== -1 && forceValue !== true) |
categories.splice(index, 1); |
// HACK: JSON values aren't saved unless they are assigned a |
// different object. |
Prefs.notifications_ignoredcategories = |
JSON.parse(JSON.stringify(categories)); |
} |
}; |