summaryrefslogtreecommitdiff
path: root/web/web_scoreboard.c
diff options
context:
space:
mode:
authorDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2022-05-04 15:16:56 -0700
committerDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2022-05-04 15:16:56 -0700
commitdf307f86ad32fcc841c770e8f5af72e8c0b80cfb (patch)
tree1881655a210d183ef775c1427906c765c1b14240 /web/web_scoreboard.c
parentba56ae56ebec73ca8ea966fde4bb385f911a6669 (diff)
downloaddartboat-df307f86ad32fcc841c770e8f5af72e8c0b80cfb.tar.gz
dartboat-df307f86ad32fcc841c770e8f5af72e8c0b80cfb.tar.xz
web: abstract away most EM_ASM calls to dom file
Diffstat (limited to 'web/web_scoreboard.c')
-rw-r--r--web/web_scoreboard.c20
1 files changed, 8 insertions, 12 deletions
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");
}