bep40 commited on
Commit
fe806fc
·
verified ·
1 Parent(s): d8f6236

Revert to aa5083a: index.html

Browse files
Files changed (1) hide show
  1. static/index.html +1 -1
static/index.html CHANGED
@@ -44,7 +44,7 @@ function switchCat(id){document.querySelectorAll('.cat').forEach(x=>x.classList.
44
  function showView(id){document.querySelectorAll('.view').forEach(x=>x.classList.remove('active'));document.getElementById(id).classList.add('active');}
45
  async function openLeaguePlayer(league,idx){showView('view-tiktok');document.querySelectorAll('.cat').forEach(x=>x.classList.remove('active'));const el=document.getElementById('view-tiktok');el.innerHTML='<div class="loading">Đang tải video...</div>';const articles=_hlLeagueData[league]||[];if(!articles.length){el.innerHTML='<div class="loading">Không có video</div>';return;}const cfg=HL_CONFIG[league]||{name:league,emoji:'🎬'};let h=`<button class="back-btn" onclick="switchCat('home')">← ${cfg.emoji} ${cfg.name}</button>`;h+=`<div class="vp-wrap" id="vp-wrap"><video id="vp-video" playsinline controls loop></video><button class="vp-ratio-btn" onclick="toggleRatio()">16:9</button></div>`;h+=`<div class="vp-title" id="vp-title"></div>`;h+=`<div class="pl-list" id="pl-list">`;articles.forEach((a,i)=>{h+=`<div class="pl-item${i===idx?' active':''}" data-idx="${i}" onclick="playFromList('${league}',${i})"><div class="pl-item-thumb">${a.img?`<img src="${a.img}">`:''}<div class="card-play">▶</div></div><div class="pl-item-body"><div class="pl-item-title">${a.title}</div></div></div>`;});h+=`</div>`;el.innerHTML=h;playFromList(league,idx);}
46
  async function playFromList(league,idx){const articles=_hlLeagueData[league]||[];const a=articles[idx];if(!a)return;document.querySelectorAll('.pl-item').forEach(x=>x.classList.remove('active'));document.querySelector(`.pl-item[data-idx="${idx}"]`)?.classList.add('active');const titleEl=document.getElementById('vp-title');if(titleEl)titleEl.textContent=a.title;const video=document.getElementById('vp-video');if(!video)return;if(_vpHls){_vpHls.destroy();_vpHls=null;}video.removeAttribute('src');video.innerHTML='';const r=await fetch('/api/video_url?url='+encodeURIComponent(a.link));const v=await r.json();if(!v||!v.src){titleEl.textContent=a.title+' (lỗi)';return;}if(v.type==='youtube'){const wrap=video.parentElement;wrap.innerHTML=`<iframe src="${v.src}" allowfullscreen allow="accelerometer;autoplay;clipboard-write;encrypted-media;gyroscope;picture-in-picture" style="width:100%;height:100%;border:none"></iframe>`;return;}if(v.poster)video.poster=v.poster;if(v.type==='hls'&&Hls.isSupported()){_vpHls=new Hls({maxBufferLength:60,maxMaxBufferLength:120,maxBufferSize:30*1000*1000,startLevel:-1});_vpHls.loadSource(v.src);_vpHls.attachMedia(video);_vpHls.on(Hls.Events.MANIFEST_PARSED,()=>{video.play().catch(()=>{});});_vpHls.on(Hls.Events.ERROR,(e,d)=>{if(d.fatal&&d.type===Hls.ErrorTypes.NETWORK_ERROR)_vpHls.startLoad();});}else{video.src=v.src;video.play().catch(()=>{});}video.scrollIntoView({behavior:'smooth',block:'start'});}
47
- async function loadHome(){const[news,sh,dantri,featured,hlLeagues]=await Promise.all([fetch('/api/homepage').then(r=>r.json()),fetch('/api/shorts').then(r=>r.json()),Promise.resolve([]),fetch('/api/livescore/featured').then(r=>r.json()).catch(()=>null),fetch('/api/highlights/leagues').then(r=>r.json()).catch(()=>({}))]);_hlLeagueData=hlLeagues;let h='';
48
  if(featured&&featured.home){_featuredEventId=featured.event_id;const sc=featured.status==='live'?'':'upcoming';const st=featured.status==='live'?`🔴 ${featured.minute||'LIVE'}`:`⏰ ${featured.time}`;h+=`<div class="featured-match" onclick="openMatch('${featured.event_id}')"><div class="fm-league">${featured.league}</div><div class="fm-teams"><div class="fm-team"><img src="${featured.home_logo}" onerror="this.style.display='none'"><span>${featured.home}</span></div><div class="fm-score">${featured.score||'VS'}</div><div class="fm-team"><img src="${featured.away_logo}" onerror="this.style.display='none'"><span>${featured.away}</span></div></div><div class="fm-status ${sc}">${st}</div></div>`;}
49
  h+=`<div class="ls-section"><div class="ls-header"><h3>⚽ Bóng Đá</h3></div><div class="ls-tabs"><span class="ls-tab" data-tab="live" onclick="loadLivescore('live')">🔴 Live</span><span class="ls-tab" data-tab="incoming" onclick="loadLivescore('incoming')">⏰ Sắp tới</span><span class="ls-tab" data-tab="results" onclick="loadLivescore('results')">✅ Kết quả</span><span class="ls-tab active" data-tab="today" onclick="loadLivescore('today')">📅 Hôm nay</span><span class="ls-tab" data-tab="bxh_nha" onclick="loadLivescore('bxh_nha')">🏆 NHA</span><span class="ls-tab" data-tab="bxh_laliga" onclick="loadLivescore('bxh_laliga')">🏆 La Liga</span><span class="ls-tab" data-tab="bxh_seriea" onclick="loadLivescore('bxh_seriea')">🏆 Serie A</span><span class="ls-tab" data-tab="bxh_bundesliga" onclick="loadLivescore('bxh_bundesliga')">🏆 Bundesliga</span><span class="ls-tab" data-tab="bxh_ligue1" onclick="loadLivescore('bxh_ligue1')">🏆 Ligue 1</span></div><div class="ls-content" id="ls-content"><div class="loading" style="padding:20px">Đang tải...</div></div></div>`;
50
  if(dantri&&dantri.length){h+='<div class="slider-wrap"><div class="slider-header"><span class="slider-label">🤖 Ứng dụng AI</span></div><div class="slider-track">';dantri.forEach(a=>{h+=`<div class="slider-item" onclick="readArticle('${a.link.replace(/'/g,"\\'")}','genk')"><div class="slider-thumb">${a.img?`<img src="${a.img}" onerror="this.parentElement.style.background='#222'">`:''}</div><div class="slider-title">${a.title}</div></div>`;});h+='</div></div>';}
 
44
  function showView(id){document.querySelectorAll('.view').forEach(x=>x.classList.remove('active'));document.getElementById(id).classList.add('active');}
45
  async function openLeaguePlayer(league,idx){showView('view-tiktok');document.querySelectorAll('.cat').forEach(x=>x.classList.remove('active'));const el=document.getElementById('view-tiktok');el.innerHTML='<div class="loading">Đang tải video...</div>';const articles=_hlLeagueData[league]||[];if(!articles.length){el.innerHTML='<div class="loading">Không có video</div>';return;}const cfg=HL_CONFIG[league]||{name:league,emoji:'🎬'};let h=`<button class="back-btn" onclick="switchCat('home')">← ${cfg.emoji} ${cfg.name}</button>`;h+=`<div class="vp-wrap" id="vp-wrap"><video id="vp-video" playsinline controls loop></video><button class="vp-ratio-btn" onclick="toggleRatio()">16:9</button></div>`;h+=`<div class="vp-title" id="vp-title"></div>`;h+=`<div class="pl-list" id="pl-list">`;articles.forEach((a,i)=>{h+=`<div class="pl-item${i===idx?' active':''}" data-idx="${i}" onclick="playFromList('${league}',${i})"><div class="pl-item-thumb">${a.img?`<img src="${a.img}">`:''}<div class="card-play">▶</div></div><div class="pl-item-body"><div class="pl-item-title">${a.title}</div></div></div>`;});h+=`</div>`;el.innerHTML=h;playFromList(league,idx);}
46
  async function playFromList(league,idx){const articles=_hlLeagueData[league]||[];const a=articles[idx];if(!a)return;document.querySelectorAll('.pl-item').forEach(x=>x.classList.remove('active'));document.querySelector(`.pl-item[data-idx="${idx}"]`)?.classList.add('active');const titleEl=document.getElementById('vp-title');if(titleEl)titleEl.textContent=a.title;const video=document.getElementById('vp-video');if(!video)return;if(_vpHls){_vpHls.destroy();_vpHls=null;}video.removeAttribute('src');video.innerHTML='';const r=await fetch('/api/video_url?url='+encodeURIComponent(a.link));const v=await r.json();if(!v||!v.src){titleEl.textContent=a.title+' (lỗi)';return;}if(v.type==='youtube'){const wrap=video.parentElement;wrap.innerHTML=`<iframe src="${v.src}" allowfullscreen allow="accelerometer;autoplay;clipboard-write;encrypted-media;gyroscope;picture-in-picture" style="width:100%;height:100%;border:none"></iframe>`;return;}if(v.poster)video.poster=v.poster;if(v.type==='hls'&&Hls.isSupported()){_vpHls=new Hls({maxBufferLength:60,maxMaxBufferLength:120,maxBufferSize:30*1000*1000,startLevel:-1});_vpHls.loadSource(v.src);_vpHls.attachMedia(video);_vpHls.on(Hls.Events.MANIFEST_PARSED,()=>{video.play().catch(()=>{});});_vpHls.on(Hls.Events.ERROR,(e,d)=>{if(d.fatal&&d.type===Hls.ErrorTypes.NETWORK_ERROR)_vpHls.startLoad();});}else{video.src=v.src;video.play().catch(()=>{});}video.scrollIntoView({behavior:'smooth',block:'start'});}
47
+ async function loadHome(){const[news,sh,dantri,featured,hlLeagues]=await Promise.all([fetch('/api/homepage').then(r=>r.json()),fetch('/api/shorts').then(r=>r.json()),fetch('/api/genk_ai').then(r=>r.json()).catch(()=>[]),fetch('/api/livescore/featured').then(r=>r.json()).catch(()=>null),fetch('/api/highlights/leagues').then(r=>r.json()).catch(()=>({}))]);_hlLeagueData=hlLeagues;let h='';
48
  if(featured&&featured.home){_featuredEventId=featured.event_id;const sc=featured.status==='live'?'':'upcoming';const st=featured.status==='live'?`🔴 ${featured.minute||'LIVE'}`:`⏰ ${featured.time}`;h+=`<div class="featured-match" onclick="openMatch('${featured.event_id}')"><div class="fm-league">${featured.league}</div><div class="fm-teams"><div class="fm-team"><img src="${featured.home_logo}" onerror="this.style.display='none'"><span>${featured.home}</span></div><div class="fm-score">${featured.score||'VS'}</div><div class="fm-team"><img src="${featured.away_logo}" onerror="this.style.display='none'"><span>${featured.away}</span></div></div><div class="fm-status ${sc}">${st}</div></div>`;}
49
  h+=`<div class="ls-section"><div class="ls-header"><h3>⚽ Bóng Đá</h3></div><div class="ls-tabs"><span class="ls-tab" data-tab="live" onclick="loadLivescore('live')">🔴 Live</span><span class="ls-tab" data-tab="incoming" onclick="loadLivescore('incoming')">⏰ Sắp tới</span><span class="ls-tab" data-tab="results" onclick="loadLivescore('results')">✅ Kết quả</span><span class="ls-tab active" data-tab="today" onclick="loadLivescore('today')">📅 Hôm nay</span><span class="ls-tab" data-tab="bxh_nha" onclick="loadLivescore('bxh_nha')">🏆 NHA</span><span class="ls-tab" data-tab="bxh_laliga" onclick="loadLivescore('bxh_laliga')">🏆 La Liga</span><span class="ls-tab" data-tab="bxh_seriea" onclick="loadLivescore('bxh_seriea')">🏆 Serie A</span><span class="ls-tab" data-tab="bxh_bundesliga" onclick="loadLivescore('bxh_bundesliga')">🏆 Bundesliga</span><span class="ls-tab" data-tab="bxh_ligue1" onclick="loadLivescore('bxh_ligue1')">🏆 Ligue 1</span></div><div class="ls-content" id="ls-content"><div class="loading" style="padding:20px">Đang tải...</div></div></div>`;
50
  if(dantri&&dantri.length){h+='<div class="slider-wrap"><div class="slider-header"><span class="slider-label">🤖 Ứng dụng AI</span></div><div class="slider-track">';dantri.forEach(a=>{h+=`<div class="slider-item" onclick="readArticle('${a.link.replace(/'/g,"\\'")}','genk')"><div class="slider-thumb">${a.img?`<img src="${a.img}" onerror="this.parentElement.style.background='#222'">`:''}</div><div class="slider-title">${a.title}</div></div>`;});h+='</div></div>';}