mirror of https://github.com/Aidaho12/haproxy-wi
v8.1.3: Improve form validation and update Port Scanner AJAX logic
Replace `==` with `===` for stricter comparisons in form validation. Modify Port Scanner to use a POST request with JSON payload and change response handling to better manage error and success states.pull/410/head v8.1.3
parent
8a99e206d4
commit
cd4d54611c
|
@ -4,16 +4,16 @@ $( function() {
|
||||||
});
|
});
|
||||||
$("#nettools_telnet_form").on("click", ":submit", function (e) {
|
$("#nettools_telnet_form").on("click", ":submit", function (e) {
|
||||||
$('#ajax-nettools').html('');
|
$('#ajax-nettools').html('');
|
||||||
var frm = $('#nettools_telnet_form');
|
let frm = $('#nettools_telnet_form');
|
||||||
if ($('#nettools_telnet_server_from option:selected').val() == '------') {
|
if ($('#nettools_telnet_server_from option:selected').val() === '------') {
|
||||||
toastr.warning('Choose a server From');
|
toastr.warning('Choose a server From');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ($('#nettools_telnet_server_to').val() == '') {
|
if ($('#nettools_telnet_server_to').val() === '') {
|
||||||
toastr.warning('Choose a server To');
|
toastr.warning('Choose a server To');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ($('#nettools_telnet_port_to').val() == '') {
|
if ($('#nettools_telnet_port_to').val() === '') {
|
||||||
toastr.warning('Enter a port To');
|
toastr.warning('Enter a port To');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -109,26 +109,29 @@ $( function() {
|
||||||
});
|
});
|
||||||
$("#nettools_portscanner_form").on("click", ":submit", function (e) {
|
$("#nettools_portscanner_form").on("click", ":submit", function (e) {
|
||||||
$('#ajax-nettools').html('');
|
$('#ajax-nettools').html('');
|
||||||
if ($('#nettools_portscanner_server').val() == '') {
|
let port_server = $('#nettools_portscanner_server').val();
|
||||||
|
$('#ajax-nettools').html('');
|
||||||
|
if (port_server === '') {
|
||||||
toastr.warning('Enter an address');
|
toastr.warning('Enter an address');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "/portscanner/scan/" + $('#nettools_portscanner_server').val(),
|
url: "/portscanner/scan",
|
||||||
|
data: JSON.stringify({'ip': port_server}),
|
||||||
|
type: "POST",
|
||||||
|
contentType: "application/json; charset=utf-8",
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
data = data.replace(/\s+/g, ' ');
|
if (data.status === 'failed') {
|
||||||
if (data.indexOf('danger') != '-1' || data.indexOf('unique') != '-1' || data.indexOf('error:') != '-1') {
|
toastr.error(data.error);
|
||||||
toastr.error(data);
|
|
||||||
} else {
|
} else {
|
||||||
toastr.clear();
|
toastr.clear();
|
||||||
$("#show_scans_ports_body").html(data);
|
$("#show_scans_ports_body").html(data.data);
|
||||||
var close_word = $('#translate').attr('data-close');
|
|
||||||
$("#show_scans_ports").dialog({
|
$("#show_scans_ports").dialog({
|
||||||
resizable: false,
|
resizable: false,
|
||||||
height: "auto",
|
height: "auto",
|
||||||
width: 360,
|
width: 360,
|
||||||
modal: true,
|
modal: true,
|
||||||
title: "{{lang.words.opened|title()}} {{lang.words.ports}}",
|
title: "Open ports",
|
||||||
buttons: [{
|
buttons: [{
|
||||||
text: close_word,
|
text: close_word,
|
||||||
click: function () {
|
click: function () {
|
||||||
|
@ -145,7 +148,7 @@ $( function() {
|
||||||
$("#nettools_whois_form").on("click", ":submit", function (e) {
|
$("#nettools_whois_form").on("click", ":submit", function (e) {
|
||||||
$('#ajax-nettools').html('');
|
$('#ajax-nettools').html('');
|
||||||
var frm = $('#nettools_whois_form');
|
var frm = $('#nettools_whois_form');
|
||||||
if ($('#nettools_whois_name').val() == '') {
|
if ($('#nettools_whois_name').val() === '') {
|
||||||
toastr.warning('Enter a Domain name');
|
toastr.warning('Enter a Domain name');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue