From df307f86ad32fcc841c770e8f5af72e8c0b80cfb Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Wed, 4 May 2022 15:16:56 -0700 Subject: web: abstract away most EM_ASM calls to dom file --- web/web_scoreboard.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'web/web_scoreboard.c') diff --git a/web/web_scoreboard.c b/web/web_scoreboard.c index 1b3660d..1d28cbf 100644 --- a/web/web_scoreboard.c +++ b/web/web_scoreboard.c @@ -27,7 +27,7 @@ void scoreboard_set_player_active(int pn) else sprintf(sel, "#p%d-info", pn); - EM_ASM({elemSetUniqClass($0, $1, $2)}, psel, "active", "[id$=-info]"); + dom_elem_set_uniq_class(psel, "active", "[id$=-info]"); } static inline void buffer_str(char *str, char **buffer, char *flushed) @@ -83,29 +83,25 @@ void scoreboard_flush_player_info(int pn) if (buffered_str_changed(buffered_info[pn-1].name, flushed_info[pn-1].name)) { strcpy(sel + len, "name"); - EM_ASM({elemSetContent($0, $1)}, - sel, buffered_info[pn-1].name); + dom_elem_set_content(sel, buffered_info[pn-1].name); } if (buffered_str_changed(buffered_info[pn-1].rem, flushed_info[pn-1].rem)) { strcpy(sel + len, "rem"); - EM_ASM({elemSetContent($0, $1)}, - sel, buffered_info[pn-1].rem); + dom_elem_set_content(sel, buffered_info[pn-1].rem); } if (buffered_str_changed(buffered_info[pn-1].sugg, flushed_info[pn-1].sugg)) { strcpy(sel + len, "sugg"); - EM_ASM({elemSetContent($0, $1)}, - sel, buffered_info[pn-1].sugg); + dom_elem_set_content(sel, buffered_info[pn-1].sugg); } if (buffered_str_changed(buffered_info[pn-1].avg, flushed_info[pn-1].avg)) { strcpy(sel + len, "avg"); - EM_ASM({elemSetContent($0, $1)}, - sel, buffered_info[pn-1].avg); + dom_elem_set_content(sel, buffered_info[pn-1].avg); } free_flushed_str(flushed_info[pn-1].name, buffered_info[pn-1].name); @@ -176,7 +172,7 @@ void show_player_info(int pn) { char sel[64]; sprintf(sel, "#p%d-info-inner", pn); - EM_ASM({elemAddClass($0, $1)}, sel, "visible"); + dom_elem_add_class(sel, "visible"); } void clear_player_info(int pn) @@ -215,7 +211,7 @@ void add_colour_class(char *buf, int pts) void draw_visits() { - EM_ASM({elemSetContent($0, $1)}, "#visits", NULL); + dom_elem_set_content("#visits", NULL); int n_visits = state->legs[0]->n_visits > state->legs[1]->n_visits ? state->legs[0]->n_visits : state->legs[1]->n_visits; @@ -265,5 +261,5 @@ void draw_visits() elem_free(elemv[i]); free(elemv); - EM_ASM({elemScrollToBottom($0)}, "#visits"); + dom_elem_scroll_to_bottom("#visits"); } -- cgit v1.2.3-70-g09d2