Skip to content
Permalink
Browse files

Add the table for GameSpy trackers.

  • Loading branch information...
roncli committed Jun 29, 2015
1 parent b46818f commit 57ec1692e8416bbad0594343891074335d64f8c6
Showing with 124 additions and 2 deletions.
  1. +74 −1 public/js/ddsn.js
  2. +47 −1 public/templates/add-server-server.htm
  3. +3 −0 websocket.js
@@ -18,6 +18,20 @@ var app = angular.module("ddsn", []),

var ws, scope;

app.directive("convertToNumber", function() {
return {
require: "ngModel",
link: function(scope, element, attrs, ngModel) {
ngModel.$parsers.push(function(val) {
return +val;
});
ngModel.$formatters.push(function(val) {
return val ? val.toString() : "";
});
}
};
});

app.directive("offline", function() {
return {
restrict: "E",
@@ -133,6 +147,53 @@ var app = angular.module("ddsn", []),
app.controller("ddsn", ["$scope", function($scope) {
$scope.data = data;

$scope.getRegionName = function(regionId) {
switch (regionId) {
case 0:
return "None";
case 1:
return "Southeast US";
case 2:
return "Western US";
case 3:
return "Midwest US";
case 4:
return "Northwest US & Western Canada";
case 5:
return "Northeast US & Eastern Canada";
case 6:
return "United Kingdom";
case 7:
return "Continental Europe";
case 8:
return "Central Asia & Middle East";
case 9:
return "Southeast Asia & Pacific";
case 10:
return "Africa";
case 11:
return "Australia & New Zealand";
case 12:
return "Central America & South America";
default:
return "Unknown";
}
};

$scope.addServerServerRemoveTracker = function(index) {
data.settings.addServer.server.trackers.splice(index, 1);
};

$scope.addServerServerAddTracker = function() {
data.settings.addServer.server.trackers.push({
region: data.settings.addServer.server.addTrackerRegion,
server: data.settings.addServer.server.addTrackerServer,
port: data.settings.addServer.server.addTrackerPort
});
data.settings.addServer.server.addTrackerServer = undefined;
data.settings.addServer.server.addTrackerPort = undefined;
};

$scope.openMenu = function(ev, screen) {
$("button.server-tab").removeClass("btn-success").addClass("btn-primary");
$(ev.currentTarget).removeClass("btn-primary").addClass("btn-success");
@@ -162,7 +223,19 @@ var app = angular.module("ddsn", []),
};

$scope.updateAddServerServerFramerate = function() {
data.settings.addServer.server.framerateValid = typeof data.settings.addServer.server.framerate === "number" && data.settings.addServer.server.framerate >= 1 && data.settings.addServer.server.framerate <= 999 && data && data.settings.addServer.server.framerate % 1 === 0;
data.settings.addServer.server.framerateValid = typeof data.settings.addServer.server.framerate === "number" && data.settings.addServer.server.framerate >= 1 && data.settings.addServer.server.framerate <= 999 && data.settings.addServer.server.framerate % 1 === 0;
};

$scope.updateAddServerServerTrackerRegion = function() {
data.settings.addServer.server.addTrackerRegionValid = typeof data.settings.addServer.server.addTrackerRegion === "number" && data.settings.addServer.server.addTrackerRegion >= 0 && data.settings.addServer.server.addTrackerRegion <= 12 && data.settings.addServer.server.addTrackerRegion % 1 === 0;
};

$scope.updateAddServerServerTrackerServer = function() {
data.settings.addServer.server.addTrackerServerValid = typeof data.settings.addServer.server.addTrackerServer === "string" && data.settings.addServer.server.addTrackerServer.length !== 0;
};

$scope.updateAddServerServerTrackerPort = function() {
data.settings.addServer.server.addTrackerPortValid = typeof data.settings.addServer.server.addTrackerPort === "number" && data.settings.addServer.server.addTrackerPort >= 1 && data.settings.addServer.server.addTrackerPort <= 65535 && data.settings.addServer.server.addTrackerPort % 1 === 0;
};

$scope.updateSettingsDescent3Path = function() {
@@ -30,7 +30,53 @@
<span class="input-group-addon" style="width: 100%; text-align: left;">
<input type="checkbox" ng-model="data.settings.addServer.server.playerMessages" />
</span>
</div><br/>
</div><br />
<table class="table table-hover table-condensed">
<tr>
<th colspan="4" class="text-center">Broadcast to these GameSpy Trackers:</th>
</tr>
<tr>
<th>Region</th>
<th>Server</th>
<th>Port</th>
<th></th>
</tr>
<tr ng-repeat="tracker in data.settings.addServer.server.trackers">
<td>{{getRegionName(tracker.region)}}</td>
<td>{{tracker.server}}</td>
<td>{{tracker.port}}</td>
<td><button class="btn btn-xs btn-danger" ng-click="addServerServerRemoveTracker($index)">Remove</button></td>
</tr>
<tr>
<th colspan="4" class="text-center">Add Other GameSpy Trackers:</th>
</tr>
<tr>
<td ng-class="{true: '', false: 'has-error'}[data.settings.addServer.server.addTrackerRegionValid]">
<select class="form-control" ng-model="data.settings.addServer.server.addTrackerRegion" convert-to-number ng-change="updateAddServerServerTrackerRegion()">
<option value="0">None</option>
<option value="1">Southeast US</option>
<option value="2">Western US</option>
<option value="3">Midwest US</option>
<option value="4">Northwest US & Western Canada</option>
<option value="5">Northeast US & Eastern Canada</option>
<option value="6">United Kingdom</option>
<option value="7">Continental Europe</option>
<option value="8">Central Asia & Middle East</option>
<option value="9">Southeast Asia & Pacific</option>
<option value="10">Africa</option>
<option value="11">Australia & New Zealand</option>
<option value="12">Central America & South America</option>
</select>
</td>
<td ng-class="{true: '', false: 'has-error'}[data.settings.addServer.server.addTrackerServerValid]">
<input type="text" class="form-control" placeholder="GameSpy server address" size="25" ng-model="data.settings.addServer.server.addTrackerServer" ng-blur="updateAddServerServerTrackerServer()" />
</td>
<td ng-class="{true: '', false: 'has-error'}[data.settings.addServer.server.addTrackerPortValid]">
<input type="number" min="0" max="65535" class="form-control" placeholder="Port" size="6" maxlength="5" ng-model="data.settings.addServer.server.addTrackerPort" ng-blur="updateAddServerServerTrackerPort()" />
</td>
<td><button class="btn btn-xs btn-success" ng-click="addServerServerAddTracker()" ng-disabled="!data.settings.addServer.server.addTrackerServerValid || !data.settings.addServer.server.addTrackerPortValid">Add</button></td>
</tr>
</table><br/>
<div class="alert alert-danger" role="alert" ng-if="!data.settings.addServer.server.portValid"><span class="glyphicon glyphicon-alert"></span> You must enter a valid port between 0 and 65535.</div>
<div class="alert alert-danger" role="alert" ng-if="!data.settings.addServer.server.gamespyportValid"><span class="glyphicon glyphicon-alert"></span> You must enter a valid GameSpy port between 0 and 65535.</div>
<div class="alert alert-danger" role="alert" ng-if="!data.settings.addServer.server.portsDiffer"><span class="glyphicon glyphicon-alert"></span> Port and GameSpy port must be different.</div>
@@ -76,6 +76,9 @@ module.exports = function() {
settings.default.server.gamespyportValid = true;
settings.default.server.portsDiffer = true;
settings.default.server.framerateValid = true;
settings.default.server.addTrackerRegionValid = false;
settings.default.server.addTrackerServerValid = false;
settings.default.server.addTrackerPortValid = false;
settings.addServer = JSON.parse(JSON.stringify(settings.default));

// Get network interfaces.

0 comments on commit 57ec169

Please sign in to comment.
You can’t perform that action at this time.