mirror of
https://github.com/OpenFusionProject/Client.git
synced 2024-11-22 05:30:05 +00:00
Adding and deleting servers works.
Still need to fix the add server validation Other changes: * Convert all files to spaces and fix indentation * We now write out the images.php and sponsor.php files if an endpoint url is defined for a server * Added comments
This commit is contained in:
parent
3d8cd79a55
commit
02f390499c
15
.gitignore
vendored
15
.gitignore
vendored
@ -1,20 +1,9 @@
|
||||
|
||||
locales/
|
||||
|
||||
*.dll
|
||||
|
||||
*.pak
|
||||
|
||||
OpenFusionClient.exe
|
||||
|
||||
*.bin
|
||||
|
||||
*.php
|
||||
OpenFusionClient.exe
|
||||
icudtl.dat
|
||||
|
||||
version
|
||||
|
||||
resources/app/files/assetInfo.php
|
||||
|
||||
resources/app/files/loginInfo.php
|
||||
|
||||
resources/app/files/rankurl.txt
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"autoupdate-check": true,
|
||||
"cache-swapping": false,
|
||||
"initial-setup-completed": true
|
||||
"autoupdate-check": true,
|
||||
"cache-swapping": false,
|
||||
"initial-setup-completed": true
|
||||
}
|
@ -1,19 +1,19 @@
|
||||
{
|
||||
"servers": [
|
||||
{
|
||||
"uuid": "d9773558-6ddf-4d00-8803-d830a22a842b",
|
||||
"description": "OpenFusion Public Server - Original",
|
||||
"ip": "144.202.52.9:23000",
|
||||
"version": "beta-20100104",
|
||||
"endpoint": "https://api.dexlabs.systems/"
|
||||
},
|
||||
{
|
||||
"uuid": "b84f6859-f500-41f2-bdfa-8e3746639ee9",
|
||||
"description": "OpenFusion Public Server - Academy",
|
||||
"ip": "144.202.52.9:24000",
|
||||
"version": "beta-20111013",
|
||||
"endpoint": "https://api.dexlabs.systems/academy/"
|
||||
}
|
||||
],
|
||||
"favorites": []
|
||||
"servers": [
|
||||
{
|
||||
"uuid": "d9773558-6ddf-4d00-8803-d830a22a842b",
|
||||
"description": "OpenFusion Public Server - Original",
|
||||
"ip": "144.202.52.9:23000",
|
||||
"version": "beta-20100104",
|
||||
"endpoint": "https://api.dexlabs.systems/"
|
||||
},
|
||||
{
|
||||
"uuid": "b84f6859-f500-41f2-bdfa-8e3746639ee9",
|
||||
"description": "OpenFusion Public Server - Academy",
|
||||
"ip": "144.202.52.9:24000",
|
||||
"version": "beta-20111013",
|
||||
"endpoint": "https://api.dexlabs.systems/academy/"
|
||||
}
|
||||
],
|
||||
"favorites": []
|
||||
}
|
@ -1,108 +1,108 @@
|
||||
{
|
||||
"versions": [
|
||||
{
|
||||
"name": "beta-20100104",
|
||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20100104/"
|
||||
},
|
||||
{
|
||||
"name": "beta-20100119",
|
||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20100119/"
|
||||
},
|
||||
{
|
||||
"name": "beta-20100207",
|
||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20100207/"
|
||||
},
|
||||
{
|
||||
"name": "beta-20100307",
|
||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20100307/"
|
||||
},
|
||||
{
|
||||
"name": "beta-20100322",
|
||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20100322/"
|
||||
},
|
||||
{
|
||||
"name": "beta-20100413",
|
||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20100413/"
|
||||
},
|
||||
{
|
||||
"name": "beta-20100502",
|
||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20100502/"
|
||||
},
|
||||
{
|
||||
"name": "beta-20100524",
|
||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20100524/"
|
||||
},
|
||||
{
|
||||
"name": "beta-20100604",
|
||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20100604/"
|
||||
},
|
||||
{
|
||||
"name": "beta-20100616",
|
||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20100616/"
|
||||
},
|
||||
{
|
||||
"name": "beta-20100711",
|
||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20100711/"
|
||||
},
|
||||
{
|
||||
"name": "beta-20100728",
|
||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20100728/"
|
||||
},
|
||||
{
|
||||
"name": "beta-20100909",
|
||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20100909/"
|
||||
},
|
||||
{
|
||||
"name": "beta-20101003",
|
||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20101003/"
|
||||
},
|
||||
{
|
||||
"name": "beta-20101011",
|
||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20101011/"
|
||||
},
|
||||
{
|
||||
"name": "beta-20101028",
|
||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20101028/"
|
||||
},
|
||||
{
|
||||
"name": "beta-20101123",
|
||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20101123/"
|
||||
},
|
||||
{
|
||||
"name": "beta-20110213",
|
||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20110213/"
|
||||
},
|
||||
{
|
||||
"name": "beta-20110314",
|
||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20110314/"
|
||||
},
|
||||
{
|
||||
"name": "beta-20110330",
|
||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20110330/"
|
||||
},
|
||||
{
|
||||
"name": "beta-20110424",
|
||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20110424/"
|
||||
},
|
||||
{
|
||||
"name": "beta-20110523",
|
||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20110523/"
|
||||
},
|
||||
{
|
||||
"name": "beta-20110725",
|
||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20110725/"
|
||||
},
|
||||
{
|
||||
"name": "beta-20110818",
|
||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20110818/"
|
||||
},
|
||||
{
|
||||
"name": "beta-20110912",
|
||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20110912/"
|
||||
},
|
||||
{
|
||||
"name": "beta-20111013",
|
||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20111013/"
|
||||
}
|
||||
]
|
||||
"versions": [
|
||||
{
|
||||
"name": "beta-20100104",
|
||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20100104/"
|
||||
},
|
||||
{
|
||||
"name": "beta-20100119",
|
||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20100119/"
|
||||
},
|
||||
{
|
||||
"name": "beta-20100207",
|
||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20100207/"
|
||||
},
|
||||
{
|
||||
"name": "beta-20100307",
|
||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20100307/"
|
||||
},
|
||||
{
|
||||
"name": "beta-20100322",
|
||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20100322/"
|
||||
},
|
||||
{
|
||||
"name": "beta-20100413",
|
||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20100413/"
|
||||
},
|
||||
{
|
||||
"name": "beta-20100502",
|
||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20100502/"
|
||||
},
|
||||
{
|
||||
"name": "beta-20100524",
|
||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20100524/"
|
||||
},
|
||||
{
|
||||
"name": "beta-20100604",
|
||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20100604/"
|
||||
},
|
||||
{
|
||||
"name": "beta-20100616",
|
||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20100616/"
|
||||
},
|
||||
{
|
||||
"name": "beta-20100711",
|
||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20100711/"
|
||||
},
|
||||
{
|
||||
"name": "beta-20100728",
|
||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20100728/"
|
||||
},
|
||||
{
|
||||
"name": "beta-20100909",
|
||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20100909/"
|
||||
},
|
||||
{
|
||||
"name": "beta-20101003",
|
||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20101003/"
|
||||
},
|
||||
{
|
||||
"name": "beta-20101011",
|
||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20101011/"
|
||||
},
|
||||
{
|
||||
"name": "beta-20101028",
|
||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20101028/"
|
||||
},
|
||||
{
|
||||
"name": "beta-20101123",
|
||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20101123/"
|
||||
},
|
||||
{
|
||||
"name": "beta-20110213",
|
||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20110213/"
|
||||
},
|
||||
{
|
||||
"name": "beta-20110314",
|
||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20110314/"
|
||||
},
|
||||
{
|
||||
"name": "beta-20110330",
|
||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20110330/"
|
||||
},
|
||||
{
|
||||
"name": "beta-20110424",
|
||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20110424/"
|
||||
},
|
||||
{
|
||||
"name": "beta-20110523",
|
||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20110523/"
|
||||
},
|
||||
{
|
||||
"name": "beta-20110725",
|
||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20110725/"
|
||||
},
|
||||
{
|
||||
"name": "beta-20110818",
|
||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20110818/"
|
||||
},
|
||||
{
|
||||
"name": "beta-20110912",
|
||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20110912/"
|
||||
},
|
||||
{
|
||||
"name": "beta-20111013",
|
||||
"url": "http://ht.cdn.turner.com/ff/big/beta-20111013/"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -19,6 +19,34 @@ function disableServerListButtons() {
|
||||
$('#of-deleteserver-button').prop('disabled', true);
|
||||
}
|
||||
|
||||
function addServer() {
|
||||
var jsontomodify = JSON.parse(remotefs.readFileSync(userdir+"\\servers.json"));
|
||||
|
||||
var server = {};
|
||||
server['uuid'] = uuidv4();
|
||||
server['description'] = $("#addserver-descinput").val();
|
||||
server['ip'] = $("#addserver-ipinput").val();
|
||||
server['version'] = $("#addserver-versionselect option:selected").text();
|
||||
//server['endpoint'] =
|
||||
|
||||
jsontomodify['servers'].push(server)
|
||||
|
||||
remotefs.writeFileSync(userdir+"\\servers.json", JSON.stringify(jsontomodify, null, 4));
|
||||
loadServerList();
|
||||
}
|
||||
|
||||
function deleteServer() {
|
||||
var jsontomodify = JSON.parse(remotefs.readFileSync(userdir+"\\servers.json"));
|
||||
var result = jsontomodify['servers'].filter(function(obj) {return (obj.uuid === getSelectedServer())})[0];
|
||||
|
||||
var resultindex = jsontomodify['servers'].indexOf(result);
|
||||
|
||||
jsontomodify['servers'].splice(resultindex, 1);
|
||||
|
||||
remotefs.writeFileSync(userdir+"\\servers.json", JSON.stringify(jsontomodify, null, 4));
|
||||
loadServerList();
|
||||
}
|
||||
|
||||
function loadGameVersions() {
|
||||
var versionjson = JSON.parse(remotefs.readFileSync(userdir+"\\versions.json"));
|
||||
versionarray = versionjson['versions'];
|
||||
@ -33,30 +61,32 @@ function loadConfig() {
|
||||
}
|
||||
|
||||
function loadServerList() {
|
||||
var serverjson = JSON.parse(remotefs.readFileSync(userdir+"\\servers.json"));
|
||||
serverarray = serverjson['servers'];
|
||||
var serverjson = JSON.parse(remotefs.readFileSync(userdir+"\\servers.json"));
|
||||
serverarray = serverjson['servers'];
|
||||
|
||||
$(".server-listing-entry").remove(); // clear out old stuff, if any
|
||||
disableServerListButtons();
|
||||
$(".server-listing-entry").remove(); // Clear out old stuff, if any
|
||||
disableServerListButtons(); // Disable buttons until another is selected
|
||||
|
||||
if (serverarray.length > 0) {
|
||||
$("#server-listing-placeholder").attr("hidden",true);
|
||||
$.each(serverarray, function( key, value ) {
|
||||
var row = document.createElement('tr');
|
||||
row.className = 'server-listing-entry'
|
||||
row.setAttribute('id', value.uuid)
|
||||
var cellName = document.createElement('td');
|
||||
cellName.textContent = value.description
|
||||
var cellVersion = document.createElement('td');
|
||||
cellVersion.textContent = value.version
|
||||
cellVersion.className = 'text-monospace'
|
||||
if (serverarray.length > 0) {
|
||||
// Servers were found in the JSON
|
||||
$("#server-listing-placeholder").attr("hidden",true);
|
||||
$.each(serverarray, function( key, value ) {
|
||||
// Create the row, and populate the cells
|
||||
var row = document.createElement('tr');
|
||||
row.className = 'server-listing-entry'
|
||||
row.setAttribute('id', value.uuid);
|
||||
var cellName = document.createElement('td');
|
||||
cellName.textContent = value.description
|
||||
var cellVersion = document.createElement('td');
|
||||
cellVersion.textContent = value.version
|
||||
cellVersion.className = 'text-monospace'
|
||||
|
||||
row.appendChild(cellName);
|
||||
row.appendChild(cellVersion);
|
||||
document.getElementById('server-tablebody').appendChild(row);
|
||||
});
|
||||
} else {
|
||||
// no servers added, make sure placeholder is visible
|
||||
row.appendChild(cellName);
|
||||
row.appendChild(cellVersion);
|
||||
$("#server-tablebody").append(row);
|
||||
});
|
||||
} else {
|
||||
// No servers are added, make sure placeholder is visible
|
||||
$("#server-listing-placeholder").attr("hidden",false);
|
||||
}
|
||||
}
|
||||
@ -71,33 +101,38 @@ function setGameInfo(serverUUID) {
|
||||
remotefs.writeFileSync(__dirname+"\\loginInfo.php", result.ip);
|
||||
|
||||
if (result.hasOwnProperty('endpoint')) {
|
||||
var rankurl = result.endpoint.replace("https://", "http://") + "getranks"
|
||||
console.log("Using rank endpoint " + rankurl)
|
||||
remotefs.writeFileSync(__dirname+"\\rankurl.txt", rankurl);
|
||||
var httpendpoint = result.endpoint.replace("https://", "http://")
|
||||
remotefs.writeFileSync(__dirname+"\\rankurl.txt", httpendpoint+"getranks");
|
||||
// Write these out too
|
||||
remotefs.writeFileSync(__dirname+"\\sponsor.php", httpendpoint+"upsell/sponsor.png");
|
||||
remotefs.writeFileSync(__dirname+"\\images.php", httpendpoint+"upsell/");
|
||||
} else {
|
||||
if (remotefs.existsSync(__dirname+"\\rankurl.txt")) {
|
||||
// delete the file, this server won't be using it
|
||||
remotefs.unlinkSync(__dirname+"\\rankurl.txt");
|
||||
remotefs.writeFileSync(__dirname+"\\sponsor.php", "assets/img/welcome.png");
|
||||
remotefs.writeFileSync(__dirname+"\\images.php", "assets/img/");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Returns the UUID of the server with the selected background color.
|
||||
// Yes, there are probably better ways to go about this, but it works well enough.
|
||||
function getSelectedServer() {
|
||||
return $("tr.bg-primary").prop("id");
|
||||
return $("#server-tablebody > tr.bg-primary").prop("id");
|
||||
}
|
||||
|
||||
function connectToServer() {
|
||||
// Get ID of the selected server, which corresponds to its UUID in the json
|
||||
var uuid = getSelectedServer();
|
||||
console.log("Connecting to server with UUID of " + uuid);
|
||||
console.log("Connecting to server with UUID of " + getSelectedServer());
|
||||
|
||||
// prevent the user from clicking anywhere else during the transition
|
||||
// Prevent the user from clicking anywhere else during the transition
|
||||
$('body,html').css('pointer-events','none');
|
||||
stopEasterEggs();
|
||||
$('#of-serverselector').fadeOut('slow', function() {
|
||||
setTimeout(function(){
|
||||
$('body,html').css('pointer-events','');
|
||||
setGameInfo(uuid);
|
||||
setGameInfo(getSelectedServer());
|
||||
launchGame();
|
||||
}, 200);
|
||||
});
|
||||
@ -112,3 +147,8 @@ $('#server-table').on('dblclick', '.server-listing-entry', function(event) {
|
||||
$(this).addClass('bg-primary').siblings().removeClass('bg-primary');
|
||||
connectToServer();
|
||||
});
|
||||
|
||||
$('#of-deleteservermodal').on('show.bs.modal', function (e) {
|
||||
var result = serverarray.filter(function(obj) {return (obj.uuid === getSelectedServer());})[0];
|
||||
$("#deleteserver-servername").html(result.description);
|
||||
});
|
||||
|
@ -69,11 +69,11 @@
|
||||
<h4 class="modal-title">Add Server</h4><button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form id="addserver-form" class="needs-validation"><label for="addserver-descinput">Server Description</label><input class="form-control form-row w-75" type="text" id="addserver-descinput" name="of-serverdesc-field" placeholder="My OpenFusion Server" required="" minlength="1" maxlength="70"><label for="addserver-ipinput">Server IP</label><input class="form-control form-row w-75" type="text" id="addserver-ipinput" name="of-serverip-field" placeholder="127.0.0.1:23000" required="" pattern="^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]):[0-9]+$"><label for="addserver-versionselect">Game Version: </label><select class="form-control w-50" id="addserver-versionselect" required="" style="margin-left: -5px;">
|
||||
<form id="addserver-form" class="needs-validation"><label for="addserver-descinput">Server Description</label><input class="form-control form-row w-75" type="text" id="addserver-descinput" placeholder="My OpenFusion Server" required="" minlength="1" maxlength="70"><label for="addserver-ipinput">Server IP</label><input class="form-control form-row w-75" type="text" id="addserver-ipinput" placeholder="127.0.0.1:23000" required="" pattern="^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]):[0-9]+$"><label for="addserver-versionselect">Game Version: </label><select class="form-control w-50" id="addserver-versionselect" required="" style="margin-left: -5px;">
|
||||
<option value="" selected="" id="addserver-versionlist-placeholder" disabled="">Please select a verison...</option>
|
||||
</select></form>
|
||||
</div>
|
||||
<div class="modal-footer"><button class="btn btn-primary border rounded border-primary btn-danger border-danger" id="addserver-cancel" type="button" data-dismiss="modal">Cancel</button><button class="btn btn-primary disabled border rounded border-primary btn-success border-success" id="addserver-savebutton" type="submit" data-dismiss="modal" disabled="" form="addserver-form" onclick="addServer();">Save</button></div>
|
||||
<div class="modal-footer"><button class="btn btn-primary border rounded border-primary btn-danger border-danger" id="addserver-cancel" type="button" data-dismiss="modal">Cancel</button><button class="btn btn-primary border rounded border-primary btn-success border-success" id="addserver-savebutton" type="submit" data-dismiss="modal" form="addserver-form" onclick="addServer();">Save</button></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -84,7 +84,7 @@
|
||||
<h4 class="modal-title">Are you sure?</h4><button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p class="lead">Do you really want to delete <a id="deleteserver-servername">SERVER_NAME</a>?<br>You could always re-add it later.</p>
|
||||
<p class="lead">Do you really want to delete<br>"<a id="deleteserver-servername">SERVER_NAME</a>"?<br><br>You could always re-add it later.</p>
|
||||
</div>
|
||||
<div class="modal-footer"><button class="btn btn-primary border rounded border-primary" type="button" data-dismiss="modal">Cancel</button><button class="btn btn-primary border rounded border-primary btn-danger border-danger" id="deleteserver-button" type="button" data-dismiss="modal" onclick="deleteServer();">Yes, Delete</button></div>
|
||||
</div>
|
||||
|
@ -96,6 +96,3 @@ function showMainWindow() {
|
||||
|
||||
mainWindow.webContents.openDevTools()
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user