(text "{% extends \"root.lisp\" %} {% block head %}") (title (text "My chats - {{ name }}")) (text "{% endblock %} {% block body %}") (div ("class" "flex w_full gap_2 justify_between items_center") (div ("class" "tabs short bar") (a ("class" "button tab") ("href" "/chats") (text "chats"))) (button ("class" "button") ("title" "Create chat") ("onclick" "document.getElementById('create_dialog').showModal()") (text "{{ icon \"plus\" }}"))) (div ("class" "card flex flex_col gap_2") (text "{% for chat in chats -%}") (div ("class" "card surface w_full flex justify_between items_center gap_2") (a ("class" "flex gap_ch items_center") ("href" "/chats/{{ chat[0].id }}") (text "{{ components::chat_name(chat=chat[0], members=chat[1], advanced=true) }}")) (div ("class" "dropdown") (button ("onclick" "open_dropdown(event)") ("exclude" "dropdown") ("class" "button") (text "{{ icon \"ellipsis\" }}")) (div ("class" "inner") (a ("class" "button") ("href" "/chats/{{ chat[0].id }}") ("target" "_blank") (text "pop open")) (text "{% if chat[0].style != \"Direct\" -%}") ; group chat only (button ("class" "button") ("onclick" "rename_gc('{{ chat[0].id }}')") (text "rename")) (text "{%- endif %}") (button ("class" "button red") ("onclick" "leave_chat('{{ chat[0].id }}')") (text "leave"))))) (text "{%- endfor %}") (text "{% if chats|length == 0 -%}") (i ("class" "flex gap_ch items_center fade") (text "{{ icon \"smile\" }} No results, yet!")) (text "{%- endif %}") ; pagination (div ("class" "flex w_full items_center gap_2 justify_between") (text "{% if page > 0 -%}") (a ("href" "?page={{ page - 1 }}") ("class" "button surface") (text "{{ icon \"arrow-left\" }} Back")) (text "{%- else -%}") (div null?) (text "{%- endif %}") (text "{% if chats|length > 0 -%}") (a ("href" "?page={{ page + 1 }}") ("class" "button surface") (text "Next {{ icon \"arrow-right\" }}")) (text "{%- endif %}"))) (dialog ("id" "create_dialog") (div ("class" "inner") (h2 ("class" "text_center w_full") (text "Create chat")) (ul ("id" "members_list")) (form ("class" "flex flex_row gap_2 w_full") ("onsubmit" "add_member(event)") (input ("type" "text") ("list" "users_search") ("name" "username") ("id" "username") ("placeholder" "username") ("oninput" "search_users(event)")) (button ("class" "button") (text "Add"))) (hr ("class" "margin")) (div ("class" "flex gap_2 justify_between") (button ("onclick" "document.getElementById('create_dialog').close()") ("class" "button red") (text "Cancel")) (button ("class" "button green") ("onclick" "create_chat_from_form()") (text "Create"))))) (datalist ("id" "users_search")) (script (text "globalThis.CHAT_MEMBERS = []; function render_members() { document.getElementById('members_list').innerHTML = \"\"; for (const member of CHAT_MEMBERS) { document.getElementById('members_list').innerHTML += `