Use a select instead of a checkbox for setting multiple-choice polls.

This commit is contained in:
default 2023-06-02 10:48:05 +02:00
parent 97b8dded00
commit 2e19c193a0

19
html.c
View file

@ -384,7 +384,10 @@ d_char *html_top_controls(snac *snac, d_char *s)
"<p>%s:<br>\n" "<p>%s:<br>\n"
"<textarea class=\"snac-textarea\" name=\"poll_options\" " "<textarea class=\"snac-textarea\" name=\"poll_options\" "
"rows=\"6\" wrap=\"virtual\"></textarea>\n" "rows=\"6\" wrap=\"virtual\"></textarea>\n"
"<p>%s: <input type=\"checkbox\" name=\"poll_multiple\">\n" "<p><select name=\"poll_multiple\">\n"
"<option value=\"off\">%s</option>\n"
"<option value=\"on\">%s</option>\n"
"</select>\n"
"<select name=\"poll_end_secs\" id=\"poll_end_secs\">\n" "<select name=\"poll_end_secs\" id=\"poll_end_secs\">\n"
"<option value=\"300\">%s</option>\n" "<option value=\"300\">%s</option>\n"
"<option value=\"3600\">%s</option>\n" "<option value=\"3600\">%s</option>\n"
@ -495,10 +498,11 @@ d_char *html_top_controls(snac *snac, d_char *s)
L("Poll..."), L("Poll..."),
L("Poll options (one per line, up to 8)"), L("Poll options (one per line, up to 8)"),
L("Multiple"), L("One choice"),
L("5 minutes"), L("Multiple choices"),
L("1 hour"), L("End in 5 minutes"),
L("1 day"), L("End in 1 hour"),
L("End in 1 day"),
L("Post"), L("Post"),
@ -1834,9 +1838,12 @@ int html_post_handler(const xs_dict *req, const char *q_path,
/* get the rest of poll configuration */ /* get the rest of poll configuration */
const char *p_multiple = xs_dict_get(p_vars, "poll_multiple"); const char *p_multiple = xs_dict_get(p_vars, "poll_multiple");
const char *p_end_secs = xs_dict_get(p_vars, "poll_end_secs"); const char *p_end_secs = xs_dict_get(p_vars, "poll_end_secs");
int multiple = 0;
int end_secs = atoi(!xs_is_null(p_end_secs) ? p_end_secs : "60"); int end_secs = atoi(!xs_is_null(p_end_secs) ? p_end_secs : "60");
int multiple = !xs_is_null(p_multiple);
if (!xs_is_null(p_multiple) && strcmp(p_multiple, "on") == 0)
multiple = 1;
msg = msg_question(&snac, content_2, attach_list, msg = msg_question(&snac, content_2, attach_list,
poll_opts, multiple, end_secs); poll_opts, multiple, end_secs);