summaryrefslogtreecommitdiff
path: root/public
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-02-25 14:09:27 +0100
committerTor Andersson <tor@ccxvii.net>2023-02-26 12:58:37 +0100
commit3371ae0b738c387aaa7d641f785207889afbcc23 (patch)
treed60a83528a1e3a5bafe69a94abee20b54848eeff /public
parent85bbfc60199996baaff0132f6d0b51ebc1e5adf8 (diff)
downloadserver-3371ae0b738c387aaa7d641f785207889afbcc23.tar.gz
Make user name and player presence lists more robust.
Cope with special characters like + etc.
Diffstat (limited to 'public')
-rw-r--r--public/common/play.js9
1 files changed, 3 insertions, 6 deletions
diff --git a/public/common/play.js b/public/common/play.js
index 964889b..77fcaab 100644
--- a/public/common/play.js
+++ b/public/common/play.js
@@ -375,9 +375,8 @@ function on_game_over() {
function init_player_names(players) {
for (let i = 0; i < roles.length; ++i) {
- let sel = "#" + roles[i].id + " .role_user"
let p = players.find(p => p.role === roles[i].role)
- document.querySelector(sel).textContent = p ? p.name : "NONE"
+ document.getElementById(roles[i].id).querySelector(".role_user").textContent = p ? p.name : "NONE"
}
}
@@ -460,12 +459,10 @@ function connect_play() {
break
case 'presence':
+ let list = Array.isArray(arg) ? arg : Object.keys(arg)
for (let i = 0; i < roles.length; ++i) {
let elt = document.getElementById(roles[i].id)
- if (roles[i].role in arg)
- elt.classList.add("present")
- else
- elt.classList.remove("present")
+ elt.classList.toggle("present", list.includes(roles[i].role))
}
break