Malina Claude Opus 4.8 commited on
Commit
cfd0328
·
1 Parent(s): a5c1169

aria(mobile): show each message's sent date+time (UTC) above 'Odpowiedz' on long-press; css/js v22

Browse files
cloudflare/pages-integration/aria.html CHANGED
@@ -6,7 +6,7 @@
6
  <title>ARIA · NNL</title>
7
  <link rel="icon" href="favicon.png" />
8
  <link rel="stylesheet" href="css/styles.css" />
9
- <link rel="stylesheet" href="css/aria.css?v=21" />
10
  </head>
11
  <body class="app-body aria-page" data-theme="default">
12
 
@@ -138,6 +138,6 @@
138
 
139
  <div class="aria-toast" id="ariaToast" hidden></div>
140
 
141
- <script type="module" src="js/aria-chat.js?v=21"></script>
142
  </body>
143
  </html>
 
6
  <title>ARIA · NNL</title>
7
  <link rel="icon" href="favicon.png" />
8
  <link rel="stylesheet" href="css/styles.css" />
9
+ <link rel="stylesheet" href="css/aria.css?v=22" />
10
  </head>
11
  <body class="app-body aria-page" data-theme="default">
12
 
 
138
 
139
  <div class="aria-toast" id="ariaToast" hidden></div>
140
 
141
+ <script type="module" src="js/aria-chat.js?v=22"></script>
142
  </body>
143
  </html>
