kontakt: [email protected]
Widżet:MTA: Różnice pomiędzy wersjami
Przejdź do nawigacji
Przejdź do wyszukiwania
chuj do dupy |
Nie podano opisu zmian |
||
(Nie pokazano 5 pośrednich wersji utworzonych przez tego samego użytkownika) | |||
Linia 1: | Linia 1: | ||
<includeonly><script type="text/javascript"> | <includeonly><!--{if $online_count_container_id or $online_list_container_id}--><script type="text/javascript"> | ||
fetch("https://api.cors.lol/?url=http://<!--{$server_url|default:'158.180.44.86:22005'|escape:'javascript'}-->/api/online").then(resp => resp.json()).then(json => { | let timer; | ||
let fetchData = () => { | |||
fetch("https://api.cors.lol/?url=http://<!--{$server_url|default:'158.180.44.86:22005'|escape:'javascript'}-->/api/v1/online").then(resp => resp.json()).then(json => {<!--{if $online_count_container_id}--> | |||
let onlineCountString = json.playersOnline.length + "/" + json.maximumPlayers; | |||
}); | let container = document.getElementById("<!--{$online_count_container_id|escape:'javascript'}-->"); | ||
</script></includeonly> | container.innerText = onlineCountString;<!--{/if}--><!--{if $online_list_container_id}--> | ||
<!--{if not $online_count_container_id}-->let <!--{/if}-->container = document.getElementById("<!--{$online_list_container_id|escape:'javascript'}-->"); | |||
let ul = document.createElement("ul"); | |||
for (let p of json.playersOnline) { | |||
let li = document.createElement("li"); | |||
li.innerHTML = `<span style="color: ${p.color};">${p.name}</span>`; | |||
ul.appendChild(li); | |||
} | |||
if (container.querySelector("ul")) { | |||
container.querySelector("ul").replaceWith(ul); | |||
} else { | |||
container.appendChild(ul); | |||
}<!--{/if}--> | |||
}); | |||
}; | |||
fetchData(); | |||
<!--{if $refresh_time}-->timer = setInterval(fetchData, <!--{$refresh_time|escape:'javascript'|validate:'int'|default:30}--> * 1000);<!--{/if}--> | |||
</script><!--{/if}--></includeonly> |