From 2709b070c5fde766c0e9fe98ade169a865e6c9ad Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Tue, 3 May 2022 21:55:21 -0700 Subject: web: oi from c --- web/web_prompt.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'web/web_prompt.c') 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 +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")) -- cgit v1.2.3-70-g09d2