diff options
author | Tor Andersson <tor@ccxvii.net> | 2022-10-03 16:30:13 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2022-10-05 17:36:50 +0200 |
commit | f972745ac092a1657d40d9fb01f7c68508a7c416 (patch) | |
tree | cf4d51b2d496f397f16aa5d1eedcc6219dc239b5 /public | |
parent | d214832a193a06f20612fcfb3e64f86562235b70 (diff) | |
download | server-f972745ac092a1657d40d9fb01f7c68508a7c416.tar.gz |
Add contact list with friends and blacklisted users.
Diffstat (limited to 'public')
-rw-r--r-- | public/join.js | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/public/join.js b/public/join.js index f199329..d140230 100644 --- a/public/join.js +++ b/public/join.js @@ -99,6 +99,14 @@ function start_event_source() { } } +function is_friend(p) { + return whitelist.includes(p.user_id) +} + +function is_enemy(p) { + return blacklist.includes(p.user_id) +} + function is_active(player, role) { return (game.active === role || game.active === "Both" || game.active === "All") } @@ -127,21 +135,27 @@ function update() { case 1: element.classList.toggle("is_active", is_active(player, role)) if (player.user_id === user_id) - element.innerHTML = `<a class="red" href="javascript:part('${role}')">\u274c</a> <a href="/${game.title_id}/play:${game.game_id}:${role}">${player.name}</a>` + element.innerHTML = `<a href="/${game.title_id}/play:${game.game_id}:${role}">${player.name}</a><a class="red" href="javascript:part('${role}')">\u274c</a>` else if (game.owner_id === user_id) - element.innerHTML = `<a class="red" href="javascript:kick('${role}')">\u274c</a> ${player.name}` + element.innerHTML = `${player.name}<a class="red" href="javascript:kick('${role}')">\u274c</a>` else element.innerHTML = player.name break case 0: if (player.user_id === user_id) - element.innerHTML = `<a class="red" href="javascript:part('${role}')">\u274c</a> ${player.name}` + element.innerHTML = `${player.name}<a class="red" href="javascript:part('${role}')">\u274c</a>` else if (game.owner_id === user_id) - element.innerHTML = `<a class="red" href="javascript:kick('${role}')">\u274c</a> ${player.name}` + element.innerHTML = `${player.name}<a class="red" href="javascript:kick('${role}')">\u274c</a>` else element.innerHTML = player.name break } + element.classList.toggle("friend", is_friend(player)) + element.classList.toggle("enemy", is_enemy(player)) + if (is_enemy(player)) + element.title = "You have blacklisted this user!" + else + element.title = "" } else { switch (game.status) { case 2: @@ -152,6 +166,9 @@ function update() { element.innerHTML = `<a class="join" href="javascript:join('${role}')">Join</a>` break } + element.classList.remove("friend") + element.classList.remove("enemy") + element.title = "" } } |