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; + } +}