diff --git a/resources/app/default_servers.json b/resources/app/default_servers.json index c1468b3..2b75de4 100644 --- a/resources/app/default_servers.json +++ b/resources/app/default_servers.json @@ -11,7 +11,8 @@ "uuid": "b84f6859-f500-41f2-bdfa-8e3746639ee9", "description": "OpenFusion Public Server - Academy", "ip": "144.202.52.9:24000", - "version": "beta-20111013" + "version": "beta-20111013", + "endpoint": "https://api.dexlabs.systems/academy/" } ], "favorites": [] diff --git a/resources/app/files/assets/img/spinner.gif b/resources/app/files/assets/img/spinner.gif new file mode 100644 index 0000000..8ff6006 Binary files /dev/null and b/resources/app/files/assets/img/spinner.gif differ diff --git a/resources/app/files/assets/js/serverselector.js b/resources/app/files/assets/js/serverselector.js index 81471fe..16be006 100644 --- a/resources/app/files/assets/js/serverselector.js +++ b/resources/app/files/assets/js/serverselector.js @@ -7,12 +7,16 @@ var serverarray function enableServerListButtons() { $('#of-connect-button').removeClass('disabled'); + $('#of-connect-button').prop('disabled', false); $('#of-deleteserver-button').removeClass('disabled'); + $('#of-deleteserver-button').prop('disabled', false); } function disableServerListButtons() { $('#of-connect-button').addClass('disabled'); + $('#of-connect-button').prop('disabled', true); $('#of-deleteserver-button').addClass('disabled'); + $('#of-deleteserver-button').prop('disabled', true); } function loadGameVersions() { @@ -26,29 +30,32 @@ function loadGameVersions() { function loadConfig() { // TODO: actually use these values var configjson = JSON.parse(remotefs.readFileSync(userdir+"\\config.json")); -} + } 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']; - 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' + $(".server-listing-entry").remove(); // clear out old stuff, if any + disableServerListButtons(); - row.appendChild(cellName); - row.appendChild(cellVersion); - document.getElementById('server-tablebody').appendChild(row); - }); - } else { + 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' + + row.appendChild(cellName); + row.appendChild(cellVersion); + document.getElementById('server-tablebody').appendChild(row); + }); + } else { // no servers added, make sure placeholder is visible $("#server-listing-placeholder").attr("hidden",false); } @@ -58,18 +65,28 @@ function loadServerList() { function setGameInfo(serverUUID) { var result = serverarray.filter(function(obj) {return (obj.uuid === serverUUID);})[0]; var gameversion = versionarray.filter(function(obj) {return (obj.name === result.version);})[0]; - window.asseturl = gameversion.url remotefs.writeFileSync(__dirname+"\\assetInfo.php", asseturl); remotefs.writeFileSync(__dirname+"\\loginInfo.php", result.ip); - // TODO: write rank endpoint - remotefs.writeFileSync(__dirname+"\\rankurl.txt", "http://api.dexlabs.systems/getranks"); + + if (result.hasOwnProperty('endpoint')) { + var rankurl = result.endpoint.replace("https://", "http://") + "getranks" + console.log("Using rank endpoint " + rankurl) + remotefs.writeFileSync(__dirname+"\\rankurl.txt", rankurl); + } else { + // delete the file, this server won't be using it + remotefs.unlinkSync(__dirname+"\\rankurl.txt") + } +} + +function getSelectedServer() { + return $("tr.bg-primary").prop("id"); } function connectToServer() { // Get ID of the selected server, which corresponds to its UUID in the json - var uuid = $("tr.bg-primary").prop("id"); + var uuid = getSelectedServer(); console.log("Connecting to server with UUID of " + uuid); // prevent the user from clicking anywhere else during the transition diff --git a/resources/app/files/index.html b/resources/app/files/index.html index 7e795ae..4be623b 100644 --- a/resources/app/files/index.html +++ b/resources/app/files/index.html @@ -39,8 +39,8 @@
Do you really want to delete SERVER_NAME?
You could always re-add it later.
OpenFusion is setting up...
Please wait - this should take
less than a minute.