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 |
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 "use strict"; | 18 "use strict"; |
19 | 19 |
20 let backgroundPage = ext.backgroundPage.getWindow(); | 20 const {require} = ext.backgroundPage.getWindow(); |
21 let require = backgroundPage.require; | |
22 | 21 |
23 let Utils = require("utils").Utils; | 22 const {Utils} = require("utils"); |
Sebastian Noack
2017/01/16 15:35:56
I suppose we could better use destructuring here n
kzar
2017/01/17 07:42:49
Done.
| |
24 let Notification = require("notification").Notification; | 23 const {Notification} = require("notification"); |
25 let notificationHelper = require("notificationHelper"); | 24 const {getActiveNotification, shouldDisplay} = require("notificationHelper"); |
26 let getActiveNotification = notificationHelper.getActiveNotification; | |
27 let shouldDisplayNotification = notificationHelper.shouldDisplay; | |
28 | 25 |
29 function getDocLinks(notification) | 26 function getDocLinks(notification) |
30 { | 27 { |
31 if (!notification.links) | 28 if (!notification.links) |
32 return []; | 29 return []; |
33 | 30 |
34 let docLinks = []; | 31 let docLinks = []; |
35 notification.links.forEach(link => | 32 notification.links.forEach(link => |
36 { | 33 { |
37 docLinks.push(Utils.getDocLink(link)); | 34 docLinks.push(Utils.getDocLink(link)); |
(...skipping 22 matching lines...) Expand all Loading... | |
60 newElement.href = links.shift(); | 57 newElement.href = links.shift(); |
61 insertMessage(newElement, value, links); | 58 insertMessage(newElement, value, links); |
62 element.appendChild(newElement); | 59 element.appendChild(newElement); |
63 | 60 |
64 insertMessage(element, after, links); | 61 insertMessage(element, after, links); |
65 } | 62 } |
66 | 63 |
67 window.addEventListener("load", () => | 64 window.addEventListener("load", () => |
68 { | 65 { |
69 let notification = getActiveNotification(); | 66 let notification = getActiveNotification(); |
70 if (!notification || !shouldDisplayNotification("popup", notification.type)) | 67 if (!notification || !shouldDisplay("popup", notification.type)) |
71 return; | 68 return; |
72 | 69 |
73 let texts = Notification.getLocalizedTexts(notification); | 70 let texts = Notification.getLocalizedTexts(notification); |
74 let titleElement = document.getElementById("notification-title"); | 71 let titleElement = document.getElementById("notification-title"); |
75 titleElement.textContent = texts.title; | 72 titleElement.textContent = texts.title; |
76 | 73 |
77 let docLinks = getDocLinks(notification); | 74 let docLinks = getDocLinks(notification); |
78 let messageElement = document.getElementById("notification-message"); | 75 let messageElement = document.getElementById("notification-message"); |
79 insertMessage(messageElement, texts.message, docLinks); | 76 insertMessage(messageElement, texts.message, docLinks); |
80 | 77 |
(...skipping 21 matching lines...) Expand all Loading... | |
102 break; | 99 break; |
103 case "notification-optout": | 100 case "notification-optout": |
104 Notification.toggleIgnoreCategory("*", true); | 101 Notification.toggleIgnoreCategory("*", true); |
105 case "notification-hide": | 102 case "notification-hide": |
106 notificationElement.hidden = true; | 103 notificationElement.hidden = true; |
107 notification.onClicked(); | 104 notification.onClicked(); |
108 break; | 105 break; |
109 } | 106 } |
110 }, true); | 107 }, true); |
111 }, false); | 108 }, false); |
LEFT | RIGHT |