diff --git a/assets/css/openfusion.css b/assets/css/openfusion.css index f810cf2..d95f1e3 100644 --- a/assets/css/openfusion.css +++ b/assets/css/openfusion.css @@ -1,116 +1,137 @@ -:not(input):not(textarea), :not(input):not(textarea)::after, :not(input):not(textarea)::before { - -webkit-user-select: none; - user-select: none; +:not(input):not(textarea), +:not(input):not(textarea)::after, +:not(input):not(textarea)::before { + -webkit-user-select: none; + user-select: none; } #server-table > .table-striped thead th { - background-color: #34476E; + background-color: #34476e; } #server-table > .table-striped tbody tr:nth-of-type(odd) { - background-color: #34476E; + background-color: #34476e; } #server-listing-placeholder > td { - background-color: #24314D; - user-select: none; - -webkit-user-select: none; + background-color: #24314d; + user-select: none; + -webkit-user-select: none; } -#server-table > .table-striped tbody tr:nth-of-type(even), th { - background-color: #24314D; +#server-table > .table-striped tbody tr:nth-of-type(even), +th { + background-color: #24314d; } #server-table { - font-size: 14pt; - opacity: 0.9; + font-size: 14pt; + opacity: 0.9; } #of-intro-text { - text-shadow: 1px 1px 8px #4349C4; - color: #4A76B7; - font-size: 18px; + text-shadow: 1px 1px 8px #4349c4; + color: #4a76b7; + font-size: 18px; } img { - pointer-events: none; + pointer-events: none; } :root { - --gray-dark: #343a40; - --primary: #6699FF; - --secondary: #384E7A; - --dark: #384E7A; + --gray-dark: #343a40; + --primary: #6699ff; + --secondary: #384e7a; + --dark: #384e7a; } 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"; + 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'; } #of-versionnumber { - position: fixed; - bottom: 4px; - right: 8px; + position: fixed; + bottom: 4px; + right: 8px; +} + +#of-restoreservers { + position: fixed; + bottom: 4px; + left: 8px; } .btn-primary { - background-image: url("../../assets/img/btn-primary-bg.png"); - background-repeat: repeat; + background-image: url('../../assets/img/btn-primary-bg.png'); + background-repeat: repeat; } .btn-success { - background-image: url("../../assets/img/btn-success-bg.png"); - background-repeat: repeat; + background-image: url('../../assets/img/btn-success-bg.png'); + background-repeat: repeat; } .btn-danger { - background-image: url("../../assets/img/btn-danger-bg.png"); - background-repeat: repeat; + background-image: url('../../assets/img/btn-danger-bg.png'); + background-repeat: repeat; } #of-aboutmodal > .modal-dialog > .modal-content { - background-color: #093363; - border-color: #6699FF; + background-color: #093363; + border-color: #6699ff; } #of-addservermodal > .modal-dialog > .modal-content { - background-color: #093363; - border-color: #6699FF; + background-color: #093363; + 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; + background-color: #093363; + border-color: #6699ff; } -.form-control, .form-control:focus { - border-color: #0099FF; - background-color: #000; - color: #fff; +#of-restoreserversmodal > .modal-dialog > .modal-content { + background-color: #093363; + border-color: #6699ff; +} + +.form-control, +.form-control:focus { + border-color: #0099ff; + background-color: #000; + color: #fff; } select { - border-color: #0099FF; - background-color: #000; - color: #fff; + border-color: #0099ff; + background-color: #000; + color: #fff; } button:disabled { - cursor: not-allowed; - pointer-events: all !important; + cursor: not-allowed; + pointer-events: all !important; } button > i { - pointer-events: none; + pointer-events: none; } #of-logo { - opacity: 0.9; + opacity: 0.9; } #server-table .server-listing-entry { - cursor: pointer; + cursor: pointer; } - diff --git a/assets/js/serverselector.js b/assets/js/serverselector.js index f6bf45a..77e4f4f 100644 --- a/assets/js/serverselector.js +++ b/assets/js/serverselector.js @@ -8,6 +8,8 @@ var serverarray 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); } @@ -15,6 +17,8 @@ function enableServerListButtons() { 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); } @@ -35,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]; @@ -47,11 +65,17 @@ function deleteServer() { loadServerList(); } +function restoreDefaultServers() { + 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'); }); } @@ -168,6 +192,12 @@ function connectToServer() { }); } +// If applicable, deselect currently selected server. +function deselectServer() { + 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'); @@ -179,6 +209,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 dd26b0d..67c4919 100644 --- a/index.html +++ b/index.html @@ -39,8 +39,14 @@