diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..c293d88 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,33 @@ +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# dependencies +/node_modules +/.pnp +.pnp.js + +# production +/build + +# misc +.DS_Store +.env.local +.env.development.local +.env.test.local +.env.production.local + +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +locales/ +*.pak +*.bin +*.php +rankurl.txt +icudtl.dat +version +resources/app/files/rankurl.txt +node_modules/ +dist/ +UnityBugReporter.exe +*.min.* diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..2b306ad --- /dev/null +++ b/.prettierrc @@ -0,0 +1,12 @@ +{ + "trailingComma": "es5", + "useTabs": false, + "tabWidth": 4, + "singleQuote": false, + "semi": true, + "bracketSameLine": false, + "bracketSpacing": true, + "jsxSingleQuote": false, + "quoteProps": "as-needed", + "endOfLine": "lf" +} diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..84a7327 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,9 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations. + // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp + + // List of extensions which should be recommended for users of this workspace. + "recommendations": ["esbenp.prettier-vscode"], + // List of extensions recommended by VS Code that should not be recommended for users of this workspace. + "unwantedRecommendations": [] +} diff --git a/README.md b/README.md index a34d6ac..44df782 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,3 @@ # OpenFusionClient + Electron app for joining OpenFusion servers diff --git a/assets/css/openfusion.css b/assets/css/openfusion.css index cc1b11d..911dc76 100644 --- a/assets/css/openfusion.css +++ b/assets/css/openfusion.css @@ -49,9 +49,9 @@ img { body { user-select: none; background-color: #000; - font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, - 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', - 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'; + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, + "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", + "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; } #of-versionnumber { @@ -61,17 +61,17 @@ body { } .btn-primary { - background-image: url('../../assets/img/btn-primary-bg.png'); + background-image: url("../../assets/img/btn-primary-bg.png"); background-repeat: repeat; } .btn-success { - background-image: url('../../assets/img/btn-success-bg.png'); + background-image: url("../../assets/img/btn-success-bg.png"); background-repeat: repeat; } .btn-danger { - background-image: url('../../assets/img/btn-danger-bg.png'); + background-image: url("../../assets/img/btn-danger-bg.png"); background-repeat: repeat; } diff --git a/assets/js/bs-init.js b/assets/js/bs-init.js index b2e59a2..6e6f690 100644 --- a/assets/js/bs-init.js +++ b/assets/js/bs-init.js @@ -1,3 +1,3 @@ -$(document).ready(function(){ - $('[data-bs-tooltip]').tooltip(); -}); \ No newline at end of file +$(document).ready(function () { + $("[data-bs-tooltip]").tooltip(); +}); diff --git a/assets/js/eastereggs.js b/assets/js/eastereggs.js index 8b4eb5f..d7fc527 100644 --- a/assets/js/eastereggs.js +++ b/assets/js/eastereggs.js @@ -7,13 +7,13 @@ var christmasBegin = new Date(today.getFullYear(), 11, 23); var christmasEnd = new Date(today.getFullYear(), 12, 8); var sf; -if((today >= christmasBegin && today <= christmasEnd)) { - console.log("Christmas Activated."); - sf = new Snowflakes({zIndex: -100}); +if (today >= christmasBegin && today <= christmasEnd) { + console.log("Christmas Activated."); + sf = new Snowflakes({ zIndex: -100 }); } -function stopEasterEggs(){ - if (sf != null) { - sf.destroy(); - } +function stopEasterEggs() { + if (sf != null) { + sf.destroy(); + } } diff --git a/assets/js/gameclient.js b/assets/js/gameclient.js index 3b66f2f..d6f4024 100644 --- a/assets/js/gameclient.js +++ b/assets/js/gameclient.js @@ -5,7 +5,7 @@ var gameRunning = false; // Uncomment and enter credentials to skip login screen function authDoCallback(param) { - /*var unity = document.getElementById('Unity_embed'); + /*var unity = document.getElementById('Unity_embed'); unity.SendMessage("GlobalManager", "SetTEGid", "player"); unity.SendMessage("GlobalManager", "SetAuthid", "0"); unity.SendMessage("GlobalManager", "DoAuth", 0);*/ @@ -14,67 +14,85 @@ function authDoCallback(param) { function MarkProgress(param) {} function redirect(html) { - ipc.send("exit", 0); + ipc.send("exit", 0); } function HomePage(param) { - ipc.send("exit", 0); + ipc.send("exit", 0); } function PageOut(param) { - ipc.send("exit", 0); + ipc.send("exit", 0); } function updateSocialOptions(param) { - ipc.send("exit", 0); + ipc.send("exit", 0); } function PayPage(param) { - ipc.send("exit", 0); + ipc.send("exit", 0); } // Unity invoked methods end // function onResize() { - if (gameRunning == true) { - var unity = document.getElementById('Unity_embed'); - unity.style.width = window.innerWidth + 'px'; - unity.style.height = window.innerHeight + 'px'; - } + if (gameRunning == true) { + var unity = document.getElementById("Unity_embed"); + unity.style.width = window.innerWidth + "px"; + unity.style.height = window.innerHeight + "px"; + } } function launchGame() { - gameRunning = true; + gameRunning = true; - var sel = document.getElementById("of-serverselector"); - sel.remove(); + var sel = document.getElementById("of-serverselector"); + sel.remove(); - document.body.style.overflow = "hidden"; + document.body.style.overflow = "hidden"; - var object = document.createElement('object'); - object.setAttribute('classid', "clsid:444785F1-DE89-4295-863A-D46C3A781394"); - object.setAttribute('codebase', "undefined/UnityWebPlayer.cab#version=2,0,0,0"); - object.setAttribute('id', "Unity_object"); - object.setAttribute('width', "1264"); - object.setAttribute('height', "661"); + var object = document.createElement("object"); + object.setAttribute( + "classid", + "clsid:444785F1-DE89-4295-863A-D46C3A781394" + ); + object.setAttribute( + "codebase", + "undefined/UnityWebPlayer.cab#version=2,0,0,0" + ); + object.setAttribute("id", "Unity_object"); + object.setAttribute("width", "1264"); + object.setAttribute("height", "661"); - var embed = document.createElement('embed'); - embed.setAttribute('type', "application/vnd.unity"); - embed.setAttribute('pluginspage', "http://www.unity3d.com/unity-web-player-2.x"); - embed.setAttribute('id', "Unity_embed"); - embed.setAttribute('width', "1280"); - embed.setAttribute('height', "680"); - embed.setAttribute('src', window.asseturl+"main.unity3d"); - embed.setAttribute('disablecontdparaextmenu', "true"); - embed.setAttribute('bordercolor', "000000"); - embed.setAttribute('backgroundcolor', "000000"); - embed.setAttribute('disableContextMenu', true); - embed.setAttribute('textcolor', "ccffff"); - embed.setAttribute('logoimage', "assets/img/unity_dexlabs.png"); - embed.setAttribute('progressbarimage', "assets/img/unity_loadingbar.png"); - embed.setAttribute('progressframeimage', "assets/img/unity_loadingframe.png"); - embed.setAttribute('autoupdateurlsignature', "42180ee5edc4e3d4dd706bcc17cedd8d6ec7b7ac463071fd34ab97fe181f1a78df31db5feb4526677e4f69ef53acaff44471591e68b87f041c80fd54765f0d5725b08aa28f5acf7716ffb2a04e971269f35925c7e38d57dd78f6a206530caaa3da7e32f07f19810efc0ebf29a4eae976a925ad9cc5beb4dd51564c67dc489033"); - embed.setAttribute('autoupdateurl', "http://wp-cartoonnetwork.unity3d.com/ff/big/beta-20111013/autodownload_webplugin_beta"); + var embed = document.createElement("embed"); + embed.setAttribute("type", "application/vnd.unity"); + embed.setAttribute( + "pluginspage", + "http://www.unity3d.com/unity-web-player-2.x" + ); + embed.setAttribute("id", "Unity_embed"); + embed.setAttribute("width", "1280"); + embed.setAttribute("height", "680"); + embed.setAttribute("src", window.asseturl + "main.unity3d"); + embed.setAttribute("disablecontdparaextmenu", "true"); + embed.setAttribute("bordercolor", "000000"); + embed.setAttribute("backgroundcolor", "000000"); + embed.setAttribute("disableContextMenu", true); + embed.setAttribute("textcolor", "ccffff"); + embed.setAttribute("logoimage", "assets/img/unity_dexlabs.png"); + embed.setAttribute("progressbarimage", "assets/img/unity_loadingbar.png"); + embed.setAttribute( + "progressframeimage", + "assets/img/unity_loadingframe.png" + ); + embed.setAttribute( + "autoupdateurlsignature", + "42180ee5edc4e3d4dd706bcc17cedd8d6ec7b7ac463071fd34ab97fe181f1a78df31db5feb4526677e4f69ef53acaff44471591e68b87f041c80fd54765f0d5725b08aa28f5acf7716ffb2a04e971269f35925c7e38d57dd78f6a206530caaa3da7e32f07f19810efc0ebf29a4eae976a925ad9cc5beb4dd51564c67dc489033" + ); + embed.setAttribute( + "autoupdateurl", + "http://wp-cartoonnetwork.unity3d.com/ff/big/beta-20111013/autodownload_webplugin_beta" + ); - var div = document.getElementById('client'); - object.appendChild(embed); - div.appendChild(object); - document.title = "OpenFusion"; - onResize(); + var div = document.getElementById("client"); + object.appendChild(embed); + div.appendChild(object); + document.title = "OpenFusion"; + onResize(); } diff --git a/assets/js/serverselector.js b/assets/js/serverselector.js index baaf706..3d8c4e6 100644 --- a/assets/js/serverselector.js +++ b/assets/js/serverselector.js @@ -1,269 +1,328 @@ var remote = require("remote"); -var remotefs = remote.require('fs-extra'); -var dns = remote.require('dns'); +var remotefs = remote.require("fs-extra"); +var dns = remote.require("dns"); -var userdir = remote.require('app').getPath('userData'); +var userdir = remote.require("app").getPath("userData"); var versionarray; var serverarray; var config; function enableServerListButtons() { - $('#of-connect-button').removeClass('disabled'); - $('#of-connect-button').prop('disabled', false); - $('#of-editserver-button').removeClass('disabled'); - $('#of-editserver-button').prop('disabled', false); - $('#of-deleteserver-button').removeClass('disabled'); - $('#of-deleteserver-button').prop('disabled', false); + $("#of-connect-button").removeClass("disabled"); + $("#of-connect-button").prop("disabled", false); + $("#of-editserver-button").removeClass("disabled"); + $("#of-editserver-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-editserver-button').addClass('disabled'); - $('#of-editserver-button').prop('disabled', true); - $('#of-deleteserver-button').addClass('disabled'); - $('#of-deleteserver-button').prop('disabled', true); + $("#of-connect-button").addClass("disabled"); + $("#of-connect-button").prop("disabled", true); + $("#of-editserver-button").addClass("disabled"); + $("#of-editserver-button").prop("disabled", true); + $("#of-deleteserver-button").addClass("disabled"); + $("#of-deleteserver-button").prop("disabled", true); } function addServer() { - var jsontomodify = JSON.parse(remotefs.readFileSync(userdir+"\\servers.json")); + var jsontomodify = JSON.parse( + remotefs.readFileSync(userdir + "\\servers.json") + ); - var server = {}; - server['uuid'] = uuidv4(); - server['description'] = $("#addserver-descinput").val().length == 0 ? "My OpenFusion Server" : $("#addserver-descinput").val(); - server['ip'] = $("#addserver-ipinput").val().length == 0 ? "127.0.0.1:23000" : $("#addserver-ipinput").val(); - server['version'] = $("#addserver-versionselect option:selected").text(); - //server['endpoint'] = + var server = {}; + server["uuid"] = uuidv4(); + server["description"] = + $("#addserver-descinput").val().length == 0 + ? "My OpenFusion Server" + : $("#addserver-descinput").val(); + server["ip"] = + $("#addserver-ipinput").val().length == 0 + ? "127.0.0.1:23000" + : $("#addserver-ipinput").val(); + server["version"] = $("#addserver-versionselect option:selected").text(); + //server['endpoint'] = - jsontomodify['servers'].push(server); + jsontomodify["servers"].push(server); - remotefs.writeFileSync(userdir+"\\servers.json", JSON.stringify(jsontomodify, null, 4)); - loadServerList(); + remotefs.writeFileSync( + userdir + "\\servers.json", + JSON.stringify(jsontomodify, null, 4) + ); + loadServerList(); } function editServer() { - var jsontomodify = JSON.parse(remotefs.readFileSync(userdir+"\\servers.json")); - $.each(jsontomodify["servers"], function( key, value ) { - if(value["uuid"] == getSelectedServer()) { - value['description'] = $("#editserver-descinput").val().length == 0 ? value['description'] : $("#editserver-descinput").val(); - value['ip'] = $("#editserver-ipinput").val().length == 0 ? value['ip'] : $("#editserver-ipinput").val(); - value['version'] = $("#editserver-versionselect option:selected").text(); - } - }); + var jsontomodify = JSON.parse( + remotefs.readFileSync(userdir + "\\servers.json") + ); + $.each(jsontomodify["servers"], function (key, value) { + if (value["uuid"] == getSelectedServer()) { + value["description"] = + $("#editserver-descinput").val().length == 0 + ? value["description"] + : $("#editserver-descinput").val(); + value["ip"] = + $("#editserver-ipinput").val().length == 0 + ? value["ip"] + : $("#editserver-ipinput").val(); + value["version"] = $( + "#editserver-versionselect option:selected" + ).text(); + } + }); - remotefs.writeFileSync(userdir+"\\servers.json", JSON.stringify(jsontomodify, null, 4)); - loadServerList(); + 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 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); + var resultindex = jsontomodify["servers"].indexOf(result); - jsontomodify['servers'].splice(resultindex, 1); + jsontomodify["servers"].splice(resultindex, 1); - remotefs.writeFileSync(userdir+"\\servers.json", JSON.stringify(jsontomodify, null, 4)); - loadServerList(); + remotefs.writeFileSync( + userdir + "\\servers.json", + JSON.stringify(jsontomodify, null, 4) + ); + loadServerList(); } function restoreDefaultServers() { - remotefs.copySync(__dirname+"\\defaults\\servers.json", userdir+"\\servers.json"); - loadServerList(); + remotefs.copySync( + __dirname + "\\defaults\\servers.json", + userdir + "\\servers.json" + ); + loadServerList(); } function loadGameVersions() { - var versionjson = JSON.parse(remotefs.readFileSync(userdir+"\\versions.json")); - versionarray = versionjson['versions']; - $.each(versionarray, function( key, value ) { - $(new Option(value.name, 'val')).appendTo('#addserver-versionselect'); - $(new Option(value.name, 'val')).appendTo('#editserver-versionselect'); - }); + var versionjson = JSON.parse( + remotefs.readFileSync(userdir + "\\versions.json") + ); + versionarray = versionjson["versions"]; + $.each(versionarray, function (key, value) { + $(new Option(value.name, "val")).appendTo("#addserver-versionselect"); + $(new Option(value.name, "val")).appendTo("#editserver-versionselect"); + }); } function loadConfig() { - // load config object globally - config = JSON.parse(remotefs.readFileSync(userdir+"\\config.json")); + // load config object globally + config = 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"]; - $(".server-listing-entry").remove(); // Clear out old stuff, if any - disableServerListButtons(); // Disable buttons until another server is selected + $(".server-listing-entry").remove(); // Clear out old stuff, if any + disableServerListButtons(); // Disable buttons until another server is selected - 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'; + 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); - $("#server-tablebody").append(row); - }); - } else { - // No servers are added, make sure placeholder is visible - $("#server-listing-placeholder").attr("hidden",false); - } + 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); + } } // For writing loginInfo.php, assetInfo.php, etc. 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]; + var result = serverarray.filter(function (obj) { + return obj.uuid === serverUUID; + })[0]; + var gameversion = versionarray.filter(function (obj) { + return obj.name === result.version; + })[0]; - if(config['cache-swapping']) { // if cache swapping property exists AND is `true`, run cache swapping logic - // Cache folder renaming - var cachedir = userdir + '\\..\\..\\LocalLow\\Unity\\Web Player\\Cache'; - var curversion = cachedir + '\\Fusionfall'; - var newversion = cachedir + '\\' + gameversion.name; - var record = userdir + '\\.lastver'; + if (config["cache-swapping"]) { + // if cache swapping property exists AND is `true`, run cache swapping logic + // Cache folder renaming + var cachedir = userdir + "\\..\\..\\LocalLow\\Unity\\Web Player\\Cache"; + var curversion = cachedir + "\\Fusionfall"; + var newversion = cachedir + "\\" + gameversion.name; + var record = userdir + "\\.lastver"; - if (remotefs.existsSync(curversion)) { - // cache already exists - // find out what version it belongs to - if (remotefs.existsSync(record)) { - var lastversion = remotefs.readFileSync(record); - remotefs.renameSync(curversion, cachedir + '\\' + lastversion); - console.log('Cached version ' + lastversion); - } else { - console.log( - "Couldn't find last version record; cache may get overwritten" + if (remotefs.existsSync(curversion)) { + // cache already exists + // find out what version it belongs to + if (remotefs.existsSync(record)) { + var lastversion = remotefs.readFileSync(record); + remotefs.renameSync(curversion, cachedir + "\\" + lastversion); + console.log("Cached version " + lastversion); + } else { + console.log( + "Couldn't find last version record; cache may get overwritten" + ); + } + } + + if (remotefs.existsSync(newversion)) { + // rename saved cache to FusionFall + remotefs.renameSync(newversion, curversion); + console.log("Loaded cached " + gameversion.name); + } + + // make note of what version we are launching for next launch + remotefs.writeFileSync(record, gameversion.name); + } + + window.asseturl = gameversion.url; // gameclient.js needs to access this + + remotefs.writeFileSync(__dirname + "\\assetInfo.php", asseturl); + if (result.hasOwnProperty("endpoint")) { + 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/" ); - } - } - - if (remotefs.existsSync(newversion)) { - // rename saved cache to FusionFall - remotefs.renameSync(newversion, curversion); - console.log('Loaded cached ' + gameversion.name); - } - - // make note of what version we are launching for next launch - remotefs.writeFileSync(record, gameversion.name); - } - - window.asseturl = gameversion.url; // gameclient.js needs to access this - - remotefs.writeFileSync(__dirname+"\\assetInfo.php", asseturl); - if (result.hasOwnProperty('endpoint')) { - 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 { - // Remove/default the endpoint related stuff, this server won't be using it - if (remotefs.existsSync(__dirname+"\\rankurl.txt")) { - remotefs.unlinkSync(__dirname+"\\rankurl.txt"); - remotefs.writeFileSync(__dirname+"\\sponsor.php", "assets/img/welcome.png"); - remotefs.writeFileSync(__dirname+"\\images.php", "assets/img/"); - } - } - - // Server address parsing - var address; - var port; - var sepPos = result.ip.indexOf(":"); - if (sepPos > -1) { - address = result.ip.substr(0, sepPos); - port = result.ip.substr(sepPos + 1); - } else { - address = result.ip; - port = 23000 // default - } - - // DNS resolution. there is no synchronous version for some stupid reason - if(!address.match(/^[0-9.]+$/)) dns.resolve4(address, function(err, res) { - if(!err) { - console.log("Resolved " + address + " to " + res[0]); - address = res[0]; } else { - console.log("Err: " + err.code); + // Remove/default the endpoint related stuff, this server won't be using it + if (remotefs.existsSync(__dirname + "\\rankurl.txt")) { + remotefs.unlinkSync(__dirname + "\\rankurl.txt"); + remotefs.writeFileSync( + __dirname + "\\sponsor.php", + "assets/img/welcome.png" + ); + remotefs.writeFileSync(__dirname + "\\images.php", "assets/img/"); + } + } + + // Server address parsing + var address; + var port; + var sepPos = result.ip.indexOf(":"); + if (sepPos > -1) { + address = result.ip.substr(0, sepPos); + port = result.ip.substr(sepPos + 1); + } else { + address = result.ip; + port = 23000; // default + } + + // DNS resolution. there is no synchronous version for some stupid reason + if (!address.match(/^[0-9.]+$/)) + dns.resolve4(address, function (err, res) { + if (!err) { + console.log("Resolved " + address + " to " + res[0]); + address = res[0]; + } else { + console.log("Err: " + err.code); + } + prepConnection(address, port); + }); + else { + console.log(address + " is an IP; skipping DNS lookup"); + prepConnection(address, port); } - prepConnection(address, port); - }); - else { - console.log(address + " is an IP; skipping DNS lookup"); - prepConnection(address, port); - } } function prepConnection(address, port) { - var full = address + ":" + port; - console.log("Will connect to " + full); - remotefs.writeFileSync(__dirname+"\\loginInfo.php", full); - launchGame(); + var full = address + ":" + port; + console.log("Will connect to " + full); + remotefs.writeFileSync(__dirname + "\\loginInfo.php", full); + launchGame(); } // 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 $("#server-tablebody > 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 - console.log("Connecting to server with UUID of " + getSelectedServer()); + // Get ID of the selected server, which corresponds to its UUID in the json + console.log("Connecting to server with UUID of " + getSelectedServer()); - // 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(getSelectedServer()); - }, 200); - }); + // 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(getSelectedServer()); + }, 200); + }); } // If applicable, deselect currently selected server. function deselectServer() { - disableServerListButtons(); - $(".server-listing-entry").removeClass('bg-primary'); + disableServerListButtons(); + $(".server-listing-entry").removeClass("bg-primary"); } -$('#server-table').on('click', '.server-listing-entry', function(event) { - enableServerListButtons(); - $(this).addClass('bg-primary').siblings().removeClass('bg-primary'); +$("#server-table").on("click", ".server-listing-entry", function (event) { + enableServerListButtons(); + $(this).addClass("bg-primary").siblings().removeClass("bg-primary"); }); // QoL feature: if you double click on a server it will connect -$('#server-table').on('dblclick', '.server-listing-entry', function(event) { - $(this).addClass('bg-primary').siblings().removeClass('bg-primary'); - connectToServer(); +$("#server-table").on("dblclick", ".server-listing-entry", function (event) { + $(this).addClass("bg-primary").siblings().removeClass("bg-primary"); + connectToServer(); }); -$('#of-editservermodal').on('show.bs.modal', function (e) { +$("#of-editservermodal").on("show.bs.modal", function (e) { + var jsontomodify = JSON.parse( + remotefs.readFileSync(userdir + "\\servers.json") + ); + $.each(jsontomodify["servers"], function (key, value) { + if (value["uuid"] == getSelectedServer()) { + $("#editserver-descinput")[0].value = value["description"]; + $("#editserver-ipinput")[0].value = value["ip"]; - var jsontomodify = JSON.parse(remotefs.readFileSync(userdir+"\\servers.json")); - $.each(jsontomodify["servers"], function( key, value ) { - if(value["uuid"] == getSelectedServer()) { - $("#editserver-descinput")[0].value = value['description']; - $("#editserver-ipinput")[0].value = value['ip']; - - var versionIndex = -1; - $.each($("#editserver-versionselect")[0], function( key, val ) { - if(val.text === value['version']) { - versionIndex = key; + var versionIndex = -1; + $.each($("#editserver-versionselect")[0], function (key, val) { + if (val.text === value["version"]) { + versionIndex = key; + } + }); + $("#editserver-versionselect")[0].selectedIndex = versionIndex; } - }); - $("#editserver-versionselect")[0].selectedIndex = versionIndex; - } - }); + }); }); -$('#of-deleteservermodal').on('show.bs.modal', function (e) { - var result = serverarray.filter(function(obj) {return (obj.uuid === getSelectedServer());})[0]; - $("#deleteserver-servername").html(result.description); +$("#of-deleteservermodal").on("show.bs.modal", function (e) { + var result = serverarray.filter(function (obj) { + return obj.uuid === getSelectedServer(); + })[0]; + $("#deleteserver-servername").html(result.description); }); diff --git a/defaults/config.json b/defaults/config.json index 53e485a..a9c121c 100644 --- a/defaults/config.json +++ b/defaults/config.json @@ -2,4 +2,4 @@ "autoupdate-check": true, "cache-swapping": true, "last-version-initialized": "1.4" -} \ No newline at end of file +} diff --git a/index.html b/index.html index 7c39202..9af07d1 100644 --- a/index.html +++ b/index.html @@ -1,139 +1,485 @@ +
+ + +Welcome to OpenFusion.
Select a server from the list below to get started.
+ Welcome to OpenFusion.
Select a server from the
+ list below to get started.
+
Description | -Game Version | -
---|---|
No servers added yet... perhaps you should find one? | -
Description | +Game Version | +
---|---|
+ No servers added yet... perhaps you + should find one? + | +