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_dom.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'web/web_dom.c') 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 #include #include #include @@ -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); +} -- cgit v1.2.3-70-g09d2