refactor: clean up chat and split up embed handling
This commit is contained in:
parent
03751c6d00
commit
7e4ab72fe6
14 changed files with 352 additions and 274 deletions
35
public/js/embeds/tidal.js
Normal file
35
public/js/embeds/tidal.js
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
const TIDAL_EXTRACTOR =
|
||||
/^\/(?:(?<action>.*?)\/)?(?<item_type>(?:album|artist|episode|playlist|tracks?))\/(?<item_id>[0-9]+)/gi;
|
||||
|
||||
function embed_tidal(link_info) {
|
||||
const is_tidal_link = ["tidal.com", "tidalhi.fi"].includes(link_info.domain?.toLowerCase());
|
||||
|
||||
if (!is_tidal_link) {
|
||||
return;
|
||||
}
|
||||
|
||||
TIDAL_EXTRACTOR.lastIndex = 0;
|
||||
|
||||
const {
|
||||
groups: { action, item_type, item_id },
|
||||
} = TIDAL_EXTRACTOR.exec(link_info.path ?? "") ?? { groups: {} };
|
||||
|
||||
if (!(item_type && item_id)) {
|
||||
return;
|
||||
}
|
||||
|
||||
return `
|
||||
<div class="embed-container iframe ${item_type.toLowerCase().indexOf("track") === 0 ? "short" : "square"} tidal">
|
||||
<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://embed.tidal.com/${item_type.at(-1) === "s" ? item_type : `${item_type}s`}/${item_id}"
|
||||
allow="encrypted-media"
|
||||
sandbox="allow-same-origin allow-scripts allow-forms allow-popups"
|
||||
title="TIDAL Embed Player"
|
||||
loading="lazy"
|
||||
></iframe>
|
||||
</div>`;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue