mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
Add the elinks.alert method.
This commit is contained in:
parent
6e0d4374c1
commit
30ccbaaf21
@ -12,6 +12,25 @@
|
||||
#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 = {
|
||||
"elinks",
|
||||
0,
|
||||
@ -20,10 +39,15 @@ static const JSClass elinks_class = {
|
||||
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub
|
||||
};
|
||||
|
||||
static const JSFunctionSpec elinks_funcs[] = {
|
||||
{ "alert", elinks_alert, 1 },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
JSObject *
|
||||
smjs_get_elinks_object(JSObject *global_object)
|
||||
{
|
||||
return JS_InitClass(smjs_ctx, global_object, NULL,
|
||||
(JSClass *) &elinks_class, NULL, 0, NULL,
|
||||
NULL, NULL, NULL);
|
||||
(JSFunctionSpec *) elinks_funcs, NULL, NULL);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user