refactor: clean up chat and split up embed handling

This commit is contained in:
Andy Burke 2025-09-16 12:25:11 -07:00
parent 03751c6d00
commit 7e4ab72fe6
14 changed files with 352 additions and 274 deletions

35
public/js/embeds/vimeo.js Normal file
View file

@ -0,0 +1,35 @@
const VIMEO_ID_EXTRACTOR =
/(?<video_domain>vimeo\.com)(?:\/(?<action>video|embed|watch|shorts|v))?.*(?:(?:\/|v=)(?<video_id>[A-Za-z0-9._%-]*))\S*/gi;
function embed_vimeo(link_info) {
const is_vimeo_link = ["vimeo.com"].includes(link_info.domain?.toLowerCase());
if (!is_vimeo_link) {
return;
}
VIMEO_ID_EXTRACTOR.lastIndex = 0;
const {
groups: { video_domain, action, video_id },
} = VIMEO_ID_EXTRACTOR.exec(link_info.url) ?? { groups: {} };
if (!video_id) {
return;
}
return `
<div class="embed-container iframe letterbox vimeo">
<div class="embed-actions-container">
<button class="icon plus" onclick="console.log(\"close\");"/>
<button class="icon pause" onclick="console.log(\"stop\");"/>
</div>
<iframe
src="https://player.vimeo.com/video/${video_id}"
frameborder="0"
allow="fullscreen; picture-in-picture; clipboard-write; encrypted-media; web-share"
referrerpolicy="strict-origin-when-cross-origin"
title="Star Trek: Legacy"
loading="lazy"></iframe>
</div>`;
}