1
0
mirror of https://github.com/KubaPro010/fm-dx-webserver.git synced 2026-02-26 22:13:53 +01:00

banlist & config fixes

This commit is contained in:
Marek Farkaš
2025-01-11 20:30:57 +01:00
parent 4d3380f068
commit 49c6e08b98
9 changed files with 157 additions and 156 deletions

View File

@@ -9,6 +9,7 @@ $(document).ready(function() {
showPanelFromHash();
initNav();
initBanlist();
});
/**
@@ -85,6 +86,54 @@ function initNav() {
});
}
function initBanlist() {
$('.banlist-add').on('click', function(e) {
e.preventDefault();
const ipAddress = $('#banlist-add-ip').val();
const reason = $('#banlist-add-reason').val();
$.ajax({
url: '/addToBanlist',
method: 'GET',
data: { ip: ipAddress, reason: reason },
success: function(response) {
// Refresh the page if the request was successful
if (response.success) {
location.reload();
} else {
console.error('Failed to add to banlist');
}
},
error: function() {
console.error('Error occurred during the request');
}
});
});
$('.banlist-remove').on('click', function(e) {
e.preventDefault();
const ipAddress = $(this).closest('tr').find('td').first().text();
$.ajax({
url: '/removeFromBanlist',
method: 'GET',
data: { ip: ipAddress },
success: function(response) {
if (response.success) {
location.reload();
} else {
console.error('Failed to remove from banlist');
}
},
error: function() {
console.error('Error occurred during the request');
}
});
});
}
function toggleNav() {
const navOpen = $("#navigation").css('margin-left') === '0px';
const isMobile = window.innerWidth <= 768;