summaryrefslogtreecommitdiff
path: root/web/web_prompt.c
diff options
context:
space:
mode:
Diffstat (limited to 'web/web_prompt.c')
-rw-r--r--web/web_prompt.c20
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"))