diff --git a/assets/css/openfusion.css b/assets/css/openfusion.css index f810cf2..93464ba 100644 --- a/assets/css/openfusion.css +++ b/assets/css/openfusion.css @@ -80,6 +80,11 @@ body { border-color: #6699FF; } +#of-editservermodal > .modal-dialog > .modal-content { + background-color: #093363; + border-color: #6699FF; +} + #of-deleteservermodal > .modal-dialog > .modal-content { background-color: #093363; border-color: #6699FF; diff --git a/assets/js/serverselector.js b/assets/js/serverselector.js index c720fe5..f79f328 100644 --- a/assets/js/serverselector.js +++ b/assets/js/serverselector.js @@ -39,6 +39,20 @@ function addServer() { 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(); + } + }); + + 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]; @@ -56,6 +70,7 @@ function loadGameVersions() { versionarray = versionjson['versions']; $.each(versionarray, function( key, value ) { $(new Option(value.name, 'val')).appendTo('#addserver-versionselect'); + $(new Option(value.name, 'val')).appendTo('#editserver-versionselect'); }); } @@ -189,6 +204,25 @@ $('#server-table').on('dblclick', '.server-listing-entry', function(event) { connectToServer(); }); +$('#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 versionIndex = -1; + $.each($("#editserver-versionselect")[0], function( key, val ) { + if(val.text === value['version']) { + versionIndex = key; + } + }); + $("#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); diff --git a/index.html b/index.html index 45bb85e..38dae89 100644 --- a/index.html +++ b/index.html @@ -41,7 +41,7 @@
- +
@@ -79,6 +79,19 @@
+