From 7ea5b4763007cd48bd13d7ccefd054952ea3ee8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 11 Sep 2018 00:16:13 +0200 Subject: [PATCH] Catch undefined Notification for IE Notification is not defined on IE. Also it is better to put javascript in the js files. issue7683 review54341002 --- index.html | 2 -- src/bus.js | 7 ++++++- src/sao.js | 6 ++++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/index.html b/index.html index 38b89c3a54..7277a11de8 100644 --- a/index.html +++ b/index.html @@ -93,8 +93,6 @@ this repository contains the full copyright notices and license terms. --> } } }); - Notification.requestPermission(); - Sao.login(); }); diff --git a/src/bus.js b/src/bus.js index 5846cd3396..794648b66b 100644 --- a/src/bus.js +++ b/src/bus.js @@ -59,7 +59,12 @@ Sao.Bus.handle = function(message) { var notify = function(message) { - if (Notification.permission != "granted") { + try { + if (Notification.permission != "granted") { + return; + } + } catch (e) { + (console.error || console.log).call(console, e, e.stack); return; } diff --git a/src/sao.js b/src/sao.js index 7664788ac0..5cdcbacd13 100644 --- a/src/sao.js +++ b/src/sao.js @@ -1003,6 +1003,12 @@ var Sao = {}; jQuery(document).ready(function() { set_shortcuts(); + try { + Notification.requestPermission(); + } catch (e) { + (console.error || console.log).call(console, e, e.stack); + } + Sao.login(); }); function set_shortcuts() {