1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

Defined document.write and document.writeln for SEE

This commit is contained in:
2006-01-27 14:55:53 +01:00
parent 8bf45d0ece
commit 9c9fa1d81c
5 changed files with 53 additions and 1 deletions

View File

@ -366,6 +366,7 @@ imported:
done_string(&code);
if (!ret.length) return;
/* FIXME: it doesn't work */
part = format_html_part(html_context, ret.source,
ret.source + ret.length, par_format.align,
par_format.leftmargin, document->options.box.width,

View File

@ -51,6 +51,7 @@ static void document_put(struct SEE_interpreter *, struct SEE_object *, struct S
static int document_canput(struct SEE_interpreter *, struct SEE_object *, struct SEE_string *);
static int document_hasproperty(struct SEE_interpreter *, struct SEE_object *, struct SEE_string *);
static void js_document_write(struct SEE_interpreter *, struct SEE_object *, struct SEE_object *, int, struct SEE_value **, struct SEE_value *);
static void js_document_writeln(struct SEE_interpreter *, struct SEE_object *, struct SEE_object *, int, struct SEE_value **, struct SEE_value *);
void location_goto(struct document_view *, unsigned char *);
@ -140,6 +141,8 @@ document_get(struct SEE_interpreter *interp, struct SEE_object *o,
SEE_SET_OBJECT(res, doc->forms);
} else if (p == s_write) {
SEE_SET_OBJECT(res, doc->write);
} else if (p == s_writeln) {
SEE_SET_OBJECT(res, doc->writeln);
} else {
struct form *form;
unsigned char *string = SEE_string_to_unsigned_char(p);
@ -204,10 +207,51 @@ js_document_write(struct SEE_interpreter *interp, struct SEE_object *self,
struct SEE_object *thisobj, int argc, struct SEE_value **argv,
struct SEE_value *res)
{
#ifdef CONFIG_LEDS
struct global_object *g = (struct global_object *)interp;
struct view_state *vs = g->win->vs;
struct string *ret = g->ret;
if (argc >= 1 && ret) {
unsigned char *code = SEE_value_to_unsigned_char(interp, argv[0]);
if (code) {
add_to_string(ret, code);
mem_free(code);
}
}
#ifdef CONFIG_LEDS
/* XXX: I don't know about you, but I have *ENOUGH* of those 'Undefined
* function' errors, I want to see just the useful ones. So just
* lighting a led and going away, no muss, no fuss. --pasky */
/* TODO: Perhaps we can introduce ecmascript.error_report_unsupported
* -> "Show information about the document using some valid,
* nevertheless unsupported methods/properties." --pasky too */
set_led_value(vs->doc_view->session->status.ecmascript_led, 'J');
#endif
checktime(interp);
SEE_SET_BOOLEAN(res, 0);
}
static void
js_document_writeln(struct SEE_interpreter *interp, struct SEE_object *self,
struct SEE_object *thisobj, int argc, struct SEE_value **argv,
struct SEE_value *res)
{
struct global_object *g = (struct global_object *)interp;
struct view_state *vs = g->win->vs;
struct string *ret = g->ret;
if (argc >= 1 && ret) {
unsigned char *code = SEE_value_to_unsigned_char(interp, argv[0]);
if (code) {
add_to_string(ret, code);
mem_free(code);
add_char_to_string(ret, '\n');
}
}
#ifdef CONFIG_LEDS
/* XXX: I don't know about you, but I have *ENOUGH* of those 'Undefined
* function' errors, I want to see just the useful ones. So just
* lighting a led and going away, no muss, no fuss. --pasky */
@ -258,4 +302,5 @@ init_js_document_object(struct ecmascript_interpreter *interpreter)
SEE_OBJECT_PUT(interp, interp->Global, s_document, &v, 0);
doc->write = SEE_cfunction_make(interp, js_document_write, s_write, 1);
doc->writeln = SEE_cfunction_make(interp, js_document_writeln, s_writeln, 1);
}

View File

@ -6,6 +6,7 @@ struct ecmascript_interpreter;
struct js_document_object {
struct SEE_object object;
struct SEE_object *write;
struct SEE_object *writeln;
struct SEE_object *forms;
};

View File

@ -71,6 +71,7 @@ struct SEE_string *s_referrer;
struct SEE_string *s_title;
struct SEE_string *s_url;
struct SEE_string *s_write;
struct SEE_string *s_writeln;
struct SEE_string *s_Mozilla;
struct SEE_string *s_ELinks_;
@ -228,6 +229,8 @@ init_intern_strings(void)
static struct SEE_string S_url = SEE_STRING_DECL(SA_url);
static SEE_char_t SA_write[] = {'w','r','i','t','e'};
static struct SEE_string S_write = SEE_STRING_DECL(SA_write);
static SEE_char_t SA_writeln[] = {'w','r','i','t','e','l','n'};
static struct SEE_string S_writeln = SEE_STRING_DECL(SA_writeln);
static SEE_char_t SA_Mozilla[] = {'M','o','z','i','l','l','a'};
static struct SEE_string S_Mozilla = SEE_STRING_DECL(SA_Mozilla);
@ -354,6 +357,7 @@ init_intern_strings(void)
SEE_intern_global(s_title = &S_title);
SEE_intern_global(s_url = &S_url);
SEE_intern_global(s_write = &S_write);
SEE_intern_global(s_writeln = &S_writeln);
SEE_intern_global(s_Mozilla = &S_Mozilla);
SEE_intern_global(s_ELinks_ = &S_ELinks_);

View File

@ -77,6 +77,7 @@ extern struct SEE_string *s_referrer;
extern struct SEE_string *s_title;
extern struct SEE_string *s_url;
extern struct SEE_string *s_write;
extern struct SEE_string *s_writeln;
extern struct SEE_string *s_Mozilla;
extern struct SEE_string *s_ELinks_;