Mercurial Hosting > chat
view src/index.html.luan @ 83:a47036fd0158
group chat
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 11 Mar 2025 13:56:59 -0600 |
parents | b5a316575e64 |
children | 3053a4fc10be |
line wrap: on
line source
local Luan = require "luan:Luan.luan" local error = Luan.error local Io = require "luan:Io.luan" local Http = require "luan:http/Http.luan" local Shared = require "site:/lib/Shared.luan" local head = Shared.head or error() local header = Shared.header or error() local started = Shared.started or error() local chats_html = Shared.chats_html or error() local User = require "site:/lib/User.luan" local current_user = User.current or error() local Chat = require "site:/lib/Chat.luan" local get_chat_by_id = Chat.get_by_id or error() local Logging = require "luan:logging/Logging.luan" local logger = Logging.logger "index.html" return function() local user = current_user() if user == nil then Http.response.send_redirect("/login.html") return end local user_id = user.id local chat = Http.request.parameters.chat chat = chat and get_chat_by_id(chat) Io.stdout = Http.response.text_writer() %> <!doctype html> <html> <head> <% head() %> <style> @import "chat.css?s=<%=started%>"; </style> <script src="chat.js?s=<%=started%>"></script> </head> <body> <% header() %> <div chat_content show="intro"> <div chats> <% chats_html() %> </div> <div intro> <h3 or>Choose a chat on the left</h3> <p or>or</p> <h3>Chat with another person</h3> <form action="javascript:invite()"> <p> <label>Person's email</label><br> <input type=email name=email required><br> </p> <p> <input type=submit> </p> </form> </div> <div posts></div> </div> <div hidden> <span pulldown=author> <img onclick="clickMenu(this)" src="/images/more_vert.svg"> <div> <span onclick="editPost(this)">Edit</span> <span onclick="replyPost(this)">Reply</span> <span onclick="deletePost(this)">Delete</span> </div> </span> <span pulldown=other> <img onclick="clickMenu(this)" src="/images/more_vert.svg"> <div> <span onclick="replyPost(this)">Reply</span> </div> </span> </div> <dialog delete_chat> <h2>Delete Chat</h2> <p>Are you sure that you want to delete this chat?</p> <div buttons> <button onclick="closeModal(this)">Cancel</button> <button onclick="doDeleteChat(this)">Delete</button> </div> </dialog> <dialog delete_post> <h2>Delete Message</h2> <p>Are you sure that you want to delete this message?</p> <div buttons> <button onclick="closeModal(this)">Cancel</button> <button onclick="doDeletePost(this)">Delete</button> </div> </dialog> <dialog edit_post> <h2>Edit Message</h2> <p><textarea onfocus="fixTextarea(event)" oninput="fixTextarea(event)" onkeydown="editTextareaKey(event)"></textarea></p> <div buttons> <button onclick="closeModal(this)">Cancel</button> <button onclick="savePost(this)">Save</button> </div> </dialog> <dialog invite> <h2>Chat with another person</h2> <p>We have sent an invite to <span email></span></p> <div buttons> <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> <dialog add> <h2>Add Someone to Chat</h2> <form action="javascript:addToChat()"> <p> <label>Person's email</label><br> <input type=email name=email required><br> <span error></span> </p> <div buttons> <button onclick="closeModal(this)">Cancel</button> <button type=submit>Add</button> </div> </form> </dialog> <input type="file" required onchange="loadedFile(this)"> <script> 'use strict'; <% if chat ~= nil then %> selectChat('<%=chat.id%>'); <% end %> setUserEventSource(<%=user_id%>); lastUpdate = <%=user.last_update()%>; userId = '<%=user_id%>'; </script> </body> </html> <% end