diff options
| author | 2023-05-24 10:11:48 +0200 | |
|---|---|---|
| committer | 2023-05-24 10:11:48 +0200 | |
| commit | 2b6d6d3412b13ca7b91ddfaa320f5e37a2357d3f (patch) | |
| tree | 4a82d312eaf855832643bae80fbcfb341a2972d9 | |
| parent | Some prototype tweaks. (diff) | |
| download | penes-snac2-2b6d6d3412b13ca7b91ddfaa320f5e37a2357d3f.tar.gz penes-snac2-2b6d6d3412b13ca7b91ddfaa320f5e37a2357d3f.tar.xz penes-snac2-2b6d6d3412b13ca7b91ddfaa320f5e37a2357d3f.zip | |
Finished polls are shown.
| -rw-r--r-- | html.c | 33 |
1 files changed, 32 insertions, 1 deletions
| @@ -729,7 +729,7 @@ xs_str *html_entry(snac *snac, xs_str *os, const xs_dict *msg, int local, | |||
| 729 | return xs_str_cat(os, s); | 729 | return xs_str_cat(os, s); |
| 730 | } | 730 | } |
| 731 | else | 731 | else |
| 732 | if (strcmp(type, "Note") != 0) { | 732 | if (strcmp(type, "Note") != 0 && strcmp(type, "Question") != 0) { |
| 733 | /* skip oddities */ | 733 | /* skip oddities */ |
| 734 | return os; | 734 | return os; |
| 735 | } | 735 | } |
| @@ -881,6 +881,37 @@ xs_str *html_entry(snac *snac, xs_str *os, const xs_dict *msg, int local, | |||
| 881 | } | 881 | } |
| 882 | } | 882 | } |
| 883 | 883 | ||
| 884 | if (strcmp(type, "Question") == 0) { | ||
| 885 | xs_list *oo = xs_dict_get(msg, "oneOf"); | ||
| 886 | xs_list *ao = xs_dict_get(msg, "anyOf"); | ||
| 887 | xs_list *p; | ||
| 888 | xs_dict *v; | ||
| 889 | |||
| 890 | p = oo != NULL ? oo : ao; | ||
| 891 | |||
| 892 | if (!xs_is_null(xs_dict_get(msg, "closed"))) { | ||
| 893 | /* closed poll */ | ||
| 894 | c = xs_str_cat(c, "<table>\n"); | ||
| 895 | |||
| 896 | while (xs_list_iter(&p, &v)) { | ||
| 897 | const char *name = xs_dict_get(v, "name"); | ||
| 898 | const xs_dict *replies = xs_dict_get(v, "replies"); | ||
| 899 | |||
| 900 | if (name && replies) { | ||
| 901 | int nr = xs_number_get(xs_dict_get(replies, "totalItems")); | ||
| 902 | xs *l = xs_fmt("<tr><td>%s:</td><td>%d</td></tr>\n", name, nr); | ||
| 903 | |||
| 904 | c = xs_str_cat(c, l); | ||
| 905 | } | ||
| 906 | } | ||
| 907 | |||
| 908 | c = xs_str_cat(c, "</table>\n"); | ||
| 909 | } | ||
| 910 | else { | ||
| 911 | /* poll still active */ | ||
| 912 | } | ||
| 913 | } | ||
| 914 | |||
| 884 | s = xs_str_cat(s, c); | 915 | s = xs_str_cat(s, c); |
| 885 | } | 916 | } |
| 886 | 917 | ||