cloudflare/pages-integration/css/aria.css CHANGED
@@ -159,6 +159,7 @@ body.aria-page { position: fixed; inset: 0; width: 100%; height: 100%; display:
159
  .aria-held-clone.me { background: var(--aria-me); color: var(--aria-me-fg); border-bottom-right-radius: 5px; }
160
  .aria-holdmenu { position: fixed; z-index: 64; display: flex; flex-direction: column; min-width: 150px; background: var(--bg-2, #0a0a0f); border: 1px solid var(--line-strong, #ffffff29); border-radius: 14px; overflow: hidden; box-shadow: 0 10px 34px rgba(0,0,0,0.55); transform: scale(.85); opacity: 0; transform-origin: top center; transition: transform .18s var(--ease, ease), opacity .18s; }
161
  .aria-holdmenu.in { transform: scale(1); opacity: 1; }
 
162
  .aria-holdmenu-item { background: none; border: 0; color: var(--text, #fff); font: inherit; font-size: 15px; text-align: left; padding: 12px 16px; cursor: pointer; }
163
  .aria-holdmenu-item:hover { background: var(--surface-2, #ffffff0d); }
164
  .aria-react-picker { z-index: 82; } /* above the blur overlay */
 
159
  .aria-held-clone.me { background: var(--aria-me); color: var(--aria-me-fg); border-bottom-right-radius: 5px; }
160
  .aria-holdmenu { position: fixed; z-index: 64; display: flex; flex-direction: column; min-width: 150px; background: var(--bg-2, #0a0a0f); border: 1px solid var(--line-strong, #ffffff29); border-radius: 14px; overflow: hidden; box-shadow: 0 10px 34px rgba(0,0,0,0.55); transform: scale(.85); opacity: 0; transform-origin: top center; transition: transform .18s var(--ease, ease), opacity .18s; }
161
  .aria-holdmenu.in { transform: scale(1); opacity: 1; }
162
+ .aria-holdmenu-time { padding: 9px 16px 7px; font-size: 11px; color: var(--text-dim, #7c808d); border-bottom: 1px solid var(--line, #ffffff14); white-space: nowrap; }
163
  .aria-holdmenu-item { background: none; border: 0; color: var(--text, #fff); font: inherit; font-size: 15px; text-align: left; padding: 12px 16px; cursor: pointer; }
164
  .aria-holdmenu-item:hover { background: var(--surface-2, #ffffff0d); }
165
  .aria-react-picker { z-index: 82; } /* above the blur overlay */
cloudflare/pages-integration/js/aria-chat.js CHANGED
@@ -18,7 +18,7 @@ const state = {
18
  outbox: [], lastRecv: 0, wsGen: 0, // WS resilience: unacked events, liveness, generation
19
  };
20
  let _pressTimer = null, _psx = 0, _psy = 0;
21
- let _overlay = null, _picker = null, _menu = null, _holdRow = null, _holdClone = null, _holdAuto = null;
22
 
23
  /* ---- keep the app glued to the VISIBLE viewport (mobile keyboard) ----
24
  iOS Safari shrinks visualViewport.height when the keyboard opens and may offset the
@@ -254,25 +254,26 @@ function renderHistory(events, bubbles) {
254
  ].sort((a, z) => a.t - z.t);
255
  for (const item of timeline) {
256
  if (item.kind === "event") renderEvent(item.e);
257
- else addBubble({ id: item.b.id, bubble: item.b.text, kind: item.b.kind, reaction: item.b.reaction, reply_to: item.b.reply_to }, false);
258
  }
259
  scrollDown();
260
  }
261
  function renderEvent(e) {
262
  const reply = e.payload?.reply_to;
263
- if (e.type === "message") addUserRow(textNode(e.payload.text), e.id, e.reaction, reply);
264
- else if (e.type === "image") addUserRow(mediaNode(e.payload, true), e.id, e.reaction, reply);
265
- else if (e.type === "file") addUserRow(mediaNode(e.payload, false), e.id, e.reaction, reply);
266
  }
267
  function onEcho(e) { // a message we sent on another device
268
  if (!e || $("ariaMessages").querySelector(`.aria-row[data-id="${cssId(e.id)}"]`)) return; // dedup
269
  renderEvent(e);
270
  }
271
 
272
- function row(side, id) {
273
  const r = document.createElement("div");
274
  r.className = `aria-row ${side} show-av`;
275
  if (id) r.dataset.id = id;
 
276
  if (side === "them") { const av = document.createElement("span"); av.className = "aria-avatar sm"; r.appendChild(av); }
277
  return r;
278
  }
@@ -293,8 +294,8 @@ function addQuote(bubble, refId) {
293
  const el = document.createElement("div"); el.className = "aria-quote"; el.textContent = q;
294
  bubble.appendChild(el);
295
  }
296
- function addUserRow(contentEl, id, reaction, replyTo) {
297
- const r = row("me", id);
298
  const b = bubbleEl();
299
  if (replyTo) addQuote(b, replyTo);
300
  const wrap = document.createElement("span"); wrap.className = "aria-bubble-text"; wrap.appendChild(contentEl);
@@ -305,7 +306,7 @@ function addUserRow(contentEl, id, reaction, replyTo) {
305
  }
306
  function addBubble(m, animate = true) {
307
  if (state.cur?.muted || state.cur?.blocked) return;
308
- const r = row("them", m.id);
309
  const b = bubbleEl(null, m.kind || "response");
310
  if (m.reply_to) addQuote(b, m.reply_to);
311
  const wrap = document.createElement("span"); wrap.className = "aria-bubble-text"; wrap.textContent = m.bubble;
@@ -350,6 +351,7 @@ function mediaNode(p, isImage) {
350
  }
351
  function scrollDown() { const m = $("ariaMessages"); m.scrollTop = m.scrollHeight; }
352
  function cssId(s) { return (window.CSS && CSS.escape) ? CSS.escape(s) : s; }
 
353
 
354
  /* ---------------- reactions ---------------- */
355
  const REACTIONS = ["❤️", "😆", "😮", "🥹", "😢", "😡"];
@@ -386,7 +388,7 @@ async function onSend(e) {
386
  // attachments first
387
  for (const a of state.attachments.splice(0)) {
388
  const ev = makeEvent(a.mime.startsWith("image/") ? "image" : "file", a, reply);
389
- addUserRow(mediaNode(a, a.mime.startsWith("image/")), ev.id, null, reply);
390
  queueEvent(ev);
391
  }
392
  $("ariaTray").hidden = true; $("ariaTray").innerHTML = "";
@@ -395,7 +397,7 @@ async function onSend(e) {
395
  $("ariaUserTyping").hidden = true; setTyping(false);
396
  if (text) {
397
  const ev = makeEvent("message", { text }, reply);
398
- addUserRow(textNode(text), ev.id, null, reply);
399
  queueEvent(ev);
400
  }
401
  clearReply();
@@ -518,6 +520,8 @@ function ensureHoldDom() {
518
  _picker.appendChild(btn);
519
  }
520
  _menu = document.createElement("div"); _menu.className = "aria-holdmenu";
 
 
521
  const reply = document.createElement("button"); reply.type = "button"; reply.className = "aria-holdmenu-item";
522
  reply.textContent = "Odpowiedz";
523
  reply.addEventListener("click", (e) => { e.stopPropagation(); const r = _holdRow; closeHold(); if (r) startReply(r); });
@@ -528,6 +532,7 @@ function ensureHoldDom() {
528
  function openHold(rowEl) {
529
  ensureHoldDom();
530
  _holdRow = rowEl;
 
531
  const bubble = rowEl.querySelector(".aria-bubble");
532
  if (!bubble) return;
533
  const rect = bubble.getBoundingClientRect();
 
18
  outbox: [], lastRecv: 0, wsGen: 0, // WS resilience: unacked events, liveness, generation
19
  };
20
  let _pressTimer = null, _psx = 0, _psy = 0;
21
+ let _overlay = null, _picker = null, _menu = null, _menuTime = null, _holdRow = null, _holdClone = null, _holdAuto = null;
22
 
23
  /* ---- keep the app glued to the VISIBLE viewport (mobile keyboard) ----
24
  iOS Safari shrinks visualViewport.height when the keyboard opens and may offset the
 
254
  ].sort((a, z) => a.t - z.t);
255
  for (const item of timeline) {
256
  if (item.kind === "event") renderEvent(item.e);
257
+ else addBubble({ id: item.b.id, bubble: item.b.text, kind: item.b.kind, reaction: item.b.reaction, reply_to: item.b.reply_to, ts: item.b.created_at }, false);
258
  }
259
  scrollDown();
260
  }
261
  function renderEvent(e) {
262
  const reply = e.payload?.reply_to;
263
+ if (e.type === "message") addUserRow(textNode(e.payload.text), e.id, e.reaction, reply, e.ts);
264
+ else if (e.type === "image") addUserRow(mediaNode(e.payload, true), e.id, e.reaction, reply, e.ts);
265
+ else if (e.type === "file") addUserRow(mediaNode(e.payload, false), e.id, e.reaction, reply, e.ts);
266
  }
267
  function onEcho(e) { // a message we sent on another device
268
  if (!e || $("ariaMessages").querySelector(`.aria-row[data-id="${cssId(e.id)}"]`)) return; // dedup
269
  renderEvent(e);
270
  }
271
 
272
+ function row(side, id, ts) {
273
  const r = document.createElement("div");
274
  r.className = `aria-row ${side} show-av`;
275
  if (id) r.dataset.id = id;
276
+ if (ts) r.dataset.ts = ts;
277
  if (side === "them") { const av = document.createElement("span"); av.className = "aria-avatar sm"; r.appendChild(av); }
278
  return r;
279
  }
 
294
  const el = document.createElement("div"); el.className = "aria-quote"; el.textContent = q;
295
  bubble.appendChild(el);
296
  }
297
+ function addUserRow(contentEl, id, reaction, replyTo, ts) {
298
+ const r = row("me", id, ts);
299
  const b = bubbleEl();
300
  if (replyTo) addQuote(b, replyTo);
301
  const wrap = document.createElement("span"); wrap.className = "aria-bubble-text"; wrap.appendChild(contentEl);
 
306
  }
307
  function addBubble(m, animate = true) {
308
  if (state.cur?.muted || state.cur?.blocked) return;
309
+ const r = row("them", m.id, m.ts || Date.now());
310
  const b = bubbleEl(null, m.kind || "response");
311
  if (m.reply_to) addQuote(b, m.reply_to);
312
  const wrap = document.createElement("span"); wrap.className = "aria-bubble-text"; wrap.textContent = m.bubble;
 
351
  }
352
  function scrollDown() { const m = $("ariaMessages"); m.scrollTop = m.scrollHeight; }
353
  function cssId(s) { return (window.CSS && CSS.escape) ? CSS.escape(s) : s; }
354
+ function fmtTs(ms) { if (!ms) return ""; return new Date(ms).toISOString().slice(0, 19).replace("T", " ") + " UTC"; }
355
 
356
  /* ---------------- reactions ---------------- */
357
  const REACTIONS = ["❤️", "😆", "😮", "🥹", "😢", "😡"];
 
388
  // attachments first
389
  for (const a of state.attachments.splice(0)) {
390
  const ev = makeEvent(a.mime.startsWith("image/") ? "image" : "file", a, reply);
391
+ addUserRow(mediaNode(a, a.mime.startsWith("image/")), ev.id, null, reply, ev.ts);
392
  queueEvent(ev);
393
  }
394
  $("ariaTray").hidden = true; $("ariaTray").innerHTML = "";
 
397
  $("ariaUserTyping").hidden = true; setTyping(false);
398
  if (text) {
399
  const ev = makeEvent("message", { text }, reply);
400
+ addUserRow(textNode(text), ev.id, null, reply, ev.ts);
401
  queueEvent(ev);
402
  }
403
  clearReply();
 
520
  _picker.appendChild(btn);
521
  }
522
  _menu = document.createElement("div"); _menu.className = "aria-holdmenu";
523
+ _menuTime = document.createElement("div"); _menuTime.className = "aria-holdmenu-time";
524
+ _menu.appendChild(_menuTime); // sent date+time, shown above "Odpowiedz"
525
  const reply = document.createElement("button"); reply.type = "button"; reply.className = "aria-holdmenu-item";
526
  reply.textContent = "Odpowiedz";
527
  reply.addEventListener("click", (e) => { e.stopPropagation(); const r = _holdRow; closeHold(); if (r) startReply(r); });
 
532
  function openHold(rowEl) {
533
  ensureHoldDom();
534
  _holdRow = rowEl;
535
+ if (_menuTime) { const ts = Number(rowEl.dataset.ts); _menuTime.textContent = fmtTs(ts); _menuTime.style.display = ts ? "block" : "none"; }
536
  const bubble = rowEl.querySelector(".aria-bubble");
537
  if (!bubble) return;
538
  const rect = bubble.getBoundingClientRect();