adding desktop notifications

This commit is contained in:
Rodolphe Breard 2013-01-13 20:09:01 +01:00
parent de8a0b2e37
commit 81d4941553
2 changed files with 18 additions and 3 deletions

View file

@ -98,6 +98,21 @@ Nsui.prototype.addContentToTab = function(tab_name, content) {
if ($cs.opts.get("enable_msg")) {
tab = this.addNewTab(tab_name);
tab.appendMessage(content);
if (typeof content.login !== "undefined" && content.login !== null && $cs.opts.get("enable_notif")) {
$cs.avatars.get(content.login, function(url) {
var notif = webkitNotifications.createNotification(
url,
content.login,
content.message.substr(0, 24)
);
console.log(notif);
notif.show();
setTimeout(function() {
notif.cancel();
}, 5000);
});
}
}
};