Compare commits

...

22 Commits

Author SHA1 Message Date
Charlotte Som e6d09b14c5 Update cachebust version 2023-02-02 06:38:45 +00:00
Charlotte Som 4b61c44d6a Update editorconfig if using LF endings 2023-02-02 06:36:01 +00:00
easrng f3ee2ecc83 fuck it, converting the rest to unix line endings 2023-02-01 20:29:47 -05:00
easrng 1bd7071cec use plyr for video controls 2023-02-01 20:20:07 -05:00
easrng e43184ab49 fix the color input styles on chrome 2022-07-12 20:21:36 +00:00
Charlotte Som 61c456eceb Default captions to enabled 2022-04-29 23:50:35 +01:00
Charlotte Som 0fc8953a69 Textual feedback for personal colour 2022-04-29 23:41:33 +01:00
Charlotte Som 8e19d7b34d Don't allow controls by default 2022-04-29 23:28:11 +01:00
Charlotte Som 8717e0dff2 Bust cache 2022-04-29 23:25:31 +01:00
Charlotte Som bfdcf2afed Default personal colour to white 2022-04-29 23:24:37 +01:00
Charlotte Som 8531c83574 Sort unicode emoji before emojos, let enter fill an emoji 2022-04-29 23:22:23 +01:00
Charlotte Som 0d555adf21 Remove blobcat.png
It should be gitignored anyway
2022-04-29 23:08:10 +01:00
maia arson crimew b72a7d11d7 bust cache 2022-03-30 16:28:10 +02:00
maia arson crimew ee93fb84af turn the beep into a pling 2022-03-30 16:26:34 +02:00
maia arson crimew 40b20b2157 Improve global state handling 2022-03-30 15:02:08 +02:00
maia arson crimew 9a2ac1c432 make pings send browser notifications 2022-03-30 13:45:59 +02:00
maia arson crimew 2197d2b757 make the ping sound a lot more tolerable 2022-03-30 13:28:35 +02:00
maia arson crimew 3d4ea0773d Clicking the join chip will directly join the session without a reload
also adds a /join command (most likely still requires some further debugging)
2022-03-30 13:17:44 +02:00
easrng 2d544620ed add linkification and time and join chips 2022-03-09 18:38:22 -05:00
easrng 60672a04ef oh no aaaa 2022-03-08 15:35:12 -05:00
easrng c8ccb7afc4 fix broken things 2022-03-08 15:34:55 -05:00
easrng 2adc8b9d02 fix emoji name overflow (again) and sorting 2022-03-08 15:33:14 -05:00
23 changed files with 2331 additions and 2032 deletions

View File

@ -3,7 +3,7 @@ root = true
[*] [*]
indent_style = space indent_style = space
indent_size = 2 indent_size = 2
end_of_line = crlf end_of_line = lf
charset = utf-8 charset = utf-8
trim_trailing_whitespace = false trim_trailing_whitespace = false
insert_final_newline = true insert_final_newline = true

View File

@ -3,7 +3,7 @@
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<title>watch party :D</title> <title>watch party :D</title>
<link rel="stylesheet" href="/styles.css?v=048af96" /> <link rel="stylesheet" href="/styles.css?v=4b61c4" />
</head> </head>
<body> <body>
@ -47,6 +47,6 @@
</form> </form>
</div> </div>
<script type="module" src="/create.mjs?v=048af96"></script> <script type="module" src="/create.mjs?v=4b61c4"></script>
</body> </body>
</html> </html>

View File

