1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-11-04 08:17:17 -05:00

Add the elinks.alert method.

This commit is contained in:
Miciah Dashiel Butler Masters 2005-12-18 17:49:21 +00:00 committed by Miciah Dashiel Butler Masters
parent 6e0d4374c1
commit 30ccbaaf21

View File

@ -12,6 +12,25 @@
#include "scripting/smjs/elinks_object.h" #include "scripting/smjs/elinks_object.h"
static JSBool
elinks_alert(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
unsigned char *string;
if (argc != 1)
return JS_TRUE;
string = jsval_to_string(ctx, &argv[0]);
if (!*string)
return JS_TRUE;
alert_smjs_error(string);
undef_to_jsval(ctx, rval);
return JS_TRUE;
}
static const JSClass elinks_class = { static const JSClass elinks_class = {
"elinks", "elinks",
0, 0,
@ -20,10 +39,15 @@ static const JSClass elinks_class = {
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub
}; };
static const JSFunctionSpec elinks_funcs[] = {
{ "alert", elinks_alert, 1 },
{ NULL }
};
JSObject * JSObject *
smjs_get_elinks_object(JSObject *global_object) smjs_get_elinks_object(JSObject *global_object)
{ {
return JS_InitClass(smjs_ctx, global_object, NULL, return JS_InitClass(smjs_ctx, global_object, NULL,
(JSClass *) &elinks_class, NULL, 0, NULL, (JSClass *) &elinks_class, NULL, 0, NULL,
NULL, NULL, NULL); (JSFunctionSpec *) elinks_funcs, NULL, NULL);
} }