From 8ab8437d25f15d3d0ada06709bf4e329fe27a2e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8B=E1=85=A2=E1=84=91=E1=85=B3=E1=86=AF=20=E1=84=82?= =?UTF-8?q?=E1=85=A9=E1=84=90=E1=85=B3=E1=84=87=E1=85=AE=E1=86=A8?= Date: Tue, 11 Dec 2018 10:47:51 +0900 Subject: [PATCH] Fix: Notification check for IE --- src/web/client/license_timer.html | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/src/web/client/license_timer.html b/src/web/client/license_timer.html index 4b697a0..9642029 100644 --- a/src/web/client/license_timer.html +++ b/src/web/client/license_timer.html @@ -82,18 +82,31 @@ var timeOutEventID; function ShowNotifyTimeOver(timeLeft) { - if(Notification) { // except IE - Notification.requestPermission(function (result) { - Notification.permission = result; + var isNotificationIsSupported = !!(window.Notification /* W3C Specification */ || win.webkitNotifications /* old WebKit Browsers */ || navigator.mozNotification /* Firefox for Android and Firefox OS */) - console.log(result); - if(result !== "denied") + if(isNotificationIsSupported) { + if(Notification) { // prepared browser for using Notification + if(Notification.permission === "granted") { AddNotifyEventByNotification(timeLeft); - else + return; + } + + Notification.requestPermission(function (result) { + Notification.permission = result; + + if(result === "granted") { + AddNotifyEventByNotification(timeLeft); + return; + } + AddNotifyEventByAlert(timeLeft); - }); - } else { // IE - console.log("no notification"); + }); + } else { // not prepared browser for using Notification + console.log("no notification - !Notification"); + AddNotifyEventByAlert(timeLeft); + } + } else { // not prepared browser for using Notification - IE + console.log("no notification - Notification in window"); AddNotifyEventByAlert(timeLeft); } }