add Disconnect
added disconnect feature auto formatted js/html code
This commit is contained in:
@@ -1,101 +1,114 @@
|
||||
var app = angular.module('RconApp', ['ngRoute', 'nvd3']);
|
||||
|
||||
app.service('rconService', [RconService]);
|
||||
|
||||
var app = angular.module( 'RconApp', ['ngRoute', 'nvd3'] );
|
||||
app.config(function($routeProvider) {
|
||||
$routeProvider.when("/home", {Title: "Home"});
|
||||
$routeProvider.when("/:address/info", {
|
||||
Title: "Server",
|
||||
templateUrl: "html/serverInfo.html",
|
||||
Nav: true
|
||||
});
|
||||
$routeProvider.when("/:address/console", {
|
||||
Title: "Console",
|
||||
templateUrl: "html/console.html",
|
||||
Nav: true
|
||||
});
|
||||
$routeProvider.when("/:address/chat", {
|
||||
Title: "Chat",
|
||||
templateUrl: "html/chat.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.otherwise({redirectTo: '/home'});
|
||||
});
|
||||
|
||||
app.service( 'rconService', [RconService] );
|
||||
app.controller('RconController', RconController);
|
||||
|
||||
app.config( function ( $routeProvider )
|
||||
{
|
||||
$routeProvider.when( "/home", { Title: "Home" } )
|
||||
$routeProvider.when( "/:address/info", { Title: "Server", templateUrl: "html/serverInfo.html", Nav: true } )
|
||||
$routeProvider.when( "/:address/console", { Title: "Console", templateUrl: "html/console.html", Nav: true } )
|
||||
$routeProvider.when( "/:address/chat", { Title: "Chat", templateUrl: "html/chat.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' } );
|
||||
function RconController($scope, $rootScope, rconService, $timeout, $route) {
|
||||
$scope.$route = $route;
|
||||
|
||||
} );
|
||||
$scope.pages = $.map($route.routes, function(value, index) {
|
||||
if (value.Nav) {
|
||||
return [value];
|
||||
}
|
||||
});
|
||||
|
||||
app.controller( 'RconController', RconController );
|
||||
$scope.OpenLeftMenu = function() {
|
||||
$mdSidenav('left').toggle();
|
||||
};
|
||||
|
||||
function RconController( $scope, $rootScope, rconService, $timeout, $route )
|
||||
{
|
||||
$scope.$route = $route;
|
||||
|
||||
$scope.IsConnected = function() {
|
||||
return rconService.IsConnected();
|
||||
}
|
||||
|
||||
$scope.pages = $.map( $route.routes, function ( value, index )
|
||||
{
|
||||
return [value];
|
||||
} );
|
||||
$rootScope.Nav = function(url) {
|
||||
return url.replace(":address", rconService.Address);
|
||||
}
|
||||
|
||||
$scope.OpenLeftMenu = function ()
|
||||
{
|
||||
$mdSidenav( 'left' ).toggle();
|
||||
};
|
||||
$rootScope.$on('$stateChangeStart', function(next, current) {
|
||||
console.log(next);
|
||||
});
|
||||
|
||||
$scope.IsConnected = function ()
|
||||
{
|
||||
return rconService.IsConnected();
|
||||
}
|
||||
rconService.OnOpen = function() {
|
||||
$scope.Connected = true;
|
||||
$scope.$broadcast("OnConnected");
|
||||
$scope.$digest();
|
||||
$scope.address = rconService.Address;
|
||||
}
|
||||
|
||||
$rootScope.Nav = function ( url )
|
||||
{
|
||||
return url.replace( ":address", rconService.Address );
|
||||
}
|
||||
rconService.OnClose = function(ev) {
|
||||
$scope.$broadcast("OnDisconnected", ev);
|
||||
$scope.$digest();
|
||||
}
|
||||
|
||||
$rootScope.$on( '$stateChangeStart', function ( next, current )
|
||||
{
|
||||
console.log( next );
|
||||
} );
|
||||
rconService.OnError = function(ev) {
|
||||
$scope.$broadcast("OnConnectionError", ev);
|
||||
$scope.$digest();
|
||||
}
|
||||
|
||||
rconService.OnOpen = function ()
|
||||
{
|
||||
$scope.Connected = true;
|
||||
$scope.$broadcast( "OnConnected" );
|
||||
$scope.$digest();
|
||||
$scope.address = rconService.Address;
|
||||
}
|
||||
rconService.OnMessage = function(msg) {
|
||||
$scope.$apply(function() {
|
||||
$scope.$broadcast("OnMessage", msg);
|
||||
});
|
||||
}
|
||||
|
||||
rconService.OnClose = function ( ev )
|
||||
{
|
||||
$scope.$broadcast( "OnDisconnected", ev );
|
||||
$scope.$digest();
|
||||
}
|
||||
$scope.Disconnect = function() {
|
||||
if (confirm('Do you really want to disconnect?')) {
|
||||
rconService.Disconnect();
|
||||
$scope.Connected = false;
|
||||
|
||||
rconService.OnError = function ( ev )
|
||||
{
|
||||
$scope.$broadcast( "OnConnectionError", ev );
|
||||
$scope.$digest();
|
||||
}
|
||||
|
||||
rconService.OnMessage = function ( msg )
|
||||
{
|
||||
$scope.$apply( function ()
|
||||
{
|
||||
$scope.$broadcast( "OnMessage", msg );
|
||||
} );
|
||||
}
|
||||
$scope.address = '#/home';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
app.filter( 'SecondsToDuration', [SecondsToDuration] );
|
||||
app.filter('SecondsToDuration', [SecondsToDuration]);
|
||||
|
||||
function SecondsToDuration()
|
||||
{
|
||||
return function ( input )
|
||||
{
|
||||
input = parseInt( input );
|
||||
function SecondsToDuration() {
|
||||
return function(input) {
|
||||
input = parseInt(input);
|
||||
|
||||
var out = "";
|
||||
var hours = Math.floor( input / 3600 );
|
||||
if ( input > 3600 ) out += hours + "h";
|
||||
var out = "";
|
||||
var hours = Math.floor(input / 3600);
|
||||
if (input > 3600)
|
||||
out += hours + "h";
|
||||
|
||||
var minutes = Math.floor( input / 60 ) % 60;
|
||||
if ( input > 60 ) out += minutes + "m";
|
||||
var minutes = Math.floor(input / 60) % 60;
|
||||
if (input > 60)
|
||||
out += minutes + "m";
|
||||
|
||||
var seconds = input % 60;
|
||||
out += seconds + "s";
|
||||
var seconds = input % 60;
|
||||
out += seconds + "s";
|
||||
|
||||
return out;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user