diff --git a/html/playerlist.html b/html/playerlist.html
index 3f7e4e6..3b4b404 100644
--- a/html/playerlist.html
+++ b/html/playerlist.html
@@ -1,10 +1,10 @@
diff --git a/index.html b/index.html
index 84d3ed8..a8ce0b9 100644
--- a/index.html
+++ b/index.html
@@ -20,7 +20,7 @@
-
@@ -68,6 +68,7 @@
+
diff --git a/js/app.js b/js/app.js
index da3b32c..9f6848a 100644
--- a/js/app.js
+++ b/js/app.js
@@ -11,11 +11,12 @@ app.config( function ( $mdThemingProvider, $routeProvider )
'default': '700'
}).accentPalette( 'blue' );
- $routeProvider.when( "/console", { Title: "Console", templateUrl: "html/console.html", Nav: true } )
- $routeProvider.when( "/playerlist", { Title: "Player List", templateUrl: "html/playerlist.html", Nav: true } )
- $routeProvider.when( "/player/:userid", { Title: "Player Info", templateUrl: "html/playerInfo.html" } )
- $routeProvider.when( "/player/:userid/xp", { Title: "Player Xp Stats", templateUrl: "html/playerXp.html" } )
- .otherwise( { redirectTo: '/console' } );
+ $routeProvider.when( "/home", { Title: "Home", templateUrl: "html/home.html" } )
+ $routeProvider.when( "/:address/console", { Title: "Console", templateUrl: "html/console.html", Nav: true } )
+ $routeProvider.when( "/:address/playerlist", { Title: "Player List", templateUrl: "html/playerlist.html", Nav: true } )
+ $routeProvider.when( "/:address/player/:userid", { Title: "Player Info", templateUrl: "html/playerInfo.html" } )
+ $routeProvider.when( "/:address/player/:userid/xp", { Title: "Player Xp Stats", templateUrl: "html/playerXp.html" } )
+ $routeProvider.otherwise( { redirectTo: '/home' } );
} );
@@ -24,6 +25,7 @@ app.controller( 'RconController', RconController );
function RconController( $scope, $rootScope, rconService, $mdSidenav, $timeout, $mdDialog, $route )
{
$scope.$route = $route;
+
$scope.pages = $.map( $route.routes, function ( value, index )
{
@@ -40,6 +42,11 @@ function RconController( $scope, $rootScope, rconService, $mdSidenav, $timeout,
return rconService.IsConnected();
}
+ $rootScope.Nav = function ( url )
+ {
+ return url.replace( ":address", rconService.Address );
+ }
+
$rootScope.$on( '$stateChangeStart', function ( next, current )
{
console.log( next );
@@ -50,6 +57,7 @@ function RconController( $scope, $rootScope, rconService, $mdSidenav, $timeout,
$scope.Connected = true;
$scope.$broadcast( "OnConnected" );
$scope.$digest();
+ $scope.address = rconService.Address;
}
rconService.OnClose = function ( ev )
@@ -73,55 +81,6 @@ function RconController( $scope, $rootScope, rconService, $mdSidenav, $timeout,
}
}
-app.controller( 'ConnectionController', ConnectionController );
-
-function ConnectionController( $scope, rconService )
-{
- $scope.Address = "";
- $scope.Password = "";
- $scope.SaveConnection = true;
-
- if ( localStorage.previousConnections != null )
- $scope.PreviousConnects = angular.fromJson( localStorage.previousConnections );
-
- if ( $scope.PreviousConnects == null )
- $scope.PreviousConnects = new Array();
-
- $scope.Connect = function ()
- {
- $scope.LastErrorMessage = null;
- rconService.Connect( $scope.Address, $scope.Password );
- }
-
- $scope.ConnectTo = function ( c )
- {
- $scope.SaveConnection = false;
- $scope.LastErrorMessage = null;
- rconService.Connect( c.Address, c.Password );
- }
-
- $scope.$on( "OnDisconnected", function ( x, ev )
- {
- console.log( ev );
- $scope.LastErrorMessage = "Connection was closed - Error " + ev.code;
- $scope.$digest();
- } );
-
- $scope.$on( "OnConnected", function ( x, ev )
- {
- if ( $scope.SaveConnection )
- {
- $scope.PreviousConnects.push( { Address: $scope.Address, Password: $scope.Password } );
- localStorage.previousConnections = angular.toJson( $scope.PreviousConnects );
- }
- } );
-}
-
-
-
-
-
-
app.filter( 'SecondsToDuration', [SecondsToDuration] );
function SecondsToDuration()
diff --git a/js/connection.js b/js/connection.js
new file mode 100644
index 0000000..28f2db8
--- /dev/null
+++ b/js/connection.js
@@ -0,0 +1,64 @@
+
+app.controller( 'ConnectionController', ConnectionController );
+
+function ConnectionController( $scope, rconService, $routeParams, $timeout )
+{
+ $scope.Address = "";
+ $scope.Password = "";
+ $scope.SaveConnection = true;
+
+ if ( localStorage.previousConnections != null )
+ $scope.PreviousConnects = angular.fromJson( localStorage.previousConnections );
+
+ if ( $scope.PreviousConnects == null )
+ $scope.PreviousConnects = new Array();
+
+ $scope.Connect = function ()
+ {
+ $scope.LastErrorMessage = null;
+ rconService.Connect( $scope.Address, $scope.Password );
+ }
+
+ $scope.ConnectTo = function ( c )
+ {
+ $scope.SaveConnection = false;
+ $scope.LastErrorMessage = null;
+ rconService.Connect( c.Address, c.Password );
+ }
+
+ $scope.$on( "OnDisconnected", function ( x, ev )
+ {
+ console.log( ev );
+ $scope.LastErrorMessage = "Connection was closed - Error " + ev.code;
+ $scope.$digest();
+ } );
+
+ $scope.$on( "OnConnected", function ( x, ev )
+ {
+ if ( $scope.SaveConnection )
+ {
+ $scope.PreviousConnects.push( { Address: $scope.Address, Password: $scope.Password } );
+ localStorage.previousConnections = angular.toJson( $scope.PreviousConnects );
+ }
+ } );
+
+
+ //
+ // If a server address is passed in.. try to connect if we have a saved entry
+ //
+ $timeout( function ()
+ {
+ $scope.Address = $routeParams.address;
+
+ if ( $scope.Address != null )
+ {
+ var foundAddress = Enumerable.From( $scope.PreviousConnects ).Where( function ( x ) { return x.Address == $scope.Address } ).First();
+ if ( foundAddress != null )
+ {
+ $scope.ConnectTo( foundAddress );
+ }
+ }
+
+ }, 20 );
+}
+
diff --git a/js/rconService.js b/js/rconService.js
index 15db19e..01fed47 100644
--- a/js/rconService.js
+++ b/js/rconService.js
@@ -12,6 +12,7 @@ function RconService()
s.Connect = function ( addr, pass )
{
s.Socket = new WebSocket( "ws://" + addr + "/" + pass );
+ s.Address = addr;
s.Socket.onmessage = function ( e )
{
@@ -49,8 +50,6 @@ function RconService()
s.Socket.onopen = s.OnOpen;
s.Socket.onclose = s.OnClose;
s.Socket.onerror = s.OnError;
-
- console.log( s.Socket );
}
s.Command = function ( msg, identifier )