mirror of
https://github.com/FAUSheppy/open-web-leaderboard.git
synced 2025-12-06 07:01:36 +01:00
implement liveupdates player count via set interval
This commit is contained in:
@@ -12,17 +12,21 @@
|
|||||||
<div class="container mt-3 mb-3" role="main">
|
<div class="container mt-3 mb-3" role="main">
|
||||||
<div id="playerDisplay" class="playerDisplay mb-3 mt-2">
|
<div id="playerDisplay" class="playerDisplay mb-3 mt-2">
|
||||||
<script>
|
<script>
|
||||||
fetch("/players-online").then(
|
function players(){
|
||||||
response => response.json()
|
fetch("/players-online").then(
|
||||||
).then(
|
response => response.json()
|
||||||
data => {
|
).then(
|
||||||
if(data["error"] == ""){
|
data => {
|
||||||
document.getElementById("playerDisplay").innerHTML = "Players Online: " + data["player_total"]
|
if(data["error"] == ""){
|
||||||
}else{
|
document.getElementById("playerDisplay").innerHTML = "Players Online: " + data["player_total"]
|
||||||
document.getElementById("playerDisplay").innerHTML = "Players Online: (error)" + data["error"]
|
}else{
|
||||||
|
document.getElementById("playerDisplay").innerHTML = "Players Online: (error)" + data["error"]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
)
|
||||||
)
|
}
|
||||||
|
players()
|
||||||
|
setInterval(players, 2000)
|
||||||
</script>
|
</script>
|
||||||
</div>
|
</div>
|
||||||
<table id="tableMain" class="table table-striped table-bordered table-sm"
|
<table id="tableMain" class="table table-striped table-bordered table-sm"
|
||||||
|
|||||||
Reference in New Issue
Block a user