From c95ca0445a3c4735dc65b7c1a3d4cff6c8ec755f Mon Sep 17 00:00:00 2001 From: Garry Newman Date: Tue, 12 Apr 2016 10:49:34 +0100 Subject: [PATCH] Allow using password param to connect --- js/connection.js | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/js/connection.js b/js/connection.js index 30aea0f..4dce60f 100644 --- a/js/connection.js +++ b/js/connection.js @@ -1,12 +1,14 @@ app.controller( 'ConnectionController', ConnectionController ); -function ConnectionController( $scope, rconService, $routeParams, $timeout ) +function ConnectionController( $scope, rconService, $routeParams, $timeout, $location ) { $scope.Address = ""; $scope.Password = ""; $scope.SaveConnection = true; + console.log( $location.search ); + if ( localStorage.previousConnections != null ) $scope.PreviousConnects = angular.fromJson( localStorage.previousConnections ); @@ -53,13 +55,31 @@ function ConnectionController( $scope, rconService, $routeParams, $timeout ) { $scope.Address = $routeParams.address; + // + // If a password was passed as a search param, use that + // + var pw = $location.search().password; + if ( pw ) + { + $scope.Password = pw; + $location.search( "password", null ); + } + if ( $scope.Address != null ) { + // If we have a password (passed as a search param) then connect using that + if ( $scope.Password != "" ) + { + $scope.Connect(); + return; + } + var foundAddress = Enumerable.From( $scope.PreviousConnects ).Where( function ( x ) { return x.Address == $scope.Address } ).First(); if ( foundAddress != null ) { $scope.ConnectTo( foundAddress ); - } + } + } }, 20 );