From d17c24bde74ca7f1b47c63e830d4c80f6d5c4851 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Ple=C3=9F?= Date: Sun, 4 Sep 2022 14:17:54 +0200 Subject: [PATCH] added comments, fixed if sytax, fixed console log --- public/js/app.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/public/js/app.js b/public/js/app.js index 55756be..41ff93b 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -5,6 +5,7 @@ var gpower; angular.module('roomstateapp.controllers', []). controller('StatusCtrl', function ($scope, $http, Socket) { + // on page load request current data via simple API. $http({ method: 'GET', url: '/api/simple/v2' @@ -18,8 +19,9 @@ angular.module('roomstateapp.controllers', []). console.log("error getting data"); }); + // while page is loaded, new data will arrive via Websocket. Socket.on('sdata', function(message) { - console.log("received data from server: " + message.data.names); + console.log("received data from server: " + JSON.stringify(message.data)); $scope.simple = message.data; gpower.refresh(message.data.power); }); @@ -61,7 +63,7 @@ angular.module('roomstateapp.services', []). angular.module('roomstateapp.statusfilter', []).filter('statustostring', function() { return function(input) { - return input == true ? 'geöffnet' : input == false ? 'geschlossen' : 'unbekannt'; + return input === true ? 'geöffnet' : input === false ? 'geschlossen' : 'unbekannt'; }; });