Index: notification.js |
=================================================================== |
new file mode 100644 |
--- /dev/null |
+++ b/notification.js |
@@ -0,0 +1,35 @@ |
+window.addEventListener("load", function() |
+{ |
+ var backgroundPage = chrome.extension.getBackgroundPage(); |
+ var notification = backgroundPage.activeNotification; |
+ if (!notification) |
+ return; |
+ |
+ if (notification.onClicked) |
+ notification.onClicked(); |
+ |
+ var texts = backgroundPage.getLocalizedTexts(notification); |
Wladimir Palant
2013/07/21 11:15:30
Call Notification and Utils directly here (via req
Felix Dahlke
2013/07/22 12:30:15
Done. Not sure why I didn't do it in fact.
|
+ var titleElement = document.getElementById("title"); |
+ titleElement.innerHTML = texts.title; |
Wladimir Palant
2013/07/21 11:15:30
textContent please, not innerHTML.
Felix Dahlke
2013/07/22 12:30:15
Done.
|
+ var messageElement = document.getElementById("message"); |
+ messageElement.innerHTML = texts.message; |
Wladimir Palant
2013/07/21 11:15:30
Please use the same code as in Firefox here, not i
Felix Dahlke
2013/07/21 12:19:53
Hehe, I thought I'd try :D This should be safe in
Felix Dahlke
2013/07/22 12:30:15
Done. I think it's less than great that this code
|
+ |
+ var docLinks = backgroundPage.getDocLinks(notification); |
+ var linkElements = messageElement.getElementsByTagName("a"); |
+ for (var i = 0; i < linkElements.length; i++) |
+ { |
+ var linkElement = linkElements[i]; |
+ if (docLinks && docLinks.length) |
+ linkElement.href = docLinks.shift(); |
+ linkElement.addEventListener("click", function(event) |
+ { |
+ event.preventDefault(); |
+ event.stopPropagation(); |
+ chrome.tabs.create({url: linkElement.href}); |
+ }); |
+ } |
+ |
+ var notificationElement = document.getElementById("notification"); |
+ notificationElement.className = notification.severity; |
+ notificationElement.style.display = "block"; |
+}); |