mirror of
https://github.com/rkd77/elinks.git
synced 2024-11-04 08:17:17 -05:00
[mujs] window.event
This commit is contained in:
parent
ced7b7b294
commit
fb1c70564e
@ -25,6 +25,8 @@ struct keyboard {
|
|||||||
unicode_val_T keyCode;
|
unicode_val_T keyCode;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extern struct term_event last_event;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
mjs_keyboardEvent_finalizer(js_State *J, void *val)
|
mjs_keyboardEvent_finalizer(js_State *J, void *val)
|
||||||
{
|
{
|
||||||
@ -44,7 +46,7 @@ mjs_push_keyboardEvent(js_State *J, struct term_event *ev)
|
|||||||
js_error(J, "out of memory");
|
js_error(J, "out of memory");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
keyCode = keyb->keyCode = get_kbd_key(ev);
|
keyCode = keyb->keyCode = ev ? get_kbd_key(ev) : 0;
|
||||||
|
|
||||||
js_newobject(J);
|
js_newobject(J);
|
||||||
{
|
{
|
||||||
@ -79,10 +81,12 @@ mjs_keyboardEvent_get_property_keyCode(js_State *J)
|
|||||||
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
||||||
#endif
|
#endif
|
||||||
struct keyboard *keyb = (struct keyboard *)js_touserdata(J, 0, "event");
|
struct keyboard *keyb = (struct keyboard *)js_touserdata(J, 0, "event");
|
||||||
|
unicode_val_T code;
|
||||||
|
|
||||||
if (!keyb) {
|
if (!keyb) {
|
||||||
js_pushnull(J);
|
js_pushnull(J);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
js_pushnumber(J, keyb->keyCode);
|
code = keyb->keyCode ?: get_kbd_key(&last_event);
|
||||||
|
js_pushnumber(J, code);
|
||||||
}
|
}
|
||||||
|
@ -64,8 +64,6 @@ struct el_message {
|
|||||||
struct el_window *elwin;
|
struct el_window *elwin;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct term_event last_event;
|
|
||||||
|
|
||||||
static
|
static
|
||||||
void mjs_window_finalizer(js_State *J, void *val)
|
void mjs_window_finalizer(js_State *J, void *val)
|
||||||
{
|
{
|
||||||
@ -100,7 +98,7 @@ mjs_window_get_property_event(js_State *J)
|
|||||||
#ifdef ECMASCRIPT_DEBUG
|
#ifdef ECMASCRIPT_DEBUG
|
||||||
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
|
||||||
#endif
|
#endif
|
||||||
mjs_push_keyboardEvent(J, &last_event);
|
mjs_push_keyboardEvent(J, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -650,9 +648,9 @@ mjs_window_init(js_State *J)
|
|||||||
addproperty(J, "top", mjs_window_get_property_top, NULL);
|
addproperty(J, "top", mjs_window_get_property_top, NULL);
|
||||||
addproperty(J, "window", mjs_window_get_property_self, NULL);
|
addproperty(J, "window", mjs_window_get_property_self, NULL);
|
||||||
}
|
}
|
||||||
js_defglobal(J, "window", JS_DONTENUM);
|
js_defglobal(J, "window", 0);
|
||||||
|
|
||||||
js_dostring(J, "function alert(text) { return window.alert(text); }\n"
|
js_dostring(J, "var event = window.event; function alert(text) { return window.alert(text); }\n"
|
||||||
"function clearTimeout(h) { return window.clearTimeout(h); }\n"
|
"function clearTimeout(h) { return window.clearTimeout(h); }\n"
|
||||||
"function open(a, b, c) { return window.open(a, b, c); }\n"
|
"function open(a, b, c) { return window.open(a, b, c); }\n"
|
||||||
"function setTimeout(a, b) { return window.setTimeout(a, b); }\n"
|
"function setTimeout(a, b) { return window.setTimeout(a, b); }\n"
|
||||||
|
@ -404,6 +404,7 @@ quickjs_eval_boolback(struct ecmascript_interpreter *interpreter,
|
|||||||
|
|
||||||
JS_ToInt32(ctx, &ret, r);
|
JS_ToInt32(ctx, &ret, r);
|
||||||
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +86,6 @@ current_link_evhook(struct document_view *doc_view, enum script_event_hook_type
|
|||||||
if (!link) return -1;
|
if (!link) return -1;
|
||||||
if (!doc_view->vs->ecmascript) return -1;
|
if (!doc_view->vs->ecmascript) return -1;
|
||||||
|
|
||||||
#if defined(CONFIG_ECMASCRIPT_SMJS) || defined(CONFIG_QUICKJS) || defined(CONFIG_MUJS)
|
|
||||||
void *mapa = (void *)doc_view->document->element_map;
|
void *mapa = (void *)doc_view->document->element_map;
|
||||||
|
|
||||||
if (mapa) {
|
if (mapa) {
|
||||||
@ -97,7 +96,7 @@ current_link_evhook(struct document_view *doc_view, enum script_event_hook_type
|
|||||||
check_element_event(doc_view->vs->ecmascript, elem, event_name, NULL);
|
check_element_event(doc_view->vs->ecmascript, elem, event_name, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if (!link->event_hooks) return -1;
|
if (!link->event_hooks) return -1;
|
||||||
|
|
||||||
foreach (evhook, *link->event_hooks) {
|
foreach (evhook, *link->event_hooks) {
|
||||||
|
Loading…
Reference in New Issue
Block a user