mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-22 21:35:04 +00:00
Finished polls are shown.
This commit is contained in:
parent
c356379cdd
commit
2b6d6d3412
1 changed files with 32 additions and 1 deletions
33
html.c
33
html.c
|
@ -729,7 +729,7 @@ xs_str *html_entry(snac *snac, xs_str *os, const xs_dict *msg, int local,
|
||||||
return xs_str_cat(os, s);
|
return xs_str_cat(os, s);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (strcmp(type, "Note") != 0) {
|
if (strcmp(type, "Note") != 0 && strcmp(type, "Question") != 0) {
|
||||||
/* skip oddities */
|
/* skip oddities */
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
@ -881,6 +881,37 @@ xs_str *html_entry(snac *snac, xs_str *os, const xs_dict *msg, int local,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (strcmp(type, "Question") == 0) {
|
||||||
|
xs_list *oo = xs_dict_get(msg, "oneOf");
|
||||||
|
xs_list *ao = xs_dict_get(msg, "anyOf");
|
||||||
|
xs_list *p;
|
||||||
|
xs_dict *v;
|
||||||
|
|
||||||
|
p = oo != NULL ? oo : ao;
|
||||||
|
|
||||||
|
if (!xs_is_null(xs_dict_get(msg, "closed"))) {
|
||||||
|
/* closed poll */
|
||||||
|
c = xs_str_cat(c, "<table>\n");
|
||||||
|
|
||||||
|
while (xs_list_iter(&p, &v)) {
|
||||||
|
const char *name = xs_dict_get(v, "name");
|
||||||
|
const xs_dict *replies = xs_dict_get(v, "replies");
|
||||||
|
|
||||||
|
if (name && replies) {
|
||||||
|
int nr = xs_number_get(xs_dict_get(replies, "totalItems"));
|
||||||
|
xs *l = xs_fmt("<tr><td>%s:</td><td>%d</td></tr>\n", name, nr);
|
||||||
|
|
||||||
|
c = xs_str_cat(c, l);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
c = xs_str_cat(c, "</table>\n");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* poll still active */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
s = xs_str_cat(s, c);
|
s = xs_str_cat(s, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue