Mercurial Hosting > chat
comparison src/chat.html.luan @ 10:f9e6a4cc4f7d
add Post
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Wed, 30 Oct 2024 23:18:45 -0600 |
parents | b8b12fd8be22 |
children | 8b8905f63d80 |
comparison
equal
deleted
inserted
replaced
9:b8b12fd8be22 | 10:f9e6a4cc4f7d |
---|---|
1 local Luan = require "luan:Luan.luan" | 1 local Luan = require "luan:Luan.luan" |
2 local error = Luan.error | 2 local error = Luan.error |
3 local ipairs = Luan.ipairs or error() | 3 local ipairs = Luan.ipairs or error() |
4 local pairs = Luan.pairs or error() | 4 local pairs = Luan.pairs or error() |
5 local range = Luan.range or error() | |
5 local Table = require "luan:Table.luan" | 6 local Table = require "luan:Table.luan" |
6 local concat = Table.concat or error() | 7 local concat = Table.concat or error() |
7 local is_empty = Table.is_empty or error() | 8 local is_empty = Table.is_empty or error() |
8 local size = Table.size or error() | 9 local size = Table.size or error() |
9 local Io = require "luan:Io.luan" | 10 local Io = require "luan:Io.luan" |
10 local Http = require "luan:http/Http.luan" | 11 local Http = require "luan:http/Http.luan" |
11 local Shared = require "site:/lib/Shared.luan" | 12 local Shared = require "site:/lib/Shared.luan" |
12 local head = Shared.head or error() | 13 local head = Shared.head or error() |
13 local header = Shared.header or error() | 14 local header = Shared.header or error() |
15 local started = Shared.started or error() | |
14 local User = require "site:/lib/User.luan" | 16 local User = require "site:/lib/User.luan" |
15 local current_user = User.current or error() | 17 local current_user = User.current or error() |
16 local get_user_by_email = User.get_by_email or error() | 18 local get_user_by_email = User.get_by_email or error() |
17 local Utils = require "site:/lib/Utils.luan" | 19 local Utils = require "site:/lib/Utils.luan" |
18 local to_set = Utils.to_set or error() | 20 local to_set = Utils.to_set or error() |
80 <!doctype html> | 82 <!doctype html> |
81 <html> | 83 <html> |
82 <head> | 84 <head> |
83 <% head() %> | 85 <% head() %> |
84 <style> | 86 <style> |
85 body { | 87 @import "chat.css?s=<%=started%>"; |
86 height: 100vh; | |
87 display: flex; | |
88 flex-direction: column; | |
89 } | |
90 div[content] { | |
91 margin-bottom: 0; | |
92 display: flex; | |
93 height: 100%; | |
94 margin-left: calc(3% - 8px); | |
95 } | |
96 div[chats] { | |
97 width: 250px; | |
98 padding-right: 8px; | |
99 } | |
100 div[chats] > div { | |
101 margin-top: 2px; | |
102 margin-bottom: 2px; | |
103 padding-top: 16px; | |
104 padding-bottom: 16px; | |
105 padding-left: 8px; | |
106 padding-right: 8px; | |
107 border-radius: 4px; | |
108 } | |
109 div[chats] > div:hover, | |
110 div[chats] > div[selected] { | |
111 background-color: LightBlue; | |
112 } | |
113 div[posts] { | |
114 padding-left: 8px; | |
115 border-left: 1px solid; | |
116 } | |
117 </style> | 88 </style> |
118 <script> | 89 <script src="chat.js?s=<%=started%>"></script> |
119 'use strict'; | |
120 | |
121 let currentChatId = null; | |
122 | |
123 function selectChat(div) { | |
124 let chatId = div.getAttribute('chat'); | |
125 if( chatId === currentChatId ) | |
126 return; | |
127 let selected = div.parentNode.querySelector('[selected]'); | |
128 if( selected ) selected.removeAttribute('selected'); | |
129 div.setAttribute('selected',''); | |
130 ajax(`chat.js?chat=${chatId}`); | |
131 } | |
132 </script> | |
133 </head> | 90 </head> |
134 <body> | 91 <body> |
135 <% header() %> | 92 <% header() %> |
136 <div content> | 93 <div content> |
137 <div chats> | 94 <div chats> |