From 172ee95216df367e88aa0c110a8429ce5c7ecbf1 Mon Sep 17 00:00:00 2001 From: alexfriesen Date: Wed, 18 May 2016 14:10:03 +0200 Subject: [PATCH] rconService.getUsers() will get and parse the userdata PlayerInfo displays Info and provide a link to steam profile Dropdown in the Playerlist offers more options the selected Player --- html/playerInfo.html | 44 +++++++++++++++++++++++++++++++++++++++++--- html/playerlist.html | 18 +++++++++++++++++- js/playerInfo.js | 32 ++++++++++++++++++++++++++++++++ js/playerlist.js | 6 +++--- js/rconService.js | 17 ++++++++++++++--- 5 files changed, 107 insertions(+), 10 deletions(-) diff --git a/html/playerInfo.html b/html/playerInfo.html index 781ddfa..d44223e 100644 --- a/html/playerInfo.html +++ b/html/playerInfo.html @@ -1,9 +1,47 @@
- Info about player {{userid}} +
-

View XP info for this player

-Show info about this player here +
+ +

+ Player: {{getUsername()}} +
+ +
+

+ + + +
+ +
+

+ Info +

+ +
+ This Player is currently not connected to this server! +
+
+ +
+

{{key}}: {{value}}

+
+
\ No newline at end of file diff --git a/html/playerlist.html b/html/playerlist.html index 4feacba..db35f53 100644 --- a/html/playerlist.html +++ b/html/playerlist.html @@ -33,8 +33,24 @@ diff --git a/js/playerInfo.js b/js/playerInfo.js index 92d07a2..87c2dc8 100644 --- a/js/playerInfo.js +++ b/js/playerInfo.js @@ -4,4 +4,36 @@ app.controller( 'PlayerInfoController', PlayerInfoController ); function PlayerInfoController( $scope, rconService, $routeParams ) { $scope.userid = $routeParams.userid; + + $scope.info = null; + + $scope.refresh = function () + { + rconService.getUsers($scope, function(users) { + + for(var i in users) { + if(users[i].SteamID === $scope.userid){ + + // set player data + $scope.info = users[i]; + + return; + } + } + + // info not found + $scope.info = null; + }); + } + + $scope.getUsername = function () + { + if($scope.info && $scope.info.DisplayName) { + return $scope.info.DisplayName; + } + + return $scope.userid; + } + + rconService.InstallService( $scope, $scope.refresh ) } \ No newline at end of file diff --git a/js/playerlist.js b/js/playerlist.js index 390ab88..45955d2 100644 --- a/js/playerlist.js +++ b/js/playerlist.js @@ -3,14 +3,14 @@ app.controller( 'PlayerListController', PlayerListController ); function PlayerListController( $scope, rconService, $interval ) { - $scope.Output = new Array(); + $scope.Output = []; $scope.OrderBy = '-ConnectedSeconds'; $scope.Refresh = function () { - rconService.Request( "playerlist", $scope, function ( msg ) + rconService.getUsers($scope, function ( users ) { - $scope.Players = JSON.parse( msg.Message ); + $scope.Players = users; }); } diff --git a/js/rconService.js b/js/rconService.js index 58aa456..4703e69 100644 --- a/js/rconService.js +++ b/js/rconService.js @@ -1,9 +1,9 @@ function RconService() { - var s = {}; - - s.Callbacks = {}; + var s = { + Callbacks: {} + }; s.Connect = function ( addr, pass ) { @@ -102,5 +102,16 @@ function RconService() } } + s.getUsers = function(scope, success) { + this.Request( "playerlist", scope, function ( response ) + { + var players = JSON.parse( response.Message ); + + if(typeof success === 'function') { + success.call(scope, players); + } + }); + } + return s; } \ No newline at end of file