update preview JS/HTML

This commit is contained in:
Evgeny Poberezkin
2026-06-02 07:58:40 +01:00
parent 7c2c6eec40
commit 589e15cc1f
2 changed files with 7 additions and 5 deletions
+3 -2
View File
@@ -12,9 +12,10 @@
<body>
<div
data-simplex-channel-preview
data-relay-domains="relay1.example.com"
data-channel-link="YOUR_CHANNEL_LINK"
data-channel-id="YOUR_CHANNEL_ID"
data-channel-link="simplex:/g#YOUR_CHANNEL_LINK"
data-relay-domains="relay1.example.com"
<!-- data-relay-scheme="https" -->
></div>
<script src="https://simplex.chat/js/channel-preview.js"></script>
</body>
+4 -3
View File
@@ -433,6 +433,7 @@ const FORWARD_ICON_SVG = `<svg width="14" height="14" viewBox="0 -960 960 960" f
function initChannelPreview(container) {
const relayDomains = (container.dataset.relayDomains || '').split(',').map(u => u.trim()).filter(Boolean);
const relayScheme = container.dataset.relayScheme || 'https';
const channelId = container.dataset.channelId || '';
const channelLink = container.dataset.channelLink || '';
@@ -445,7 +446,7 @@ function initChannelPreview(container) {
container.classList.add('simplex-preview-container');
container.innerHTML = '<p class="simplex-preview-empty">Loading channel...</p>';
fetchPreview(relayDomains, channelId, channelLink).then(data => {
fetchPreview(relayScheme, relayDomains, channelLink, channelId).then(data => {
if (!data) {
container.innerHTML = '<p class="simplex-preview-empty">Failed to load channel preview.</p>';
return;
@@ -463,10 +464,10 @@ function injectStyles() {
document.head.appendChild(style);
}
async function fetchPreview(relayDomains, channelId, channelLink) {
async function fetchPreview(relayScheme, relayDomains, channelLink, channelId) {
for (const domain of relayDomains) {
try {
const url = `https://${domain}/channel/${channelId}.json`;
const url = `${relayScheme}://${domain}/channel/${channelId}.json`;
const resp = await fetch(url);
if (!resp.ok) continue;
const data = await resp.json();