From e4fae9ca530b7a3ae244264fb5d225244666195d Mon Sep 17 00:00:00 2001 From: Tim Windelschmidt Date: Wed, 6 Jan 2016 08:28:39 +0100 Subject: [PATCH] Moved the if(enabled) to notification api --- node/public/js/app.js | 4 +-- node/public/js/vendor/notification.js | 42 ++++++++++++++------------- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/node/public/js/app.js b/node/public/js/app.js index 9b7879b..775a50e 100644 --- a/node/public/js/app.js +++ b/node/public/js/app.js @@ -86,10 +86,10 @@ gpower = new JustGage({ }); function stateNotification(state) { - if (state == true && laststate != true && laststate != null && enabledNotifications) { + if (state == true && laststate != true && laststate != null) { laststate = true; showNotification("CTDO - Status", "Der Chaostreff ist nun offen.", "/img/green.png", 4); - } else if (state == false && laststate != false && laststate != null && enabledNotifications) { + } else if (state == false && laststate != false && laststate != null) { laststate = false; showNotification("CTDO - Staus", "Der Chaostreff ist nun geschlossen", "/img/red.png", 4); } else { diff --git a/node/public/js/vendor/notification.js b/node/public/js/vendor/notification.js index d0d0cad..214c584 100644 --- a/node/public/js/vendor/notification.js +++ b/node/public/js/vendor/notification.js @@ -26,25 +26,27 @@ function toggleNotifications() { function showNotification(name, body, icon, timeout) { - var instance = new Notification( - name, { - body: body, - icon: icon - } - ); + if (enabledNotifications) { + var instance = new Notification( + name, { + body: body, + icon: icon + } + ); - instance.onclick = function () { - // Something to do - }; - instance.onerror = function () { - // Something to do - }; - instance.onshow = function () { - setTimeout(function(){ - instance.close(); - }, timeout * 1000); - }; - instance.onclose = function () { - // Something to do - }; + instance.onclick = function () { + // Something to do + }; + instance.onerror = function () { + // Something to do + }; + instance.onshow = function () { + setTimeout(function(){ + instance.close(); + }, timeout * 1000); + }; + instance.onclose = function () { + // Something to do + }; + } }