Switching to Chrome Rich Notifications when available
This commit is contained in:
parent
6e756f89be
commit
e6e0ec2d76
1 changed files with 36 additions and 13 deletions
23
lib/nsui.js
23
lib/nsui.js
|
@ -117,6 +117,28 @@ Nsui.prototype.sendNotification = function(image, title, message) {
|
||||||
message = message.substr(0, 32) + "…";
|
message = message.substr(0, 32) + "…";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (typeof chrome.notifications !== "undefined") {
|
||||||
|
chrome.notifications.create(
|
||||||
|
'',
|
||||||
|
{
|
||||||
|
type: 'basic',
|
||||||
|
iconUrl: image,
|
||||||
|
title: title,
|
||||||
|
message: message,
|
||||||
|
priority: 0
|
||||||
|
},
|
||||||
|
function(id) {
|
||||||
|
setTimeout(function() {
|
||||||
|
chrome.notifications.clear(id, function() {});
|
||||||
|
}, 5000);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
chrome.notifications.onClicked.addListener(function(id) {
|
||||||
|
window.focus();
|
||||||
|
chrome.notifications.clear(id, function() {});
|
||||||
|
});
|
||||||
|
} else {
|
||||||
notif = webkitNotifications.createNotification(
|
notif = webkitNotifications.createNotification(
|
||||||
image,
|
image,
|
||||||
title,
|
title,
|
||||||
|
@ -133,6 +155,7 @@ Nsui.prototype.sendNotification = function(image, title, message) {
|
||||||
notif.cancel();
|
notif.cancel();
|
||||||
}, 5000);
|
}, 5000);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Nsui.prototype.addContentToTab = function(tab_name, content) {
|
Nsui.prototype.addContentToTab = function(tab_name, content) {
|
||||||
var tab = null;
|
var tab = null;
|
||||||
|
|
Reference in a new issue