woodpecker/server/app/scripts/services/notify.js

24 lines
547 B
JavaScript
Raw Normal View History

'use strict';
angular.module('app').service('notify', ['$window', '$timeout', function($window, $timeout) {
this.supported = function() {
return ("Notification" in $window)
}
this.granted = function() {
return ("Notification" in $window) && Notification.permission === "granted";
}
this.requestPermission = function() {
Notification.requestPermission();
}
this.send = function(title, opts) {
if ("Notification" in $window) {
var n = new Notification(title, opts);
$timeout(function() { n.close(); }, 10000);
}
};
}]);