Index: notification.js |
=================================================================== |
new file mode 100644 |
--- /dev/null |
+++ b/notification.js |
@@ -0,0 +1,41 @@ |
+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); |
+ var titleElement = document.getElementById("title"); |
+ titleElement.innerHTML = texts.title; |
+ var messageElement = document.getElementById("message"); |
+ messageElement.innerHTML = texts.message; |
+ |
+ 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(); |
+ var url = linkElement.href; |
+ if (!/^https?:\/\//.test(url)) |
+ { |
+ reportError("Illegal link scheme in URL: " + url); |
+ return; |
+ } |
+ chrome.tabs.create({url: linkElement.href}); |
+ }); |
+ } |
+ |
+ var notificationElement = document.getElementById("notification"); |
+ notificationElement.className = notification.severity; |
+ notificationElement.style.display = "block"; |
+}); |