raumstatus/node/public/js/vendor/notification.js

31 lines
701 B
JavaScript

var Notification = window.Notification || window.mozNotification || window.webkitNotification;
Notification.requestPermission(function (permission) {
// console.log(permission);
});
function showNotification(name, body, icon, timeout) {
var instance = new Notification(
name, {
body: body,
icon: icon
}
);
instance.onclick = function () {
// Something to do
};
instance.onerror = function () {
// Something to do
};
instance.onshow = function () {
setTimeout(function(){
instance.close();
}, timeout * 1000);
};
instance.onclose = function () {
// Something to do
};
}