update channels

This commit is contained in:
Luke Pulverenti 2014-06-06 13:14:02 -04:00
parent 1ccf18adbe
commit 658b824d5a

View File

@ -70,25 +70,7 @@ if (!Array.prototype.filter) {
var WebNotifications = { var WebNotifications = {
show: function (data) { show: function (data) {
if (window.webkitNotifications) { if (window.Notification) {
if (!webkitNotifications.checkPermission()) {
var notif = webkitNotifications.createNotification(data.icon, data.title, data.body);
notif.show();
if (data.timeout) {
setTimeout(function () {
notif.cancel();
}, data.timeout);
}
return notif;
} else {
webkitNotifications.requestPermission(function () {
return WebNotifications.show(data);
});
}
}
else if (window.Notification) {
var level = Notification.permissionLevel ? Notification.permissionLevel() : Notification.permission; var level = Notification.permissionLevel ? Notification.permissionLevel() : Notification.permission;
@ -99,9 +81,15 @@ var WebNotifications = {
notif.show(); notif.show();
} }
if (data.timeout && notif.cancel) { if (data.timeout) {
setTimeout(function () { setTimeout(function () {
if (notif.close) {
notif.close();
}
else if (notif.cancel) {
notif.cancel(); notif.cancel();
}
}, data.timeout); }, data.timeout);
} }
@ -112,6 +100,31 @@ var WebNotifications = {
}); });
} }
} }
else if (window.webkitNotifications) {
if (!webkitNotifications.checkPermission()) {
var notif = webkitNotifications.createNotification(data.icon, data.title, data.body);
notif.show();
if (data.timeout) {
setTimeout(function () {
if (notif.close) {
notif.close();
}
else if (notif.cancel) {
notif.cancel();
}
}, data.timeout);
}
return notif;
} else {
webkitNotifications.requestPermission(function () {
return WebNotifications.show(data);
});
}
}
}, },
requestPermission: function () { requestPermission: function () {