summaryrefslogtreecommitdiff
path: root/web/web_dom.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_dom.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_dom.c')
-rw-r--r--web/web_dom.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/web/web_dom.c b/web/web_dom.c
index 3a862f7..9e7684a 100644
--- a/web/web_dom.c
+++ b/web/web_dom.c
@@ -1,5 +1,6 @@
#include "web_dom.h"
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -68,3 +69,48 @@ void append_elemv(char *sel, int elemc, struct elem **elemv)
offsetof(struct elem, attr_names),
offsetof(struct elem, attr_vals));
}
+
+inline char *dom_elem_get_content(char *sel)
+{
+ return (char *)EM_ASM_INT({return elemGetContent($0)}, sel);
+}
+
+inline void dom_elem_set_content(char *sel, char *str)
+{
+ EM_ASM({elemSetContent($0, $1)}, sel, str);
+}
+
+inline void dom_elem_set_value(char *sel, char *str)
+{
+ EM_ASM({elemSetValue($0, $1)}, sel, str);
+}
+
+inline bool dom_elem_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)
+{
+ EM_ASM({elemAddClass($0, $1)}, sel, class);
+}
+
+inline void dom_elem_remove_class(char *sel, char *class)
+{
+ EM_ASM({elemRemoveClass($0, $1)}, sel, class);
+}
+
+inline void dom_elem_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)
+{
+ EM_ASM({elemSetUniqClass($0, $1, $2)}, sel, class, sel_set);
+}
+
+inline void dom_elem_scroll_to_bottom(char *sel)
+{
+ EM_ASM({elemScrollToBottom($0)}, sel);
+}