document.addEventListener("DOMContentLoaded",function(){const s=document.getElementById("pingForm"),n=document.getElementById("pingResult"),o=document.getElementById("pingOutput");s&&s.addEventListener("submit",function(t){t.preventDefault(),u()});function u(){const t=document.getElementById("ping_host").value.trim(),d=document.getElementById("ping_count").value||4;if(!t){i("Host address is required");return}c(),fetch("/api/v1/admin/network-tools/ping",{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer "+document.querySelector('meta[name="api-token"]').getAttribute("content")},body:JSON.stringify({host:t,count:parseInt(d)})}).then(e=>e.json()).then(e=>{e.success?r(e.data):i(e.message||"Ping query failed")}).catch(e=>{console.error("Error:",e),i("An error occurred: "+e.message)})}function r(t){o.textContent=t.output||"Output not found",n.style.display="block"}function c(){o.textContent="Pinging...",n.style.display="block"}function i(t){o.innerHTML=`<div class="alert alert-danger">${t}</div>`,n.style.display="block"}});
