Merge pull request #4 from gsemaj/edit

This commit is contained in:
Gent Semaj 2021-09-19 10:56:29 -04:00 committed by GitHub
commit d21b0040fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 156 additions and 53 deletions

View File

@ -1,116 +1,137 @@
:not(input):not(textarea), :not(input):not(textarea)::after, :not(input):not(textarea)::before { :not(input):not(textarea),
-webkit-user-select: none; :not(input):not(textarea)::after,
user-select: none; :not(input):not(textarea)::before {
-webkit-user-select: none;
user-select: none;
} }
#server-table > .table-striped thead th { #server-table > .table-striped thead th {
background-color: #34476E; background-color: #34476e;
} }
#server-table > .table-striped tbody tr:nth-of-type(odd) { #server-table > .table-striped tbody tr:nth-of-type(odd) {
background-color: #34476E; background-color: #34476e;
} }
#server-listing-placeholder > td { #server-listing-placeholder > td {
background-color: #24314D; background-color: #24314d;
user-select: none; user-select: none;
-webkit-user-select: none; -webkit-user-select: none;
} }
#server-table > .table-striped tbody tr:nth-of-type(even), th { #server-table > .table-striped tbody tr:nth-of-type(even),
background-color: #24314D; th {
background-color: #24314d;
} }
#server-table { #server-table {
font-size: 14pt; font-size: 14pt;
opacity: 0.9; opacity: 0.9;
} }
#of-intro-text { #of-intro-text {
text-shadow: 1px 1px 8px #4349C4; text-shadow: 1px 1px 8px #4349c4;
color: #4A76B7; color: #4a76b7;
font-size: 18px; font-size: 18px;
} }
img { img {
pointer-events: none; pointer-events: none;
} }
:root { :root {
--gray-dark: #343a40; --gray-dark: #343a40;
--primary: #6699FF; --primary: #6699ff;
--secondary: #384E7A; --secondary: #384e7a;
--dark: #384E7A; --dark: #384e7a;
} }
body { body {
user-select: none; user-select: none;
background-color: #000; 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 { #of-versionnumber {
position: fixed; position: fixed;
bottom: 4px; bottom: 4px;
right: 8px; right: 8px;
}
#of-restoreservers {
position: fixed;
bottom: 4px;
left: 8px;
} }
.btn-primary { .btn-primary {
background-image: url("../../assets/img/btn-primary-bg.png"); background-image: url('../../assets/img/btn-primary-bg.png');
background-repeat: repeat; background-repeat: repeat;
} }
.btn-success { .btn-success {
background-image: url("../../assets/img/btn-success-bg.png"); background-image: url('../../assets/img/btn-success-bg.png');
background-repeat: repeat; background-repeat: repeat;
} }
.btn-danger { .btn-danger {
background-image: url("../../assets/img/btn-danger-bg.png"); background-image: url('../../assets/img/btn-danger-bg.png');
background-repeat: repeat; background-repeat: repeat;
} }
#of-aboutmodal > .modal-dialog > .modal-content { #of-aboutmodal > .modal-dialog > .modal-content {
background-color: #093363; background-color: #093363;
border-color: #6699FF; border-color: #6699ff;
} }
#of-addservermodal > .modal-dialog > .modal-content { #of-addservermodal > .modal-dialog > .modal-content {
background-color: #093363; background-color: #093363;
border-color: #6699FF; border-color: #6699ff;
}
#of-editservermodal > .modal-dialog > .modal-content {
background-color: #093363;
border-color: #6699ff;
} }
#of-deleteservermodal > .modal-dialog > .modal-content { #of-deleteservermodal > .modal-dialog > .modal-content {
background-color: #093363; background-color: #093363;
border-color: #6699FF; border-color: #6699ff;
} }
.form-control, .form-control:focus { #of-restoreserversmodal > .modal-dialog > .modal-content {
border-color: #0099FF; background-color: #093363;
background-color: #000; border-color: #6699ff;
color: #fff; }
.form-control,
.form-control:focus {
border-color: #0099ff;
background-color: #000;
color: #fff;
} }
select { select {
border-color: #0099FF; border-color: #0099ff;
background-color: #000; background-color: #000;
color: #fff; color: #fff;
} }
button:disabled { button:disabled {
cursor: not-allowed; cursor: not-allowed;
pointer-events: all !important; pointer-events: all !important;
} }
button > i { button > i {
pointer-events: none; pointer-events: none;
} }
#of-logo { #of-logo {
opacity: 0.9; opacity: 0.9;
} }
#server-table .server-listing-entry { #server-table .server-listing-entry {
cursor: pointer; cursor: pointer;
} }

View File

@ -8,6 +8,8 @@ var serverarray
function enableServerListButtons() { function enableServerListButtons() {
$('#of-connect-button').removeClass('disabled'); $('#of-connect-button').removeClass('disabled');
$('#of-connect-button').prop('disabled', false); $('#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').removeClass('disabled');
$('#of-deleteserver-button').prop('disabled', false); $('#of-deleteserver-button').prop('disabled', false);
} }
@ -15,6 +17,8 @@ function enableServerListButtons() {
function disableServerListButtons() { function disableServerListButtons() {
$('#of-connect-button').addClass('disabled'); $('#of-connect-button').addClass('disabled');
$('#of-connect-button').prop('disabled', true); $('#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').addClass('disabled');
$('#of-deleteserver-button').prop('disabled', true); $('#of-deleteserver-button').prop('disabled', true);
} }
@ -35,6 +39,20 @@ function addServer() {
loadServerList(); 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() { function deleteServer() {
var jsontomodify = JSON.parse(remotefs.readFileSync(userdir+"\\servers.json")); var jsontomodify = JSON.parse(remotefs.readFileSync(userdir+"\\servers.json"));
var result = jsontomodify['servers'].filter(function(obj) {return (obj.uuid === getSelectedServer())})[0]; var result = jsontomodify['servers'].filter(function(obj) {return (obj.uuid === getSelectedServer())})[0];
@ -47,11 +65,17 @@ function deleteServer() {
loadServerList(); loadServerList();
} }
function restoreDefaultServers() {
remotefs.copySync(__dirname+"\\defaults\\servers.json", userdir+"\\servers.json");
loadServerList();
}
function loadGameVersions() { function loadGameVersions() {
var versionjson = JSON.parse(remotefs.readFileSync(userdir+"\\versions.json")); var versionjson = JSON.parse(remotefs.readFileSync(userdir+"\\versions.json"));
versionarray = versionjson['versions']; versionarray = versionjson['versions'];
$.each(versionarray, function( key, value ) { $.each(versionarray, function( key, value ) {
$(new Option(value.name, 'val')).appendTo('#addserver-versionselect'); $(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) { $('#server-table').on('click', '.server-listing-entry', function(event) {
enableServerListButtons(); enableServerListButtons();
$(this).addClass('bg-primary').siblings().removeClass('bg-primary'); $(this).addClass('bg-primary').siblings().removeClass('bg-primary');
@ -179,6 +209,25 @@ $('#server-table').on('dblclick', '.server-listing-entry', function(event) {
connectToServer(); 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) { $('#of-deleteservermodal').on('show.bs.modal', function (e) {
var result = serverarray.filter(function(obj) {return (obj.uuid === getSelectedServer());})[0]; var result = serverarray.filter(function(obj) {return (obj.uuid === getSelectedServer());})[0];
$("#deleteserver-servername").html(result.description); $("#deleteserver-servername").html(result.description);

View File

@ -39,8 +39,14 @@
</div> </div>
</div> </div>
<div class="row row-cols-2 d-xl-flex justify-content-center justify-content-xl-center" id="of-serverbuttons" style="padding-bottom: 16px;"> <div class="row row-cols-2 d-xl-flex justify-content-center justify-content-xl-center" id="of-serverbuttons" style="padding-bottom: 16px;">
<div class="col-4 text-left d-inline-flex justify-content-xl-start"><button class="btn btn-success mr-1" data-toggle="modal" data-bs-tooltip="" data-placement="bottom" id="of-addserver-button" type="button" title="Add Server" data-target="#of-addservermodal"><i class="fas fa-plus"></i></button><button class="btn btn-danger disabled" data-toggle="modal" data-bs-tooltip="" data-placement="bottom" id="of-deleteserver-button" type="button" title="Delete Server" data-target="#of-deleteservermodal" disabled=""><i class="fas fa-trash-alt"></i></button></div> <div class="col-4 text-left d-inline-flex justify-content-xl-start">
<div class="col-4 d-inline-flex justify-content-end"><button class="btn btn-primary disabled" id="of-connect-button" type="button" onclick="connectToServer()" disabled="">Connect&nbsp;<i class="fas fa-angle-double-right"></i></button></div> <button class="btn btn-success mr-1" data-toggle="modal" data-bs-tooltip="" data-placement="bottom" id="of-addserver-button" type="button" title="Add Server" data-target="#of-addservermodal" onclick="deselectServer()"><i class="fas fa-plus"></i></button>
<button class="btn btn-primary mr-1 disabled" data-toggle="modal" data-bs-tooltip="" data-placement="bottom" id="of-editserver-button" type="button" title="Edit Server" data-target="#of-editservermodal" disabled=""><i class="fas fa-edit"></i></button>
<button class="btn btn-danger mr-1 disabled" data-toggle="modal" data-bs-tooltip="" data-placement="bottom" id="of-deleteserver-button" type="button" title="Delete Server" data-target="#of-deleteservermodal" disabled=""><i class="fas fa-trash-alt"></i></button>
</div>
<div class="col-4 d-inline-flex justify-content-end">
<button class="btn btn-primary disabled" id="of-connect-button" type="button" onclick="connectToServer()" disabled="">Connect&nbsp;<i class="fas fa-angle-double-right"></i></button>
</div>
</div> </div>
</div> </div>
<div class="modal fade" role="dialog" tabindex="-1" id="of-aboutmodal"> <div class="modal fade" role="dialog" tabindex="-1" id="of-aboutmodal">
@ -75,6 +81,19 @@
</div> </div>
</div> </div>
</div> </div>
<div class="modal fade" role="dialog" tabindex="-1" id="of-editservermodal">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Edit 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="editserver-form" class="needs-validation"><label for="editserver-descinput">Server Description</label><input class="form-control form-row w-75" type="text" id="editserver-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="editserver-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="editserver-versionselect">Game Version:&nbsp;</label><select class="form-control w-50" id="editserver-versionselect" required="" style="margin-left: -5px;"></select></form>
</div>
<div class="modal-footer"><button class="btn btn-primary border rounded border-primary btn-danger border-danger" id="editserver-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="editserver-form" onclick="editServer();">Save</button></div>
</div>
</div>
</div>
<div class="modal fade" role="dialog" tabindex="-1" id="of-deleteservermodal"> <div class="modal fade" role="dialog" tabindex="-1" id="of-deleteservermodal">
<div class="modal-dialog modal-dialog-centered" role="document"> <div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content"> <div class="modal-content">
@ -88,7 +107,21 @@
</div> </div>
</div> </div>
</div> </div>
<div class="modal fade" role="dialog" tabindex="-1" id="of-restoreserversmodal">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<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 restore the default servers?</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="restoreDefaultServers();">Yes, Restore</button></div>
</div>
</div>
</div>
<div id="of-versionnumber"><a class="text-monospace text-secondary" href="#of-aboutmodal" data-toggle="modal" data-target="#of-aboutmodal">v1.3</a></div> <div id="of-versionnumber"><a class="text-monospace text-secondary" href="#of-aboutmodal" data-toggle="modal" data-target="#of-aboutmodal">v1.3</a></div>
<div id="of-restoreservers"><a class="text-monospace text-secondary" href="#of-restoreserversmodal" data-toggle="modal" data-target="#of-restoreserversmodal">Reset to Default Servers</a></div>
</section> </section>
<section> <section>
<div id="client" style="width: 100%;height: 100%;margin: 0;padding: 0;background: #000;clear:both;"></div> <div id="client" style="width: 100%;height: 100%;margin: 0;padding: 0;background: #000;clear:both;"></div>