Untitled
unknown
plain_text
13 days ago
3.3 kB
4
Indexable
d = [ { name: "HorizonMTA", logo: "v4", api: "HorizonMTA", color: "#E93A27", fb: "", ucp: "", forum: "", }, ]; for (let E = 0; E < d.length; E++) { d[E].chart = ot(!1); d[E].playerNum = ot(!1); } function h(response) { if (response.data) { const data = JSON.parse(response.data); for (let i = 0; i < d.length; i++) { if (d[i].api === "HorizonMTA") { console.log("found"); d[i].playerNum.value = data.players; let maxTime = 0; if (d[i].chart.value) { for (let j = 0; j < d[i].chart.value.length; j++) { maxTime = Math.max(maxTime, d[i].chart.value[j].x); } const currentTime = Date.now() / 1000; console.log("delta: " + (currentTime - maxTime)); if (currentTime - maxTime > 60) { console.log("Új perc chart frissítés"); d[i].chart.value.push({ x: parseInt(currentTime), y: data.players }); if (d[i].chart.value.length > 30) { d[i].chart.value.shift(); // Max 30 adatpont } } } } } } } function g(response) { if (response.data) { const data = JSON.parse(response.data); for (let i = 0; i < d.length; i++) { if (d[i].api === "HorizonMTA") { console.log("found historical data"); let chartData = []; if (Array.isArray(data.chart)) { for (let j = 0; j < data.chart.length; j++) { chartData.push({ x: parseInt(data.chart[j].x), y: parseInt(data.chart[j].y) }); } } d[i].chart.value = chartData; } } } } function x() { console.log("refreshing player nums"); ce.get("server_status.php").then(h); } let C = !1; Ht(() => { window.addEventListener("scroll", i); window.addEventListener("resize", i); i(); x(); C = setInterval(x, 30 * 1e3); ce.get("server_status.php").then(g); }); bn(() => { window.removeEventListener("scroll", i); window.removeEventListener("resize", i); clearInterval(C); }); const R = ot(Math.floor(Math.random() * 20) + 1);
Editor is loading...
Leave a Comment