| Left: | ||
| Right: |
| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, |
| 3 * Copyright (C) 2006-2013 Eyeo GmbH | 3 * Copyright (C) 2006-2013 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 |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 285 { | 285 { |
| 286 activeNotification.onClicked = function() | 286 activeNotification.onClicked = function() |
| 287 { | 287 { |
| 288 iconAnimation.stop(); | 288 iconAnimation.stop(); |
| 289 activeNotification = null; | 289 activeNotification = null; |
| 290 }; | 290 }; |
| 291 | 291 |
| 292 iconAnimation.update(activeNotification.severity); | 292 iconAnimation.update(activeNotification.severity); |
| 293 } | 293 } |
| 294 | 294 |
| 295 function notificationWindowClick() { | |
|
Thomas Greiner
2014/02/17 10:02:41
Nit: Bracket on next line
saroyanm
2014/02/18 10:25:08
Done.
| |
| 296 if (activeNotification.links) | |
| 297 { | |
| 298 activeNotification.links.forEach(function(link) | |
| 299 { | |
| 300 chrome.tabs.create({ url: Utils.getDocLink(link) }); | |
|
Thomas Greiner
2014/02/17 10:02:41
This is Chrome-specific. We do have an "openTab" m
saroyanm
2014/02/18 10:25:08
Done.
| |
| 301 }); | |
| 302 } | |
| 303 prepareNotificationIconAndPopup(); | |
| 304 } | |
| 305 | |
| 306 function notificationButtonClick(id, index) { | |
|
Thomas Greiner
2014/02/17 10:02:41
Nit: Bracket on next line
saroyanm
2014/02/18 10:25:08
Done.
| |
| 307 chrome.tabs.create({url: Utils.getDocLink(activeNotification.links[index])}); | |
|
Thomas Greiner
2014/02/17 10:02:41
This is Chrome-specific. We do have an "openTab" m
saroyanm
2014/02/18 10:25:08
Done.
| |
| 308 prepareNotificationIconAndPopup(); | |
| 309 } | |
| 310 | |
| 295 function showNotification(notification) | 311 function showNotification(notification) |
| 296 { | 312 { |
| 297 activeNotification = notification; | 313 activeNotification = notification; |
| 298 | 314 if (activeNotification.severity === "critical") |
| 299 if (activeNotification.severity === "critical" | |
| 300 && typeof webkitNotifications !== "undefined") | |
| 301 { | 315 { |
| 302 var notification = webkitNotifications.createHTMLNotification("notification. html"); | 316 var isWebkit = typeof webkitNotifications !== "undefined"; |
|
Thomas Greiner
2014/02/17 10:02:41
All browsers based on this repository use WebKit s
saroyanm
2014/02/18 10:25:08
Done.
| |
| 303 notification.show(); | 317 if (isWebkit && "createHTMLNotification" in webkitNotifications) |
| 304 notification.addEventListener("close", prepareNotificationIconAndPopup); | 318 { |
| 319 notification = webkitNotifications.createHTMLNotification("notification.ht ml"); | |
| 320 notification.show(); | |
| 321 notification.addEventListener("close", prepareNotificationIconAndPopup); | |
| 322 return; | |
| 323 } | |
| 324 | |
| 325 var texts = Notification.getLocalizedTexts(notification); | |
| 326 var title = texts.title ? texts.title : ""; | |
| 327 var message = texts.message ? texts.message : ""; | |
| 328 var iconUrl = "icons/abp-128.png"; | |
| 329 if ("notifications" in chrome) | |
|
Thomas Greiner
2014/02/17 10:02:41
This is Chrome-specific but the adblockpluschrome
saroyanm
2014/02/18 10:25:08
Thanks, for pointing this, now I see what is under
Thomas Greiner
2014/02/18 14:26:17
That's OK for now. We can add a Safari-specific im
| |
| 330 { | |
| 331 var buttons = []; | |
| 332 var links = notification.links; | |
| 333 links.forEach(function(link, index){ | |
|
Thomas Greiner
2014/02/17 10:02:41
Nit: Missing space after closing bracket.
| |
| 334 buttons.push({"title": link.replace(new RegExp("_", 'g'), " ")}); | |
|
Thomas Greiner
2014/02/17 10:02:41
The link texts can actually be extracted from the
saroyanm
2014/02/18 10:25:08
Maybe it make sense also to remove anchors with th
| |
| 335 }); | |
| 336 var opt = { | |
| 337 type: "basic", | |
| 338 title: title, | |
| 339 message: message, | |
| 340 iconUrl: iconUrl, | |
|
Thomas Greiner
2014/02/17 10:02:41
You can directly inline "title", "message" and "ic
Thomas Greiner
2014/02/17 10:02:41
Use |ext.getURL("icons/abp-128.png")| as the icon
saroyanm
2014/02/18 10:25:08
while I've added also else case I'm using that var
Thomas Greiner
2014/02/18 14:26:17
Right, that's fine then. Although you could write
| |
| 341 buttons: buttons | |
| 342 }; | |
| 343 notification = chrome.notifications; | |
|
Thomas Greiner
2014/02/17 10:02:41
Avoid creating global variables by adding "var".
saroyanm
2014/02/18 10:25:08
Done.
| |
| 344 notification.create("", opt, function(){}); | |
|
Thomas Greiner
2014/02/17 10:02:41
Nit: Missing space after closing bracket.
saroyanm
2014/02/18 10:25:08
Done.
| |
| 345 notification.onClosed.addListener(prepareNotificationIconAndPopup); | |
| 346 notification.onClicked.addListener(notificationWindowClick); | |
| 347 notification.onButtonClicked.addListener(notificationButtonClick); | |
| 348 } | |
| 349 else if (isWebkit && "createNotification" in webkitNotifications) | |
| 350 { | |
| 351 notification = webkitNotifications.createNotification(iconUrl, title, mess age); | |
| 352 notification.show(); | |
| 353 notification.addEventListener("close", prepareNotificationIconAndPopup); | |
|
Thomas Greiner
2014/02/17 10:02:41
Nit: Add third parameter
saroyanm
2014/02/18 10:25:08
Done.
| |
| 354 notification.addEventListener("click", notificationWindowClick); | |
|
Thomas Greiner
2014/02/17 10:02:41
Nit: Add third parameter
saroyanm
2014/02/18 10:25:08
Done.
| |
| 355 } | |
|
Thomas Greiner
2014/02/17 10:02:41
What about the "else" case here?
saroyanm
2014/02/18 10:25:08
Added also confirm dialog for else case, thanks fo
| |
| 305 } | 356 } |
| 306 else | 357 else |
| 307 prepareNotificationIconAndPopup(); | 358 prepareNotificationIconAndPopup(); |
| 308 } | 359 } |
| 309 | 360 |
| 310 ext.onMessage.addListener(function (msg, sender, sendResponse) | 361 ext.onMessage.addListener(function (msg, sender, sendResponse) |
| 311 { | 362 { |
| 312 switch (msg.type) | 363 switch (msg.type) |
| 313 { | 364 { |
| 314 case "get-selectors": | 365 case "get-selectors": |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 419 tab.sendMessage({type: "clickhide-deactivate"}); | 470 tab.sendMessage({type: "clickhide-deactivate"}); |
| 420 refreshIconAndContextMenu(tab); | 471 refreshIconAndContextMenu(tab); |
| 421 }); | 472 }); |
| 422 | 473 |
| 423 setTimeout(function() | 474 setTimeout(function() |
| 424 { | 475 { |
| 425 var notificationToShow = Notification.getNextToShow(); | 476 var notificationToShow = Notification.getNextToShow(); |
| 426 if (notificationToShow) | 477 if (notificationToShow) |
| 427 showNotification(notificationToShow); | 478 showNotification(notificationToShow); |
| 428 }, 3 * 60 * 1000); | 479 }, 3 * 60 * 1000); |
| OLD | NEW |