diff options
| author | 2024-03-15 19:05:42 +0100 | |
|---|---|---|
| committer | 2024-03-15 19:05:42 +0100 | |
| commit | d50b0391044ed0c15ea996577164300bd518c0e9 (patch) | |
| tree | 895308331901621ca7f2f8eba24b9289fc20cc80 | |
| parent | Added a type Note to poll options. (diff) | |
| download | snac2-d50b0391044ed0c15ea996577164300bd518c0e9.tar.gz snac2-d50b0391044ed0c15ea996577164300bd518c0e9.tar.xz snac2-d50b0391044ed0c15ea996577164300bd518c0e9.zip | |
Set display to none for children details that are empty.
| -rw-r--r-- | html.c | 34 |
1 files changed, 23 insertions, 11 deletions
| @@ -1858,6 +1858,8 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only, | |||
| 1858 | 1858 | ||
| 1859 | xs_list *p = children; | 1859 | xs_list *p = children; |
| 1860 | char *cmd5; | 1860 | char *cmd5; |
| 1861 | int cnt = 0; | ||
| 1862 | |||
| 1861 | while (xs_list_iter(&p, &cmd5)) { | 1863 | while (xs_list_iter(&p, &cmd5)) { |
| 1862 | xs *chd = NULL; | 1864 | xs *chd = NULL; |
| 1863 | 1865 | ||
| @@ -1866,23 +1868,33 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only, | |||
| 1866 | else | 1868 | else |
| 1867 | object_get_by_md5(cmd5, &chd); | 1869 | object_get_by_md5(cmd5, &chd); |
| 1868 | 1870 | ||
| 1869 | if (chd != NULL && xs_is_null(xs_dict_get(chd, "name"))) { | 1871 | if (chd != NULL) { |
| 1870 | xs_html *che = html_entry(user, chd, read_only, level + 1, cmd5, hide_children); | 1872 | if (xs_is_null(xs_dict_get(chd, "name"))) { |
| 1873 | xs_html *che = html_entry(user, chd, read_only, | ||
| 1874 | level + 1, cmd5, hide_children); | ||
| 1875 | |||
| 1876 | if (che != NULL) { | ||
| 1877 | if (left > 3) | ||
| 1878 | xs_html_add(ch_older, | ||
| 1879 | che); | ||
| 1880 | else | ||
| 1881 | xs_html_add(ch_container, | ||
| 1882 | che); | ||
| 1871 | 1883 | ||
| 1872 | if (che != NULL) { | 1884 | cnt++; |
| 1873 | if (left > 3) | 1885 | } |
| 1874 | xs_html_add(ch_older, | ||
| 1875 | che); | ||
| 1876 | else | ||
| 1877 | xs_html_add(ch_container, | ||
| 1878 | che); | ||
| 1879 | } | 1886 | } |
| 1887 | |||
| 1888 | left--; | ||
| 1880 | } | 1889 | } |
| 1881 | else | 1890 | else |
| 1882 | srv_debug(2, xs_fmt("cannot read child %s", cmd5)); | 1891 | srv_debug(2, xs_fmt("cannot read child %s", cmd5)); |
| 1883 | |||
| 1884 | left--; | ||
| 1885 | } | 1892 | } |
| 1893 | |||
| 1894 | /* if no children were finally added, hide the details */ | ||
| 1895 | if (cnt == 0) | ||
| 1896 | xs_html_add(ch_details, | ||
| 1897 | xs_html_attr("style", "display: none")); | ||
| 1886 | } | 1898 | } |
| 1887 | } | 1899 | } |
| 1888 | 1900 | ||