Files
Froxlor/templates/Froxlor/assets/js/jquery/ipsandports.js
Michael Kaufmann bb83e78c64 fix missing csrf tokens for some ajax requests
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
2024-03-27 10:08:13 +01:00

35 lines
874 B
JavaScript

export default function () {
$(function () {
/*
* ipsandports - check for internal ip and output a notice if private-range ip is given
*/
$('#ip').on('change', function () {
var ipval = $(this).val();
if (ipval.length > 0) {
$('#ipnote').remove();
$('#ip').removeClass('is-invalid');
$.ajax({
url: "admin_ipsandports.php?page=overview&action=jqCheckIP",
type: "POST",
data: {
ip: ipval
},
dataType: "json",
beforeSend: function (request) {
request.setRequestHeader('X-CSRF-TOKEN', document.querySelector('meta[name="csrf-token"]').getAttribute('content'));
},
success: function (json) {
if (json != 0) {
$('#ip').addClass('is-invalid');
$('#ip').parent().append(json);
}
},
error: function (a, b) {
console.log(a, b);
}
});
}
});
});
}