document.addEventListener("DOMContentLoaded",function(){var t=new ApexCharts(document.querySelector("#chart"),{chart:{type:"bar",height:"100%"},series:[{name:"Metrics",data:[0,0,0]}],xaxis:{categories:["Total Users","Blocked Users","Done Steps"]},plotOptions:{bar:{distributed:!0,borderRadius:5,dataLabels:{position:"top"}}},fill:{colors:["rgba(0, 143, 251, 0.85)","#ec3c3c","#009688"]},dataLabels:{enabled:!0,formatter:function(t){return t},offsetY:-20,style:{fontSize:"12px",colors:["#FFF"]}},yaxis:{title:{text:"Counts"}}});t.render(),setInterval(function e(){var n=new XMLHttpRequest;n.open("GET","../get-panel/statics.json",!0),n.onload=function(){if(200===n.status){var e=JSON.parse(n.responseText),o=e.total_visit,s=e.total_block,r=e.total_done_steps;document.getElementById("visit-count").textContent=o,document.getElementById("block-count").textContent=s,document.getElementById("steps-count").textContent=r,document.getElementById("visitors").textContent=o,document.getElementById("blockedUsers").textContent=s,document.getElementById("stepsDone").textContent=r,t.updateSeries([{data:[o,s,r]}])}},n.onerror=function(){console.error("Error fetching JSON data")},n.send()},1e3)});
function fetchAndUpdateContent(){var e=document.getElementById("dynamicSection"),t=new XMLHttpRequest;t.open("GET","../actions/fetch_panel.php",!0),t.onreadystatechange=function(){t.readyState===XMLHttpRequest.DONE&&200===t.status&&(e.innerHTML=t.responseText)},t.send(),setTimeout(fetchAndUpdateContent,2e3)}fetchAndUpdateContent();const updatePage=document.getElementById("updatePage");updatePage.addEventListener("click",()=>{location.reload()}),document.getElementById("clearTableInformationUser").addEventListener("click",function(){var e=new XMLHttpRequest;e.open("GET","../actions/remove_data.php",!0),e.onreadystatechange=function(){e.readyState===XMLHttpRequest.DONE&&(200===e.status?e.responseText:alert("Error: "+e.statusText))},e.send()});
const menu=document.getElementById("menu"),buttonMenu=document.getElementById("buttonMenu"),buttonIcon=document.getElementById("buttonIcon");buttonMenu.addEventListener("click",()=>{menu.classList.toggle("show-menu"),!0===menu.classList.contains("show-menu")?buttonIcon.className="fa-solid fa-circle-xmark":buttonIcon.className="fa-solid fa-bars"});