2023-12-09 19:38:58 -08:00

1 line
2.2 KiB
JavaScript

$(".ip_dropdown").on("change",function(){$(".modal.show .btn").removeAttr("disabled")}),$(".conf_dropdown").on("change",function(){$(".modal.show .ip_dropdown").html('<option value="none" selected="selected" disabled>Loading...'),$.ajax({url:"/get_ping_ip",method:"POST",data:"config="+$(this).children("option:selected").val(),success:function(t){$(".modal.show .ip_dropdown").html(""),$(".modal.show .ip_dropdown").append('<option value="none" selected="selected" disabled>Choose an IP'),$(".modal.show .ip_dropdown").append(t)}})}),$(".send_ping").on("click",function(){$(this).attr("disabled","disabled"),$(this).html("Pinging..."),$("#ping_modal .form-control").attr("disabled","disabled"),$.ajax({method:"POST",data:"ip="+$(":selected",$("#ping_modal .ip_dropdown")).val()+"&count="+$("#ping_modal .ping_count").val(),url:"/ping_ip",success:function(t){$(".ping_result tbody").html("");let e='<tr><th scope="row">Address</th><td>'+t.address+'</td></tr><tr><th scope="row">Is Alive</th><td>'+t.is_alive+'</td></tr><tr><th scope="row">Min RTT</th><td>'+t.min_rtt+'ms</td></tr><tr><th scope="row">Average RTT </th><td>'+t.avg_rtt+'ms</td></tr><tr><th scope="row">Max RTT</th><td>'+t.max_rtt+'ms</td></tr><tr><th scope="row">Package Sent</th><td>'+t.package_sent+'</td></tr><tr><th scope="row">Package Received</th><td>'+t.package_received+'</td></tr><tr><th scope="row">Package Loss</th><td>'+t.package_loss+"</td></tr>";$(".ping_result tbody").html(e),$(".send_ping").removeAttr("disabled"),$(".send_ping").html("Ping"),$("#ping_modal .form-control").removeAttr("disabled")}})}),$(".send_traceroute").on("click",function(){$(this).attr("disabled","disabled"),$(this).html("Tracing..."),$("#traceroute_modal .form-control").attr("disabled","disabled"),$.ajax({url:"/traceroute_ip",method:"POST",data:"ip="+$(":selected",$("#traceroute_modal .ip_dropdown")).val(),success:function(t){$(".traceroute_result tbody").html(""),t.forEach(t=>$(".traceroute_result tbody").append('<tr><th scope="row">'+t.hop+"</th><td>"+t.ip+"</td><td>"+t.avg_rtt+"</td><td>"+t.min_rtt+"</td><td>"+t.max_rtt+"</td></tr>")),$(".send_traceroute").removeAttr("disabled").html("Traceroute"),$("#traceroute_modal .form-control").removeAttr("disabled")}})});