Commit 7bc2bd569be2358696aa8411f8eff6758e72e267
1 parent
6e9986a8
Exists in
master
and in
3 other branches
Modifying notification as permission
Showing
1 changed file
with
8 additions
and
10 deletions
Show diff stats
amadeus/static/js/socket.js
1 | +if (("Notification" in window)) { | ||
2 | + if (Notification.permission !== 'denied') { | ||
3 | + Notification.requestPermission(); | ||
4 | + } | ||
5 | +} | ||
6 | + | ||
7 | + | ||
1 | socket = new WebSocket("ws://" + window.location.host + "/"); | 8 | socket = new WebSocket("ws://" + window.location.host + "/"); |
2 | 9 | ||
3 | socket.onmessage = function(e) { | 10 | socket.onmessage = function(e) { |
@@ -20,16 +27,7 @@ socket.onmessage = function(e) { | @@ -20,16 +27,7 @@ socket.onmessage = function(e) { | ||
20 | var notification = new Notification("", options); | 27 | var notification = new Notification("", options); |
21 | 28 | ||
22 | setTimeout(notification.close.bind(notification), 3000); | 29 | setTimeout(notification.close.bind(notification), 3000); |
23 | - } else if (Notification.permission !== 'denied') { | ||
24 | - Notification.requestPermission(function (permission) { | ||
25 | - // If the user accepts, let's create a notification | ||
26 | - if (permission === "granted") { | ||
27 | - var notification = new Notification("", options); | ||
28 | - | ||
29 | - setTimeout(notification.close.bind(notification), 3000); | ||
30 | - } | ||
31 | - }); | ||
32 | - } | 30 | + } |
33 | } | 31 | } |
34 | } | 32 | } |
35 | } | 33 | } |