players_element.innerHTML = '';
for (const player of players) {
- var li =document.createElement('li');
+ var li = document.createElement('li');
+ li.id = "player-" + player.id;
li.innerText = player.name;
players_element.appendChild(li);
}
const player = JSON.parse(event.data);
const li = document.createElement('li');
+ li.id = "player-" + player.id;
li.innerText = player.name;
players.appendChild(li);
});
+
+events.addEventListener("player-deregister", function(event) {
+ const players = document.getElementById("players");
+ const id = JSON.parse(event.data);
+ const player = document.getElementById("player-" + id.id);
+
+ players.removeChild(player);
+});
+
+events.addEventListener("capture", function(event_string) {
+ const players = document.getElementById("players");
+ const event = JSON.parse(event_string.data);
+ const player = document.getElementById("player-" + event.captee);
+
+ players.removeChild(player);
+});