renamed rconService.getUsers() to rconService.getPlayers() to be consistent

console History rotates correctly up and down
This commit is contained in:
alexfriesen
2016-05-19 18:58:36 +02:00
parent 12c58af9af
commit 90c60f9fa9
4 changed files with 30 additions and 10 deletions
+19 -2
View File
@@ -11,8 +11,25 @@ function ConsoleController( $scope, rconService, $timeout )
{ {
switch(event.keyCode) { switch(event.keyCode) {
// Arrow Up Key // Arrow Key Up
case 38: case 38:
// rotate through commandHistory
$scope.commandHistoryIndex--;
if($scope.commandHistoryIndex < 0) {
$scope.commandHistoryIndex = $scope.commandHistory.length;
}
// set command from history
if($scope.commandHistory[$scope.commandHistoryIndex]) {
$scope.Command = $scope.commandHistory[$scope.commandHistoryIndex];
}
break;
// Arrow Key Down
case 40:
// rotate through commandHistory // rotate through commandHistory
$scope.commandHistoryIndex++; $scope.commandHistoryIndex++;
if($scope.commandHistoryIndex >= $scope.commandHistory.length) { if($scope.commandHistoryIndex >= $scope.commandHistory.length) {
@@ -28,7 +45,7 @@ function ConsoleController( $scope, rconService, $timeout )
default: default:
// reset command history index // reset command history index
$scope.commandHistoryIndex = 0; $scope.commandHistoryIndex = $scope.commandHistory.length;
break; break;
} }
} }
+8 -5
View File
@@ -9,29 +9,32 @@ function PlayerInfoController( $scope, rconService, $routeParams )
$scope.refresh = function () $scope.refresh = function ()
{ {
rconService.getUsers($scope, function(users) { rconService.getPlayers($scope, function(players) {
for(var i in users) { for(var i in players) {
if(users[i].SteamID === $scope.userid){ if(players[i].SteamID === $scope.userid){
// set player data // set player data
$scope.info = users[i]; $scope.info = players[i];
return; return;
} }
} }
// info not found // player not found
// reset data to null
$scope.info = null; $scope.info = null;
}); });
} }
$scope.getUsername = function () $scope.getUsername = function ()
{ {
// try to find players name in info
if($scope.info && $scope.info.DisplayName) { if($scope.info && $scope.info.DisplayName) {
return $scope.info.DisplayName; return $scope.info.DisplayName;
} }
// otherwise show the id
return $scope.userid; return $scope.userid;
} }
+2 -2
View File
@@ -8,9 +8,9 @@ function PlayerListController( $scope, rconService, $interval )
$scope.Refresh = function () $scope.Refresh = function ()
{ {
rconService.getUsers($scope, function ( users ) rconService.getPlayers($scope, function ( players )
{ {
$scope.Players = users; $scope.Players = players;
}); });
} }
+1 -1
View File
@@ -102,7 +102,7 @@ function RconService()
} }
} }
s.getUsers = function(scope, success) { s.getPlayers = function(scope, success) {
this.Request( "playerlist", scope, function ( response ) this.Request( "playerlist", scope, function ( response )
{ {
var players = JSON.parse( response.Message ); var players = JSON.parse( response.Message );