diff options
| -rw-r--r-- | html.c | 31 |
1 files changed, 23 insertions, 8 deletions
| @@ -948,9 +948,9 @@ xs_str *html_entry(snac *snac, xs_str *os, const xs_dict *msg, int local, | |||
| 948 | const char *name = xs_dict_get(v, "name"); | 948 | const char *name = xs_dict_get(v, "name"); |
| 949 | 949 | ||
| 950 | if (name) { | 950 | if (name) { |
| 951 | /* FIXME: process anyOf (checkbox) correctly */ | 951 | xs *opt = xs_fmt("<input type=\"%s\"" |
| 952 | xs *opt = xs_fmt("<input type=\"radio\"" | ||
| 953 | " id=\"%s\" value=\"%s\" name=\"question\"> %s<br>\n", | 952 | " id=\"%s\" value=\"%s\" name=\"question\"> %s<br>\n", |
| 953 | !xs_is_null(oo) ? "radio" : "checkbox", | ||
| 954 | name, name, name); | 954 | name, name, name); |
| 955 | 955 | ||
| 956 | s1 = xs_str_cat(s1, opt); | 956 | s1 = xs_str_cat(s1, opt); |
| @@ -1981,16 +1981,31 @@ int html_post_handler(const xs_dict *req, const char *q_path, | |||
| 1981 | const char *opt = xs_dict_get(p_vars, "question"); | 1981 | const char *opt = xs_dict_get(p_vars, "question"); |
| 1982 | const char *actor = xs_dict_get(p_vars, "actor"); | 1982 | const char *actor = xs_dict_get(p_vars, "actor"); |
| 1983 | 1983 | ||
| 1984 | xs *msg = msg_note(&snac, "", actor, irt, NULL, 1); | 1984 | xs *ls = NULL; |
| 1985 | 1985 | ||
| 1986 | /* set the option */ | 1986 | /* multiple choices? */ |
| 1987 | msg = xs_dict_append(msg, "name", opt); | 1987 | if (xs_type(opt) == XSTYPE_LIST) |
| 1988 | ls = xs_dup(opt); | ||
| 1989 | else { | ||
| 1990 | ls = xs_list_new(); | ||
| 1991 | ls = xs_list_append(ls, opt); | ||
| 1992 | } | ||
| 1988 | 1993 | ||
| 1989 | xs *c_msg = msg_create(&snac, msg); | 1994 | xs_list *p = ls; |
| 1995 | xs_str *v; | ||
| 1996 | |||
| 1997 | while (xs_list_iter(&p, &v)) { | ||
| 1998 | xs *msg = msg_note(&snac, "", actor, irt, NULL, 1); | ||
| 1990 | 1999 | ||
| 1991 | enqueue_message(&snac, c_msg); | 2000 | /* set the option */ |
| 2001 | msg = xs_dict_append(msg, "name", v); | ||
| 1992 | 2002 | ||
| 1993 | timeline_add(&snac, xs_dict_get(msg, "id"), msg); | 2003 | xs *c_msg = msg_create(&snac, msg); |
| 2004 | |||
| 2005 | enqueue_message(&snac, c_msg); | ||
| 2006 | |||
| 2007 | timeline_add(&snac, xs_dict_get(msg, "id"), msg); | ||
| 2008 | } | ||
| 1994 | 2009 | ||
| 1995 | status = 303; | 2010 | status = 303; |
| 1996 | } | 2011 | } |