Spaces:
Running
Running
Upload index.html
Browse files- index.html +32 -6
index.html
CHANGED
|
@@ -1573,13 +1573,41 @@ async function rpc(op, args = {}) {
|
|
| 1573 |
}
|
| 1574 |
|
| 1575 |
// ββ Share: kiungo cha moja kwa moja kwenye video (#/watch/ID) ββ
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1576 |
async function shareTitle(d, se, ep){
|
| 1577 |
const base = location.origin + location.pathname.replace(/index\.html$/i, '');
|
| 1578 |
const url = base + '#/watch/' + d.id + (se != null && ep != null ? '?se=' + se + '&ep=' + ep : '');
|
| 1579 |
const text = d.title + ' β JAYNES MAX';
|
| 1580 |
-
|
| 1581 |
-
try { await navigator.clipboard.writeText(url); showToast(t('link_copied')); }
|
| 1582 |
-
catch (_) { prompt('Nakili kiungo:', url); }
|
| 1583 |
}
|
| 1584 |
|
| 1585 |
// ββ Watchlist (localStorage) ββ
|
|
@@ -4104,9 +4132,7 @@ async function shareTranslatedTitle(d) {
|
|
| 4104 |
const base = location.origin + location.pathname.replace(/index\.html$/i, '');
|
| 4105 |
const shareUrl = base + '#/translated/' + d.id;
|
| 4106 |
const text = d.title + ' β JAYNES MAX (' + T('nav_translated') + ')';
|
| 4107 |
-
|
| 4108 |
-
try { await navigator.clipboard.writeText(shareUrl); showToast(t('link_copied')); }
|
| 4109 |
-
catch (_) { prompt('Nakili kiungo:', shareUrl); }
|
| 4110 |
}
|
| 4111 |
|
| 4112 |
// ββ MICHEZO (fawa-live) ββ
|
|
|
|
| 1573 |
}
|
| 1574 |
|
| 1575 |
// ββ Share: kiungo cha moja kwa moja kwenye video (#/watch/ID) ββ
|
| 1576 |
+
// ββ Kushiriki na picha: bango (poster) au nembo ya chaneli inaambatanishwa ββ
|
| 1577 |
+
async function shareImageFile(src){
|
| 1578 |
+
if (!src) return null;
|
| 1579 |
+
try {
|
| 1580 |
+
const r = await fetch(src, { mode: 'cors' });
|
| 1581 |
+
if (!r.ok) return null;
|
| 1582 |
+
const b = await r.blob();
|
| 1583 |
+
if (!b.type || !b.type.startsWith('image/')) return null;
|
| 1584 |
+
const ext = (b.type.split('/')[1] || 'jpg').replace('jpeg', 'jpg').replace('svg+xml', 'svg');
|
| 1585 |
+
return new File([b], 'jaynesmax-' + Date.now() + '.' + ext, { type: b.type });
|
| 1586 |
+
} catch (_) { return null; }
|
| 1587 |
+
}
|
| 1588 |
+
|
| 1589 |
+
async function shareWithPoster(d, url, text){
|
| 1590 |
+
const poster = d.poster || d.logo || null;
|
| 1591 |
+
if (navigator.share) {
|
| 1592 |
+
const file = await shareImageFile(poster);
|
| 1593 |
+
const withFile = { title: text, text, url };
|
| 1594 |
+
if (file && navigator.canShare && navigator.canShare({ files: [file] })) withFile.files = [file];
|
| 1595 |
+
try { await navigator.share(withFile); return; }
|
| 1596 |
+
catch (e) { if (e && e.name === 'AbortError') return; }
|
| 1597 |
+
// Kama kushiriki na picha kumeshindikana, jaribu kushiriki kiungo na maelezo tu
|
| 1598 |
+
try { await navigator.share({ title: text, text, url }); } catch (_) {}
|
| 1599 |
+
return;
|
| 1600 |
+
}
|
| 1601 |
+
const clip = text + '\n' + url + (poster ? '\nPicha: ' + poster : '');
|
| 1602 |
+
try { await navigator.clipboard.writeText(clip); showToast(t('link_copied')); }
|
| 1603 |
+
catch (_) { prompt('Nakili kiungo:', clip); }
|
| 1604 |
+
}
|
| 1605 |
+
|
| 1606 |
async function shareTitle(d, se, ep){
|
| 1607 |
const base = location.origin + location.pathname.replace(/index\.html$/i, '');
|
| 1608 |
const url = base + '#/watch/' + d.id + (se != null && ep != null ? '?se=' + se + '&ep=' + ep : '');
|
| 1609 |
const text = d.title + ' β JAYNES MAX';
|
| 1610 |
+
return shareWithPoster(d, url, text);
|
|
|
|
|
|
|
| 1611 |
}
|
| 1612 |
|
| 1613 |
// ββ Watchlist (localStorage) ββ
|
|
|
|
| 4132 |
const base = location.origin + location.pathname.replace(/index\.html$/i, '');
|
| 4133 |
const shareUrl = base + '#/translated/' + d.id;
|
| 4134 |
const text = d.title + ' β JAYNES MAX (' + T('nav_translated') + ')';
|
| 4135 |
+
return shareWithPoster(d, shareUrl, text);
|
|
|
|
|
|
|
| 4136 |
}
|
| 4137 |
|
| 4138 |
// ββ MICHEZO (fawa-live) ββ
|