From 8e041efb86b12d8ef62e9dfb22e8a120731c4504 Mon Sep 17 00:00:00 2001 From: Tim Windelschmidt Date: Wed, 16 Sep 2015 17:33:56 +0200 Subject: [PATCH] Moved the Notifications into the AngularJS System --- node/public/js/app.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/node/public/js/app.js b/node/public/js/app.js index bad3237..dee81b3 100644 --- a/node/public/js/app.js +++ b/node/public/js/app.js @@ -1,6 +1,7 @@ 'use strict'; var gpower; +var laststate; angular.module('roomstateapp.controllers', []). controller('StatusCtrl', function ($scope, $http, Socket) { @@ -20,6 +21,7 @@ angular.module('roomstateapp.controllers', []). Socket.on('sdata', function(message) { console.log("received data from server: " + message.data.names); + stateNotification(message.data.state); $scope.simple = message.data; gpower.refresh(message.data.power); }); @@ -82,3 +84,15 @@ gpower = new JustGage({ }); }); + +function stateNotification(state) { + 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) { + laststate = false; + showNotification("CTDO - Staus", "Der Chaostreff ist nun geschlossen", "/img/red.png", 4); + } else { + laststate = state; + } +}