Mercurial Hosting > chat
changeset 65:6cfef9850520
people popup
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Wed, 05 Mar 2025 22:30:35 -0700 |
parents | bc9f452ee168 |
children | f067de76084c |
files | src/chat.css src/chat.js src/get_chat.js.luan src/index.html.luan |
diffstat | 4 files changed, 58 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/chat.css Wed Mar 05 21:43:11 2025 -0700 +++ b/src/chat.css Wed Mar 05 22:30:35 2025 -0700 @@ -171,6 +171,19 @@ display: none; } +a[people] { + color: black; +} + +div[people] { + margin-bottom: 40px; +} + +div[people] img[phone] { + display: inline-block; + height: 1em; +} + @media (min-width: 700px) { div[chat_content] { margin-left: calc(3% - 8px);
--- a/src/chat.js Wed Mar 05 21:43:11 2025 -0700 +++ b/src/chat.js Wed Mar 05 22:30:35 2025 -0700 @@ -333,3 +333,8 @@ }; reader.readAsArrayBuffer(file); } + +function openPeople() { + let dialog = document.querySelector('dialog[people]'); + openModal(dialog); +}
--- a/src/get_chat.js.luan Wed Mar 05 21:43:11 2025 -0700 +++ b/src/get_chat.js.luan Wed Mar 05 22:30:35 2025 -0700 @@ -5,6 +5,8 @@ local digest_message = String.digest_message or error() local Parsers = require "luan:Parsers.luan" local json_string = Parsers.json_string or error() +local Html = require "luan:Html.luan" +local html_encode = Html.encode or error() local Io = require "luan:Io.luan" local Http = require "luan:http/Http.luan" local User = require "site:/lib/User.luan" @@ -30,7 +32,7 @@ <span><% local user_id = chat.other_user_id(user.id) local other_user = get_user_by_id(user_id) or error(user_id) - %><%= other_user.name_html() %><span online="<%= other_user.id %>"></span><% + %><a people href="javascript:openPeople()"><%= other_user.name_html() %></a><span online="<%= other_user.id %>"></span><% local voice_url = other_user.voice_url if voice_url ~= nil then %> <a href="<%=voice_url%>" title="Call" target="voice"><img phone src="/images/call.svg"></a><% @@ -54,6 +56,32 @@ <% end +local function people(chat) + for _, user_id in ipairs(chat.user_ids) do + local user = get_user_by_id(user_id) + local name = user.name + local email = user.email + local voice_url = user.voice_url + local voice = voice_url and `%> <a href="<%=voice_url%>" title="Call" target="voice"><img phone src="/images/call.svg"><%` or "" +%> + <p> +<% + if name == nil then +%> + <b><%=html_encode(email)%></b><%=voice%> +<% + else +%> + <b><%=html_encode(name)%></b><%=voice%><br> + <%=html_encode(email)%> +<% + end +%> + </p> +<% + end +end + return function() local user = current_user() or error() local chat = Http.request.parameters.chat or error() @@ -64,5 +92,6 @@ %> gotChat(<%=json_string(html)%>); filebinUrl = 'https://filebin.net/<%=digest%>/'; + document.querySelector('dialog[people] div[people]').innerHTML = <%=json_string(`people(chat)`)%>; <% end
--- a/src/index.html.luan Wed Mar 05 21:43:11 2025 -0700 +++ b/src/index.html.luan Wed Mar 05 22:30:35 2025 -0700 @@ -23,10 +23,7 @@ end local user_id = user.id local chat = Http.request.parameters.chat - local selected = nil - if chat ~= nil then - selected = get_chat_by_id(chat) - end + chat = chat and get_chat_by_id(chat) Io.stdout = Http.response.text_writer() %> <!doctype html> @@ -101,14 +98,21 @@ <button onclick="gotoInvite(this)">Close</button> </div> </dialog> + <dialog people> + <h2>People in the chat</h2> + <div people></div> + <div buttons> + <button onclick="closeModal(this)">Close</button> + </div> + </dialog> <input type="file" required onchange="loadedFile(this)"> <script> 'use strict'; <% - if selected ~= nil then + if chat ~= nil then %> - selectChat('<%=selected.id%>'); + selectChat('<%=chat.id%>'); <% end %>