Chat: paper slips under the camera, Twitch + 7TV emotes
- public/chat/chat.css + chat.js (window.HSChat): cream paper slips with the name on a washi-tape label, newest on top sliding out from under the webcam, older ones glide down and fade at the bottom; message_timeout / max_messages - Emotes: Twitch (tags.emotes) and 7TV global + channel sets (refreshed every 10 min), zero-width 7TV emotes stack, emote-only messages get bigger emotes - Deleted messages, timeouts, bans and /clear remove slips at once - overlay.ejs: old chat CSS/JS removed, new files load only for ?parts=chat Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
0cc53e1d73
commit
463c6580f4
4 changed files with 264 additions and 55 deletions
|
|
@ -10,6 +10,7 @@
|
|||
<link rel="stylesheet" href="/alerts/cassette.css">
|
||||
<link rel="stylesheet" href="/alerts/fx.css">
|
||||
<% } %>
|
||||
<% if (has('chat')) { %><link rel="stylesheet" href="/chat/chat.css"><% } %>
|
||||
<% if (has('poll')) { %><link rel="stylesheet" href="/alerts/poll.css"><% } %>
|
||||
<% if (has('hypebar')) { %><link rel="stylesheet" href="/alerts/hypebar.css"><% } %>
|
||||
<% if (has('raid')) { %><link rel="stylesheet" href="/alerts/raidcard.css"><% } %>
|
||||
|
|
@ -19,18 +20,10 @@
|
|||
<script src="/alerts/nowplaying.js"></script> (same)
|
||||
the nowplaying line in ws.onmessage below %>
|
||||
<style>
|
||||
/* Chat box and legacy text/video action alerts. Values were taken from the layout editor
|
||||
(removed 2026-11-20); change them here, or override with Custom CSS in Settings. */
|
||||
/* Legacy text/video action alerts. Values were taken from the layout editor (removed 2026-11-20);
|
||||
change them here, or override with Custom CSS in Settings. The chat has its own /chat/chat.css. */
|
||||
:root {
|
||||
--chat-left: 78%;
|
||||
--chat-top: 75%;
|
||||
--chat-width: 20%;
|
||||
--chat-height: 23%;
|
||||
--chat-font-size: 16px;
|
||||
--chat-font-family: Inter, sans-serif;
|
||||
--chat-bg-opacity: 0.1;
|
||||
--chat-text-color: #ffffff;
|
||||
--chat-border-radius: 10px;
|
||||
--alert-left: 50%;
|
||||
--alert-top: 40%;
|
||||
--alert-font-size: 32px;
|
||||
|
|
@ -40,30 +33,6 @@
|
|||
* { margin: 0; padding: 0; box-sizing: border-box; }
|
||||
body { background: transparent; overflow: hidden; width: 1920px; height: 1080px; }
|
||||
|
||||
#chat {
|
||||
position: fixed;
|
||||
left: var(--chat-left);
|
||||
top: var(--chat-top);
|
||||
width: var(--chat-width);
|
||||
max-height: var(--chat-height);
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
font-family: var(--chat-font-family);
|
||||
font-size: var(--chat-font-size);
|
||||
color: var(--chat-text-color);
|
||||
}
|
||||
.chat-msg {
|
||||
background: rgba(0, 0, 0, var(--chat-bg-opacity));
|
||||
border-radius: var(--chat-border-radius);
|
||||
padding: 5px 10px;
|
||||
word-break: break-word;
|
||||
animation: fadeIn 0.25s ease;
|
||||
transition: opacity 0.5s ease;
|
||||
}
|
||||
.chat-msg .username { font-weight: 700; margin-right: 4px; }
|
||||
|
||||
#alert-box {
|
||||
position: fixed;
|
||||
left: var(--alert-left);
|
||||
|
|
@ -103,6 +72,7 @@
|
|||
<video id="alert-video" autoplay></video><% } %>
|
||||
|
||||
<script src="/vendor/tmi.min.js"></script>
|
||||
<% if (has('chat')) { %><script src="/chat/chat.js"></script><% } %>
|
||||
<% if (has('alerts')) { %>
|
||||
<script src="/alerts/cassette.js"></script>
|
||||
<script src="/alerts/fx.js"></script>
|
||||
|
|
@ -113,6 +83,7 @@
|
|||
<% if (has('raid')) { %><script src="/alerts/raidcard.js"></script><% } %>
|
||||
<script>
|
||||
const S = <%- JSON.stringify(settings) %>;
|
||||
window.S = S; // chat.js reads message_timeout / max_messages from here (settings_update keeps it current)
|
||||
// which parts this browser source shows (?parts=chat / ?parts=nochat / ?parts=chat,raid / nothing = all)
|
||||
const PARTS = new Set(<%- JSON.stringify(parts) %>);
|
||||
const chat = document.getElementById('chat'); // null when this source has no chat part
|
||||
|
|
@ -135,6 +106,15 @@
|
|||
user: t['display-name'] || t.login, streak: t['msg-param-value'] });
|
||||
});
|
||||
|
||||
// channel id for the 7TV channel emotes, and moderation: deleted messages / timeouts / bans leave the screen
|
||||
if (PARTS.has('chat')) {
|
||||
client.on('roomstate', (_ch, state) => HSChat.setRoom(state['room-id']));
|
||||
client.on('messagedeleted', (_ch, _user, _msg, tags) => HSChat.removeId(tags['target-msg-id']));
|
||||
client.on('timeout', (_ch, user) => HSChat.removeUser(user));
|
||||
client.on('ban', (_ch, user) => HSChat.removeUser(user));
|
||||
client.on('clearchat', () => HSChat.clear());
|
||||
}
|
||||
|
||||
client.on('message', (channel, tags, message) => {
|
||||
if (!PARTS.has('chat')) return; // other sources only listen to chat for watch streaks
|
||||
const now = Date.now();
|
||||
|
|
@ -152,26 +132,10 @@
|
|||
}
|
||||
|
||||
lastMsgTime = now;
|
||||
addMessage(tags['display-name'] || tags.username, tags.color || '#b4a0d4', message);
|
||||
HSChat.add(tags, message, tags['message-type'] === 'action');
|
||||
});
|
||||
}
|
||||
|
||||
function addMessage(username, color, text) {
|
||||
const div = document.createElement('div');
|
||||
div.className = 'chat-msg';
|
||||
div.innerHTML = `<span class="username" style="color:${esc(color)}">${esc(username)}</span>: ${esc(text)}`;
|
||||
chat.appendChild(div);
|
||||
|
||||
while (chat.children.length > S.max_messages) chat.removeChild(chat.firstChild);
|
||||
|
||||
if (S.message_timeout > 0) {
|
||||
setTimeout(() => {
|
||||
div.style.opacity = '0';
|
||||
setTimeout(() => div.remove(), 500);
|
||||
}, S.message_timeout * 1000);
|
||||
}
|
||||
}
|
||||
|
||||
// --- Alert WebSocket ---
|
||||
// ?overlay=<id> marks this page as the real overlay, so the server accepts chat_notice messages from it
|
||||
let ws = null;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue