Appease sonar

This commit is contained in:
amcmanu3
2023-09-04 20:05:25 -04:00
parent 3467c1ccd6
commit c1d0902ea5
4 changed files with 36 additions and 42 deletions

View File

@ -77,8 +77,8 @@
{% block js %} {% block js %}
<script> <script>
// ##### Log Filter Block ##### // ##### Log Filter Block #####
var lines = []; let lines = [];
var words = []; let words = [];
if (localStorage.getItem("words")) { if (localStorage.getItem("words")) {
try { try {
words = JSON.parse(localStorage.getItem("words")); words = JSON.parse(localStorage.getItem("words"));
@ -199,9 +199,9 @@
}, },
}); });
let responseData = await res.json(); let responseData = await res.json();
html = `` let html = ``
if (responseData.status === "ok") { if (responseData.status === "ok") {
for (i = 0; i < responseData.data.length; i++) { for (let i = 0; i < responseData.data.length; i++) {
html += `<span class='box'>${responseData.data[i]}<br /></span>` html += `<span class='box'>${responseData.data[i]}<br /></span>`
} }
console.log('Got Log From Server') console.log('Got Log From Server')

View File

@ -59,7 +59,7 @@
</div> </div>
</div> </div>
<div class="card-body"> <div class="card-body">
<table class="table table-hover d-none d-lg-block responsive-table" id="schedule_table" width="100%" <table class="table table-hover d-none d-lg-block responsive-table" id="schedule_table"
style="table-layout:fixed;" aria-describedby="Schedule List"> style="table-layout:fixed;" aria-describedby="Schedule List">
<thead> <thead>
<tr class="rounded"> <tr class="rounded">
@ -128,7 +128,7 @@
</tbody> </tbody>
</table> </table>
<hr /> <hr />
<table class="table table-hover d-block d-lg-none" id="mini_schedule_table" width="100%" <table class="table table-hover d-block d-lg-none" id="mini_schedule_table"
style="table-layout:fixed;" aria-describedby="Schedule List Mobile"> style="table-layout:fixed;" aria-describedby="Schedule List Mobile">
<thead> <thead>
<tr class="rounded"> <tr class="rounded">

View File

@ -196,12 +196,10 @@
document.getElementById('control_buttons').innerHTML = '<button onclick="" id="start-btn" style="max-width: 7rem;" class="btn btn-primary m-1 flex-grow-1">{{ translate("serverTerm", "updating", data["lang"]) }}</button><button onclick="" id="restart-btn" style="max-width: 7rem;" class="btn btn-outline-primary m-1 flex-grow-1">{% raw translate("serverTerm", "restart", data["lang"]) %}</button><button onclick="" id="stop-btn" style="max-width: 7rem;" class="btn btn-danger m-1 flex-grow-1 disabled">{{ translate("serverTerm", "stop", data["lang"]) }}</button>'; document.getElementById('control_buttons').innerHTML = '<button onclick="" id="start-btn" style="max-width: 7rem;" class="btn btn-primary m-1 flex-grow-1">{{ translate("serverTerm", "updating", data["lang"]) }}</button><button onclick="" id="restart-btn" style="max-width: 7rem;" class="btn btn-outline-primary m-1 flex-grow-1">{% raw translate("serverTerm", "restart", data["lang"]) %}</button><button onclick="" id="stop-btn" style="max-width: 7rem;" class="btn btn-danger m-1 flex-grow-1 disabled">{{ translate("serverTerm", "stop", data["lang"]) }}</button>';
} }
} }
else { else if (updateButton.server_id == serverId) {
if (updateButton.server_id == serverId) {
window.location.reload() window.location.reload()
document.getElementById('update_control_buttons').innerHTML = '<button onclick="send_command(serverId, "start_server");" id="start-btn" style="max-width: 7rem;" class="btn btn-primary m-1 flex-grow-1">{{ translate("serverTerm", "start", data["lang"]) }}</button><button onclick="send_command(serverId, "restart_server");" id="restart-btn" style="max-width: 7rem;" class="btn btn-outline-primary m-1 flex-grow-1">{% raw translate("serverTerm", "restart", data["lang"]) %}</button><button onclick="" id="stop-btn" style="max-width: 7rem;" class="btn btn-danger m-1 flex-grow-1 disabled">{{ translate("serverTerm", "stop", data["lang"]) }}</button>'; document.getElementById('update_control_buttons').innerHTML = '<button onclick="send_command(serverId, "start_server");" id="start-btn" style="max-width: 7rem;" class="btn btn-primary m-1 flex-grow-1">{{ translate("serverTerm", "start", data["lang"]) }}</button><button onclick="send_command(serverId, "restart_server");" id="restart-btn" style="max-width: 7rem;" class="btn btn-outline-primary m-1 flex-grow-1">{% raw translate("serverTerm", "restart", data["lang"]) %}</button><button onclick="" id="stop-btn" style="max-width: 7rem;" class="btn btn-danger m-1 flex-grow-1 disabled">{{ translate("serverTerm", "stop", data["lang"]) }}</button>';
} }
}
}); });
} }
// Convert running to lower case (example: 'True' converts to 'true') and // Convert running to lower case (example: 'True' converts to 'true') and
@ -240,9 +238,9 @@
}, },
}); });
let responseData = await res.json(); let responseData = await res.json();
html = `` let html = ``
if (responseData.status === "ok") { if (responseData.status === "ok") {
for (i = 0; i < responseData.data.length; i++) { for (let i = 0; i < responseData.data.length; i++) {
html += `<span class='box'>${responseData.data[i]}<br /></span>` html += `<span class='box'>${responseData.data[i]}<br /></span>`
} }
console.log('Got Log From Server') console.log('Got Log From Server')
@ -273,7 +271,7 @@
//used to get cookies from browser - this is part of tornados xsrf protection - it's for extra security //used to get cookies from browser - this is part of tornados xsrf protection - it's for extra security
function getCookie(name) { function getCookie(name) {
var r = document.cookie.match("\\b" + name + "=([^;]*)\\b"); let r = document.cookie.match("\\b" + name + "=([^;]*)\\b");
return r ? r[1] : undefined; return r ? r[1] : undefined;
} }
@ -308,7 +306,7 @@
}); });
function scrollConsole() { function scrollConsole() {
var logview = $('#virt_console'); let logview = $('#virt_console');
if (logview.length) if (logview.length)
logview.scrollTop(logview[0].scrollHeight - logview.height()); logview.scrollTop(logview[0].scrollHeight - logview.height());
} }
@ -387,7 +385,7 @@
} }
$(document).ready(() => { $(document).ready(() => {
var scrolled = false; let scrolled = false;
$('#virt_console').on('scroll', chkScroll); $('#virt_console').on('scroll', chkScroll);
$('#to-bottom').on('click', scrollToBottom) $('#to-bottom').on('click', scrollToBottom)
}); });

View File

@ -822,8 +822,7 @@
} else { } else {
document.getElementById('root_files_button').classList.add('clicked') document.getElementById('root_files_button').classList.add('clicked')
} }
const token = getCookie("_xsrf"); bootbox.dialog({
var dialog = bootbox.dialog({
message: '<p class="text-center mb-0"><i class="fa fa-spin fa-cog"></i> Please wait while we gather your files...</p>', message: '<p class="text-center mb-0"><i class="fa fa-spin fa-cog"></i> Please wait while we gather your files...</p>',
closeButton: false closeButton: false
}); });
@ -840,8 +839,7 @@
} else { } else {
document.getElementById('root_upload_button').classList.add('clicked') document.getElementById('root_upload_button').classList.add('clicked')
} }
const token = getCookie("_xsrf"); bootbox.dialog({
var dialog = bootbox.dialog({
message: '<p class="text-center mb-0"><i class="fa fa-spin fa-cog"></i> Please wait while we gather your files...</p>', message: '<p class="text-center mb-0"><i class="fa fa-spin fa-cog"></i> Please wait while we gather your files...</p>',
closeButton: false closeButton: false
}); });
@ -885,8 +883,6 @@
document.getElementById("lower_half").hidden = false; document.getElementById("lower_half").hidden = false;
} }
else { else {
let response_text = JSON.parse(event.target.responseText);
var x = document.querySelector('.bootbox');
console.log(JSON.parse(event.target.responseText).info) console.log(JSON.parse(event.target.responseText).info)
bootbox.alert({ bootbox.alert({
message: JSON.parse(event.target.responseText).info, message: JSON.parse(event.target.responseText).info,
@ -894,7 +890,7 @@
window.location.reload(); window.location.reload();
} }
}); });
doUpload = false; let doUpload = false;
} }
}, false); }, false);
xmlHttpRequest.addEventListener('error', (e) => { xmlHttpRequest.addEventListener('error', (e) => {
@ -1111,7 +1107,7 @@
} }
function hide(event) { function hide(event) {
var items = document.getElementsByClassName('menu'); let items = document.getElementsByClassName('menu');
items.forEach(item => { items.forEach(item => {
item.classList.add("d-none"); item.classList.add("d-none");
}) })
@ -1121,11 +1117,11 @@
$(document).ready(function () { $(document).ready(function () {
console.log('ready'); console.log('ready');
var forms = $('form.server-wizard'); let forms = $('form.server-wizard');
forms.each(function (i, formEl) { forms.each(function (i, formEl) {
var form = $(formEl); let form = $(formEl);
var min = form.find('[name=min_memory]'); let min = form.find('[name=min_memory]');
var max = form.find('[name=max_memory]'); let max = form.find('[name=max_memory]');
console.log(form, min, max) console.log(form, min, max)
min.change(function () { min.change(function () {
check_sizes(max, min, 'min'); check_sizes(max, min, 'min');
@ -1145,8 +1141,8 @@
function check_sizes(a, b, changed) { function check_sizes(a, b, changed) {
max_mem = parseFloat(a.val()); let max_mem = parseFloat(a.val());
min_mem = parseFloat(b.val()); let min_mem = parseFloat(b.val());
if (max_mem < min_mem && changed === 'min') { if (max_mem < min_mem && changed === 'min') {
a.val(min_mem) a.val(min_mem)
} }
@ -1192,18 +1188,19 @@
</script> </script>
<script type="text/javascript"> <script type="text/javascript">
var text = '{% raw data["js_server_types"] %}'; const text = '{% raw data["js_server_types"] %}';
var serverTypesLists = JSON.parse(text); const serverTypesLists = JSON.parse(text);
/* CountryChange() is called from the onchange event of a select element. /* CountryChange() is called from the onchange event of a select element.
* param selectObj - the select object which fired the on change event. * param selectObj - the select object which fired the on change event.
*/ */
function serverTypeChange(selectObj) { function serverTypeChange(selectObj) {
// get the index of the selected option // get the index of the selected option
var idx = document.getElementById('server_type').selectedIndex; let idx = document.getElementById('server_type').selectedIndex;
// get the value of the selected option // get the value of the selected option
var cSelect = document.getElementById("server"); let cSelect = document.getElementById("server");
let which;
try { try {
var which = document.getElementById('server_type').options[idx].value; which = document.getElementById('server_type').options[idx].value;
} catch { } catch {
while (cSelect.options.length > 0) { while (cSelect.options.length > 0) {
cSelect.remove(0); cSelect.remove(0);
@ -1215,13 +1212,12 @@
// use the selected option value to retrieve the list of items from the serverTypesLists array // use the selected option value to retrieve the list of items from the serverTypesLists array
let cList = serverTypesLists[server_type]; let cList = serverTypesLists[server_type];
// get the country select element via its known id // get the country select element via its known id
var cSelect = document.getElementById("server"); cSelect = document.getElementById("server");
// remove the current options from the country select // remove the current options from the country select
var len = cSelect.options.length;
while (cSelect.options.length > 0) { while (cSelect.options.length > 0) {
cSelect.remove(0); cSelect.remove(0);
} }
var newOption; let newOption;
// create new options ordered by ascending // create new options ordered by ascending
cList[server].forEach(type => { cList[server].forEach(type => {
newOption = document.createElement("option"); newOption = document.createElement("option");
@ -1241,8 +1237,9 @@
let type_select = document.getElementById('server_jar') let type_select = document.getElementById('server_jar')
let tidx = type_select.selectedIndex; let tidx = type_select.selectedIndex;
let val = type_select.options[tidx].value; let val = type_select.options[tidx].value;
let jcSelect = "";
if (val == 'None') { if (val == 'None') {
var jcSelect = document.getElementById("server_type"); jcSelect = document.getElementById("server_type");
while (jcSelect.options.length > 0) { while (jcSelect.options.length > 0) {
jcSelect.remove(0); jcSelect.remove(0);
} }
@ -1250,19 +1247,18 @@
return; return;
} }
// get the index of the selected option // get the index of the selected option
var jidx = selectObj.selectedIndex; let jidx = selectObj.selectedIndex;
// get the value of the selected option // get the value of the selected option
var jwhich = selectObj.options[jidx].value; let jwhich = selectObj.options[jidx].value;
// use the selected option value to retrieve the list of items from the serverTypesLists array // use the selected option value to retrieve the list of items from the serverTypesLists array
jcList = Object.keys(serverTypesLists[jwhich]); jcList = Object.keys(serverTypesLists[jwhich]);
// get the country select element via its known id // get the country select element via its known id
var jcSelect = document.getElementById("server_type"); jcSelect = document.getElementById("server_type");
// remove the current options from the country select // remove the current options from the country select
var jlen = jcSelect.options.length;
while (jcSelect.options.length > 0) { while (jcSelect.options.length > 0) {
jcSelect.remove(0); jcSelect.remove(0);
} }
var jnewOption; let jnewOption;
// create new options ordered by ascending // create new options ordered by ascending
jcList.forEach(type => { jcList.forEach(type => {
jnewOption = document.createElement("option"); jnewOption = document.createElement("option");