blob: 2cb4481fa0021d7c4d4913cf43a8defd42fc06b9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# Written by GitLab @gitlab
((w) ->
notifyMe = (message,body, icon) ->
notification = undefined
opts =
body: body
icon: icon
# Let's check if the browser supports notifications
if !('Notification' of window)
# do nothing
else if Notification.permission == 'granted'
# If it's okay let's create a notification
notification = new Notification(message, opts)
else if Notification.permission != 'denied'
Notification.requestPermission (permission) ->
# If the user accepts, let's create a notification
if permission == 'granted'
notification = new Notification(message, opts)
return
return
w.notify = notifyMe
return
) window
Notification.requestPermission()
|