@ -1,4 +1,4 @@
import { setupCreateSessionForm } from "./lib/create-session.mjs?v=048af96"; import { setupCreateSessionForm } from "./lib/create-session.mjs?v=4b61c4";
const main = () => { const main = () => {
setupCreateSessionForm(); setupCreateSessionForm();

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

View File

@ -3,7 +3,8 @@
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<title>watch party :D</title> <title>watch party :D</title>
<link rel="stylesheet" href="/styles.css?v=048af96" /> <link rel="stylesheet" href="/lib/plyr-3.7.3.css" />
<link rel="stylesheet" href="/styles.css?v=4b61c4" />
</head> </head>
<body> <body>
@ -30,8 +31,10 @@
required required
/> />
<label for="join-session-colour">Colour:</label> <label id="join-session-colour-label" for="join-session-colour">
<input type="color" id="join-session-colour" value="#7ed0ff" required /> Personal Colour:
</label>
<input type="color" id="join-session-colour" value="#ffffff" required />
<label for="join-session-id">Session ID:</label> <label for="join-session-id">Session ID:</label>
<input <input
@ -64,6 +67,19 @@
</form> </form>
</div> </div>
<script type="module" src="/main.mjs?v=048af96"></script> <script type="module" src="/main.mjs?v=4b61c4"></script>
<script>
const updateColourLabel = () => {
const colour = document.querySelector("#join-session-colour").value;
document.querySelector(
"#join-session-colour-label"
).textContent = `Personal Colour: ${colour}`;
};
document
.querySelector("#join-session-colour")
.addEventListener("input", updateColourLabel);
updateColourLabel();
</script>
</body> </body>
</html> </html>

View File

@ -2,8 +2,13 @@ import {
setDebounce, setDebounce,
setVideoTime, setVideoTime,
setPlaying, setPlaying,
} from "./watch-session.mjs?v=048af96"; sync,
import { emojify, findEmojis } from "./emojis.mjs?v=048af96"; } from "./watch-session.mjs?v=4b61c4";
import { emojify, findEmojis } from "./emojis.mjs?v=4b61c4";
import { linkify } from "./links.mjs?v=4b61c4";
import { joinSession } from "./watch-session.mjs?v=4b61c4";
import { pling } from "./pling.mjs?v=4b61c4";
import { state } from "./state.mjs";
function setCaretPosition(elem, caretPos) { function setCaretPosition(elem, caretPos) {
if (elem.createTextRange) { if (elem.createTextRange) {
@ -35,77 +40,81 @@ const setupChatboxEvents = (socket) => {
}; };
async function autocomplete(fromListTimeout) { async function autocomplete(fromListTimeout) {
if (autocompleting) return; if (autocompleting) return;
clearInterval(showListTimer); try {
emojiAutocomplete.textContent = ""; clearInterval(showListTimer);
autocompleting = true; emojiAutocomplete.textContent = "";
let text = messageInput.value.slice(0, messageInput.selectionStart); autocompleting = true;
const match = text.match(/(:[^\s:]+)?:([^\s:]*)$/); let text = messageInput.value.slice(0, messageInput.selectionStart);
if (!match || match[1]) return (autocompleting = false); // We don't need to autocomplete. const match = text.match(/(:[^\s:]+)?:([^\s:]{2,})$/);
const prefix = text.slice(0, match.index); if (!match || match[1]) return (autocompleting = false); // We don't need to autocomplete.
const search = text.slice(match.index + 1); const prefix = text.slice(0, match.index);
if (search.length < 1 && !fromListTimeout) { const search = text.slice(match.index + 1);
if (search.length < 1 && !fromListTimeout) {
autocompleting = false;
showListTimer = setTimeout(() => autocomplete(true), 500);
return;
}
const suffix = messageInput.value.slice(messageInput.selectionStart);
let selected;
const select = (button) => {
if (selected) selected.classList.remove("selected");
selected = button;
button.classList.add("selected");
};
let results = await findEmojis(search);
let yieldAt = performance.now() + 13;
for (let i = 0; i < results.length; i += 100) {
emojiAutocomplete.append.apply(
emojiAutocomplete,
results.slice(i, i + 100).map(([name, replaceWith, ext], i) => {
const button = Object.assign(document.createElement("button"), {
className: "emoji-option",
onmousedown: (e) => e.preventDefault(),
onclick: () => {
messageInput.value = prefix + replaceWith + " " + suffix;
setCaretPosition(
messageInput,
(prefix + " " + replaceWith).length
);
},
onmouseover: () => select(button),
onfocus: () => select(button),
type: "button",
title: name,
});
button.append(
replaceWith[0] !== ":"
? Object.assign(document.createElement("span"), {
textContent: replaceWith,
className: "emoji",
})
: Object.assign(new Image(), {
loading: "lazy",
src: `/emojis/${name}${ext}`,
className: "emoji",
}),
Object.assign(document.createElement("span"), {
textContent: name,
className: "emoji-name",
})
);
return button;
})
);
if (i == 0 && emojiAutocomplete.children[0]) {
emojiAutocomplete.children[0].scrollIntoView();
select(emojiAutocomplete.children[0]);
}
const now = performance.now();
if (now > yieldAt) {
yieldAt = now + 13;
await new Promise((cb) => setTimeout(cb, 0));
}
}
autocompleting = false;
} catch (e) {
autocompleting = false; autocompleting = false;
showListTimer = setTimeout(() => autocomplete(true), 500);
return;
} }
const suffix = messageInput.value.slice(messageInput.selectionStart);
let selected;
const select = (button) => {
if (selected) selected.classList.remove("selected");
selected = button;
button.classList.add("selected");
};
let results = await findEmojis(search);
let yieldAt = performance.now() + 13;
for (let i = 0; i < results.length; i += 100) {
emojiAutocomplete.append.apply(
emojiAutocomplete,
results.slice(i, i + 100).map(([name, replaceWith, ext], i) => {
const button = Object.assign(document.createElement("button"), {
className: "emoji-option",
onmousedown: (e) => e.preventDefault(),
onclick: () => {
messageInput.value = prefix + replaceWith + " " + suffix;
setCaretPosition(
messageInput,
(prefix + " " + replaceWith).length
);
},
onmouseover: () => select(button),
onfocus: () => select(button),
type: "button",
title: name,
});
button.append(
replaceWith[0] !== ":"
? Object.assign(document.createElement("span"), {
textContent: replaceWith,
className: "emoji",
})
: Object.assign(new Image(), {
loading: "lazy",
src: `/emojis/${name}${ext}`,
className: "emoji",
}),
Object.assign(document.createElement("span"), {
textContent: name,
className: "emoji-name",
})
);
return button;
})
);
if (i == 0 && emojiAutocomplete.children[0]) {
emojiAutocomplete.children[0].scrollIntoView();
select(emojiAutocomplete.children[0]);
}
const now = performance.now();
if (now > yieldAt) {
yieldAt = now + 13;
await new Promise((cb) => setTimeout(cb, 0));
}
}
autocompleting = false;
} }
messageInput.addEventListener("input", () => autocomplete()); messageInput.addEventListener("input", () => autocomplete());
messageInput.addEventListener("selectionchange", () => autocomplete()); messageInput.addEventListener("selectionchange", () => autocomplete());
@ -125,7 +134,7 @@ const setupChatboxEvents = (socket) => {
selected.classList.add("selected"); selected.classList.add("selected");
selected.scrollIntoView({ scrollMode: "if-needed", block: "nearest" }); selected.scrollIntoView({ scrollMode: "if-needed", block: "nearest" });
} }
if (event.key == "Tab") { if (event.key == "Tab" || event.key == "Enter") {
let selected = document.querySelector(".emoji-option.selected"); let selected = document.querySelector(".emoji-option.selected");
if (!selected) return; if (!selected) return;
event.preventDefault(); event.preventDefault();
@ -156,14 +165,7 @@ const setupChatboxEvents = (socket) => {
handled = true; handled = true;
break; break;
case "/sync": case "/sync":
const sessionId = window.location.hash.slice(1); await sync();
const { current_time_ms, is_playing } = await fetch(
`/sess/${sessionId}`
).then((r) => r.json());
setDebounce();
setPlaying(is_playing);
setVideoTime(current_time_ms);
const syncMessageContent = document.createElement("span"); const syncMessageContent = document.createElement("span");
syncMessageContent.appendChild( syncMessageContent.appendChild(
@ -184,6 +186,11 @@ const setupChatboxEvents = (socket) => {
); );
handled = true; handled = true;
break; break;
case "/join":
state().sessionId = args;
joinSession();
handled = true;
break;
case "/help": case "/help":
const helpMessageContent = document.createElement("span"); const helpMessageContent = document.createElement("span");
helpMessageContent.innerHTML = helpMessageContent.innerHTML =
@ -191,7 +198,8 @@ const setupChatboxEvents = (socket) => {
"&emsp;<code>/help</code> - display this help message<br>" + "&emsp;<code>/help</code> - display this help message<br>" +
"&emsp;<code>/ping [message]</code> - ping all viewers<br>" + "&emsp;<code>/ping [message]</code> - ping all viewers<br>" +
"&emsp;<code>/sync</code> - resyncs you with other viewers<br>" + "&emsp;<code>/sync</code> - resyncs you with other viewers<br>" +
"&emsp;<code>/shrug</code> - appends ¯\\_(ツ)_/¯ to your message"; "&emsp;<code>/shrug</code> - appends ¯\\_(ツ)_/¯ to your message<br>" +
"&emsp;<code>/join [session id]</code> - joins another session";
printChatMessage( printChatMessage(
"command-message", "command-message",
@ -227,13 +235,6 @@ const setupChatboxEvents = (socket) => {
export const setupChat = async (socket) => { export const setupChat = async (socket) => {
document.querySelector("#chatbox-container").style["display"] = "flex"; document.querySelector("#chatbox-container").style["display"] = "flex";
setupChatboxEvents(socket); setupChatboxEvents(socket);
window.addEventListener("keydown", (event) => {
try {
const isSelectionEmpty = window.getSelection().toString().length === 0;
if (event.code.match(/Key\w/) && isSelectionEmpty) messageInput.focus();
} catch (_err) {}
});
}; };
const addToChat = (node) => { const addToChat = (node) => {
@ -296,7 +297,7 @@ const matpad = (n) => {
* @param {string?} user * @param {string?} user
* @param {Node?} content * @param {Node?} content
*/ */
const printChatMessage = (eventType, user, colour, content) => { export const printChatMessage = (eventType, user, colour, content) => {
const chatMessage = document.createElement("div"); const chatMessage = document.createElement("div");
chatMessage.classList.add("chat-message"); chatMessage.classList.add("chat-message");
chatMessage.classList.add(eventType); chatMessage.classList.add(eventType);
@ -354,7 +355,7 @@ export const logEventToChat = async (event) => {
case "ChatMessage": { case "ChatMessage": {
const messageContent = document.createElement("span"); const messageContent = document.createElement("span");
messageContent.classList.add("message-content"); messageContent.classList.add("message-content");
messageContent.append(...(await emojify(event.data))); messageContent.append(...(await linkify(event.data, emojify)));
printChatMessage( printChatMessage(
"chat-message", "chat-message",
event.user, event.user,
@ -411,28 +412,29 @@ export const logEventToChat = async (event) => {
} }
printChatMessage("ping", event.user, event.colour, messageContent); printChatMessage("ping", event.user, event.colour, messageContent);
beep(); pling();
if ("Notification" in window) {
const title = "watch party :)";
const options = {
body: event.data
? `${event.user} pinged saying: ${event.data}`
: `${event.user} pinged`,
};
if (Notification.permission === "granted") {
new Notification(title, options);
} else if (Notification.permission !== "denied") {
Notification.requestPermission().then(function (permission) {
if (permission === "granted") {
new Notification(title, options);
}
});
}
}
break; break;
} }
} }
}; };
const beep = () => {
const context = new AudioContext();
const gain = context.createGain();
gain.connect(context.destination);
gain.gain.value = 0.1;
const oscillator = context.createOscillator();
oscillator.connect(gain);
oscillator.frequency.value = 520;
oscillator.type = "square";
oscillator.start(context.currentTime);
oscillator.stop(context.currentTime + 0.22);
};
export const updateViewerList = (viewers) => { export const updateViewerList = (viewers) => {
const listContainer = document.querySelector("#viewer-list"); const listContainer = document.querySelector("#viewer-list");

View File

@ -1,4 +1,4 @@
import { createSession } from "./watch-session.mjs?v=048af96"; import { createSession } from "./watch-session.mjs?v=4b61c4";
export const setupCreateSessionForm = () => { export const setupCreateSessionForm = () => {
const form = document.querySelector("#create-session-form"); const form = document.querySelector("#create-session-form");

View File

@ -5,7 +5,10 @@ export async function emojify(text) {
text.replace(/:([^\s:]+):/g, (match, name, index) => { text.replace(/:([^\s:]+):/g, (match, name, index) => {
if (last <= index) if (last <= index)
nodes.push(document.createTextNode(text.slice(last, index))); nodes.push(document.createTextNode(text.slice(last, index)));
let emoji = emojis[name.toLowerCase()[0]].find((e) => e[0] == name); let emoji;
try {
emoji = emojis[name.toLowerCase()[0]].find((e) => e[0] == name);
} catch (e) {}
if (!emoji) { if (!emoji) {
nodes.push(document.createTextNode(match)); nodes.push(document.createTextNode(match));
} else { } else {
@ -29,7 +32,15 @@ export async function emojify(text) {
const emojis = {}; const emojis = {};
export const emojisLoaded = Promise.all([ export const emojisLoaded = Promise.all([
fetch("/emojis") fetch("/emojis/unicode.json")
.then((e) => e.json())
.then((a) => {
for (let e of a) {
emojis[e[0][0]] = emojis[e[0][0]] || [];
emojis[e[0][0]].push([e[0], e[1], null, e[0]]);
}
}),
fetch("/emojos")
.then((e) => e.json()) .then((e) => e.json())
.then((a) => { .then((a) => {
for (let e of a) { for (let e of a) {
@ -39,21 +50,13 @@ export const emojisLoaded = Promise.all([
emojis[lower[0]].push([name, ":" + name + ":", e.slice(-4), lower]); emojis[lower[0]].push([name, ":" + name + ":", e.slice(-4), lower]);
} }
}), }),
fetch("/emojis/unicode.json")
.then((e) => e.json())
.then((a) => {
for (let e of a) {
emojis[e[0][0]] = emojis[e[0][0]] || [];
emojis[e[0][0]].push([e[0], e[1], null, e[0]]);
}
}),
]); ]);
export async function findEmojis(search) { export async function findEmojis(search) {
await emojisLoaded; await emojisLoaded;
let groups = [[], []]; let groups = [[], []];
if (search.length < 1) { if (search.length < 1) {
for (let letter in emojis) for (let letter of Object.keys(emojis).sort())
for (let emoji of emojis[letter]) { for (let emoji of emojis[letter]) {
(emoji[1][0] === ":" ? groups[0] : groups[1]).push(emoji); (emoji[1][0] === ":" ? groups[0] : groups[1]).push(emoji);
} }
@ -65,5 +68,5 @@ export async function findEmojis(search) {
} }
} }
} }
return [...groups[0], ...groups[1]]; return [...groups[1], ...groups[0]];
} }

View File

@ -1,4 +1,5 @@
import { joinSession } from "./watch-session.mjs?v=048af96"; import { joinSession } from "./watch-session.mjs?v=4b61c4";
import { state } from "./state.mjs";
/** /**
* @param {HTMLInputElement} field * @param {HTMLInputElement} field
@ -53,11 +54,13 @@ const displayPostCreateMessage = () => {
if (params.get("created") == "true") { if (params.get("created") == "true") {
document.querySelector("#post-create-message").style["display"] = "block"; document.querySelector("#post-create-message").style["display"] = "block";
window.history.replaceState({}, document.title, `/${window.location.hash}`); window.history.replaceState({}, document.title, `/${window.location.hash}`);
return true;
} }
return false;
}; };
export const setupJoinSessionForm = () => { export const setupJoinSessionForm = () => {
displayPostCreateMessage(); const created = displayPostCreateMessage();
const form = document.querySelector("#join-session-form"); const form = document.querySelector("#join-session-form");
const nickname = form.querySelector("#join-session-nickname"); const nickname = form.querySelector("#join-session-nickname");
@ -80,11 +83,10 @@ export const setupJoinSessionForm = () => {
saveNickname(nickname); saveNickname(nickname);
saveColour(colour); saveColour(colour);
try { try {
await joinSession( state().nickname = nickname.value;
nickname.value, state().sessionId = sessionId.value;
sessionId.value, state().colour = colour.value.replace(/^#/, "");
colour.value.replace(/^#/, "") await joinSession(created);
);
} catch (e) { } catch (e) {
alert(e.message); alert(e.message);
button.disabled = false; button.disabled = false;

121
frontend/lib/links.mjs Normal file
View File

@ -0,0 +1,121 @@
import { joinSession } from "./watch-session.mjs?v=4b61c4";
import { state } from "./state.mjs";
export async function linkify(
text,
next = async (t) => [document.createTextNode(t)]
) {
let last = 0;
let nodes = [];
let promise = Promise.resolve();
// matching non-urls isn't a problem, we use the browser's url parser to filter them out
text.replace(
/[^:/?#\s]+:\/\/\S+/g,
(match, index) =>
(promise = promise.then(async () => {
if (last <= index) nodes.push(...(await next(text.slice(last, index))));
let url;
try {
url = new URL(match);
if (url.protocol === "javascript:") throw new Error();
} catch (e) {
url = null;
}
if (!url) {
nodes.push(...(await next(match)));
} else {
let s;
if (
url.origin == location.origin &&
url.pathname == "/" &&
url.hash.length > 1
) {
nodes.push(
Object.assign(document.createElement("a"), {
textContent: "Join Session",
className: "chip join-chip",
onclick: () => {
state().sessionId = url.hash.substring(1);
joinSession();
},
})
);
} else if (
url.hostname == "xiv.st" &&
(s = url.pathname.match(/(\d?\d).?(\d\d)/))
) {
if (s) {
const date = new Date();
date.setUTCSeconds(0);
date.setUTCMilliseconds(0);
date.setUTCHours(s[1]), date.setUTCMinutes(s[2]);
nodes.push(
Object.assign(document.createElement("a"), {
href: url.href,
textContent: date.toLocaleString([], {
hour: "2-digit",
minute: "2-digit",
}),
className: "chip time-chip",
target: "_blank",
})
);
}
} else {
nodes.push(
Object.assign(document.createElement("a"), {
href: url.href,
textContent: url.href,
target: "_blank",
})
);
}
}
last = index + match.length;
}))
);
await promise;
if (last < text.length) nodes.push(...(await next(text.slice(last))));
return nodes;
}
const emojis = {};
export const emojisLoaded = Promise.all([
fetch("/emojis")
.then((e) => e.json())
.then((a) => {
for (let e of a) {
const name = e.slice(0, -4),
lower = name.toLowerCase();
emojis[lower[0]] = emojis[lower[0]] || [];
emojis[lower[0]].push([name, ":" + name + ":", e.slice(-4), lower]);
}
}),
fetch("/emojis/unicode.json")
.then((e) => e.json())
.then((a) => {
for (let e of a) {
emojis[e[0][0]] = emojis[e[0][0]] || [];
emojis[e[0][0]].push([e[0], e[1], null, e[0]]);
}
}),
]);
export async function findEmojis(search) {
await emojisLoaded;
let groups = [[], []];
if (search.length < 1) {
for (let letter of Object.keys(emojis).sort())
for (let emoji of emojis[letter]) {
(emoji[1][0] === ":" ? groups[0] : groups[1]).push(emoji);
}
} else {
search = search.toLowerCase();
for (let emoji of emojis[search[0]]) {
if (search.length == 1 || emoji[3].startsWith(search)) {
(emoji[1][0] === ":" ? groups[0] : groups[1]).push(emoji);
}
}
}
return [...groups[0], ...groups[1]];
}

79
frontend/lib/pling.mjs Normal file
View File

@ -0,0 +1,79 @@
export const pling = () => {
const maxGain = 0.3;
const duration = 0.22;
const fadeDuration = 0.1;
const secondBeepOffset = 0.05;
const thirdBeepOffset = 2 * secondBeepOffset;
const ctx = new AudioContext();
const firstBeepGain = ctx.createGain();
firstBeepGain.connect(ctx.destination);
firstBeepGain.gain.setValueAtTime(0.01, ctx.currentTime);
firstBeepGain.gain.exponentialRampToValueAtTime(
maxGain,
ctx.currentTime + fadeDuration
);
firstBeepGain.gain.setValueAtTime(
maxGain,
ctx.currentTime + (duration - fadeDuration)
);
firstBeepGain.gain.exponentialRampToValueAtTime(
0.01,
ctx.currentTime + duration
);
const firstBeep = ctx.createOscillator();
firstBeep.connect(firstBeepGain);
firstBeep.frequency.value = 400;
firstBeep.type = "sine";
const secondBeepGain = ctx.createGain();
secondBeepGain.connect(ctx.destination);
secondBeepGain.gain.setValueAtTime(0.01, ctx.currentTime + secondBeepOffset);
secondBeepGain.gain.exponentialRampToValueAtTime(
maxGain,
ctx.currentTime + secondBeepOffset + fadeDuration
);
secondBeepGain.gain.setValueAtTime(
maxGain,
ctx.currentTime + secondBeepOffset + (duration - fadeDuration)
);
secondBeepGain.gain.exponentialRampToValueAtTime(
0.01,
ctx.currentTime + secondBeepOffset + duration
);
const secondBeep = ctx.createOscillator();
secondBeep.connect(secondBeepGain);
secondBeep.frequency.value = 600;
secondBeep.type = "sine";
const thirdBeepGain = ctx.createGain();
thirdBeepGain.connect(ctx.destination);
thirdBeepGain.gain.setValueAtTime(0.01, ctx.currentTime + thirdBeepOffset);
thirdBeepGain.gain.exponentialRampToValueAtTime(
maxGain,
ctx.currentTime + thirdBeepOffset + fadeDuration
);
thirdBeepGain.gain.setValueAtTime(
maxGain,
ctx.currentTime + thirdBeepOffset + (duration - fadeDuration)
);
thirdBeepGain.gain.exponentialRampToValueAtTime(
0.01,
ctx.currentTime + thirdBeepOffset + duration
);
const thirdBeep = ctx.createOscillator();
thirdBeep.connect(thirdBeepGain);
thirdBeep.frequency.value = 900;
thirdBeep.type = "sine";
firstBeep.start(ctx.currentTime);
firstBeep.stop(ctx.currentTime + duration);
secondBeep.start(ctx.currentTime + secondBeepOffset);
secondBeep.stop(ctx.currentTime + (secondBeepOffset + duration));
thirdBeep.start(ctx.currentTime + thirdBeepOffset);
thirdBeep.stop(ctx.currentTime + (thirdBeepOffset + duration));
};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -11,6 +11,7 @@ export default class ReconnectingWebSocket {
this._lastConnect = 0; this._lastConnect = 0;
this._socket = null; this._socket = null;
this._unsent = []; this._unsent = [];
this._closing = false;
this._connect(true); this._connect(true);
} }
_connect(first) { _connect(first) {
@ -26,9 +27,9 @@ export default class ReconnectingWebSocket {
} }
this._socket.addEventListener("close", () => this._reconnect()); this._socket.addEventListener("close", () => this._reconnect());
this._socket.addEventListener("error", () => this._reconnect()); this._socket.addEventListener("error", () => this._reconnect());
this._socket.addEventListener("message", ({ data }) => this._socket.addEventListener("message", ({ data }) => {
this._eventTarget.dispatchEvent(new MessageEvent("message", { data })) this._eventTarget.dispatchEvent(new MessageEvent("message", { data }));
); });
this._socket.addEventListener("open", (e) => { this._socket.addEventListener("open", (e) => {
if (first) this._eventTarget.dispatchEvent(new Event("open")); if (first) this._eventTarget.dispatchEvent(new Event("open"));
if (this._reconnecting) if (this._reconnecting)
@ -40,6 +41,7 @@ export default class ReconnectingWebSocket {
}); });
} }
_reconnect() { _reconnect() {
if (this._closing) return;
if (this._reconnecting) return; if (this._reconnecting) return;
this._eventTarget.dispatchEvent(new Event("reconnecting")); this._eventTarget.dispatchEvent(new Event("reconnecting"));
this._reconnecting = true; this._reconnecting = true;
@ -56,6 +58,10 @@ export default class ReconnectingWebSocket {
this._unsent.push(message); this._unsent.push(message);
} }
} }
close() {
this._closing = true;
this._socket.close();
}
addEventListener(...a) { addEventListener(...a) {
return this._eventTarget.addEventListener(...a); return this._eventTarget.addEventListener(...a);
} }

7
frontend/lib/state.mjs Normal file
View File

@ -0,0 +1,7 @@
let instance = null;
export const state = () => {
if (!instance) {
instance = {};
}
return instance;
};

View File

@ -1,132 +1,84 @@
const loadVolume = () => { import Plyr from "./plyr-3.7.3.min.esm.js";
try {
const savedVolume = localStorage.getItem("watch-party-volume");
if (savedVolume != null && savedVolume != "") {
return +savedVolume;
}
} catch (_err) {
// Sometimes localStorage is blocked from use
}
// default
return 0.5;
};
/**
* @param {number} volume
*/
const saveVolume = (volume) => {
try {
localStorage.setItem("watch-party-volume", volume);
} catch (_err) {
// see loadVolume
}
};
const loadCaptionTrack = () => {
try {
const savedTrack = localStorage.getItem("watch-party-captions");
if (savedTrack != null && savedTrack != "") {
return +savedTrack;
}
} catch (_err) {
// Sometimes localStorage is blocked from use
}
// default
return -1;
};
/**
* @param {number} track
*/
const saveCaptionsTrack = (track) => {
try {
localStorage.setItem("watch-party-captions", track);
} catch (_err) {
// see loadCaptionsTrack
}
};
/** /**
* @param {string} videoUrl * @param {string} videoUrl
* @param {{name: string, url: string}[]} subtitles * @param {{name: string, url: string}[]} subtitles
*/ */
const createVideoElement = (videoUrl, subtitles) => { const createVideoElement = (videoUrl, subtitles, created) => {
const oldVideo = document.getElementById(".plyr");
if (oldVideo) {
oldVideo.remove();
}
const video = document.createElement("video"); const video = document.createElement("video");
video.controls = true; video.id = "video";
video.autoplay = false;
video.volume = loadVolume();
video.crossOrigin = "anonymous"; video.crossOrigin = "anonymous";
video.addEventListener("volumechange", async () => {
saveVolume(video.volume);
});
const source = document.createElement("source"); const source = document.createElement("source");
source.src = videoUrl; source.src = videoUrl;
video.appendChild(source); video.appendChild(source);
const storedTrack = loadCaptionTrack();
let id = 0;
for (const { name, url } of subtitles) { for (const { name, url } of subtitles) {
const track = document.createElement("track"); const track = document.createElement("track");
track.label = name; track.label = name;
track.srclang = "xx-" + name.toLowerCase();
track.src = url; track.src = url;
track.kind = "captions"; track.kind = "captions";
if (id == storedTrack) {
track.default = true;
}
video.appendChild(track); video.appendChild(track);
id++;
} }
video.textTracks.addEventListener("change", async () => { const videoContainer = document.querySelector("#video-container");
let id = 0; videoContainer.style.display = "block";
for (const track of video.textTracks) { videoContainer.appendChild(video);
if (track.mode != "disabled") {
saveCaptionsTrack(id);
return;
}
id++;
}
saveCaptionsTrack(-1);
});
// watch for attribute changes on the video object to detect hiding/showing of controls const player = new Plyr(video, {
// as far as i can tell this is the least hacky solutions to get control visibility change events clickToPlay: false,
const observer = new MutationObserver(async (mutations) => { settings: ["captions", "quality"],
for (const mutation of mutations) { autopause: false,
if (mutation.attributeName == "controls") {
if (video.controls) {
// enable media button support
navigator.mediaSession.setActionHandler("play", null);
navigator.mediaSession.setActionHandler("pause", null);
navigator.mediaSession.setActionHandler("stop", null);
navigator.mediaSession.setActionHandler("seekbackward", null);
navigator.mediaSession.setActionHandler("seekforward", null);
navigator.mediaSession.setActionHandler("seekto", null);
navigator.mediaSession.setActionHandler("previoustrack", null);
navigator.mediaSession.setActionHandler("nexttrack", null);
} else {
// disable media button support by ignoring the events
navigator.mediaSession.setActionHandler("play", () => {});
navigator.mediaSession.setActionHandler("pause", () => {});
navigator.mediaSession.setActionHandler("stop", () => {});
navigator.mediaSession.setActionHandler("seekbackward", () => {});
navigator.mediaSession.setActionHandler("seekforward", () => {});
navigator.mediaSession.setActionHandler("seekto", () => {});
navigator.mediaSession.setActionHandler("previoustrack", () => {});
navigator.mediaSession.setActionHandler("nexttrack", () => {});
}
return;
}
}
}); });
observer.observe(video, { attributes: true }); player.elements.controls.insertAdjacentHTML(
"afterbegin",
`<button type="button" aria-pressed="false" class="plyr__controls__item plyr__control lock-controls"><svg aria-hidden="true" focusable="false" viewBox="0 0 24 24"><path d="M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2zm-6 9c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zM9 8V6c0-1.66 1.34-3 3-3s3 1.34 3 3v2H9z"></path></svg><span class="label--pressed plyr__sr-only">Unlock controls</span><span class="label--not-pressed plyr__sr-only">Lock controls</span></button>`
);
const lockButton = player.elements.controls.children[0];
let controlsEnabled = created;
const setControlsEnabled = (enabled) => {
controlsEnabled = enabled;
lockButton.setAttribute("aria-pressed", enabled);
lockButton.classList.toggle("plyr__control--pressed", enabled);
player.elements.buttons.play[0].disabled =
player.elements.buttons.play[1].disabled =
player.elements.inputs.seek.disabled =
!enabled;
if (!enabled) {
// enable media button support
navigator.mediaSession.setActionHandler("play", null);
navigator.mediaSession.setActionHandler("pause", null);
navigator.mediaSession.setActionHandler("stop", null);
navigator.mediaSession.setActionHandler("seekbackward", null);
navigator.mediaSession.setActionHandler("seekforward", null);
navigator.mediaSession.setActionHandler("seekto", null);
navigator.mediaSession.setActionHandler("previoustrack", null);
navigator.mediaSession.setActionHandler("nexttrack", null);
} else {
// disable media button support by ignoring the events
navigator.mediaSession.setActionHandler("play", () => {});
navigator.mediaSession.setActionHandler("pause", () => {});
navigator.mediaSession.setActionHandler("stop", () => {});
navigator.mediaSession.setActionHandler("seekbackward", () => {});
navigator.mediaSession.setActionHandler("seekforward", () => {});
navigator.mediaSession.setActionHandler("seekto", () => {});
navigator.mediaSession.setActionHandler("previoustrack", () => {});
navigator.mediaSession.setActionHandler("nexttrack", () => {});
}
};
setControlsEnabled(controlsEnabled);
lockButton.addEventListener("click", () =>
setControlsEnabled(!controlsEnabled)
);
window.__plyr = player;
return video; return player;
}; };
/** /**
@ -135,24 +87,26 @@ const createVideoElement = (videoUrl, subtitles) => {
* @param {number} currentTime * @param {number} currentTime
* @param {boolean} playing * @param {boolean} playing
*/ */
export const setupVideo = async (videoUrl, subtitles, currentTime, playing) => { export const setupVideo = async (
videoUrl,
subtitles,
currentTime,
playing,
created
) => {
document.querySelector("#pre-join-controls").style["display"] = "none"; document.querySelector("#pre-join-controls").style["display"] = "none";
const video = createVideoElement(videoUrl, subtitles); const player = createVideoElement(videoUrl, subtitles, created);
const videoContainer = document.querySelector("#video-container"); player.currentTime = currentTime / 1000.0;
videoContainer.style.display = "block";
videoContainer.appendChild(video);
video.currentTime = currentTime / 1000.0;
try { try {
if (playing) { if (playing) {
await video.play(); player.play();
} else { } else {
video.pause(); player.pause();
} }
} catch (err) { } catch (err) {
// Auto-play is probably disabled, we should uhhhhhhh do something about it // Auto-play is probably disabled, we should uhhhhhhh do something about it
} }
return video; return player;
}; };

View File

@ -1,21 +1,23 @@
import { setupVideo } from "./video.mjs?v=048af96"; import { setupVideo } from "./video.mjs?v=4b61c4";
import { import {
setupChat, setupChat,
logEventToChat, logEventToChat,
updateViewerList, updateViewerList,
} from "./chat.mjs?v=048af96"; printChatMessage,
} from "./chat.mjs?v=4b61c4";
import ReconnectingWebSocket from "./reconnecting-web-socket.mjs"; import ReconnectingWebSocket from "./reconnecting-web-socket.mjs";
import { state } from "./state.mjs";
let player;
/** /**
* @param {string} sessionId * @param {string} sessionId
* @param {string} nickname * @param {string} nickname
* @returns {ReconnectingWebSocket} * @returns {ReconnectingWebSocket}
*/ */
const createWebSocket = (sessionId, nickname, colour) => { const createWebSocket = () => {
const wsUrl = new URL( const wsUrl = new URL(
`/sess/${sessionId}/subscribe` + `/sess/${state().sessionId}/subscribe` +
`?nickname=${encodeURIComponent(nickname)}` + `?nickname=${encodeURIComponent(state().nickname)}` +
`&colour=${encodeURIComponent(colour)}`, `&colour=${encodeURIComponent(state().colour)}`,
window.location.href window.location.href
); );
wsUrl.protocol = "ws" + window.location.protocol.slice(4); wsUrl.protocol = "ws" + window.location.protocol.slice(4);
@ -40,26 +42,18 @@ export const setDebounce = () => {
}, 500); }, 500);
}; };
export const setVideoTime = (time, video = null) => { export const setVideoTime = (time) => {
if (video == null) {
video = document.querySelector("video");
}
const timeSecs = time / 1000.0; const timeSecs = time / 1000.0;
if (Math.abs(video.currentTime - timeSecs) > 0.5) { if (Math.abs(player.currentTime - timeSecs) > 0.5) {
video.currentTime = timeSecs; player.currentTime = timeSecs;
} }
}; };
export const setPlaying = async (playing, video = null) => { export const setPlaying = async (playing) => {
if (video == null) {
video = document.querySelector("video");
}
if (playing) { if (playing) {
await video.play(); await player.play();
} else { } else {
video.pause(); player.pause();
} }
}; };
@ -67,27 +61,26 @@ export const setPlaying = async (playing, video = null) => {
* @param {HTMLVideoElement} video * @param {HTMLVideoElement} video
* @param {ReconnectingWebSocket} socket * @param {ReconnectingWebSocket} socket
*/ */
const setupIncomingEvents = (video, socket) => { const setupIncomingEvents = (player, socket) => {
socket.addEventListener("message", async (messageEvent) => { socket.addEventListener("message", async (messageEvent) => {
try { try {
const event = JSON.parse(messageEvent.data); const event = JSON.parse(messageEvent.data);
if (!event.reflected) { if (!event.reflected) {
switch (event.op) { switch (event.op) {
case "SetPlaying": case "SetPlaying":
setDebounce(); setDebounce();
if (event.data.playing) { if (event.data.playing) {
await video.play(); await player.play();
} else { } else {
video.pause(); player.pause();
} }
setVideoTime(event.data.time, video); setVideoTime(event.data.time);
break; break;
case "SetTime": case "SetTime":
setDebounce(); setDebounce();
setVideoTime(event.data, video); setVideoTime(event.data);
break; break;
case "UpdateViewerList": case "UpdateViewerList":
updateViewerList(event.data); updateViewerList(event.data);
@ -101,19 +94,19 @@ const setupIncomingEvents = (video, socket) => {
}; };
/** /**
* @param {HTMLVideoElement} video * @param {Plyr} player
* @param {ReconnectingWebSocket} socket * @param {ReconnectingWebSocket} socket
*/ */
const setupOutgoingEvents = (video, socket) => { const setupOutgoingEvents = (player, socket) => {
const currentVideoTime = () => (video.currentTime * 1000) | 0; const currentVideoTime = () => (player.currentTime * 1000) | 0;
video.addEventListener("pause", async (event) => { player.on("pause", async () => {
if (outgoingDebounce || !video.controls) { if (outgoingDebounce || player.elements.inputs.seek.disabled) {
return; return;
} }
// don't send a pause event for the video ending // don't send a pause event for the video ending
if (video.currentTime == video.duration) { if (player.currentTime == player.duration) {
return; return;
} }
@ -128,8 +121,8 @@ const setupOutgoingEvents = (video, socket) => {
); );
}); });
video.addEventListener("play", (event) => { player.on("play", () => {
if (outgoingDebounce || !video.controls) { if (outgoingDebounce || player.elements.inputs.seek.disabled) {
return; return;
} }
@ -145,14 +138,14 @@ const setupOutgoingEvents = (video, socket) => {
}); });
let firstSeekComplete = false; let firstSeekComplete = false;
video.addEventListener("seeked", async (event) => { player.on("seeked", async (event) => {
if (!firstSeekComplete) { if (!firstSeekComplete) {
// The first seeked event is performed by the browser when the video is loading // The first seeked event is performed by the browser when the video is loading
firstSeekComplete = true; firstSeekComplete = true;
return; return;
} }
if (outgoingDebounce || !video.controls) { if (outgoingDebounce || player.elements.inputs.seek.disabled) {
return; return;
} }
@ -167,19 +160,29 @@ const setupOutgoingEvents = (video, socket) => {
}); });
}; };
/** export const joinSession = async (created) => {
* @param {string} nickname if (state().activeSession) {
* @param {string} sessionId if (state().activeSession === state().sessionId) {
*/ // we are already in this session, dont rejoin
export const joinSession = async (nickname, sessionId, colour) => { return;
}
// we are joining a new session from an existing session
const messageContent = document.createElement("span");
messageContent.appendChild(document.createTextNode("joining new session "));
messageContent.appendChild(document.createTextNode(state().sessionId));
printChatMessage("join-session", "watch-party", "#fffff", messageContent);
}
state().activeSession = state().sessionId;
// try { // we are handling errors in the join form. // try { // we are handling errors in the join form.
const genericConnectionError = new Error( const genericConnectionError = new Error(
"There was an issue getting the session information." "There was an issue getting the session information."
); );
window.location.hash = sessionId; window.location.hash = state().sessionId;
let response, video_url, subtitle_tracks, current_time_ms, is_playing; let response, video_url, subtitle_tracks, current_time_ms, is_playing;
try { try {
response = await fetch(`/sess/${sessionId}`); response = await fetch(`/sess/${state().sessionId}`);
} catch (e) { } catch (e) {
console.error(e); console.error(e);
throw genericConnectionError; throw genericConnectionError;
@ -203,24 +206,27 @@ export const joinSession = async (nickname, sessionId, colour) => {
throw genericConnectionError; throw genericConnectionError;
} }
const socket = createWebSocket(sessionId, nickname, colour); if (state().socket) {
state().socket.close();
state().socket = null;
}
const socket = createWebSocket();
state().socket = socket;
socket.addEventListener("open", async () => { socket.addEventListener("open", async () => {
const video = await setupVideo( player = await setupVideo(
video_url, video_url,
subtitle_tracks, subtitle_tracks,
current_time_ms, current_time_ms,
is_playing is_playing,
created
); );
// By default, we should disable video controls if the video is already playing. player.on("canplay", () => {
// This solves an issue where Safari users join and seek to 00:00:00 because of sync();
// outgoing events. });
if (current_time_ms != 0) {
video.controls = false;
}
setupOutgoingEvents(video, socket); setupOutgoingEvents(player, socket);
setupIncomingEvents(video, socket); setupIncomingEvents(player, socket);
setupChat(socket); setupChat(socket);
}); });
socket.addEventListener("reconnecting", (e) => { socket.addEventListener("reconnecting", (e) => {
@ -250,3 +256,15 @@ export const createSession = async (videoUrl, subtitleTracks) => {
window.location = `/?created=true#${id}`; window.location = `/?created=true#${id}`;
}; };
export const sync = async () => {
setDebounce();
await setPlaying(false);
const { current_time_ms, is_playing } = await fetch(
`/sess/${state().sessionId}`
).then((r) => r.json());
setDebounce();
setVideoTime(current_time_ms);
if (is_playing) await setPlaying(is_playing);
};

View File

@ -1,4 +1,4 @@
import { setupJoinSessionForm } from "./lib/join-session.mjs?v=048af96"; import { setupJoinSessionForm } from "./lib/join-session.mjs?v=4b61c4";
const main = () => { const main = () => {
setupJoinSessionForm(); setupJoinSessionForm();

View File

@ -1,4 +1,6 @@
* { *,
*:before,
*:after {
box-sizing: border-box; box-sizing: border-box;
} }
@ -17,6 +19,20 @@
var(--fg-transparent) var(--fg-transparent)
), ),
linear-gradient(var(--bg), var(--bg)); linear-gradient(var(--bg), var(--bg));
--chip-bg: linear-gradient(
var(--accent-transparent),
var(--accent-transparent)
),
linear-gradient(var(--bg), var(--bg));
--accent-transparent: rgba(var(--accent-rgb), 0.25);
--plyr-color-main: var(--accent);
--plyr-control-radius: 6px;
--plyr-menu-radius: 6px;
--plyr-menu-background: var(--autocomplete-bg);
--plyr-menu-color: var(--fg);
--plyr-menu-arrow-color: var(--fg);
--plyr-menu-back-border-color: var(--fg-transparent);
--plyr-menu-back-border-shadow-color: transparent;
} }
html { html {
@ -41,11 +57,41 @@ body {
flex-direction: column; flex-direction: column;
} }
video { .lock-controls.plyr__control--pressed svg {
display: block; opacity: 0.5;
}
.plyr {
width: 100%; width: 100%;
height: 100%; height: 100%;
object-fit: contain; }
.plyr__menu__container {
--plyr-video-control-background-hover: var(--fg-transparent);
--plyr-video-control-color-hover: var(--fg);
--plyr-control-radius: 4px;
--plyr-control-spacing: calc(0.25rem / 0.7);
--plyr-font-size-menu: 0.75rem;
--plyr-menu-arrow-size: 0;
margin-bottom: 0.48rem;
max-height: 27vmin;
clip-path: inset(0 0 0 0 round 4px);
scrollbar-width: thin;
}
.plyr__menu__container .plyr__control[role="menuitemradio"]::after {
left: 10px;
}
.plyr__menu__container
.plyr__control[role="menuitemradio"][aria-checked="true"].plyr__tab-focus::before,
.plyr__menu__container
.plyr__control[role="menuitemradio"][aria-checked="true"]:hover::before {
background: var(--accent);
}
[data-plyr="language"] .plyr__menu__value {
display: none;
} }
#video-container { #video-container {
@ -58,6 +104,45 @@ a {
color: var(--accent); color: var(--accent);
} }
.chip {
color: var(--fg);
background: var(--chip-bg);
text-decoration: none;
padding: 0 0.5rem 0 1.45rem;
display: inline-flex;
position: relative;
font-size: 0.9rem;
height: 1.125rem;
align-items: center;
border-radius: 2rem;
overflow: hidden;
}
.chip::before {
content: "";
position: absolute;
left: 0;
top: 0;
width: 1.125rem;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
text-align: center;
background: var(--accent-transparent);
background-repeat: no-repeat;
background-size: 18px;
background-position: center;
}
.join-chip::before {
background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0iI2ZmZiI+PHBhdGggZD0iTTggNXYxNGwxMS03eiIvPjwvc3ZnPg==");
}
.time-chip::before {
background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0iI2ZmZiI+PHBhdGggZD0iTTExLjk5IDJDNi40NyAyIDIgNi40OCAyIDEyczQuNDcgMTAgOS45OSAxMEMxNy41MiAyMiAyMiAxNy41MiAyMiAxMlMxNy41MiAyIDExLjk5IDJ6TTEyIDIwYy00LjQyIDAtOC0zLjU4LTgtOHMzLjU4LTggOC04IDggMy41OCA4IDgtMy41OCA4LTggOHoiLz48cGF0aCBkPSJNMTIuNSA3SDExdjZsNS4yNSAzLjE1Ljc1LTEuMjMtNC41LTIuNjd6Ii8+PC9zdmc+");
}
label { label {
display: block; display: block;
} }
@ -84,7 +169,7 @@ input[type="text"] {
overflow-y: scroll; overflow-y: scroll;
} }
button { button:not(.plyr button) {
background-color: var(--accent); background-color: var(--accent);
border: var(--accent); border: var(--accent);
border-radius: 6px; border-radius: 6px;
@ -164,6 +249,7 @@ button.small-button {
.chat-message { .chat-message {
overflow-wrap: break-word; overflow-wrap: break-word;
margin-bottom: 0.125rem;
} }
.chat-message > strong, .chat-message > strong,
@ -171,21 +257,6 @@ button.small-button {
color: var(--user-color, var(--default-user-color)); color: var(--user-color, var(--default-user-color));
} }
/*
@supports (-webkit-background-clip: text) {
.chat-message > strong,
#viewer-list strong {
background: linear-gradient(var(--fg-transparent), var(--fg-transparent)),
linear-gradient(
var(--user-color, var(--default-user-color)),
var(--user-color, var(--default-user-color))
);
-webkit-background-clip: text;
color: transparent !important;
}
}
*/
.chat-message.user-join, .chat-message.user-join,
.chat-message.user-leave, .chat-message.user-leave,
.chat-message.ping { .chat-message.ping {
@ -193,7 +264,8 @@ button.small-button {
} }
.chat-message.set-time, .chat-message.set-time,
.chat-message.set-playing { .chat-message.set-playing,
.chat-message.join-session {
font-style: italic; font-style: italic;
text-align: right; text-align: right;
font-size: 0.85em; font-size: 0.85em;
@ -204,7 +276,8 @@ button.small-button {
} }
.chat-message.set-time > strong, .chat-message.set-time > strong,
.chat-message.set-playing > strong { .chat-message.set-playing > strong,
.chat-message.join-session > strong {
color: unset !important; color: unset !important;
} }
@ -268,7 +341,7 @@ button.small-button {
display: none; display: none;
} }
.emoji-option { .emoji-option:not(:root) {
background: transparent; background: transparent;
font-size: 0.75rem; font-size: 0.75rem;
text-align: left; text-align: left;
@ -280,9 +353,11 @@ button.small-button {
padding: 0.25rem 0.5rem; padding: 0.25rem 0.5rem;
scroll-margin: 0.25rem; scroll-margin: 0.25rem;
} }
.emoji-option:first-child { .emoji-option:first-child {
margin-top: 0.25rem; margin-top: 0.25rem;
} }
.emoji-option:last-child { .emoji-option:last-child {
margin-bottom: 0.25rem; margin-bottom: 0.25rem;
} }
@ -299,6 +374,11 @@ button.small-button {
flex-shrink: 0; flex-shrink: 0;
} }
.emoji-name {
overflow: hidden;
text-overflow: ellipsis;
}
.emoji-option.selected { .emoji-option.selected {
background: var(--fg-transparent); background: var(--fg-transparent);
} }
@ -317,10 +397,19 @@ button.small-button {
cursor: pointer; cursor: pointer;
} }
input[type="color"]::-moz-color-swatch, input[type="color"]::-moz-color-swatch {
input[type="color"]::-webkit-color-swatch, border: none;
margin: 0;
padding: 0;
}
input[type="color"]::-webkit-color-swatch {
border: none;
margin: 0;
padding: 0;
}
input[type="color"]::-webkit-color-swatch-wrapper { input[type="color"]::-webkit-color-swatch-wrapper {
/* This *should* be working in Chrome, but it doesn't for reasons that are beyond me. */
border: none; border: none;
margin: 0; margin: 0;
padding: 0; padding: 0;

View File

@ -62,7 +62,7 @@ async fn main() {
warb::reply::json(&json!({ "id": session_uuid.to_string(), "session": session_view })) warb::reply::json(&json!({ "id": session_uuid.to_string(), "session": session_view }))
}); });
let get_emoji_route = warb::path!("emojis").and_then(get_emoji_list); let get_emoji_route = warb::path!("emojos").and_then(get_emoji_list);
enum RequestedSession { enum RequestedSession {
Session(Uuid, WatchSession), Session(Uuid, WatchSession),