Skip to content

Commit

Permalink
Check browser support
Browse files Browse the repository at this point in the history
  • Loading branch information
Naoto Takai committed Feb 13, 2017
1 parent a12d113 commit 2bbb957
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 7 additions & 1 deletion app/assets/javascripts/kuroko2/application.js
Expand Up @@ -40,6 +40,10 @@ jQuery(function ($) {
}

$('#notification').click(function (e) {
if (!('Notification' in window)) {
return;
}

if (Notification.permission === 'default') {
Notification.requestPermission(function (permission) {
if (permission === "granted") {
Expand All @@ -57,5 +61,7 @@ jQuery(function ($) {
}
});

showNotificationStatus();
if ('Notification' in window) {
showNotificationStatus();
}
});
4 changes: 4 additions & 0 deletions app/assets/javascripts/kuroko2/job_instances.js
Expand Up @@ -4,6 +4,10 @@
jQuery(function ($) {
var logIntervalId;
var notifyIfNeeded = function (status, name) {
if (!('Notification' in window)) {
return;
}

if (Notification.permission === 'granted' && Cookies.get('notification') === 'on') {
var notification = new Notification(
"[" + status + "] " + name,
Expand Down

0 comments on commit 2bbb957

Please sign in to comment.