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

Ecmascript: introduced selectedIndex

This commit is contained in:
Witold Filipczyk 2006-05-02 09:36:23 +02:00 committed by Witold Filipczyk
parent c540a9ed63
commit d9d6bc23ae
4 changed files with 16 additions and 2 deletions

View File

@ -239,6 +239,7 @@ input_get(struct SEE_interpreter *interp, struct SEE_object *o,
case FC_RESET: str = s_reset; break; case FC_RESET: str = s_reset; break;
case FC_BUTTON: str = s_button; break; case FC_BUTTON: str = s_button; break;
case FC_HIDDEN: str = s_hidden; break; case FC_HIDDEN: str = s_hidden; break;
case FC_SELECT: str = s_select; break;
default: str = NULL; default: str = NULL;
} }
if (str) { if (str) {
@ -247,6 +248,8 @@ input_get(struct SEE_interpreter *interp, struct SEE_object *o,
} else if (p == s_value) { } else if (p == s_value) {
str = string_to_SEE_string(interp, fs->value); str = string_to_SEE_string(interp, fs->value);
SEE_SET_STRING(res, str); SEE_SET_STRING(res, str);
} else if (p == s_selectedIndex) {
if (fc->type == FC_SELECT) SEE_SET_NUMBER(res, fs->state);
} else if (p == s_blur) { } else if (p == s_blur) {
SEE_SET_OBJECT(res, input->blur); SEE_SET_OBJECT(res, input->blur);
} else if (p == s_click) { } else if (p == s_click) {
@ -483,10 +486,10 @@ js_get_form_control_object(struct SEE_interpreter *interp, struct js_form *jsfor
case FC_RESET: case FC_RESET:
case FC_BUTTON: case FC_BUTTON:
case FC_HIDDEN: case FC_HIDDEN:
case FC_SELECT:
return js_get_input_object(interp, jsform, fs); return js_get_input_object(interp, jsform, fs);
case FC_TEXTAREA: case FC_TEXTAREA:
case FC_SELECT:
/* TODO */ /* TODO */
return NULL; return NULL;

View File

@ -51,6 +51,7 @@ struct SEE_string *s_blur;
struct SEE_string *s_click; struct SEE_string *s_click;
struct SEE_string *s_focus; struct SEE_string *s_focus;
struct SEE_string *s_select; struct SEE_string *s_select;
struct SEE_string *s_selectedIndex;
struct SEE_string *s_elements; struct SEE_string *s_elements;
struct SEE_string *s_item; struct SEE_string *s_item;
@ -193,6 +194,8 @@ init_intern_strings(void)
static struct SEE_string S_focus = SEE_STRING_DECL(SA_focus); static struct SEE_string S_focus = SEE_STRING_DECL(SA_focus);
static SEE_char_t SA_select[] ={'s','e','l','e','c','t'}; static SEE_char_t SA_select[] ={'s','e','l','e','c','t'};
static struct SEE_string S_select = SEE_STRING_DECL(SA_select); static struct SEE_string S_select = SEE_STRING_DECL(SA_select);
static SEE_char_t SA_selectedIndex[] ={'s','e','l','e','c','t','e','d','I','n','d','e','x'};
static struct SEE_string S_selectedIndex = SEE_STRING_DECL(SA_selectedIndex);
static SEE_char_t SA_elements[] ={'e','l','e','m','e','n','t','s'}; static SEE_char_t SA_elements[] ={'e','l','e','m','e','n','t','s'};
static struct SEE_string S_elements = SEE_STRING_DECL(SA_elements); static struct SEE_string S_elements = SEE_STRING_DECL(SA_elements);
@ -337,6 +340,7 @@ init_intern_strings(void)
SEE_intern_global(s_click = &S_click); SEE_intern_global(s_click = &S_click);
SEE_intern_global(s_focus = &S_focus); SEE_intern_global(s_focus = &S_focus);
SEE_intern_global(s_select = &S_select); SEE_intern_global(s_select = &S_select);
SEE_intern_global(s_selectedIndex = &S_selectedIndex);
SEE_intern_global(s_elements = &S_elements); SEE_intern_global(s_elements = &S_elements);
SEE_intern_global(s_item = &S_item); SEE_intern_global(s_item = &S_item);

View File

@ -57,6 +57,7 @@ extern struct SEE_string *s_blur;
extern struct SEE_string *s_click; extern struct SEE_string *s_click;
extern struct SEE_string *s_focus; extern struct SEE_string *s_focus;
extern struct SEE_string *s_select; extern struct SEE_string *s_select;
extern struct SEE_string *s_selectedIndex;
extern struct SEE_string *s_elements; extern struct SEE_string *s_elements;
extern struct SEE_string *s_item; extern struct SEE_string *s_item;

View File

@ -71,6 +71,7 @@ enum input_prop {
JSP_INPUT_MAX_LENGTH, JSP_INPUT_MAX_LENGTH,
JSP_INPUT_NAME, JSP_INPUT_NAME,
JSP_INPUT_READONLY, JSP_INPUT_READONLY,
JSP_INPUT_SELECTED_INDEX,
JSP_INPUT_SIZE, JSP_INPUT_SIZE,
JSP_INPUT_SRC, JSP_INPUT_SRC,
JSP_INPUT_TABINDEX, JSP_INPUT_TABINDEX,
@ -94,6 +95,7 @@ static const JSPropertySpec input_props[] = {
{ "maxLength", JSP_INPUT_MAX_LENGTH, JSPROP_ENUMERATE }, { "maxLength", JSP_INPUT_MAX_LENGTH, JSPROP_ENUMERATE },
{ "name", JSP_INPUT_NAME, JSPROP_ENUMERATE }, { "name", JSP_INPUT_NAME, JSPROP_ENUMERATE },
{ "readonly", JSP_INPUT_READONLY, JSPROP_ENUMERATE }, { "readonly", JSP_INPUT_READONLY, JSPROP_ENUMERATE },
{ "selectedIndex",JSP_INPUT_SELECTED_INDEX,JSPROP_ENUMERATE },
{ "size", JSP_INPUT_SIZE, JSPROP_ENUMERATE | JSPROP_READONLY }, { "size", JSP_INPUT_SIZE, JSPROP_ENUMERATE | JSPROP_READONLY },
{ "src", JSP_INPUT_SRC, JSPROP_ENUMERATE }, { "src", JSP_INPUT_SRC, JSPROP_ENUMERATE },
{ "tabindex", JSP_INPUT_TABINDEX, JSPROP_ENUMERATE | JSPROP_READONLY }, { "tabindex", JSP_INPUT_TABINDEX, JSPROP_ENUMERATE | JSPROP_READONLY },
@ -210,6 +212,7 @@ input_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
case FC_RESET: s = "reset"; break; case FC_RESET: s = "reset"; break;
case FC_BUTTON: s = "button"; break; case FC_BUTTON: s = "button"; break;
case FC_HIDDEN: s = "hidden"; break; case FC_HIDDEN: s = "hidden"; break;
case FC_SELECT: s = "select"; break;
default: INTERNAL("input_get_property() upon a non-input item."); break; default: INTERNAL("input_get_property() upon a non-input item."); break;
} }
string_to_jsval(ctx, vp, s); string_to_jsval(ctx, vp, s);
@ -219,6 +222,9 @@ input_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
string_to_jsval(ctx, vp, fs->value); string_to_jsval(ctx, vp, fs->value);
break; break;
case JSP_INPUT_SELECTED_INDEX:
if (fc->type == FC_SELECT) int_to_jsval(ctx, vp, fs->state);
break;
default: default:
INTERNAL("Invalid ID %d in input_get_property().", JSVAL_TO_INT(id)); INTERNAL("Invalid ID %d in input_get_property().", JSVAL_TO_INT(id));
break; break;
@ -416,10 +422,10 @@ get_form_control_object(JSContext *ctx, JSObject *jsform, enum form_type type, s
case FC_RESET: case FC_RESET:
case FC_BUTTON: case FC_BUTTON:
case FC_HIDDEN: case FC_HIDDEN:
case FC_SELECT:
return get_input_object(ctx, jsform, fs); return get_input_object(ctx, jsform, fs);
case FC_TEXTAREA: case FC_TEXTAREA:
case FC_SELECT:
/* TODO */ /* TODO */
return NULL; return NULL;