1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-09-30 03:26:23 -04:00

SpiderMonkey: added setTimeout.

This commit is contained in:
Witold Filipczyk 2006-10-24 15:52:44 +02:00 committed by Witold Filipczyk
parent e5e6727e81
commit c76ce39a87

View File

@ -262,10 +262,12 @@ window_set_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
static JSBool window_alert(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
static JSBool window_open(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
static JSBool window_setTimeout(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
const JSFunctionSpec window_funcs[] = {
{ "alert", window_alert, 1 },
{ "open", window_open, 3 },
{ "setTimeout", window_setTimeout, 2 },
{ NULL }
};
@ -382,3 +384,25 @@ end:
return JS_TRUE;
}
static JSBool
window_setTimeout(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
struct ecmascript_interpreter *interpreter = JS_GetContextPrivate(ctx);
unsigned char *code;
int timeout;
if (argc != 2)
return JS_TRUE;
code = jsval_to_string(ctx, &argv[0]);
if (!*code)
return JS_TRUE;
code = stracpy(code);
if (!code)
return JS_TRUE;
timeout = atoi(jsval_to_string(ctx, &argv[1]));
ecmascript_set_timeout(interpreter, code, timeout);
return JS_TRUE;
}