diff options
author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2022-05-03 21:55:21 -0700 |
---|---|---|
committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2022-05-03 21:55:21 -0700 |
commit | 2709b070c5fde766c0e9fe98ade169a865e6c9ad (patch) | |
tree | 3e8c19cccfbd9fa88b21c8e44e9cd7f7e6d30b9f /web/web_prompt.c | |
parent | 1ab3c4995e44f44a845dce7b241554c0621527b9 (diff) | |
download | dartboat-2709b070c5fde766c0e9fe98ade169a865e6c9ad.tar.gz dartboat-2709b070c5fde766c0e9fe98ade169a865e6c9ad.tar.xz |
web: oi from c
Diffstat (limited to 'web/web_prompt.c')
-rw-r--r-- | web/web_prompt.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/web/web_prompt.c b/web/web_prompt.c index e96e567..814b08e 100644 --- a/web/web_prompt.c +++ b/web/web_prompt.c @@ -9,6 +9,8 @@ #include <emscripten/emscripten.h> +int oi_timeout; + struct prompt_state { char *msgl, *input, *msgr; }; @@ -17,6 +19,22 @@ struct prompt_state prompt_buffered, prompt_flushed; enum prompt_mode pm; +void oi() +{ + EM_ASM({elemAddClass($0, $1)}, "#oi", "visible"); + oi_timeout = EM_ASM_INT({return scheduleCCall($0, $1)}, "clear_oi", 3000); +} + +EMSCRIPTEN_KEEPALIVE +void clear_oi() +{ + if (oi_timeout) { + EM_ASM({elemRemoveClass($0, $1)}, "#oi", "visible"); + EM_ASM({clearTimeout($0)}, oi_timeout); + oi_timeout = 0; + } +} + static inline void buffer_str(char *str, char **buffer, char *flushed) { if (str == *buffer || (str && *buffer && !strcmp(str, *buffer))) @@ -170,7 +188,7 @@ void prompt_handle_pre(char *command) if (pm == PM_DARTBOARD) return; - EM_ASM(clearOi()); + clear_oi(); if ((pm == PM_VISIT || pm == PM_NUM_DARTS || pm == PM_END_MATCH) && strcmp(command, "undo")) |