Upload index.html
Browse files- index.html +125 -35
index.html
CHANGED
|
@@ -2468,7 +2468,7 @@ function posterCard(item, gridMode) {
|
|
| 2468 |
return Router.go((item.kind === 'sport' ? '/match/' : '/live/') + encodeURIComponent(item.id));
|
| 2469 |
}
|
| 2470 |
if (item.kind === 'movie' && isShortItem(item)) return openShortsFeed(item);
|
| 2471 |
-
if (item.kind === 'translated') {
|
| 2472 |
return openDetail(item.id);
|
| 2473 |
});
|
| 2474 |
return div;
|
|
@@ -2963,62 +2963,123 @@ async function loadTranslated() {
|
|
| 2963 |
}
|
| 2964 |
}
|
| 2965 |
|
| 2966 |
-
|
| 2967 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2968 |
try {
|
| 2969 |
-
const r = await fetch(TRANSLATED_BASE + '?id=' + encodeURIComponent(id), { headers: { apikey: TRANSLATED_KEY } });
|
| 2970 |
const d = await r.json();
|
| 2971 |
if (!d.ok) throw new Error(d.error || 'Haipatikani');
|
| 2972 |
-
const m = d.movie;
|
| 2973 |
-
ptitle.textContent = m.title || '';
|
| 2974 |
const vids = m.video_urls || {};
|
| 2975 |
const isSeries = Object.values(vids).some(v => v && typeof v === 'object');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2976 |
|
| 2977 |
-
|
| 2978 |
-
|
| 2979 |
-
|
| 2980 |
-
|
| 2981 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2982 |
|
| 2983 |
-
|
| 2984 |
-
|
| 2985 |
-
|
| 2986 |
-
|
| 2987 |
-
|
| 2988 |
-
|
| 2989 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2990 |
|
|
|
|
| 2991 |
const renderEpisodes = (seasonName) => {
|
| 2992 |
-
const eps = vids[seasonName] || {};
|
| 2993 |
-
|
|
|
|
| 2994 |
`<div class="tab-chip${i === 0 ? ' active' : ''}" data-ep="${esc(ek)}">${esc(ek)}</div>`
|
| 2995 |
-
).join('');
|
| 2996 |
-
|
| 2997 |
chip.onclick = () => {
|
| 2998 |
-
|
| 2999 |
chip.classList.add('active');
|
| 3000 |
-
|
|
|
|
| 3001 |
};
|
|
|
|
| 3002 |
});
|
| 3003 |
-
const first = Object.values(eps)[0];
|
| 3004 |
-
if (first) playTranslatedUrl(first);
|
| 3005 |
};
|
| 3006 |
-
|
| 3007 |
-
|
| 3008 |
chip.onclick = () => {
|
| 3009 |
-
|
| 3010 |
chip.classList.add('active');
|
| 3011 |
-
|
|
|
|
|
|
|
| 3012 |
};
|
| 3013 |
});
|
| 3014 |
-
renderEpisodes(Object.keys(vids)[0]);
|
| 3015 |
-
} catch (e) {
|
| 3016 |
-
statusMsg('Imeshindikana: ' + esc(e.message || 'Hitilafu'));
|
| 3017 |
}
|
| 3018 |
}
|
| 3019 |
|
| 3020 |
-
function playTranslatedUrl(url) {
|
| 3021 |
-
if (!url) {
|
|
|
|
|
|
|
| 3022 |
stage.innerHTML = '<video id="vid" controls autoplay playsinline></video>';
|
| 3023 |
const v = document.getElementById('vid');
|
| 3024 |
attachPlayerEnhancements(v);
|
|
@@ -3026,6 +3087,35 @@ function playTranslatedUrl(url) {
|
|
| 3026 |
v.src = url;
|
| 3027 |
}
|
| 3028 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3029 |
// ββ MICHEZO (fawa-live) ββ
|
| 3030 |
// Inarudisha orodha bapa (flat) ya mechi zote β inatumika na loadSports()
|
| 3031 |
// (kuonyesha kwa rails, kikundi kwa ligi) na search (kuchuja kwa query).
|
|
|
|
| 2468 |
return Router.go((item.kind === 'sport' ? '/match/' : '/live/') + encodeURIComponent(item.id));
|
| 2469 |
}
|
| 2470 |
if (item.kind === 'movie' && isShortItem(item)) return openShortsFeed(item);
|
| 2471 |
+
if (item.kind === 'translated') { return openTranslatedDetailScreen(item); }
|
| 2472 |
return openDetail(item.id);
|
| 2473 |
});
|
| 2474 |
return div;
|
|
|
|
| 2963 |
}
|
| 2964 |
}
|
| 2965 |
|
| 2966 |
+
// Detail screen ya "Zilizotafsiriwa" (DJ) β poster, dj, season/episode,
|
| 2967 |
+
// Play/Download/Share β badala ya kuruka moja kwa moja kwenye player.
|
| 2968 |
+
// `item` ni ile ile kadi ya kwenye rail (ina poster/subtitle=dj tayari),
|
| 2969 |
+
// kwa hiyo detail inaonekana papo hapo hata kabla ya fetch ya ziada kumalizika.
|
| 2970 |
+
let currentTranslatedDetail = null;
|
| 2971 |
+
|
| 2972 |
+
async function openTranslatedDetailScreen(item) {
|
| 2973 |
+
window.__ovKey = 'translated:' + item.id;
|
| 2974 |
+
if (playerEl.classList.contains('on')) { stopPlayer(); playerEl.classList.remove('on'); }
|
| 2975 |
+
detailOv.classList.add('on');
|
| 2976 |
+
detailTitleBar.textContent = item.title || '';
|
| 2977 |
+
detailBody.innerHTML = stateBoxHTML(t('state_loading'));
|
| 2978 |
+
fadeInScreen(detailBody);
|
| 2979 |
try {
|
| 2980 |
+
const r = await fetch(TRANSLATED_BASE + '?id=' + encodeURIComponent(item.id), { headers: { apikey: TRANSLATED_KEY } });
|
| 2981 |
const d = await r.json();
|
| 2982 |
if (!d.ok) throw new Error(d.error || 'Haipatikani');
|
| 2983 |
+
const m = d.movie || {};
|
|
|
|
| 2984 |
const vids = m.video_urls || {};
|
| 2985 |
const isSeries = Object.values(vids).some(v => v && typeof v === 'object');
|
| 2986 |
+
const detail = {
|
| 2987 |
+
id: item.id, title: m.title || item.title,
|
| 2988 |
+
poster: m.thumb_url || m.poster_url || item.poster || null,
|
| 2989 |
+
dj: m.dj || (item.subtitle && item.subtitle !== 'Series' && item.subtitle !== 'Movie' ? item.subtitle : '') || '',
|
| 2990 |
+
isSeries, vids,
|
| 2991 |
+
seasons: isSeries ? Object.keys(vids) : [],
|
| 2992 |
+
selectedSeason: isSeries ? Object.keys(vids)[0] : null,
|
| 2993 |
+
};
|
| 2994 |
+
renderTranslatedDetail(detail);
|
| 2995 |
+
} catch (e) {
|
| 2996 |
+
detailBody.innerHTML = stateBoxHTML('Imeshindikana: ' + esc(e.message || 'Hitilafu'), true);
|
| 2997 |
+
const btn = detailBody.querySelector('.retry-btn');
|
| 2998 |
+
if (btn) btn.onclick = () => openTranslatedDetailScreen(item);
|
| 2999 |
+
}
|
| 3000 |
+
}
|
| 3001 |
|
| 3002 |
+
function renderTranslatedDetail(d) {
|
| 3003 |
+
currentTranslatedDetail = d;
|
| 3004 |
+
detailTitleBar.textContent = d.title;
|
| 3005 |
+
let html = '';
|
| 3006 |
+
html += `<div class="detail-backdrop">${d.poster ? `<img src="${esc(d.poster)}" alt="">` : ''}</div>`;
|
| 3007 |
+
html += `<div class="detail-info">`;
|
| 3008 |
+
html += `<div class="detail-title">${esc(d.title)}</div>`;
|
| 3009 |
+
html += `<div class="detail-meta">`;
|
| 3010 |
+
if (d.dj) html += `<span>π ${esc(d.dj)}</span>`;
|
| 3011 |
+
html += `<span>${d.isSeries ? 'Series Iliyotafsiriwa' : 'Movie Iliyotafsiriwa'}</span></div>`;
|
| 3012 |
+
html += `<div class="detail-actions">
|
| 3013 |
+
<button class="btn btn-primary" id="trPlayBtn">βΆ ${d.isSeries ? 'Cheza Ep 1' : 'Cheza'}</button>
|
| 3014 |
+
<button class="btn btn-outline" id="trDownloadBtn">${ICON_DOWNLOAD} ${esc(t('dl_btn_download'))}</button>
|
| 3015 |
+
<button class="btn btn-outline" id="trShareBtn">π Shiriki</button>
|
| 3016 |
+
</div>`;
|
| 3017 |
+
html += `</div>`;
|
| 3018 |
|
| 3019 |
+
if (d.isSeries) {
|
| 3020 |
+
html += `<div class="rail-title" style="padding:0 16px 8px;margin-top:6px">Season</div>`;
|
| 3021 |
+
html += `<div class="chip-row" id="trSeasonRow" style="color:var(--text)">` +
|
| 3022 |
+
d.seasons.map((sn, i) => `<div class="tab-chip ${i === 0 ? 'active' : ''}" data-season="${esc(sn)}">${esc(sn)}</div>`).join('') + `</div>`;
|
| 3023 |
+
html += `<div class="rail-title" style="padding:12px 16px 8px">Episode</div>`;
|
| 3024 |
+
html += `<div class="chip-row" id="trEpisodeRow" style="padding:0 16px 24px"></div>`;
|
| 3025 |
+
}
|
| 3026 |
+
|
| 3027 |
+
detailBody.innerHTML = html;
|
| 3028 |
+
fadeInScreen(detailBody);
|
| 3029 |
+
|
| 3030 |
+
function currentUrl() {
|
| 3031 |
+
if (!d.isSeries) return d.vids.main || Object.values(d.vids)[0] || null;
|
| 3032 |
+
const eps = d.vids[d.selectedSeason] || {};
|
| 3033 |
+
return d.selectedEpisodeUrl || Object.values(eps)[0] || null;
|
| 3034 |
+
}
|
| 3035 |
+
|
| 3036 |
+
const playBtn = document.getElementById('trPlayBtn');
|
| 3037 |
+
playBtn.onclick = () => {
|
| 3038 |
+
const url = currentUrl();
|
| 3039 |
+
if (!url) { showToast('Hakuna link ya kucheza bado.'); return; }
|
| 3040 |
+
playTranslatedUrl(url, d.title);
|
| 3041 |
+
};
|
| 3042 |
+
document.getElementById('trDownloadBtn').onclick = () => {
|
| 3043 |
+
const url = currentUrl();
|
| 3044 |
+
if (!url) { showToast('Hakuna link ya kupakua bado.'); return; }
|
| 3045 |
+
downloadTranslatedUrl(url, d.title);
|
| 3046 |
+
};
|
| 3047 |
+
document.getElementById('trShareBtn').onclick = () => shareTranslatedTitle(d, currentUrl());
|
| 3048 |
|
| 3049 |
+
if (d.isSeries) {
|
| 3050 |
const renderEpisodes = (seasonName) => {
|
| 3051 |
+
const eps = d.vids[seasonName] || {};
|
| 3052 |
+
const epRow = document.getElementById('trEpisodeRow');
|
| 3053 |
+
epRow.innerHTML = Object.keys(eps).map((ek, i) =>
|
| 3054 |
`<div class="tab-chip${i === 0 ? ' active' : ''}" data-ep="${esc(ek)}">${esc(ek)}</div>`
|
| 3055 |
+
).join('') || '<span class="poster-sub">Hakuna vipindi bado.</span>';
|
| 3056 |
+
epRow.querySelectorAll('.tab-chip').forEach((chip, i) => {
|
| 3057 |
chip.onclick = () => {
|
| 3058 |
+
epRow.querySelectorAll('.tab-chip').forEach(c => c.classList.remove('active'));
|
| 3059 |
chip.classList.add('active');
|
| 3060 |
+
d.selectedEpisodeUrl = eps[chip.dataset.ep];
|
| 3061 |
+
playTranslatedUrl(d.selectedEpisodeUrl, d.title + ' - ' + chip.dataset.ep);
|
| 3062 |
};
|
| 3063 |
+
if (i === 0) d.selectedEpisodeUrl = eps[chip.dataset.ep];
|
| 3064 |
});
|
|
|
|
|
|
|
| 3065 |
};
|
| 3066 |
+
renderEpisodes(d.selectedSeason);
|
| 3067 |
+
document.getElementById('trSeasonRow').querySelectorAll('.tab-chip').forEach(chip => {
|
| 3068 |
chip.onclick = () => {
|
| 3069 |
+
document.getElementById('trSeasonRow').querySelectorAll('.tab-chip').forEach(c => c.classList.remove('active'));
|
| 3070 |
chip.classList.add('active');
|
| 3071 |
+
d.selectedSeason = chip.dataset.season;
|
| 3072 |
+
d.selectedEpisodeUrl = null;
|
| 3073 |
+
renderEpisodes(d.selectedSeason);
|
| 3074 |
};
|
| 3075 |
});
|
|
|
|
|
|
|
|
|
|
| 3076 |
}
|
| 3077 |
}
|
| 3078 |
|
| 3079 |
+
function playTranslatedUrl(url, title) {
|
| 3080 |
+
if (!url) { showToast('Hakuna link ya kucheza.'); return; }
|
| 3081 |
+
detailOv.classList.remove('on');
|
| 3082 |
+
openPlayerShell(title || (currentTranslatedDetail && currentTranslatedDetail.title) || '');
|
| 3083 |
stage.innerHTML = '<video id="vid" controls autoplay playsinline></video>';
|
| 3084 |
const v = document.getElementById('vid');
|
| 3085 |
attachPlayerEnhancements(v);
|
|
|
|
| 3087 |
v.src = url;
|
| 3088 |
}
|
| 3089 |
|
| 3090 |
+
// Download ya moja kwa moja β video_urls ni link ya wazi (si DRM), kwa hiyo
|
| 3091 |
+
// hatuhitaji mfumo mzito wa openDownloadSheet (ulioundwa kwa ajili ya
|
| 3092 |
+
// movies.play/qualityVariants za Supabase backend).
|
| 3093 |
+
function downloadTranslatedUrl(url, title) {
|
| 3094 |
+
try {
|
| 3095 |
+
const a = document.createElement('a');
|
| 3096 |
+
a.href = url;
|
| 3097 |
+
a.download = (title || 'video').replace(/[^\w\- ]+/g, '').trim() + '.mp4';
|
| 3098 |
+
a.target = '_blank';
|
| 3099 |
+
a.rel = 'noopener';
|
| 3100 |
+
document.body.appendChild(a);
|
| 3101 |
+
a.click();
|
| 3102 |
+
a.remove();
|
| 3103 |
+
showToast('Kupakua kumeanza...');
|
| 3104 |
+
} catch (_) {
|
| 3105 |
+
window.open(url, '_blank');
|
| 3106 |
+
}
|
| 3107 |
+
}
|
| 3108 |
+
|
| 3109 |
+
// Shiriki β kwa sababu "Zilizotafsiriwa" haina ukurasa wake wa Router bado,
|
| 3110 |
+
// tunashiriki kiungo cha moja kwa moja cha video (si deep-link ya app).
|
| 3111 |
+
async function shareTranslatedTitle(d, url) {
|
| 3112 |
+
const text = d.title + ' β JAYNES MAX (Zilizotafsiriwa)';
|
| 3113 |
+
const shareUrl = url || location.origin;
|
| 3114 |
+
if (navigator.share) { try { await navigator.share({ title: text, text, url: shareUrl }); } catch (_) {} return; }
|
| 3115 |
+
try { await navigator.clipboard.writeText(shareUrl); showToast('Kiungo kimenakiliwa'); }
|
| 3116 |
+
catch (_) { prompt('Nakili kiungo:', shareUrl); }
|
| 3117 |
+
}
|
| 3118 |
+
|
| 3119 |
// ββ MICHEZO (fawa-live) ββ
|
| 3120 |
// Inarudisha orodha bapa (flat) ya mechi zote β inatumika na loadSports()
|
| 3121 |
// (kuonyesha kwa rails, kikundi kwa ligi) na search (kuchuja kwa query).
|