summaryrefslogtreecommitdiff
path: root/web/web_dom.c
diff options
context:
space:
mode:
authorDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2022-05-05 02:08:11 -0700
committerDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2022-05-05 02:08:25 -0700
commit9ea94a3ac33559c956946a5c49aa2536b218e0fc (patch)
tree08cbe1fc490bc41eb7a700408586d9fcda21468b /web/web_dom.c
parentd5cc3a92f6fd8533b2e1b6240016a402c6fa20ff (diff)
downloaddartboat-9ea94a3ac33559c956946a5c49aa2536b218e0fc.tar.gz
dartboat-9ea94a3ac33559c956946a5c49aa2536b218e0fc.tar.xz
web: clean up scoreboard and dom functions
Diffstat (limited to 'web/web_dom.c')
-rw-r--r--web/web_dom.c44
1 files changed, 22 insertions, 22 deletions
diff --git a/web/web_dom.c b/web/web_dom.c
index 9e7684a..5ce7a3f 100644
--- a/web/web_dom.c
+++ b/web/web_dom.c
@@ -7,9 +7,9 @@
#include <emscripten/emscripten.h>
-struct elem *elem_init(char *ns, char *name, int size_attrs)
+struct dom_elem *dom_elem_init(char *ns, char *name, int size_attrs)
{
- struct elem *e = malloc(sizeof(*e));
+ struct dom_elem *e = malloc(sizeof(*e));
e->ns = ns ? strdup(ns) : NULL;
e->name = strdup(name);
@@ -23,7 +23,7 @@ struct elem *elem_init(char *ns, char *name, int size_attrs)
return e;
}
-void elem_free(struct elem *e)
+void dom_elem_free(struct dom_elem *e)
{
for(int i = 0; i < e->n_attrs; ++i) {
free(e->attr_names[i]);
@@ -37,7 +37,7 @@ void elem_free(struct elem *e)
free(e);
}
-void elem_add_attr(struct elem *e, char *name, char *val)
+void dom_elem_add_attr(struct dom_elem *e, char *name, char *val)
{
if (e->n_attrs == e->size_attrs) {
e->size_attrs *= 2;
@@ -51,66 +51,66 @@ void elem_add_attr(struct elem *e, char *name, char *val)
e->attr_vals[e->n_attrs++] = strdup(val);
}
-void elem_add_attr_double(struct elem *e, char *name, double val)
+void dom_elem_add_attrd(struct dom_elem *e, char *name, double val)
{
char str[512];
sprintf(str, "%f", val);
- elem_add_attr(e, name, str);
+ dom_elem_add_attr(e, name, str);
}
-void append_elemv(char *sel, int elemc, struct elem **elemv)
+void dom_append_elemv(char *sel, int elemc, struct dom_elem **elemv)
{
EM_ASM({elemAppendElemv($0, $1, $2, $3, $4, $5, $6, $7, $8)},
sel, elemc, elemv,
- offsetof(struct elem, ns),
- offsetof(struct elem, name),
- offsetof(struct elem, content),
- offsetof(struct elem, n_attrs),
- offsetof(struct elem, attr_names),
- offsetof(struct elem, attr_vals));
+ offsetof(struct dom_elem, ns),
+ offsetof(struct dom_elem, name),
+ offsetof(struct dom_elem, content),
+ offsetof(struct dom_elem, n_attrs),
+ offsetof(struct dom_elem, attr_names),
+ offsetof(struct dom_elem, attr_vals));
}
-inline char *dom_elem_get_content(char *sel)
+inline char *dom_get_content(char *sel)
{
return (char *)EM_ASM_INT({return elemGetContent($0)}, sel);
}
-inline void dom_elem_set_content(char *sel, char *str)
+inline void dom_set_content(char *sel, char *str)
{
EM_ASM({elemSetContent($0, $1)}, sel, str);
}
-inline void dom_elem_set_value(char *sel, char *str)
+inline void dom_set_value(char *sel, char *str)
{
EM_ASM({elemSetValue($0, $1)}, sel, str);
}
-inline bool dom_elem_has_class(char *sel, char *class)
+inline bool dom_has_class(char *sel, char *class)
{
return EM_ASM_INT({return elemHasClass($0, $1)}, sel, class);
}
-inline void dom_elem_add_class(char *sel, char *class)
+inline void dom_add_class(char *sel, char *class)
{
EM_ASM({elemAddClass($0, $1)}, sel, class);
}
-inline void dom_elem_remove_class(char *sel, char *class)
+inline void dom_remove_class(char *sel, char *class)
{
EM_ASM({elemRemoveClass($0, $1)}, sel, class);
}
-inline void dom_elem_toggle_class(char *sel, char *class)
+inline void dom_toggle_class(char *sel, char *class)
{
EM_ASM({elemToggleClass($0, $1)}, sel, class);
}
-inline void dom_elem_set_uniq_class(char *sel, char *class, char *sel_set)
+inline void dom_set_uniq_class(char *sel, char *class, char *sel_set)
{
EM_ASM({elemSetUniqClass($0, $1, $2)}, sel, class, sel_set);
}
-inline void dom_elem_scroll_to_bottom(char *sel)
+inline void dom_scroll_to_bottom(char *sel)
{
EM_ASM({elemScrollToBottom($0)}, sel);
}