Index: notification.js |
diff --git a/notification.js b/notification.js |
index 2c553d2ca291941a4f3f1f699ef77b684f29ccd3..817e80bdd008fe5ea9ae58dd590b3eca69335d76 100644 |
--- a/notification.js |
+++ b/notification.js |
@@ -15,22 +15,24 @@ |
* along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
*/ |
-var backgroundPage = ext.backgroundPage.getWindow(); |
-var require = backgroundPage.require; |
+"use strict"; |
-var Utils = require("utils").Utils; |
-var Notification = require("notification").Notification; |
-var notificationHelper = require("notificationHelper"); |
-var getActiveNotification = notificationHelper.getActiveNotification; |
-var shouldDisplayNotification = notificationHelper.shouldDisplay; |
+let backgroundPage = ext.backgroundPage.getWindow(); |
+let require = backgroundPage.require; |
+ |
+let Utils = require("utils").Utils; |
+let Notification = require("notification").Notification; |
+let notificationHelper = require("notificationHelper"); |
+let getActiveNotification = notificationHelper.getActiveNotification; |
+let shouldDisplayNotification = notificationHelper.shouldDisplay; |
function getDocLinks(notification) |
{ |
if (!notification.links) |
return []; |
- var docLinks = []; |
- notification.links.forEach(function(link) |
+ let docLinks = []; |
+ notification.links.forEach(link => |
{ |
docLinks.push(Utils.getDocLink(link)); |
}); |
@@ -39,21 +41,21 @@ function getDocLinks(notification) |
function insertMessage(element, text, links) |
{ |
- var match = /^(.*?)<(a|strong)>(.*?)<\/\2>(.*)$/.exec(text); |
+ let match = /^(.*?)<(a|strong)>(.*?)<\/\2>(.*)$/.exec(text); |
if (!match) |
{ |
element.appendChild(document.createTextNode(text)); |
return; |
} |
- var before = match[1]; |
- var tagName = match[2]; |
- var value = match[3]; |
- var after = match[4]; |
+ let before = match[1]; |
+ let tagName = match[2]; |
+ let value = match[3]; |
+ let after = match[4]; |
insertMessage(element, before, links); |
- var newElement = document.createElement(tagName); |
+ let newElement = document.createElement(tagName); |
if (tagName === "a" && links && links.length) |
newElement.href = links.shift(); |
insertMessage(newElement, value, links); |
@@ -62,23 +64,23 @@ function insertMessage(element, text, links) |
insertMessage(element, after, links); |
} |
-window.addEventListener("load", function() |
+window.addEventListener("load", () => |
{ |
- var notification = getActiveNotification(); |
+ let notification = getActiveNotification(); |
if (!notification || !shouldDisplayNotification("popup", notification.type)) |
return; |
- var texts = Notification.getLocalizedTexts(notification); |
- var titleElement = document.getElementById("notification-title"); |
+ let texts = Notification.getLocalizedTexts(notification); |
+ let titleElement = document.getElementById("notification-title"); |
titleElement.textContent = texts.title; |
- var docLinks = getDocLinks(notification); |
- var messageElement = document.getElementById("notification-message"); |
+ let docLinks = getDocLinks(notification); |
+ let messageElement = document.getElementById("notification-message"); |
insertMessage(messageElement, texts.message, docLinks); |
- messageElement.addEventListener("click", function(event) |
+ messageElement.addEventListener("click", event => |
{ |
- var link = event.target; |
+ let link = event.target; |
while (link && link !== messageElement && link.localName !== "a") |
link = link.parentNode; |
if (!link) |
@@ -88,10 +90,10 @@ window.addEventListener("load", function() |
ext.pages.open(link.href); |
}); |
- var notificationElement = document.getElementById("notification"); |
+ let notificationElement = document.getElementById("notification"); |
notificationElement.className = notification.type; |
notificationElement.hidden = false; |
- notificationElement.addEventListener("click", function(event) |
+ notificationElement.addEventListener("click", event => |
{ |
switch (event.target.id) |
{ |