mirror of
https://github.com/rkd77/elinks.git
synced 2024-11-04 08:17:17 -05:00
Deleted ecmascript code using SEE.
AFAIK SEE is no longer developped. I see no reason to use SEE in ELinks.
This commit is contained in:
parent
ad9c144e5c
commit
81c9f462c2
54
configure.in
54
configure.in
@ -571,54 +571,6 @@ if test "$CONFIG_OS_WIN32" = yes; then
|
||||
EL_CONFIG_OS_WIN32
|
||||
fi
|
||||
|
||||
# ===================================================================
|
||||
# Check for SEE (Simple Ecmascript Engine)
|
||||
# ===================================================================
|
||||
AC_ARG_WITH(see, [ --with-see enable Simple Ecmascript Engine (SEE) support],
|
||||
[ if test "x$withval" != xno; then enable_see=yes; fi ])
|
||||
|
||||
# The following is probably bad, ugly and so on. Stolen from Guile's (1.4)
|
||||
# GUILE_FLAGS but I really don't want to require people to have Guile in order
|
||||
# to compile CVS. Also, the macro seems to be really stupid regarding searching
|
||||
# for Guile in $PATH etc. --pasky
|
||||
|
||||
CONFIG_ECMASCRIPT_SEE=no
|
||||
|
||||
if test "$enable_see" = "yes"; then
|
||||
if test -d "$withval"; then
|
||||
SEE_PATH="$withval:$PATH"
|
||||
else
|
||||
SEE_PATH="$PATH"
|
||||
fi
|
||||
|
||||
AC_PATH_PROG(SEE_CONFIG, libsee-config, no, $SEE_PATH)
|
||||
AC_MSG_CHECKING([for SEE (2.0.1131 or later)])
|
||||
if test "$SEE_CONFIG" != no; then
|
||||
EL_SAVE_FLAGS
|
||||
SEE_LIBS="`$SEE_CONFIG --libs`"
|
||||
SEE_CFLAGS="`$SEE_CONFIG --cppflags`"
|
||||
CPPFLAGS="$SEE_CFLAGS $CPPFLAGS"
|
||||
LIBS="$SEE_LIBS $LIBS_X"
|
||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <see/see.h>]], [[#if SEE_VERSION_API_MAJOR < 2
|
||||
#error SEE too old
|
||||
#endif
|
||||
]])],[cf_result=yes],[cf_result=no])
|
||||
EL_RESTORE_FLAGS
|
||||
if test "$cf_result" = yes; then
|
||||
LIBS="$SEE_LIBS $LIBS"
|
||||
EL_CONFIG(CONFIG_ECMASCRIPT_SEE, [SEE])
|
||||
AC_SUBST(SEE_CFLAGS)
|
||||
fi
|
||||
AC_MSG_RESULT($cf_result)
|
||||
else
|
||||
if test -n "$withval" && test "x$withval" != xno; then
|
||||
AC_MSG_ERROR([SEE not found])
|
||||
else
|
||||
AC_MSG_WARN([SEE support disabled])
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# ===================================================================
|
||||
# Check for SpiderMonkey, optional even if installed.
|
||||
# ===================================================================
|
||||
@ -708,15 +660,13 @@ elif test -n "$with_spidermonkey" && test "x$with_spidermonkey" != "xno"; then
|
||||
fi
|
||||
EL_RESTORE_FLAGS
|
||||
|
||||
if test "x$CONFIG_SPIDERMONKEY" = xyes &&
|
||||
test "x$CONFIG_ECMASCRIPT_SEE" != xyes; then
|
||||
if test "x$CONFIG_SPIDERMONKEY" = xyes; then
|
||||
EL_CONFIG(CONFIG_ECMASCRIPT_SMJS, [SpiderMonkey document scripting])
|
||||
else
|
||||
CONFIG_ECMASCRIPT_SMJS=no
|
||||
fi
|
||||
|
||||
EL_CONFIG_DEPENDS(CONFIG_ECMASCRIPT, [CONFIG_ECMASCRIPT_SEE CONFIG_ECMASCRIPT_SMJS], [ECMAScript (JavaScript)])
|
||||
AC_SUBST(CONFIG_ECMASCRIPT_SEE)
|
||||
EL_CONFIG_DEPENDS(CONFIG_ECMASCRIPT, [CONFIG_ECMASCRIPT_SMJS], [ECMAScript (JavaScript)])
|
||||
AC_SUBST(CONFIG_ECMASCRIPT_SMJS)
|
||||
|
||||
if test "x$CONFIG_ECMASCRIPT_SMJS" = xyes &&
|
||||
|
@ -1,11 +1,9 @@
|
||||
top_builddir=../..
|
||||
include $(top_builddir)/Makefile.config
|
||||
INCLUDES += $(SPIDERMONKEY_CFLAGS) $(SEE_CFLAGS)
|
||||
INCLUDES += $(SPIDERMONKEY_CFLAGS)
|
||||
|
||||
SUBDIRS-$(CONFIG_ECMASCRIPT_SEE) += see
|
||||
SUBDIRS-$(CONFIG_ECMASCRIPT_SMJS) += spidermonkey
|
||||
|
||||
OBJS-$(CONFIG_ECMASCRIPT_SEE) += see.o
|
||||
OBJS-$(CONFIG_ECMASCRIPT_SMJS) += spidermonkey.o
|
||||
|
||||
ifeq ($(CONFIG_ECMASCRIPT_SMJS), yes)
|
||||
|
@ -12,7 +12,6 @@
|
||||
#include "document/document.h"
|
||||
#include "document/view.h"
|
||||
#include "ecmascript/ecmascript.h"
|
||||
#include "ecmascript/see.h"
|
||||
#include "ecmascript/spidermonkey.h"
|
||||
#include "intl/gettext/libintl.h"
|
||||
#include "main/module.h"
|
||||
@ -86,11 +85,7 @@ ecmascript_get_interpreter(struct view_state *vs)
|
||||
init_list(interpreter->onload_snippets);
|
||||
/* The following backend call reads interpreter->vs. */
|
||||
if (
|
||||
#ifdef CONFIG_ECMASCRIPT_SEE
|
||||
!see_get_interpreter(interpreter)
|
||||
#else
|
||||
!spidermonkey_get_interpreter(interpreter)
|
||||
#endif
|
||||
) {
|
||||
/* Undo what was done above. */
|
||||
interpreter->vs->ecmascript_fragile = 1;
|
||||
@ -112,11 +107,7 @@ ecmascript_put_interpreter(struct ecmascript_interpreter *interpreter)
|
||||
* interpreter than to corrupt memory. */
|
||||
if_assert_failed return;
|
||||
|
||||
#ifdef CONFIG_ECMASCRIPT_SEE
|
||||
see_put_interpreter(interpreter);
|
||||
#else
|
||||
spidermonkey_put_interpreter(interpreter);
|
||||
#endif
|
||||
free_string_list(&interpreter->onload_snippets);
|
||||
done_string(&interpreter->code);
|
||||
/* Is it superfluous? */
|
||||
@ -142,11 +133,7 @@ ecmascript_eval(struct ecmascript_interpreter *interpreter,
|
||||
return;
|
||||
assert(interpreter);
|
||||
interpreter->backend_nesting++;
|
||||
#ifdef CONFIG_ECMASCRIPT_SEE
|
||||
see_eval(interpreter, code, ret);
|
||||
#else
|
||||
spidermonkey_eval(interpreter, code, ret);
|
||||
#endif
|
||||
interpreter->backend_nesting--;
|
||||
}
|
||||
|
||||
@ -160,11 +147,7 @@ ecmascript_eval_stringback(struct ecmascript_interpreter *interpreter,
|
||||
return NULL;
|
||||
assert(interpreter);
|
||||
interpreter->backend_nesting++;
|
||||
#ifdef CONFIG_ECMASCRIPT_SEE
|
||||
result = see_eval_stringback(interpreter, code);
|
||||
#else
|
||||
result = spidermonkey_eval_stringback(interpreter, code);
|
||||
#endif
|
||||
interpreter->backend_nesting--;
|
||||
return result;
|
||||
}
|
||||
@ -179,11 +162,7 @@ ecmascript_eval_boolback(struct ecmascript_interpreter *interpreter,
|
||||
return -1;
|
||||
assert(interpreter);
|
||||
interpreter->backend_nesting++;
|
||||
#ifdef CONFIG_ECMASCRIPT_SEE
|
||||
result = see_eval_boolback(interpreter, code);
|
||||
#else
|
||||
result = spidermonkey_eval_boolback(interpreter, code);
|
||||
#endif
|
||||
interpreter->backend_nesting--;
|
||||
return result;
|
||||
}
|
||||
@ -191,29 +170,17 @@ ecmascript_eval_boolback(struct ecmascript_interpreter *interpreter,
|
||||
void
|
||||
ecmascript_detach_form_view(struct form_view *fv)
|
||||
{
|
||||
#ifdef CONFIG_ECMASCRIPT_SEE
|
||||
see_detach_form_view(fv);
|
||||
#else
|
||||
spidermonkey_detach_form_view(fv);
|
||||
#endif
|
||||
}
|
||||
|
||||
void ecmascript_detach_form_state(struct form_state *fs)
|
||||
{
|
||||
#ifdef CONFIG_ECMASCRIPT_SEE
|
||||
see_detach_form_state(fs);
|
||||
#else
|
||||
spidermonkey_detach_form_state(fs);
|
||||
#endif
|
||||
}
|
||||
|
||||
void ecmascript_moved_form_state(struct form_state *fs)
|
||||
{
|
||||
#ifdef CONFIG_ECMASCRIPT_SEE
|
||||
see_moved_form_state(fs);
|
||||
#else
|
||||
spidermonkey_moved_form_state(fs);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
@ -359,9 +326,7 @@ ecmascript_set_timeout(struct ecmascript_interpreter *interpreter, unsigned char
|
||||
}
|
||||
|
||||
static struct module *ecmascript_modules[] = {
|
||||
#ifdef CONFIG_ECMASCRIPT_SEE
|
||||
&see_module,
|
||||
#elif defined(CONFIG_ECMASCRIPT_SMJS)
|
||||
#ifdef CONFIG_ECMASCRIPT_SMJS
|
||||
&spidermonkey_module,
|
||||
#endif
|
||||
NULL,
|
||||
|
@ -1,194 +0,0 @@
|
||||
/* The SEE ECMAScript backend. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "elinks.h"
|
||||
|
||||
#include <see/see.h>
|
||||
|
||||
#include "bfu/dialog.h"
|
||||
#include "cache/cache.h"
|
||||
#include "cookies/cookies.h"
|
||||
#include "dialogs/menu.h"
|
||||
#include "dialogs/status.h"
|
||||
#include "document/html/frames.h"
|
||||
#include "document/document.h"
|
||||
#include "document/forms.h"
|
||||
#include "document/view.h"
|
||||
#include "ecmascript/ecmascript.h"
|
||||
#include "ecmascript/see.h"
|
||||
#include "ecmascript/see/document.h"
|
||||
#include "ecmascript/see/form.h"
|
||||
#include "ecmascript/see/input.h"
|
||||
#include "ecmascript/see/location.h"
|
||||
#include "ecmascript/see/navigator.h"
|
||||
#include "ecmascript/see/strings.h"
|
||||
#include "ecmascript/see/unibar.h"
|
||||
#include "ecmascript/see/window.h"
|
||||
#include "intl/gettext/libintl.h"
|
||||
#include "main/select.h"
|
||||
#include "osdep/newwin.h"
|
||||
#include "osdep/sysname.h"
|
||||
#include "protocol/http/http.h"
|
||||
#include "protocol/uri.h"
|
||||
#include "session/history.h"
|
||||
#include "session/location.h"
|
||||
#include "session/session.h"
|
||||
#include "session/task.h"
|
||||
#include "terminal/tab.h"
|
||||
#include "terminal/terminal.h"
|
||||
#include "util/conv.h"
|
||||
#include "util/string.h"
|
||||
#include "viewer/text/draw.h"
|
||||
#include "viewer/text/form.h"
|
||||
#include "viewer/text/link.h"
|
||||
#include "viewer/text/vs.h"
|
||||
|
||||
|
||||
/*** Global methods */
|
||||
|
||||
|
||||
/* TODO? Are there any which need to be implemented? */
|
||||
|
||||
static void
|
||||
see_init(struct module *xxx)
|
||||
{
|
||||
init_intern_strings();
|
||||
SEE_system.periodic = checktime;
|
||||
}
|
||||
|
||||
static void
|
||||
see_done(struct module *xxx)
|
||||
{
|
||||
}
|
||||
|
||||
void *
|
||||
see_get_interpreter(struct ecmascript_interpreter *interpreter)
|
||||
{
|
||||
struct global_object *g = SEE_NEW(NULL, struct global_object);
|
||||
struct SEE_interpreter *interp = &g->interp;
|
||||
|
||||
interpreter->backend_data = g;
|
||||
g->max_exec_time = get_opt_int("ecmascript.max_exec_time",
|
||||
interpreter->vs->doc_view->session);
|
||||
g->exec_start = time(NULL);
|
||||
/* used by setTimeout */
|
||||
g->interpreter = interpreter;
|
||||
SEE_interpreter_init(interp);
|
||||
init_js_window_object(interpreter);
|
||||
init_js_menubar_object(interpreter);
|
||||
init_js_statusbar_object(interpreter);
|
||||
init_js_navigator_object(interpreter);
|
||||
init_js_history_object(interpreter);
|
||||
init_js_location_object(interpreter);
|
||||
init_js_document_object(interpreter);
|
||||
init_js_forms_object(interpreter);
|
||||
return interp;
|
||||
}
|
||||
|
||||
void
|
||||
see_put_interpreter(struct ecmascript_interpreter *interpreter)
|
||||
{
|
||||
interpreter->backend_data = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
see_eval(struct ecmascript_interpreter *interpreter,
|
||||
struct string *code, struct string *ret)
|
||||
{
|
||||
|
||||
struct SEE_interpreter *interp = interpreter->backend_data;
|
||||
struct global_object *g = (struct global_object *)interp;
|
||||
struct SEE_input *input = see_input_elinks(interp, code->source);
|
||||
SEE_try_context_t try_ctxt;
|
||||
struct SEE_value result;
|
||||
|
||||
g->exec_start = time(NULL);
|
||||
g->ret = ret;
|
||||
SEE_TRY(interp, try_ctxt) {
|
||||
SEE_Global_eval(interp, input, &result);
|
||||
}
|
||||
|
||||
SEE_INPUT_CLOSE(input);
|
||||
SEE_CAUGHT(try_ctxt);
|
||||
}
|
||||
|
||||
|
||||
unsigned char *
|
||||
see_eval_stringback(struct ecmascript_interpreter *interpreter,
|
||||
struct string *code)
|
||||
{
|
||||
struct SEE_interpreter *interp = interpreter->backend_data;
|
||||
struct global_object *g = (struct global_object *)interp;
|
||||
struct SEE_input *input = see_input_elinks(interp, code->source);
|
||||
SEE_try_context_t try_ctxt;
|
||||
struct SEE_value result;
|
||||
/* 'volatile' qualifier prevents register allocation which fixes:
|
||||
* warning: variable 'xxx' might be clobbered by 'longjmp' or 'vfork'
|
||||
*/
|
||||
unsigned char *volatile string = NULL;
|
||||
|
||||
g->exec_start = time(NULL);
|
||||
g->ret = NULL;
|
||||
SEE_TRY(interp, try_ctxt) {
|
||||
SEE_Global_eval(interp, input, &result);
|
||||
if (SEE_VALUE_GET_TYPE(&result) == SEE_STRING)
|
||||
string = see_value_to_unsigned_char(interp, &result);
|
||||
|
||||
}
|
||||
SEE_INPUT_CLOSE(input);
|
||||
if (SEE_CAUGHT(try_ctxt)) {
|
||||
return NULL;
|
||||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
int
|
||||
see_eval_boolback(struct ecmascript_interpreter *interpreter,
|
||||
struct string *code)
|
||||
{
|
||||
struct SEE_interpreter *interp = interpreter->backend_data;
|
||||
struct global_object *g = (struct global_object *)interp;
|
||||
struct SEE_input *input = see_input_elinks(interp, code->source);
|
||||
struct SEE_object *fun;
|
||||
SEE_try_context_t try_ctxt;
|
||||
struct SEE_value result;
|
||||
/* 'volatile' qualifier prevents register allocation which fixes:
|
||||
* warning: variable 'xxx' might be clobbered by 'longjmp' or 'vfork'
|
||||
*/
|
||||
SEE_int32_t volatile res = 0;
|
||||
|
||||
g->exec_start = time(NULL);
|
||||
g->ret = NULL;
|
||||
SEE_TRY(interp, try_ctxt) {
|
||||
fun = SEE_Function_new(interp, NULL, NULL, input);
|
||||
SEE_OBJECT_CALL(interp, fun, NULL, 0, NULL, &result);
|
||||
/* history.back() returns SEE_NULL */
|
||||
if (SEE_VALUE_GET_TYPE(&result) == SEE_NULL)
|
||||
res = 0;
|
||||
else
|
||||
res = SEE_ToInt32(interp, &result);
|
||||
}
|
||||
|
||||
SEE_INPUT_CLOSE(input);
|
||||
if (SEE_CAUGHT(try_ctxt)) {
|
||||
return -1;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
struct module see_module = struct_module(
|
||||
/* name: */ N_("SEE"),
|
||||
/* options: */ NULL,
|
||||
/* events: */ NULL,
|
||||
/* submodules: */ NULL,
|
||||
/* data: */ NULL,
|
||||
/* init: */ see_init,
|
||||
/* done: */ see_done
|
||||
);
|
@ -1,19 +0,0 @@
|
||||
#ifndef EL__ECMASCRIPT_SEE_H
|
||||
#define EL__ECMASCRIPT_SEE_H
|
||||
|
||||
struct ecmascript_interpreter;
|
||||
struct string;
|
||||
|
||||
void *see_get_interpreter(struct ecmascript_interpreter *interpreter);
|
||||
void see_put_interpreter(struct ecmascript_interpreter *interpreter);
|
||||
|
||||
void see_detach_form_view(struct form_view *fv);
|
||||
void see_detach_form_state(struct form_state *fs);
|
||||
void see_moved_form_state(struct form_state *fs);
|
||||
|
||||
void see_eval(struct ecmascript_interpreter *interpreter, struct string *code, struct string *ret);
|
||||
unsigned char *see_eval_stringback(struct ecmascript_interpreter *interpreter, struct string *code);
|
||||
int see_eval_boolback(struct ecmascript_interpreter *interpreter, struct string *code);
|
||||
|
||||
extern struct module see_module;
|
||||
#endif
|
@ -1,7 +0,0 @@
|
||||
top_builddir=../../..
|
||||
include $(top_builddir)/Makefile.config
|
||||
INCLUDES += $(SEE_CFLAGS)
|
||||
|
||||
OBJS = checktype.o document.o form.o input.o location.o navigator.o strings.o unibar.o window.o
|
||||
|
||||
include $(top_srcdir)/Makefile.lib
|
@ -1,20 +0,0 @@
|
||||
/* Check the type of a SEE object so it's safe to cast */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <see/see.h>
|
||||
#include "ecmascript/see/checktype.h"
|
||||
|
||||
void
|
||||
see_check_class(struct SEE_interpreter *interp,
|
||||
const struct SEE_object *object,
|
||||
const struct SEE_objectclass *class)
|
||||
{
|
||||
if (object->objectclass != class)
|
||||
SEE_error_throw(interp, interp->TypeError,
|
||||
"got %s, expected %s",
|
||||
object->objectclass->Class,
|
||||
class->Class);
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
#ifndef EL__ECMASCRIPT_SEE_CHECKTYPE_H
|
||||
#define EL__ECMASCRIPT_SEE_CHECKTYPE_H
|
||||
|
||||
struct SEE_interpreter;
|
||||
struct SEE_object;
|
||||
struct SEE_objectclass;
|
||||
|
||||
void see_check_class(struct SEE_interpreter *interp,
|
||||
const struct SEE_object *object,
|
||||
const struct SEE_objectclass *class);
|
||||
|
||||
#endif
|
@ -1,297 +0,0 @@
|
||||
/* The SEE document object implementation. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "elinks.h"
|
||||
|
||||
#include <see/see.h>
|
||||
|
||||
#include "bfu/dialog.h"
|
||||
#include "cache/cache.h"
|
||||
#include "cookies/cookies.h"
|
||||
#include "dialogs/menu.h"
|
||||
#include "dialogs/status.h"
|
||||
#include "document/html/frames.h"
|
||||
#include "document/document.h"
|
||||
#include "document/forms.h"
|
||||
#include "document/view.h"
|
||||
#include "ecmascript/ecmascript.h"
|
||||
#include "ecmascript/see/checktype.h"
|
||||
#include "ecmascript/see/document.h"
|
||||
#include "ecmascript/see/form.h"
|
||||
#include "ecmascript/see/input.h"
|
||||
#include "ecmascript/see/strings.h"
|
||||
#include "ecmascript/see/window.h"
|
||||
#include "intl/gettext/libintl.h"
|
||||
#include "main/select.h"
|
||||
#include "osdep/newwin.h"
|
||||
#include "osdep/sysname.h"
|
||||
#include "protocol/http/http.h"
|
||||
#include "protocol/uri.h"
|
||||
#include "session/history.h"
|
||||
#include "session/location.h"
|
||||
#include "session/session.h"
|
||||
#include "session/task.h"
|
||||
#include "terminal/tab.h"
|
||||
#include "terminal/terminal.h"
|
||||
#include "util/conv.h"
|
||||
#include "util/memory.h"
|
||||
#include "util/string.h"
|
||||
#include "viewer/text/draw.h"
|
||||
#include "viewer/text/form.h"
|
||||
#include "viewer/text/link.h"
|
||||
#include "viewer/text/vs.h"
|
||||
|
||||
static void document_get(struct SEE_interpreter *, struct SEE_object *, struct SEE_string *, struct SEE_value *);
|
||||
static void document_put(struct SEE_interpreter *, struct SEE_object *, struct SEE_string *, struct SEE_value *, int);
|
||||
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 *);
|
||||
|
||||
struct SEE_objectclass js_document_object_class = {
|
||||
"document",
|
||||
document_get,
|
||||
document_put,
|
||||
document_canput,
|
||||
document_hasproperty,
|
||||
SEE_no_delete,
|
||||
SEE_no_defaultvalue,
|
||||
SEE_no_enumerator,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
static void
|
||||
document_get(struct SEE_interpreter *interp, struct SEE_object *o,
|
||||
struct SEE_string *p, struct SEE_value *res)
|
||||
{
|
||||
struct global_object *g = (struct global_object *)interp;
|
||||
struct js_window_object *win = g->win;
|
||||
struct view_state *vs = win->vs;
|
||||
struct document_view *doc_view = vs->doc_view;
|
||||
struct document *document = doc_view->document;
|
||||
struct js_document_object *doc = (struct js_document_object *)o;
|
||||
struct session *ses = doc_view->session;
|
||||
struct SEE_string *str;
|
||||
unsigned char *string;
|
||||
|
||||
SEE_SET_UNDEFINED(res);
|
||||
|
||||
if (p == s_cookie) {
|
||||
#ifdef CONFIG_COOKIES
|
||||
struct string *cookies = send_cookies(vs->uri);
|
||||
|
||||
if (cookies) {
|
||||
static unsigned char cookiestr[1024];
|
||||
strncpy(cookiestr, cookies->source, 1024);
|
||||
done_string(cookies);
|
||||
|
||||
str = string_to_SEE_string(interp, cookiestr);
|
||||
} else {
|
||||
str = string_to_SEE_string(interp, "");
|
||||
}
|
||||
SEE_SET_STRING(res, str);
|
||||
#endif
|
||||
} else if (p == s_title) {
|
||||
str = string_to_SEE_string(interp, document->title);
|
||||
SEE_SET_STRING(res, str);
|
||||
} else if (p == s_url) {
|
||||
string = get_uri_string(document->uri, URI_ORIGINAL);
|
||||
str = string_to_SEE_string(interp, string);
|
||||
mem_free_if(string);
|
||||
SEE_SET_STRING(res, str);
|
||||
} else if (p == s_location) {
|
||||
SEE_OBJECT_GET(interp, interp->Global, s_location, res);
|
||||
} else if (p == s_referrer) {
|
||||
switch (get_opt_int("protocol.http.referer.policy", NULL)) {
|
||||
case REFERER_NONE:
|
||||
SEE_SET_UNDEFINED(res);
|
||||
break;
|
||||
case REFERER_FAKE:
|
||||
str = string_to_SEE_string(interp,
|
||||
get_opt_str("protocol.http.referer.fake",
|
||||
NULL));
|
||||
SEE_SET_STRING(res, str);
|
||||
break;
|
||||
case REFERER_TRUE:
|
||||
if (ses->referrer) {
|
||||
string = get_uri_string(ses->referrer, URI_HTTP_REFERRER);
|
||||
str = string_to_SEE_string(interp, string);
|
||||
mem_free_if(string);
|
||||
SEE_SET_STRING(res, str);
|
||||
}
|
||||
break;
|
||||
case REFERER_SAME_URL:
|
||||
string = get_uri_string(document->uri, URI_HTTP_REFERRER);
|
||||
str = string_to_SEE_string(interp, string);
|
||||
mem_free_if(string);
|
||||
SEE_SET_STRING(res, str);
|
||||
break;
|
||||
|
||||
}
|
||||
} else if (p == s_forms) {
|
||||
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);
|
||||
struct form_view *form_view;
|
||||
struct js_form *form_object;
|
||||
|
||||
if (!string) return;
|
||||
|
||||
foreach (form, document->forms) {
|
||||
if (!form->name || c_strcasecmp(string, form->name))
|
||||
continue;
|
||||
form_view = find_form_view(doc_view, form);
|
||||
form_object = js_get_form_object(interp, doc, form_view);
|
||||
SEE_SET_OBJECT(res, (struct SEE_object *)form_object);
|
||||
break;
|
||||
}
|
||||
mem_free(string);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
document_put(struct SEE_interpreter *interp, struct SEE_object *o,
|
||||
struct SEE_string *p, struct SEE_value *val, int attr)
|
||||
{
|
||||
struct global_object *g = (struct global_object *)interp;
|
||||
struct view_state *vs = g->win->vs;
|
||||
struct document_view *doc_view = vs->doc_view;
|
||||
struct document *document = doc_view->document;
|
||||
struct js_document_object *doc = (struct js_document_object *)o;
|
||||
struct SEE_value res;
|
||||
unsigned char *string;
|
||||
|
||||
if (p == s_forms) {
|
||||
SEE_ToObject(interp, val, &res);
|
||||
doc->forms = res.u.object;
|
||||
} else if (p == s_title) {
|
||||
string = see_value_to_unsigned_char(interp, val);
|
||||
mem_free_set(&document->title, string);
|
||||
print_screen_status(doc_view->session);
|
||||
} else if (p == s_location || p == s_url) {
|
||||
/* According to the specs this should be readonly but some
|
||||
* broken sites still assign to it (i.e.
|
||||
* http://www.e-handelsfonden.dk/validering.asp?URL=www.polyteknisk.dk).
|
||||
* So emulate window.location. */
|
||||
string = see_value_to_unsigned_char(interp, val);
|
||||
location_goto(doc_view, string);
|
||||
mem_free_if(string);
|
||||
} else if (p == s_cookie) {
|
||||
#ifdef CONFIG_COOKIES
|
||||
string = see_value_to_unsigned_char(interp, val);
|
||||
set_cookie(vs->uri, string);
|
||||
mem_free_if(string);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
js_document_write_do(struct SEE_interpreter *interp, struct SEE_object *self,
|
||||
struct SEE_object *thisobj, int argc, struct SEE_value **argv,
|
||||
struct SEE_value *res, int newline)
|
||||
{
|
||||
struct global_object *g = (struct global_object *)interp;
|
||||
struct view_state *vs = g->win->vs;
|
||||
struct string *ret = g->ret;
|
||||
|
||||
see_check_class(interp, thisobj, &js_document_object_class);
|
||||
|
||||
if (argc >= 1 && ret) {
|
||||
int i = 0;
|
||||
|
||||
for (; i < argc; ++i) {
|
||||
unsigned char *code;
|
||||
|
||||
code = see_value_to_unsigned_char(interp, argv[i]);
|
||||
|
||||
if (code) {
|
||||
add_to_string(ret, code);
|
||||
mem_free(code);
|
||||
}
|
||||
}
|
||||
|
||||
if (newline)
|
||||
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 */
|
||||
/* 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
|
||||
SEE_SET_BOOLEAN(res, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
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)
|
||||
{
|
||||
js_document_write_do(interp, self, thisobj, argc, argv, 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)
|
||||
{
|
||||
js_document_write_do(interp, self, thisobj, argc, argv, res, 1);
|
||||
}
|
||||
|
||||
static int
|
||||
document_canput(struct SEE_interpreter *interp, struct SEE_object *o,
|
||||
struct SEE_string *p)
|
||||
{
|
||||
if (p == s_location || p == s_url || p == s_cookie)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
document_hasproperty(struct SEE_interpreter *interp, struct SEE_object *o,
|
||||
struct SEE_string *p)
|
||||
{
|
||||
/* all unknown properties return UNDEFINED value */
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
init_js_document_object(struct ecmascript_interpreter *interpreter)
|
||||
{
|
||||
struct global_object *g = interpreter->backend_data;
|
||||
struct SEE_interpreter *interp = &g->interp;
|
||||
struct SEE_value v;
|
||||
struct js_document_object *doc = SEE_NEW(interp,
|
||||
struct js_document_object);
|
||||
|
||||
doc->object.objectclass = &js_document_object_class;
|
||||
doc->object.Prototype = NULL;
|
||||
|
||||
SEE_SET_OBJECT(&v, (struct SEE_object *)doc);
|
||||
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);
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
#ifndef EL__ECMASCRIPT_SEE_DOCUMENT_H
|
||||
#define EL__ECMASCRIPT_SEE_DOCUMENT_H
|
||||
|
||||
struct ecmascript_interpreter;
|
||||
|
||||
struct js_document_object {
|
||||
struct SEE_object object;
|
||||
struct SEE_object *write;
|
||||
struct SEE_object *writeln;
|
||||
struct SEE_object *forms;
|
||||
};
|
||||
|
||||
void init_js_document_object(struct ecmascript_interpreter *);
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
@ -1,19 +0,0 @@
|
||||
#ifndef EL__ECMASCRIPT_SEE_FORM_H
|
||||
#define EL__ECMASCRIPT_SEE_FORM_H
|
||||
|
||||
struct js_document_object;
|
||||
struct ecmascript_interpreter;
|
||||
struct form_view;
|
||||
|
||||
struct js_form {
|
||||
struct SEE_object object;
|
||||
struct js_document_object *parent;
|
||||
struct form_view *fv;
|
||||
struct SEE_object *reset;
|
||||
struct SEE_object *submit;
|
||||
};
|
||||
|
||||
struct js_form *js_get_form_object(struct SEE_interpreter *, struct js_document_object*, struct form_view *);
|
||||
void init_js_forms_object(struct ecmascript_interpreter *);
|
||||
|
||||
#endif
|
@ -1,146 +0,0 @@
|
||||
/* Input for SEE */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <see/see.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "elinks.h"
|
||||
|
||||
#include "ecmascript/see/input.h"
|
||||
#include "util/memory.h"
|
||||
|
||||
static SEE_unicode_t input_elinks_next(struct SEE_input *);
|
||||
static void input_elinks_close(struct SEE_input *);
|
||||
|
||||
static struct SEE_inputclass input_elinks_class = {
|
||||
input_elinks_next,
|
||||
input_elinks_close
|
||||
};
|
||||
|
||||
struct input_elinks {
|
||||
struct SEE_input inp;
|
||||
unsigned char *s;
|
||||
};
|
||||
|
||||
static SEE_unicode_t
|
||||
input_elinks_next(struct SEE_input *inp)
|
||||
{
|
||||
struct input_elinks *input = (struct input_elinks*)inp;
|
||||
SEE_unicode_t next;
|
||||
|
||||
next = input->inp.lookahead;
|
||||
|
||||
if (*input->s == '\0') {
|
||||
input->inp.eof = 1;
|
||||
} else {
|
||||
input->inp.lookahead = *input->s++;
|
||||
input->inp.eof = 0;
|
||||
}
|
||||
return next;
|
||||
}
|
||||
|
||||
static void
|
||||
input_elinks_close(struct SEE_input *inp)
|
||||
{
|
||||
/* nothing */
|
||||
}
|
||||
|
||||
struct SEE_input *
|
||||
see_input_elinks(struct SEE_interpreter *interp, unsigned char *s)
|
||||
{
|
||||
struct input_elinks *input;
|
||||
|
||||
input = SEE_NEW(interp, struct input_elinks);
|
||||
input->inp.interpreter = interp;
|
||||
input->inp.inputclass = &input_elinks_class;
|
||||
input->inp.filename = NULL;
|
||||
input->inp.first_lineno = 1;
|
||||
input->s = s;
|
||||
SEE_INPUT_NEXT((struct SEE_input *)input); /* prime */
|
||||
return (struct SEE_input *)input;
|
||||
}
|
||||
|
||||
unsigned char *
|
||||
see_string_to_unsigned_char(struct SEE_string *S)
|
||||
{
|
||||
int i;
|
||||
unsigned char *str = mem_alloc(S->length + 1);
|
||||
|
||||
if (!str)
|
||||
return NULL;
|
||||
|
||||
for (i = 0; i < S->length; i++)
|
||||
str[i] = (unsigned char)S->data[i];
|
||||
str[S->length] = '\0';
|
||||
return str;
|
||||
}
|
||||
|
||||
unsigned char *
|
||||
see_value_to_unsigned_char(struct SEE_interpreter *interp, struct SEE_value *val)
|
||||
{
|
||||
struct SEE_value result;
|
||||
|
||||
SEE_ToString(interp, val, &result);
|
||||
return see_string_to_unsigned_char(result.u.string);
|
||||
}
|
||||
|
||||
struct SEE_string *
|
||||
string_to_SEE_string(struct SEE_interpreter *interp, unsigned char *s)
|
||||
{
|
||||
unsigned int len;
|
||||
unsigned int i;
|
||||
struct SEE_string *str;
|
||||
|
||||
len = s ? strlen(s) : 0;
|
||||
str = SEE_string_new(interp, len);
|
||||
str->length = len;
|
||||
for (i = 0; i < len; i++)
|
||||
str->data[i] = s[i];
|
||||
return str;
|
||||
}
|
||||
|
||||
void
|
||||
append_unicode_to_SEE_string(struct SEE_interpreter *interp,
|
||||
struct SEE_string *str,
|
||||
unicode_val_T u)
|
||||
{
|
||||
/* This is supposed to make a string from which
|
||||
* SEE_string_to_unicode() can get the original @u back.
|
||||
* If @u is a surrogate, then that is not possible, so
|
||||
* throw an error instead. */
|
||||
if (u <= 0xFFFF && !is_utf16_surrogate(u)) {
|
||||
SEE_string_addch(str, u);
|
||||
} else if (needs_utf16_surrogates(u)) {
|
||||
SEE_string_addch(str, get_utf16_high_surrogate(u));
|
||||
SEE_string_addch(str, get_utf16_low_surrogate(u));
|
||||
} else {
|
||||
/* str->interpreter exists but is not documented, so don't
|
||||
* use it; use a separate @interp parameter instead.
|
||||
* Also, SEE does not support "%lX". */
|
||||
SEE_error_throw(interp, interp->RangeError,
|
||||
"UTF-16 cannot encode U+%.4X",
|
||||
(unsigned int) u);
|
||||
}
|
||||
}
|
||||
|
||||
unicode_val_T
|
||||
see_string_to_unicode(struct SEE_interpreter *interp, struct SEE_string *S)
|
||||
{
|
||||
/* This implementation ignores extra characters in the string. */
|
||||
if (S->length < 1) {
|
||||
SEE_error_throw(interp, interp->Error,
|
||||
"String is empty");
|
||||
} else if (!is_utf16_surrogate(S->data[0])) {
|
||||
return S->data[0];
|
||||
} else if (S->length >= 2
|
||||
&& is_utf16_high_surrogate(S->data[0])
|
||||
&& is_utf16_low_surrogate(S->data[1])) {
|
||||
return join_utf16_surrogates(S->data[0], S->data[1]);
|
||||
} else {
|
||||
SEE_error_throw(interp, interp->Error,
|
||||
"Invalid UTF-16 sequence");
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
#ifndef EL__ECMASCRIPT_SEE_INPUT_H
|
||||
#define EL__ECMASCRIPT_SEE_INPUT_H
|
||||
|
||||
#include "intl/charsets.h"
|
||||
|
||||
struct SEE_interpreter;
|
||||
struct SEE_string;
|
||||
struct SEE_value;
|
||||
|
||||
struct SEE_input *see_input_elinks(struct SEE_interpreter *, unsigned char *);
|
||||
unsigned char *see_string_to_unsigned_char(struct SEE_string *);
|
||||
unsigned char *see_value_to_unsigned_char(struct SEE_interpreter *, struct SEE_value *);
|
||||
struct SEE_string *string_to_SEE_string(struct SEE_interpreter *, unsigned char *);
|
||||
void append_unicode_to_SEE_string(struct SEE_interpreter *, struct SEE_string *,
|
||||
unicode_val_T);
|
||||
unicode_val_T see_string_to_unicode(struct SEE_interpreter *, struct SEE_string *);
|
||||
|
||||
#endif
|
@ -1,361 +0,0 @@
|
||||
/* The SEE location and history objects implementation. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "elinks.h"
|
||||
|
||||
#include <see/see.h>
|
||||
|
||||
#include "bfu/dialog.h"
|
||||
#include "cache/cache.h"
|
||||
#include "cookies/cookies.h"
|
||||
#include "dialogs/menu.h"
|
||||
#include "dialogs/status.h"
|
||||
#include "document/html/frames.h"
|
||||
#include "document/document.h"
|
||||
#include "document/forms.h"
|
||||
#include "document/view.h"
|
||||
#include "ecmascript/ecmascript.h"
|
||||
#include "ecmascript/see/checktype.h"
|
||||
#include "ecmascript/see/input.h"
|
||||
#include "ecmascript/see/location.h"
|
||||
#include "ecmascript/see/strings.h"
|
||||
#include "ecmascript/see/window.h"
|
||||
#include "intl/gettext/libintl.h"
|
||||
#include "main/select.h"
|
||||
#include "osdep/newwin.h"
|
||||
#include "osdep/sysname.h"
|
||||
#include "protocol/http/http.h"
|
||||
#include "protocol/uri.h"
|
||||
#include "session/history.h"
|
||||
#include "session/location.h"
|
||||
#include "session/session.h"
|
||||
#include "session/task.h"
|
||||
#include "terminal/tab.h"
|
||||
#include "terminal/terminal.h"
|
||||
#include "util/conv.h"
|
||||
#include "util/memory.h"
|
||||
#include "util/string.h"
|
||||
#include "viewer/text/draw.h"
|
||||
#include "viewer/text/form.h"
|
||||
#include "viewer/text/link.h"
|
||||
#include "viewer/text/vs.h"
|
||||
|
||||
static void delayed_goto(void *);
|
||||
static void history_get(struct SEE_interpreter *, struct SEE_object *, struct SEE_string *, struct SEE_value *);
|
||||
static int history_hasproperty(struct SEE_interpreter *, struct SEE_object *, struct SEE_string *);
|
||||
static void js_history_back(struct SEE_interpreter *, struct SEE_object *, struct SEE_object *, int, struct SEE_value **, struct SEE_value *);
|
||||
static void js_history_forward(struct SEE_interpreter *, struct SEE_object *, struct SEE_object *, int, struct SEE_value **, struct SEE_value *);
|
||||
static void js_history_go(struct SEE_interpreter *, struct SEE_object *, struct SEE_object *, int, struct SEE_value **, struct SEE_value *);
|
||||
static void js_location_toString(struct SEE_interpreter *, struct SEE_object *, struct SEE_object *, int, struct SEE_value **, struct SEE_value *);
|
||||
static void location_get(struct SEE_interpreter *, struct SEE_object *, struct SEE_string *, struct SEE_value *);
|
||||
static void location_put(struct SEE_interpreter *, struct SEE_object *, struct SEE_string *, struct SEE_value *, int);
|
||||
static int location_hasproperty(struct SEE_interpreter *, struct SEE_object *, struct SEE_string *);
|
||||
static int location_canput(struct SEE_interpreter *, struct SEE_object *, struct SEE_string *);
|
||||
|
||||
void location_goto(struct document_view *, unsigned char *);
|
||||
|
||||
struct js_history_object {
|
||||
struct SEE_object object;
|
||||
struct SEE_object *back;
|
||||
struct SEE_object *forward;
|
||||
struct SEE_object *go;
|
||||
};
|
||||
|
||||
struct js_location_object {
|
||||
struct SEE_object object;
|
||||
struct SEE_object *toString;
|
||||
};
|
||||
|
||||
struct delayed_goto {
|
||||
/* It might look more convenient to pass doc_view around but it could
|
||||
* disappear during wild dances inside of frames or so. */
|
||||
struct view_state *vs;
|
||||
struct uri *uri;
|
||||
};
|
||||
|
||||
struct SEE_objectclass js_history_object_class = {
|
||||
"history",
|
||||
history_get,
|
||||
SEE_no_put,
|
||||
SEE_no_canput,
|
||||
history_hasproperty,
|
||||
SEE_no_delete,
|
||||
SEE_no_defaultvalue,
|
||||
SEE_no_enumerator,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
struct SEE_objectclass js_location_object_class = {
|
||||
"location",
|
||||
location_get,
|
||||
location_put,
|
||||
location_canput,
|
||||
location_hasproperty,
|
||||
SEE_no_delete,
|
||||
SEE_no_defaultvalue,
|
||||
SEE_no_enumerator,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
static void
|
||||
delayed_goto(void *data)
|
||||
{
|
||||
struct delayed_goto *deg = data;
|
||||
|
||||
assert(deg);
|
||||
if (deg->vs->doc_view
|
||||
&& deg->vs->doc_view == deg->vs->doc_view->session->doc_view) {
|
||||
goto_uri_frame(deg->vs->doc_view->session, deg->uri,
|
||||
deg->vs->doc_view->name,
|
||||
CACHE_MODE_NORMAL);
|
||||
}
|
||||
done_uri(deg->uri);
|
||||
mem_free(deg);
|
||||
}
|
||||
|
||||
void
|
||||
location_goto(struct document_view *doc_view, unsigned char *url)
|
||||
{
|
||||
unsigned char *new_abs_url;
|
||||
struct uri *new_uri;
|
||||
struct delayed_goto *deg;
|
||||
|
||||
/* Workaround for bug 611. Does not crash, but may lead to infinite loop.*/
|
||||
if (!doc_view) return;
|
||||
new_abs_url = join_urls(doc_view->document->uri,
|
||||
trim_chars(url, ' ', 0));
|
||||
if (!new_abs_url)
|
||||
return;
|
||||
new_uri = get_uri(new_abs_url, 0);
|
||||
mem_free(new_abs_url);
|
||||
if (!new_uri)
|
||||
return;
|
||||
deg = mem_calloc(1, sizeof(*deg));
|
||||
if (!deg) {
|
||||
done_uri(new_uri);
|
||||
return;
|
||||
}
|
||||
assert(doc_view->vs);
|
||||
deg->vs = doc_view->vs;
|
||||
deg->uri = new_uri;
|
||||
/* It does not seem to be very safe inside of frames to
|
||||
* call goto_uri() right away. */
|
||||
register_bottom_half(delayed_goto, deg);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
history_get(struct SEE_interpreter *interp, struct SEE_object *o,
|
||||
struct SEE_string *p, struct SEE_value *res)
|
||||
{
|
||||
struct js_history_object *history = (struct js_history_object *)o;
|
||||
|
||||
if (p == s_back) {
|
||||
SEE_SET_OBJECT(res, history->back);
|
||||
} else if (p == s_forward) {
|
||||
SEE_SET_OBJECT(res, history->forward);
|
||||
} else if (p == s_go) {
|
||||
SEE_SET_OBJECT(res, history->go);
|
||||
} else {
|
||||
SEE_SET_UNDEFINED(res);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
history_hasproperty(struct SEE_interpreter *interp, struct SEE_object *o,
|
||||
struct SEE_string *p)
|
||||
{
|
||||
if (p == s_back || p == s_forward || p == s_go)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
js_history_back(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 document_view *doc_view = vs->doc_view;
|
||||
struct session *ses = doc_view->session;
|
||||
|
||||
see_check_class(interp, thisobj, &js_history_object_class);
|
||||
|
||||
SEE_SET_NULL(res);
|
||||
go_back(ses);
|
||||
}
|
||||
|
||||
static void
|
||||
js_history_forward(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 document_view *doc_view = vs->doc_view;
|
||||
struct session *ses = doc_view->session;
|
||||
|
||||
see_check_class(interp, thisobj, &js_history_object_class);
|
||||
|
||||
SEE_SET_NULL(res);
|
||||
go_unback(ses);
|
||||
}
|
||||
|
||||
static void
|
||||
js_history_go(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 document_view *doc_view = vs->doc_view;
|
||||
struct session *ses = doc_view->session;
|
||||
unsigned char *str;
|
||||
int index;
|
||||
struct location *loc;
|
||||
|
||||
see_check_class(interp, thisobj, &js_history_object_class);
|
||||
|
||||
SEE_SET_NULL(res);
|
||||
if (argc < 1)
|
||||
return;
|
||||
|
||||
str = see_value_to_unsigned_char(interp, argv[0]);
|
||||
if (!str)
|
||||
return;
|
||||
|
||||
index = atol(str);
|
||||
mem_free(str);
|
||||
|
||||
for (loc = cur_loc(ses);
|
||||
loc != (struct location *) &ses->history.history;
|
||||
loc = index > 0 ? loc->next : loc->prev) {
|
||||
if (!index) {
|
||||
go_history(ses, loc);
|
||||
break;
|
||||
}
|
||||
|
||||
index += index > 0 ? -1 : 1;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
js_location_toString(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;
|
||||
unsigned char *string = get_uri_string(vs->uri, URI_ORIGINAL);
|
||||
struct SEE_string *str = string_to_SEE_string(interp, string);
|
||||
|
||||
see_check_class(interp, thisobj, &js_location_object_class);
|
||||
|
||||
mem_free_if(string);
|
||||
|
||||
SEE_SET_STRING(res, str);
|
||||
}
|
||||
|
||||
static void
|
||||
location_get(struct SEE_interpreter *interp, struct SEE_object *o,
|
||||
struct SEE_string *p, struct SEE_value *res)
|
||||
{
|
||||
struct js_location_object *loc = (struct js_location_object *)o;
|
||||
|
||||
if (p == s_toString || p == s_toLocaleString) {
|
||||
SEE_SET_OBJECT(res, loc->toString);
|
||||
} else if (p == s_href) {
|
||||
struct global_object *g = (struct global_object *)interp;
|
||||
struct view_state *vs = g->win->vs;
|
||||
unsigned char *string = get_uri_string(vs->uri, URI_ORIGINAL);
|
||||
struct SEE_string *str = string_to_SEE_string(interp, string);
|
||||
|
||||
mem_free_if(string);
|
||||
SEE_SET_STRING(res, str);
|
||||
} else {
|
||||
SEE_SET_UNDEFINED(res);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
location_put(struct SEE_interpreter *interp, struct SEE_object *o,
|
||||
struct SEE_string *p, struct SEE_value *val, int attr)
|
||||
{
|
||||
if (p == s_href) {
|
||||
struct global_object *g = (struct global_object *)interp;
|
||||
struct view_state *vs = g->win->vs;
|
||||
struct document_view *doc_view = vs->doc_view;
|
||||
unsigned char *url = see_value_to_unsigned_char(interp, val);
|
||||
|
||||
location_goto(doc_view, url);
|
||||
mem_free(url);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
location_hasproperty(struct SEE_interpreter *interp, struct SEE_object *o,
|
||||
struct SEE_string *p)
|
||||
{
|
||||
if (p == s_toString || p == s_toLocaleString || p == s_href)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
location_canput(struct SEE_interpreter *interp, struct SEE_object *o,
|
||||
struct SEE_string *p)
|
||||
{
|
||||
if (p == s_href)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
init_js_history_object(struct ecmascript_interpreter *interpreter)
|
||||
{
|
||||
struct global_object *g = interpreter->backend_data;
|
||||
struct SEE_interpreter *interp = &g->interp;
|
||||
struct SEE_value v;
|
||||
struct js_history_object *history = SEE_NEW(interp,
|
||||
struct js_history_object);
|
||||
|
||||
history->object.objectclass = &js_history_object_class;
|
||||
history->object.Prototype = NULL;
|
||||
|
||||
SEE_SET_OBJECT(&v, (struct SEE_object *)history);
|
||||
SEE_OBJECT_PUT(interp, interp->Global, s_history, &v, 0);
|
||||
|
||||
history->back = SEE_cfunction_make(interp, js_history_back, s_back, 0);
|
||||
history->forward = SEE_cfunction_make(interp, js_history_forward, s_forward, 0);
|
||||
history->go = SEE_cfunction_make(interp, js_history_go, s_go, 1);
|
||||
}
|
||||
|
||||
void
|
||||
init_js_location_object(struct ecmascript_interpreter *interpreter)
|
||||
{
|
||||
struct global_object *g = interpreter->backend_data;
|
||||
struct SEE_interpreter *interp = &g->interp;
|
||||
struct SEE_value v;
|
||||
struct js_location_object *loc = SEE_NEW(interp,
|
||||
struct js_location_object);
|
||||
|
||||
loc->object.objectclass = &js_location_object_class;
|
||||
loc->object.Prototype = NULL;
|
||||
|
||||
SEE_SET_OBJECT(&v, (struct SEE_object *)loc);
|
||||
SEE_OBJECT_PUT(interp, interp->Global, s_location, &v, 0);
|
||||
|
||||
loc->toString = SEE_cfunction_make(interp, js_location_toString, s_toString, 0);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#ifndef EL__ECMASCRIPT_SEE_LOCATION_H
|
||||
#define EL__ECMASCRIPT_SEE_LOCATION_H
|
||||
|
||||
struct ecmascript_interpreter;
|
||||
|
||||
void init_js_history_object(struct ecmascript_interpreter *);
|
||||
void init_js_location_object(struct ecmascript_interpreter *);
|
||||
|
||||
#endif
|
@ -1,150 +0,0 @@
|
||||
/* The SEE navigator objects implementation. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "elinks.h"
|
||||
|
||||
#include <see/see.h>
|
||||
|
||||
#include "bfu/dialog.h"
|
||||
#include "cache/cache.h"
|
||||
#include "cookies/cookies.h"
|
||||
#include "dialogs/menu.h"
|
||||
#include "dialogs/status.h"
|
||||
#include "document/html/frames.h"
|
||||
#include "document/document.h"
|
||||
#include "document/forms.h"
|
||||
#include "document/view.h"
|
||||
#include "ecmascript/ecmascript.h"
|
||||
#include "ecmascript/see/input.h"
|
||||
#include "ecmascript/see/navigator.h"
|
||||
#include "ecmascript/see/strings.h"
|
||||
#include "ecmascript/see/window.h"
|
||||
#include "intl/gettext/libintl.h"
|
||||
#include "main/select.h"
|
||||
#include "osdep/newwin.h"
|
||||
#include "osdep/sysname.h"
|
||||
#include "protocol/http/http.h"
|
||||
#include "protocol/uri.h"
|
||||
#include "session/history.h"
|
||||
#include "session/location.h"
|
||||
#include "session/session.h"
|
||||
#include "session/task.h"
|
||||
#include "terminal/tab.h"
|
||||
#include "terminal/terminal.h"
|
||||
#include "util/conv.h"
|
||||
#include "util/memory.h"
|
||||
#include "util/string.h"
|
||||
#include "viewer/text/draw.h"
|
||||
#include "viewer/text/form.h"
|
||||
#include "viewer/text/link.h"
|
||||
#include "viewer/text/vs.h"
|
||||
|
||||
static void navigator_get(struct SEE_interpreter *, struct SEE_object *, struct SEE_string *, struct SEE_value *);
|
||||
static int navigator_hasproperty(struct SEE_interpreter *, struct SEE_object *, struct SEE_string *);
|
||||
|
||||
struct SEE_objectclass js_navigator_object_class = {
|
||||
"navigator",
|
||||
navigator_get,
|
||||
SEE_no_put,
|
||||
SEE_no_canput,
|
||||
navigator_hasproperty,
|
||||
SEE_no_delete,
|
||||
SEE_no_defaultvalue,
|
||||
SEE_no_enumerator,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
static void
|
||||
navigator_get(struct SEE_interpreter *interp, struct SEE_object *o,
|
||||
struct SEE_string *p, struct SEE_value *res)
|
||||
{
|
||||
struct SEE_string *str;
|
||||
|
||||
SEE_SET_UNDEFINED(res);
|
||||
if (p == s_appCodeName) {
|
||||
SEE_SET_STRING(res, s_Mozilla);
|
||||
} else if (p == s_appName) {
|
||||
SEE_SET_STRING(res, s_ELinks_);
|
||||
} else if (p == s_appVersion) {
|
||||
str = string_to_SEE_string(interp, VERSION);
|
||||
SEE_SET_STRING(res, str);
|
||||
} else if (p == s_language) {
|
||||
#ifdef CONFIG_NLS
|
||||
if (get_opt_bool("protocol.http.accept_ui_language", NULL)) {
|
||||
str = string_to_SEE_string(interp,
|
||||
language_to_iso639(current_language));
|
||||
SEE_SET_STRING(res, str);
|
||||
}
|
||||
#endif
|
||||
} else if (p == s_platform) {
|
||||
str = string_to_SEE_string(interp, system_name);
|
||||
SEE_SET_STRING(res, str);
|
||||
} else if (p == s_userAgent) {
|
||||
/* FIXME: Code duplication. */
|
||||
unsigned char *optstr = get_opt_str("protocol.http.user_agent",
|
||||
NULL);
|
||||
|
||||
if (*optstr && strcmp(optstr, " ")) {
|
||||
unsigned char *ustr, ts[64] = "";
|
||||
static unsigned char custr[256];
|
||||
/* TODO: Somehow get the terminal in which the
|
||||
* document is actually being displayed. */
|
||||
struct terminal *term = get_default_terminal();
|
||||
|
||||
if (term) {
|
||||
unsigned int tslen = 0;
|
||||
|
||||
ulongcat(ts, &tslen, term->width, 3, 0);
|
||||
ts[tslen++] = 'x';
|
||||
ulongcat(ts, &tslen, term->height, 3, 0);
|
||||
}
|
||||
ustr = subst_user_agent(optstr, VERSION_STRING, system_name, ts);
|
||||
|
||||
if (ustr) {
|
||||
safe_strncpy(custr, ustr, 256);
|
||||
mem_free(ustr);
|
||||
str = string_to_SEE_string(interp, custr);
|
||||
SEE_SET_STRING(res, str);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
navigator_hasproperty(struct SEE_interpreter *interp, struct SEE_object *o,
|
||||
struct SEE_string *p)
|
||||
{
|
||||
if (p == s_appCodeName || p == s_appName || p == s_appVersion
|
||||
|| p == s_language || p == s_platform || p == s_userAgent)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
init_js_navigator_object(struct ecmascript_interpreter *interpreter)
|
||||
{
|
||||
struct global_object *g = interpreter->backend_data;
|
||||
struct SEE_interpreter *interp = &g->interp;
|
||||
struct SEE_value v;
|
||||
struct SEE_object *navigator;
|
||||
|
||||
navigator = SEE_NEW(interp, struct SEE_object);
|
||||
|
||||
navigator->objectclass = &js_navigator_object_class;
|
||||
navigator->Prototype = NULL;
|
||||
|
||||
SEE_SET_OBJECT(&v, navigator);
|
||||
SEE_OBJECT_PUT(interp, interp->Global, s_navigator, &v, 0);
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
#ifndef EL__ECMASCRIPT_SEE_NAVIGATOR_H
|
||||
#define EL__ECMASCRIPT_SEE_NAVIGATOR_H
|
||||
|
||||
struct ecmascript_interpreter;
|
||||
|
||||
void init_js_navigator_object(struct ecmascript_interpreter *);
|
||||
|
||||
#endif
|
@ -1,200 +0,0 @@
|
||||
#include <see/see.h>
|
||||
#include "ecmascript/see/strings.h"
|
||||
|
||||
struct SEE_string *s_window;
|
||||
struct SEE_string *s_closed;
|
||||
struct SEE_string *s_parent;
|
||||
struct SEE_string *s_self;
|
||||
struct SEE_string *s_top;
|
||||
struct SEE_string *s_alert;
|
||||
struct SEE_string *s_open;
|
||||
|
||||
struct SEE_string *s_menubar;
|
||||
|
||||
struct SEE_string *s_statusbar;
|
||||
struct SEE_string *s_visible;
|
||||
|
||||
struct SEE_string *s_navigator;
|
||||
struct SEE_string *s_appCodeName;
|
||||
struct SEE_string *s_appName;
|
||||
struct SEE_string *s_appVersion;
|
||||
struct SEE_string *s_language;
|
||||
struct SEE_string *s_platform;
|
||||
struct SEE_string *s_userAgent;
|
||||
|
||||
struct SEE_string *s_history;
|
||||
struct SEE_string *s_back;
|
||||
struct SEE_string *s_forward;
|
||||
struct SEE_string *s_go;
|
||||
|
||||
struct SEE_string *s_location;
|
||||
struct SEE_string *s_href;
|
||||
struct SEE_string *s_toString;
|
||||
struct SEE_string *s_toLocaleString;
|
||||
|
||||
struct SEE_string *s_input;
|
||||
struct SEE_string *s_accessKey;
|
||||
struct SEE_string *s_alt;
|
||||
struct SEE_string *s_checked;
|
||||
struct SEE_string *s_defaultChecked;
|
||||
struct SEE_string *s_defaultValue;
|
||||
struct SEE_string *s_disabled;
|
||||
struct SEE_string *s_form;
|
||||
struct SEE_string *s_maxLength;
|
||||
struct SEE_string *s_name;
|
||||
struct SEE_string *s_readonly;
|
||||
struct SEE_string *s_size;
|
||||
struct SEE_string *s_src;
|
||||
struct SEE_string *s_tabindex;
|
||||
struct SEE_string *s_type;
|
||||
struct SEE_string *s_value;
|
||||
struct SEE_string *s_blur;
|
||||
struct SEE_string *s_click;
|
||||
struct SEE_string *s_focus;
|
||||
struct SEE_string *s_select;
|
||||
struct SEE_string *s_selectedIndex;
|
||||
|
||||
struct SEE_string *s_elements;
|
||||
struct SEE_string *s_item;
|
||||
struct SEE_string *s_namedItem;
|
||||
struct SEE_string *s_length;
|
||||
|
||||
struct SEE_string *s_action;
|
||||
struct SEE_string *s_encoding;
|
||||
struct SEE_string *s_method;
|
||||
struct SEE_string *s_target;
|
||||
struct SEE_string *s_reset;
|
||||
struct SEE_string *s_submit;
|
||||
|
||||
struct SEE_string *s_forms;
|
||||
|
||||
struct SEE_string *s_document;
|
||||
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_;
|
||||
struct SEE_string *s_cookie;
|
||||
|
||||
struct SEE_string *s_GET;
|
||||
struct SEE_string *s_POST;
|
||||
struct SEE_string *s_application_;
|
||||
struct SEE_string *s_multipart_;
|
||||
struct SEE_string *s_textplain;
|
||||
|
||||
struct SEE_string *s_text;
|
||||
struct SEE_string *s_password;
|
||||
struct SEE_string *s_file;
|
||||
struct SEE_string *s_checkbox;
|
||||
struct SEE_string *s_radio;
|
||||
struct SEE_string *s_image;
|
||||
struct SEE_string *s_button;
|
||||
struct SEE_string *s_hidden;
|
||||
|
||||
struct SEE_string *s_timeout;
|
||||
struct SEE_string *s_setTimeout;
|
||||
struct SEE_string *s_status;
|
||||
|
||||
void
|
||||
init_intern_strings(void)
|
||||
{
|
||||
s_window = SEE_intern_global("window");
|
||||
s_closed = SEE_intern_global("closed");
|
||||
s_parent = SEE_intern_global("parent");
|
||||
s_self = SEE_intern_global("self");
|
||||
s_top = SEE_intern_global("top");
|
||||
s_alert = SEE_intern_global("alert");
|
||||
s_open = SEE_intern_global("open");
|
||||
|
||||
s_menubar = SEE_intern_global("menubar");
|
||||
|
||||
s_statusbar = SEE_intern_global("statusbar");
|
||||
s_visible = SEE_intern_global("visible");
|
||||
|
||||
s_navigator = SEE_intern_global("navigator");
|
||||
s_appCodeName = SEE_intern_global("appCodeName");
|
||||
s_appName = SEE_intern_global("appName");
|
||||
s_appVersion = SEE_intern_global("appVersion");
|
||||
s_language = SEE_intern_global("language");
|
||||
s_platform = SEE_intern_global("platform");
|
||||
s_userAgent = SEE_intern_global("userAgent");
|
||||
|
||||
s_history = SEE_intern_global("history");
|
||||
s_back = SEE_intern_global("back");
|
||||
s_forward = SEE_intern_global("forward");
|
||||
s_go = SEE_intern_global("go");
|
||||
|
||||
s_location = SEE_intern_global("location");
|
||||
s_href = SEE_intern_global("href");
|
||||
s_toString = SEE_intern_global("toString");
|
||||
s_toLocaleString = SEE_intern_global("toLocaleString");
|
||||
|
||||
s_input = SEE_intern_global("input");
|
||||
s_accessKey = SEE_intern_global("accessKey");
|
||||
s_alt = SEE_intern_global("alt");
|
||||
s_checked = SEE_intern_global("checked");
|
||||
s_defaultChecked = SEE_intern_global("defaultChecked");
|
||||
s_defaultValue = SEE_intern_global("defaultValue");
|
||||
s_disabled = SEE_intern_global("disabled");
|
||||
s_form = SEE_intern_global("form");
|
||||
s_maxLength = SEE_intern_global("maxLength");
|
||||
s_name = SEE_intern_global("name");
|
||||
s_readonly = SEE_intern_global("readonly");
|
||||
s_size = SEE_intern_global("size");
|
||||
s_src = SEE_intern_global("src");
|
||||
s_tabindex = SEE_intern_global("tabindex");
|
||||
s_type = SEE_intern_global("type");
|
||||
s_value = SEE_intern_global("value");
|
||||
s_blur = SEE_intern_global("blur");
|
||||
s_click = SEE_intern_global("click");
|
||||
s_focus = SEE_intern_global("focus");
|
||||
s_select = SEE_intern_global("select");
|
||||
s_selectedIndex = SEE_intern_global("selectedIndex");
|
||||
|
||||
s_elements = SEE_intern_global("elements");
|
||||
s_item = SEE_intern_global("item");
|
||||
s_namedItem = SEE_intern_global("namedItem");
|
||||
s_length = SEE_intern_global("length");
|
||||
|
||||
s_action = SEE_intern_global("action");
|
||||
s_encoding = SEE_intern_global("encoding");
|
||||
s_method = SEE_intern_global("method");
|
||||
s_target = SEE_intern_global("target");
|
||||
s_reset = SEE_intern_global("reset");
|
||||
s_submit = SEE_intern_global("submit");
|
||||
|
||||
s_forms = SEE_intern_global("forms");
|
||||
|
||||
s_document = SEE_intern_global("document");
|
||||
s_referrer = SEE_intern_global("referrer");
|
||||
s_title = SEE_intern_global("title");
|
||||
s_url = SEE_intern_global("url");
|
||||
s_write = SEE_intern_global("write");
|
||||
s_writeln = SEE_intern_global("writeln");
|
||||
|
||||
s_Mozilla = SEE_intern_global("Mozilla");
|
||||
s_ELinks_ = SEE_intern_global("ELinks (roughly compatible with Netscape Navigator Mozilla and Microsoft Internet Explorer)");
|
||||
s_cookie = SEE_intern_global("cookie");
|
||||
|
||||
s_GET = SEE_intern_global("GET");
|
||||
s_POST = SEE_intern_global("POST");
|
||||
s_application_ = SEE_intern_global("application/x-www-form-urlencoded");
|
||||
s_multipart_ = SEE_intern_global("multipart/form-data");
|
||||
s_textplain = SEE_intern_global("text/plain");
|
||||
|
||||
s_text = SEE_intern_global("text");
|
||||
s_password = SEE_intern_global("password");
|
||||
s_file = SEE_intern_global("file");
|
||||
s_checkbox = SEE_intern_global("checkbox");
|
||||
s_radio = SEE_intern_global("radio");
|
||||
s_image = SEE_intern_global("image");
|
||||
s_button = SEE_intern_global("button");
|
||||
s_hidden = SEE_intern_global("hidden");
|
||||
|
||||
s_timeout = SEE_intern_global("timeout");
|
||||
s_setTimeout = SEE_intern_global("setTimeout");
|
||||
s_status = SEE_intern_global("status");
|
||||
}
|
@ -1,105 +0,0 @@
|
||||
|
||||
#ifndef EL__ECMASCRIPT_SEE_STRINGS_H
|
||||
#define EL__ECMASCRIPT_SEE_STRINGS_H
|
||||
|
||||
struct SEE_string;
|
||||
|
||||
void init_intern_strings(void);
|
||||
|
||||
extern struct SEE_string *s_window;
|
||||
extern struct SEE_string *s_closed;
|
||||
extern struct SEE_string *s_parent;
|
||||
extern struct SEE_string *s_self;
|
||||
extern struct SEE_string *s_top;
|
||||
extern struct SEE_string *s_alert;
|
||||
extern struct SEE_string *s_open;
|
||||
|
||||
extern struct SEE_string *s_menubar;
|
||||
|
||||
extern struct SEE_string *s_statusbar;
|
||||
extern struct SEE_string *s_visible;
|
||||
|
||||
extern struct SEE_string *s_navigator;
|
||||
extern struct SEE_string *s_appCodeName;
|
||||
extern struct SEE_string *s_appName;
|
||||
extern struct SEE_string *s_appVersion;
|
||||
extern struct SEE_string *s_language;
|
||||
extern struct SEE_string *s_platform;
|
||||
extern struct SEE_string *s_userAgent;
|
||||
|
||||
extern struct SEE_string *s_history;
|
||||
extern struct SEE_string *s_back;
|
||||
extern struct SEE_string *s_forward;
|
||||
extern struct SEE_string *s_go;
|
||||
|
||||
extern struct SEE_string *s_location;
|
||||
extern struct SEE_string *s_href;
|
||||
extern struct SEE_string *s_toString;
|
||||
extern struct SEE_string *s_toLocaleString;
|
||||
|
||||
extern struct SEE_string *s_input;
|
||||
extern struct SEE_string *s_accessKey;
|
||||
extern struct SEE_string *s_alt;
|
||||
extern struct SEE_string *s_checked;
|
||||
extern struct SEE_string *s_defaultChecked;
|
||||
extern struct SEE_string *s_defaultValue;
|
||||
extern struct SEE_string *s_disabled;
|
||||
extern struct SEE_string *s_form;
|
||||
extern struct SEE_string *s_maxLength;
|
||||
extern struct SEE_string *s_name;
|
||||
extern struct SEE_string *s_readonly;
|
||||
extern struct SEE_string *s_size;
|
||||
extern struct SEE_string *s_src;
|
||||
extern struct SEE_string *s_tabindex;
|
||||
extern struct SEE_string *s_type;
|
||||
extern struct SEE_string *s_value;
|
||||
extern struct SEE_string *s_blur;
|
||||
extern struct SEE_string *s_click;
|
||||
extern struct SEE_string *s_focus;
|
||||
extern struct SEE_string *s_select;
|
||||
extern struct SEE_string *s_selectedIndex;
|
||||
|
||||
extern struct SEE_string *s_elements;
|
||||
extern struct SEE_string *s_item;
|
||||
extern struct SEE_string *s_namedItem;
|
||||
extern struct SEE_string *s_length;
|
||||
|
||||
extern struct SEE_string *s_action;
|
||||
extern struct SEE_string *s_encoding;
|
||||
extern struct SEE_string *s_method;
|
||||
extern struct SEE_string *s_target;
|
||||
extern struct SEE_string *s_reset;
|
||||
extern struct SEE_string *s_submit;
|
||||
|
||||
extern struct SEE_string *s_forms;
|
||||
|
||||
extern struct SEE_string *s_document;
|
||||
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_;
|
||||
extern struct SEE_string *s_cookie;
|
||||
|
||||
extern struct SEE_string *s_GET;
|
||||
extern struct SEE_string *s_POST;
|
||||
extern struct SEE_string *s_application_;
|
||||
extern struct SEE_string *s_multipart_;
|
||||
extern struct SEE_string *s_textplain;
|
||||
|
||||
extern struct SEE_string *s_text;
|
||||
extern struct SEE_string *s_password;
|
||||
extern struct SEE_string *s_file;
|
||||
extern struct SEE_string *s_checkbox;
|
||||
extern struct SEE_string *s_radio;
|
||||
extern struct SEE_string *s_image;
|
||||
extern struct SEE_string *s_button;
|
||||
extern struct SEE_string *s_hidden;
|
||||
|
||||
extern struct SEE_string *s_timeout;
|
||||
extern struct SEE_string *s_setTimeout;
|
||||
extern struct SEE_string *s_status;
|
||||
#endif
|
@ -1,200 +0,0 @@
|
||||
/* The SEE location and history objects implementation. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "elinks.h"
|
||||
|
||||
#include <see/see.h>
|
||||
|
||||
#include "bfu/dialog.h"
|
||||
#include "cache/cache.h"
|
||||
#include "cookies/cookies.h"
|
||||
#include "dialogs/menu.h"
|
||||
#include "dialogs/status.h"
|
||||
#include "document/html/frames.h"
|
||||
#include "document/document.h"
|
||||
#include "document/forms.h"
|
||||
#include "document/view.h"
|
||||
#include "ecmascript/ecmascript.h"
|
||||
#include "ecmascript/see/input.h"
|
||||
#include "ecmascript/see/strings.h"
|
||||
#include "ecmascript/see/unibar.h"
|
||||
#include "ecmascript/see/window.h"
|
||||
#include "intl/gettext/libintl.h"
|
||||
#include "main/select.h"
|
||||
#include "osdep/newwin.h"
|
||||
#include "osdep/sysname.h"
|
||||
#include "protocol/http/http.h"
|
||||
#include "protocol/uri.h"
|
||||
#include "session/history.h"
|
||||
#include "session/location.h"
|
||||
#include "session/session.h"
|
||||
#include "session/task.h"
|
||||
#include "terminal/tab.h"
|
||||
#include "terminal/terminal.h"
|
||||
#include "util/conv.h"
|
||||
#include "util/memory.h"
|
||||
#include "util/string.h"
|
||||
#include "viewer/text/draw.h"
|
||||
#include "viewer/text/form.h"
|
||||
#include "viewer/text/link.h"
|
||||
#include "viewer/text/vs.h"
|
||||
|
||||
static void unibar_get(struct SEE_interpreter *, struct SEE_object *, struct SEE_string *, struct SEE_value *);
|
||||
static void unibar_put(struct SEE_interpreter *, struct SEE_object *, struct SEE_string *, struct SEE_value *, int);
|
||||
static int unibar_canput(struct SEE_interpreter *, struct SEE_object *, struct SEE_string *);
|
||||
static int unibar_hasproperty(struct SEE_interpreter *, struct SEE_object *, struct SEE_string *);
|
||||
|
||||
struct js_unibar_object {
|
||||
struct SEE_object object;
|
||||
unsigned char bar;
|
||||
};
|
||||
|
||||
struct SEE_objectclass js_menubar_object_class = {
|
||||
"menubar",
|
||||
unibar_get,
|
||||
unibar_put,
|
||||
unibar_canput,
|
||||
unibar_hasproperty,
|
||||
SEE_no_delete,
|
||||
SEE_no_defaultvalue,
|
||||
SEE_no_enumerator,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
struct SEE_objectclass js_statusbar_object_class = {
|
||||
"statusbar",
|
||||
unibar_get,
|
||||
unibar_put,
|
||||
unibar_canput,
|
||||
unibar_hasproperty,
|
||||
SEE_no_delete,
|
||||
SEE_no_defaultvalue,
|
||||
SEE_no_enumerator,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
static void
|
||||
unibar_get(struct SEE_interpreter *interp, struct SEE_object *o,
|
||||
struct SEE_string *p, struct SEE_value *res)
|
||||
{
|
||||
struct global_object *g = (struct global_object *)interp;
|
||||
struct view_state *vs = g->win->vs;
|
||||
struct document_view *doc_view = vs->doc_view;
|
||||
struct session_status *status = &doc_view->session->status;
|
||||
struct js_unibar_object *obj = (struct js_unibar_object *)o;
|
||||
unsigned char bar = obj->bar;
|
||||
|
||||
if (p == s_visible) {
|
||||
#define unibar_fetch(bar) \
|
||||
SEE_SET_BOOLEAN(res, status->force_show_##bar##_bar >= 0 \
|
||||
? status->force_show_##bar##_bar \
|
||||
: status->show_##bar##_bar)
|
||||
switch (bar) {
|
||||
case 's':
|
||||
unibar_fetch(status);
|
||||
break;
|
||||
case 't':
|
||||
unibar_fetch(title);
|
||||
break;
|
||||
default:
|
||||
SEE_SET_BOOLEAN(res, 0);
|
||||
break;
|
||||
}
|
||||
#undef unibar_fetch
|
||||
return;
|
||||
}
|
||||
SEE_SET_UNDEFINED(res);
|
||||
}
|
||||
|
||||
static void
|
||||
unibar_put(struct SEE_interpreter *interp, struct SEE_object *o,
|
||||
struct SEE_string *p, struct SEE_value *val, int attr)
|
||||
{
|
||||
if (p == s_visible) {
|
||||
struct global_object *g = (struct global_object *)interp;
|
||||
struct view_state *vs = g->win->vs;
|
||||
struct document_view *doc_view = vs->doc_view;
|
||||
struct session_status *status = &doc_view->session->status;
|
||||
struct js_unibar_object *obj = (struct js_unibar_object *)o;
|
||||
unsigned char bar = obj->bar;
|
||||
|
||||
switch (bar) {
|
||||
case 's':
|
||||
status->force_show_status_bar =
|
||||
SEE_ToUint32(interp, val);
|
||||
break;
|
||||
case 't':
|
||||
status->force_show_title_bar =
|
||||
SEE_ToUint32(interp, val);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
unibar_canput(struct SEE_interpreter *interp, struct SEE_object *o,
|
||||
struct SEE_string *p)
|
||||
{
|
||||
if (p == s_visible)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
unibar_hasproperty(struct SEE_interpreter *interp, struct SEE_object *o,
|
||||
struct SEE_string *p)
|
||||
{
|
||||
if (p == s_visible)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
init_js_menubar_object(struct ecmascript_interpreter *interpreter)
|
||||
{
|
||||
struct global_object *g = interpreter->backend_data;
|
||||
struct SEE_interpreter *interp = &g->interp;
|
||||
struct SEE_value v;
|
||||
struct js_unibar_object *menu;
|
||||
|
||||
menu = SEE_NEW(interp, struct js_unibar_object);
|
||||
|
||||
menu->object.objectclass = &js_menubar_object_class;
|
||||
menu->object.Prototype = NULL;
|
||||
menu->bar = 't';
|
||||
|
||||
SEE_SET_OBJECT(&v, (struct SEE_object *)menu);
|
||||
SEE_OBJECT_PUT(interp, interp->Global, s_menubar, &v, 0);
|
||||
}
|
||||
|
||||
void
|
||||
init_js_statusbar_object(struct ecmascript_interpreter *interpreter)
|
||||
{
|
||||
struct global_object *g = interpreter->backend_data;
|
||||
struct SEE_interpreter *interp = &g->interp;
|
||||
struct SEE_value v;
|
||||
struct js_unibar_object *status;
|
||||
|
||||
status = SEE_NEW(interp, struct js_unibar_object);
|
||||
|
||||
status->object.objectclass = &js_statusbar_object_class;
|
||||
status->object.Prototype = NULL;
|
||||
status->bar = 's';
|
||||
|
||||
SEE_SET_OBJECT(&v, (struct SEE_object *)status);
|
||||
SEE_OBJECT_PUT(interp, interp->Global, s_statusbar, &v, 0);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#ifndef EL__ECMASCRIPT_SEE_UNIBAR_H
|
||||
#define EL__ECMASCRIPT_SEE_UNIBAR_H
|
||||
|
||||
struct emascript_interpreter;
|
||||
|
||||
void init_js_menubar_object(struct ecmascript_interpreter *);
|
||||
void init_js_statusbar_object(struct ecmascript_interpreter *);
|
||||
|
||||
#endif
|
@ -1,408 +0,0 @@
|
||||
/* The SEE window object implementation. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "elinks.h"
|
||||
|
||||
#include <see/see.h>
|
||||
|
||||
#include "bfu/dialog.h"
|
||||
#include "cache/cache.h"
|
||||
#include "cookies/cookies.h"
|
||||
#include "dialogs/menu.h"
|
||||
#include "dialogs/status.h"
|
||||
#include "document/html/frames.h"
|
||||
#include "document/document.h"
|
||||
#include "document/forms.h"
|
||||
#include "document/view.h"
|
||||
#include "ecmascript/ecmascript.h"
|
||||
#include "ecmascript/see/checktype.h"
|
||||
#include "ecmascript/see/input.h"
|
||||
#include "ecmascript/see/strings.h"
|
||||
#include "ecmascript/see/window.h"
|
||||
#include "intl/gettext/libintl.h"
|
||||
#include "main/select.h"
|
||||
#include "osdep/newwin.h"
|
||||
#include "osdep/sysname.h"
|
||||
#include "protocol/http/http.h"
|
||||
#include "protocol/uri.h"
|
||||
#include "session/history.h"
|
||||
#include "session/location.h"
|
||||
#include "session/session.h"
|
||||
#include "session/task.h"
|
||||
#include "terminal/tab.h"
|
||||
#include "terminal/terminal.h"
|
||||
#include "util/conv.h"
|
||||
#include "util/memory.h"
|
||||
#include "util/string.h"
|
||||
#include "viewer/text/draw.h"
|
||||
#include "viewer/text/form.h"
|
||||
#include "viewer/text/link.h"
|
||||
#include "viewer/text/vs.h"
|
||||
|
||||
static struct js_window_object *js_get_global_object(void *);
|
||||
static struct js_window_object *js_try_resolve_frame(struct document_view *, unsigned char *);
|
||||
static void window_get(struct SEE_interpreter *, struct SEE_object *, struct SEE_string *, struct SEE_value *);
|
||||
static void window_put(struct SEE_interpreter *, struct SEE_object *, struct SEE_string *, struct SEE_value *, int);
|
||||
static int window_canput(struct SEE_interpreter *, struct SEE_object *, struct SEE_string *);
|
||||
static int window_hasproperty(struct SEE_interpreter *, struct SEE_object *, struct SEE_string *);
|
||||
static void js_window_alert(struct SEE_interpreter *, struct SEE_object *, struct SEE_object *, int, struct SEE_value **, struct SEE_value *);
|
||||
static void js_window_open(struct SEE_interpreter *, struct SEE_object *, struct SEE_object *, int, struct SEE_value **, struct SEE_value *);
|
||||
static void js_setTimeout(struct SEE_interpreter *, struct SEE_object *, struct SEE_object *, int, struct SEE_value **, struct SEE_value *);
|
||||
|
||||
void location_goto(struct document_view *, unsigned char *);
|
||||
|
||||
struct SEE_objectclass js_window_object_class = {
|
||||
"window",
|
||||
window_get,
|
||||
window_put,
|
||||
window_canput,
|
||||
window_hasproperty,
|
||||
SEE_no_delete,
|
||||
SEE_no_defaultvalue,
|
||||
SEE_no_enumerator,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
static struct js_window_object *
|
||||
js_get_global_object(void *data)
|
||||
{
|
||||
struct global_object *g = (struct global_object *)data;
|
||||
return g->win;
|
||||
}
|
||||
|
||||
static struct js_window_object *
|
||||
js_try_resolve_frame(struct document_view *doc_view, unsigned char *id)
|
||||
{
|
||||
struct session *ses = doc_view->session;
|
||||
struct frame *target;
|
||||
|
||||
assert(ses);
|
||||
target = ses_find_frame(ses, id);
|
||||
if (!target) return NULL;
|
||||
if (target->vs.ecmascript_fragile)
|
||||
ecmascript_reset_state(&target->vs);
|
||||
if (!target->vs.ecmascript) return NULL;
|
||||
return js_get_global_object(target->vs.ecmascript->backend_data);
|
||||
}
|
||||
|
||||
static void
|
||||
window_get(struct SEE_interpreter *interp, struct SEE_object *o,
|
||||
struct SEE_string *p, struct SEE_value *res)
|
||||
{
|
||||
struct js_window_object *win = (struct js_window_object *)o;
|
||||
struct view_state *vs = win->vs;
|
||||
|
||||
if (p == s_closed) {
|
||||
SEE_SET_BOOLEAN(res, 0);
|
||||
} else if (p == s_self || p == s_parent || p == s_top || p == s_status) {
|
||||
SEE_SET_OBJECT(res, o);
|
||||
#if 0
|
||||
} else if (p == s_parent || p == s_top) {
|
||||
struct document_view *doc_view = vs->doc_view;
|
||||
struct document_view *top_view = doc_view->session->doc_view;
|
||||
struct js_window_object *newjsframe;
|
||||
|
||||
assert(top_view && top_view->vs);
|
||||
if (top_view->vs->ecmascript_fragile)
|
||||
ecmascript_reset_state(top_view->vs);
|
||||
if (!top_view->vs->ecmascript) {
|
||||
SEE_SET_UNDEFINED(res);
|
||||
return;
|
||||
}
|
||||
newjsframe = js_get_global_object(
|
||||
top_view->vs->ecmascript->backend_data);
|
||||
|
||||
/* Keep this unrolled this way. Will have to check document.domain
|
||||
* JS property. */
|
||||
/* Note that this check is perhaps overparanoid. If top windows
|
||||
* is alien but some other child window is not, we should still
|
||||
* let the script walk thru. That'd mean moving the check to
|
||||
* other individual properties in this switch. */
|
||||
if (compare_uri(vs->uri, top_view->vs->uri, URI_HOST)) {
|
||||
SEE_SET_OBJECT(res, (struct SEE_object *)newjsframe);
|
||||
}
|
||||
#endif
|
||||
} else if (p == s_alert) {
|
||||
SEE_SET_OBJECT(res, win->alert);
|
||||
} else if (p == s_open) {
|
||||
SEE_SET_OBJECT(res, win->open);
|
||||
} else if (p == s_setTimeout) {
|
||||
SEE_SET_OBJECT(res, win->setTimeout);
|
||||
} else if (p == s_location) {
|
||||
SEE_OBJECT_GET(interp, interp->Global, s_location, res);
|
||||
} else if (p == s_navigator) {
|
||||
SEE_OBJECT_GET(interp, interp->Global, s_navigator, res);
|
||||
} else {
|
||||
unsigned char *frame = see_string_to_unsigned_char(p);
|
||||
struct document_view *doc_view = vs->doc_view;
|
||||
struct js_window_object *obj;
|
||||
|
||||
if (frame && (obj = js_try_resolve_frame(doc_view, frame))) {
|
||||
SEE_SET_OBJECT(res, (struct SEE_object *)obj);
|
||||
} else {
|
||||
SEE_SET_UNDEFINED(res);
|
||||
}
|
||||
mem_free_if(frame);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
window_put(struct SEE_interpreter *interp, struct SEE_object *o,
|
||||
struct SEE_string *p, struct SEE_value *val, int attr)
|
||||
{
|
||||
if (p == s_location) {
|
||||
struct js_window_object *win = (struct js_window_object *)o;
|
||||
struct view_state *vs = win->vs;
|
||||
struct document_view *doc_view = vs->doc_view;
|
||||
unsigned char *str = see_value_to_unsigned_char(interp, val);
|
||||
|
||||
if (str) {
|
||||
location_goto(doc_view, str);
|
||||
mem_free(str);
|
||||
}
|
||||
} else if (p == s_status) {
|
||||
struct global_object *g = (struct global_object *)interp;
|
||||
struct js_window_object *win = g->win;
|
||||
struct view_state *vs = win->vs;
|
||||
struct document_view *doc_view = vs->doc_view;
|
||||
struct session *ses = doc_view->session;
|
||||
unsigned char *stat = see_value_to_unsigned_char(interp, val);
|
||||
|
||||
mem_free_set(&ses->status.window_status, stat);
|
||||
print_screen_status(ses);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
window_canput(struct SEE_interpreter *interp, struct SEE_object *o,
|
||||
struct SEE_string *p)
|
||||
{
|
||||
if (p == s_location || p == s_status)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
window_hasproperty(struct SEE_interpreter *interp, struct SEE_object *o,
|
||||
struct SEE_string *p)
|
||||
{
|
||||
/* all unknown properties return UNDEFINED value */
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
js_window_alert(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 js_window_object *win = g->win;
|
||||
struct view_state *vs = win->vs;
|
||||
unsigned char *string;
|
||||
|
||||
/* Do not check thisobj->objectclass. ELinks sets this
|
||||
* function as a property of both the window object and the
|
||||
* global object, so thisobj may validly refer to either. */
|
||||
|
||||
SEE_SET_BOOLEAN(res, 1);
|
||||
if (argc < 1)
|
||||
return;
|
||||
|
||||
string = see_value_to_unsigned_char(interp, argv[0]);
|
||||
if (!string || !*string) {
|
||||
mem_free_if(string);
|
||||
return;
|
||||
}
|
||||
|
||||
info_box(vs->doc_view->session->tab->term, MSGBOX_FREE_TEXT,
|
||||
N_("JavaScript Alert"), ALIGN_CENTER, string);
|
||||
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
js_window_open(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 js_window_object *win = g->win;
|
||||
struct view_state *vs = win->vs;
|
||||
struct document_view *doc_view = vs->doc_view;
|
||||
struct session *ses = doc_view->session;
|
||||
unsigned char *frame = NULL;
|
||||
unsigned char *url, *url2;
|
||||
struct uri *uri;
|
||||
struct SEE_value url_value;
|
||||
static time_t ratelimit_start;
|
||||
static int ratelimit_count;
|
||||
|
||||
/* Do not check thisobj->objectclass. ELinks sets this
|
||||
* function as a property of both the window object and the
|
||||
* global object, so thisobj may validly refer to either. */
|
||||
|
||||
SEE_SET_OBJECT(res, (struct SEE_object *)win);
|
||||
if (get_opt_bool("ecmascript.block_window_opening", ses)) {
|
||||
#ifdef CONFIG_LEDS
|
||||
set_led_value(ses->status.popup_led, 'P');
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
if (argc < 1) return;
|
||||
|
||||
/* Ratelimit window opening. Recursive window.open() is very nice.
|
||||
* We permit at most 20 tabs in 2 seconds. The ratelimiter is very
|
||||
* rough but shall suffice against the usual cases. */
|
||||
|
||||
if (!ratelimit_start || time(NULL) - ratelimit_start > 2) {
|
||||
ratelimit_start = time(NULL);
|
||||
ratelimit_count = 0;
|
||||
} else {
|
||||
ratelimit_count++;
|
||||
if (ratelimit_count > 20)
|
||||
return;
|
||||
}
|
||||
|
||||
SEE_ToString(interp, argv[0], &url_value);
|
||||
url = see_string_to_unsigned_char(url_value.u.string);
|
||||
if (!url) return;
|
||||
trim_chars(url, ' ', 0);
|
||||
if (argc > 1) {
|
||||
struct SEE_value target_value;
|
||||
|
||||
SEE_ToString(interp, argv[1], &target_value);
|
||||
frame = see_string_to_unsigned_char(target_value.u.string);
|
||||
if (!frame) {
|
||||
mem_free(url);
|
||||
return;
|
||||
}
|
||||
}
|
||||
/* TODO: Support for window naming and perhaps some window features? */
|
||||
|
||||
url2 = join_urls(doc_view->document->uri, url);
|
||||
mem_free(url);
|
||||
if (!url2) {
|
||||
mem_free_if(frame);
|
||||
return;
|
||||
}
|
||||
uri = get_uri(url2, 0);
|
||||
mem_free(url2);
|
||||
if (!uri) {
|
||||
mem_free_if(frame);
|
||||
return;
|
||||
}
|
||||
|
||||
if (frame && *frame && c_strcasecmp(frame, "_blank")) {
|
||||
struct delayed_open *deo = mem_calloc(1, sizeof(*deo));
|
||||
|
||||
if (deo) {
|
||||
deo->ses = ses;
|
||||
deo->uri = get_uri_reference(uri);
|
||||
deo->target = stracpy(frame);
|
||||
/* target will be freed in delayed_goto_uri_frame */
|
||||
register_bottom_half(delayed_goto_uri_frame, deo);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
if (!get_cmd_opt_bool("no-connect")
|
||||
&& !get_cmd_opt_bool("no-home")
|
||||
&& !get_cmd_opt_bool("anonymous")
|
||||
&& can_open_in_new(ses->tab->term)) {
|
||||
open_uri_in_new_window(ses, uri, NULL, ENV_ANY,
|
||||
CACHE_MODE_NORMAL, TASK_NONE);
|
||||
} else {
|
||||
/* When opening a new tab, we might get rerendered, losing our
|
||||
* context and triggerring a disaster, so postpone that. */
|
||||
struct delayed_open *deo = mem_calloc(1, sizeof(*deo));
|
||||
|
||||
if (deo) {
|
||||
deo->ses = ses;
|
||||
deo->uri = get_uri_reference(uri);
|
||||
register_bottom_half(delayed_open, deo);
|
||||
}
|
||||
}
|
||||
|
||||
end:
|
||||
done_uri(uri);
|
||||
mem_free_if(frame);
|
||||
}
|
||||
|
||||
static void
|
||||
js_setTimeout(struct SEE_interpreter *interp, struct SEE_object *self,
|
||||
struct SEE_object *thisobj, int argc, struct SEE_value **argv,
|
||||
struct SEE_value *res)
|
||||
{
|
||||
struct ecmascript_interpreter *ei;
|
||||
unsigned char *code;
|
||||
int timeout;
|
||||
|
||||
/* Do not check thisobj->objectclass. ELinks sets this
|
||||
* function as a property of both the window object and the
|
||||
* global object, so thisobj may validly refer to either. */
|
||||
|
||||
if (argc != 2) return;
|
||||
ei = ((struct global_object *)interp)->interpreter;
|
||||
code = see_value_to_unsigned_char(interp, argv[0]);
|
||||
timeout = SEE_ToInt32(interp, argv[1]);
|
||||
ecmascript_set_timeout(ei, code, timeout);
|
||||
}
|
||||
|
||||
void
|
||||
init_js_window_object(struct ecmascript_interpreter *interpreter)
|
||||
{
|
||||
struct global_object *g = interpreter->backend_data;
|
||||
struct SEE_interpreter *interp = &g->interp;
|
||||
struct SEE_value v;
|
||||
|
||||
g->win = SEE_NEW(interp, struct js_window_object);
|
||||
|
||||
g->win->object.objectclass = &js_window_object_class;
|
||||
g->win->object.Prototype = NULL;
|
||||
g->win->vs = interpreter->vs;
|
||||
|
||||
SEE_SET_OBJECT(&v, (struct SEE_object *)g->win);
|
||||
SEE_OBJECT_PUT(interp, interp->Global, s_window, &v, 0);
|
||||
|
||||
g->win->alert = SEE_cfunction_make(interp, js_window_alert, s_alert, 1);
|
||||
g->win->open = SEE_cfunction_make(interp, js_window_open, s_open, 3);
|
||||
g->win->setTimeout = SEE_cfunction_make(interp, js_setTimeout, s_setTimeout, 2);
|
||||
|
||||
SEE_OBJECT_GET(interp, (struct SEE_object *)g->win, s_top, &v);
|
||||
SEE_OBJECT_PUT(interp, interp->Global, s_top, &v, 0);
|
||||
|
||||
SEE_OBJECT_GET(interp, (struct SEE_object *)g->win, s_self, &v);
|
||||
SEE_OBJECT_PUT(interp, interp->Global, s_self, &v, 0);
|
||||
|
||||
SEE_OBJECT_GET(interp, (struct SEE_object *)g->win, s_alert, &v);
|
||||
SEE_OBJECT_PUT(interp, interp->Global, s_alert, &v, 0);
|
||||
SEE_OBJECT_GET(interp, (struct SEE_object *)g->win, s_open, &v);
|
||||
SEE_OBJECT_PUT(interp, interp->Global, s_open, &v, 0);
|
||||
SEE_OBJECT_GET(interp, (struct SEE_object *)g->win, s_setTimeout, &v);
|
||||
SEE_OBJECT_PUT(interp, interp->Global, s_setTimeout, &v, 0);
|
||||
}
|
||||
|
||||
void
|
||||
checktime(struct SEE_interpreter *interp)
|
||||
{
|
||||
struct global_object *g = (struct global_object *)interp;
|
||||
|
||||
if (time(NULL) - g->exec_start > g->max_exec_time) {
|
||||
struct terminal *term = g->win->vs->doc_view->session->tab->term;
|
||||
/* A killer script! Alert! */
|
||||
ecmascript_timeout_dialog(term, g->max_exec_time);
|
||||
SEE_error_throw_string(interp, interp->Error, s_timeout);
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
#ifndef EL__ECMASCRIPT_SEE_WINDOW_H
|
||||
#define EL__ECMASCRIPT_SEE_WINDOW_H
|
||||
|
||||
struct SEE_object;
|
||||
struct SEE_interpreter;
|
||||
struct ecmascript_interpreter;
|
||||
struct string;
|
||||
struct view_state;
|
||||
|
||||
|
||||
struct js_window_object {
|
||||
struct SEE_object object;
|
||||
struct view_state *vs;
|
||||
struct SEE_object *alert;
|
||||
struct SEE_object *open;
|
||||
struct SEE_object *setTimeout;
|
||||
};
|
||||
|
||||
struct global_object {
|
||||
struct SEE_interpreter interp;
|
||||
/* used by setTimeout */
|
||||
struct ecmascript_interpreter *interpreter;
|
||||
struct js_window_object *win;
|
||||
struct string *ret;
|
||||
int exec_start;
|
||||
int max_exec_time;
|
||||
};
|
||||
|
||||
void init_js_window_object(struct ecmascript_interpreter *);
|
||||
void checktime(struct SEE_interpreter *interp);
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user