Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/notificationHelper.js

Issue 29371763: Issue 4795 - Use modern JavaScript syntax (Closed)
Patch Set: Use const as per the new rules Created Jan. 18, 2017, 7:23 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/messaging.js ('k') | lib/popupBlocker.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/notificationHelper.js
diff --git a/lib/notificationHelper.js b/lib/notificationHelper.js
index 9a8875a3ecb3c8357397763406546df3c9371be6..d997e851a478fae462f663c28ab25870723df7ef 100644
--- a/lib/notificationHelper.js
+++ b/lib/notificationHelper.js
@@ -17,12 +17,14 @@
/** @module notificationHelper */
-let {startIconAnimation, stopIconAnimation} = require("icon");
-let {Utils} = require("utils");
-let {Notification: NotificationStorage} = require("notification");
-let {stringifyURL} = require("url");
-let {initAntiAdblockNotification} = require("antiadblockInit");
-let {Prefs} = require("prefs");
+"use strict";
+
+const {startIconAnimation, stopIconAnimation} = require("icon");
+const {Utils} = require("utils");
+const {Notification: NotificationStorage} = require("notification");
+const {stringifyURL} = require("url");
+const {initAntiAdblockNotification} = require("antiadblockInit");
+const {Prefs} = require("prefs");
let activeNotification = null;
let activeButtons = null;
@@ -36,7 +38,7 @@ displayMethods.information = ["icon", "popup"];
function prepareNotificationIconAndPopup()
{
let animateIcon = shouldDisplay("icon", activeNotification.type);
- activeNotification.onClicked = function()
+ activeNotification.onClicked = () =>
{
if (animateIcon)
stopIconAnimation();
@@ -62,7 +64,7 @@ function getNotificationButtons(notificationType, message)
}
else
{
- let regex = /<a>(.*?)<\/a>/g;
+ const regex = /<a>(.*?)<\/a>/g;
let match;
while (match = regex.exec(message))
{
@@ -120,7 +122,7 @@ function notificationButtonClick(buttonIndex)
break;
case "configure":
Prefs.notifications_showui = true;
- ext.showOptions(function(page)
+ ext.showOptions(page =>
{
page.sendMessage({
type: "app.respond",
@@ -150,14 +152,14 @@ function initChromeNotifications()
if (activeNotification && activeNotification.type != "question" && !("links" in activeNotification))
return;
- chrome.notifications.clear(notificationId, function(wasCleared)
+ chrome.notifications.clear(notificationId, wasCleared =>
{
if (wasCleared)
notificationClosed();
});
}
- chrome.notifications.onButtonClicked.addListener(function(notificationId, buttonIndex)
+ chrome.notifications.onButtonClicked.addListener((notificationId, buttonIndex) =>
{
notificationButtonClick(buttonIndex);
clearActiveNotification(notificationId);
@@ -229,7 +231,7 @@ function showNotification(notification)
/**
* Initializes the notification system.
*/
-exports.initNotifications = function()
+exports.initNotifications = () =>
{
if ("notifications" in chrome)
initChromeNotifications();
@@ -241,10 +243,7 @@ exports.initNotifications = function()
*
* @return {?object}
*/
-exports.getActiveNotification = function()
-{
- return activeNotification;
-};
+exports.getActiveNotification = () => activeNotification;
let shouldDisplay =
/**
@@ -255,7 +254,7 @@ let shouldDisplay =
* @param {string} notificationType
* @return {boolean}
*/
-exports.shouldDisplay = function(method, notificationType)
+exports.shouldDisplay = (method, notificationType) =>
{
let methods = displayMethods[notificationType] || defaultDisplayMethods;
return methods.indexOf(method) > -1;
« no previous file with comments | « lib/messaging.js ('k') | lib/popupBlocker.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld