From e297ac65f8f0cde103880c73d0c92ad3cb50f161 Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Tue, 3 May 2022 13:21:24 -0700 Subject: web: more use of generic JS functions --- web/web_scoreboard.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'web/web_scoreboard.c') diff --git a/web/web_scoreboard.c b/web/web_scoreboard.c index 34ee4c5..b9b4688 100644 --- a/web/web_scoreboard.c +++ b/web/web_scoreboard.c @@ -17,6 +17,18 @@ struct player_info { struct player_info buffered_info[2], flushed_info[2]; +void scoreboard_set_player_active(int pn) +{ + char sel[64], *psel = sel; + + if (pn == -1) + psel = NULL; + else + sprintf(sel, "#p%d-info", pn); + + EM_ASM({elemSetUniqClass($0, $1, $2)}, psel, "active", "[id$=-info]"); +} + static inline void buffer_str(char *str, char **buffer, char *flushed) { if (str == *buffer || (str && *buffer && !strcmp(str, *buffer))) @@ -149,6 +161,13 @@ void update_player_rem(int pn, int rem) update_player_sugg(pn, rem); } +void show_player_info(int pn) +{ + char sel[64]; + sprintf(sel, "#p%d-info-inner", pn); + EM_ASM({elemAddClass($0, $1)}, sel, "visible"); +} + void clear_player_info(int pn) { scoreboard_set_player_name(pn, NULL); -- cgit v1.2.3-70-g09d2