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