Spaces:
Running
Running
Fix: YouTube embed iframe in TikTok player + CSS for iframe slides
Browse files- static/index.html +27 -50
static/index.html
CHANGED
|
@@ -10,14 +10,12 @@
|
|
| 10 |
<link rel="canonical" href="https://bep40-vnews.hf.space">
|
| 11 |
<script src="https://cdn.jsdelivr.net/npm/hls.js@1/dist/hls.min.js"></script>
|
| 12 |
<style>
|
| 13 |
-
*{box-sizing:border-box;margin:0;padding:0}body{background:#111;color:#eee;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;overflow-x:hidden}.header{background:linear-gradient(135deg,#0d1117,#1a3a2a 50%,#8b7500);padding:12px;text-align:center}.header h1{color:#fff;font-size:18px;font-weight:800}.header p{color:rgba(255,255,255,.6);font-size:10px;margin-top:2px}.cats{display:flex;overflow-x:auto;background:#1a1a1a;border-bottom:1px solid #333;padding:0 4px;scrollbar-width:none;position:sticky;top:0;z-index:50}.cats::-webkit-scrollbar{display:none}.cat{padding:9px 11px;color:#888;font-size:11px;cursor:pointer;white-space:nowrap;border-bottom:2px solid transparent;flex-shrink:0}.cat.active{color:#5cb87a;border-bottom-color:#5cb87a;font-weight:600}.view{display:none}.view.active{display:block}.grid{display:grid;grid-template-columns:repeat(2,1fr);gap:6px;padding:6px 4px}@media(min-width:600px){.grid{grid-template-columns:repeat(3,1fr)}}.card{background:#1a1a1a;border-radius:8px;overflow:hidden;cursor:pointer;border:1px solid #222}.card:active{transform:scale(.97)}.card-img{position:relative;width:100%;aspect-ratio:16/9;background:#333;overflow:hidden}.card-img img{width:100%;height:100%;object-fit:cover}.card-play{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:28px;height:28px;background:rgba(0,0,0,.5);border-radius:50%;color:#fff;display:flex;align-items:center;justify-content:center;font-size:11px}.card-body{padding:6px 8px}.card-title{font-size:11px;font-weight:600;color:#eee;line-height:1.3;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.badge{font-size:8px;padding:1px 5px;border-radius:3px;font-weight:700;display:inline-block;margin-bottom:2px}.badge-vne{background:#c0392b;color:#fff}.badge-bbc{background:#b80000;color:#fff}.badge-bdp{background:#1a5c35;color:#fff}.badge-
|
| 14 |
.featured-match{margin:6px 4px;background:linear-gradient(135deg,#1a2a1f,#0d1117);border-radius:10px;padding:12px;border:1px solid #2d8659;cursor:pointer}.featured-match .fm-league{color:#5cb87a;font-size:9px;font-weight:600;text-transform:uppercase;margin-bottom:6px;text-align:center}.featured-match .fm-teams{display:flex;align-items:center;justify-content:center;gap:10px}.featured-match .fm-team{display:flex;flex-direction:column;align-items:center;gap:4px;flex:1}.featured-match .fm-team img{width:32px;height:32px;object-fit:contain}.featured-match .fm-team span{font-size:10px;color:#ccc;text-align:center}.featured-match .fm-score{font-size:22px;font-weight:900;color:#fff;min-width:60px;text-align:center}.featured-match .fm-status{text-align:center;margin-top:6px;font-size:9px;color:#e74c3c;font-weight:600}.featured-match .fm-status.upcoming{color:#f0c040}
|
| 15 |
-
.ls-section{margin:6px 4px;background:#1a1a1a;border-radius:8px;overflow:hidden;border:1px solid #2a2a2a}.ls-header{padding:8px 10px}.ls-header h3{color:#fff;font-size:13px;font-weight:700}.ls-tabs{display:flex;gap:4px;padding:0 10px 8px;overflow-x:auto;scrollbar-width:none}.ls-tabs::-webkit-scrollbar{display:none}.ls-tab{padding:4px 10px;background:#222;border:1px solid #333;border-radius:12px;color:#999;font-size:10px;cursor:pointer;white-space:nowrap;flex-shrink:0}.ls-tab.active{background:#2d8659;border-color:#2d8659;color:#fff;font-weight:600}.ls-content{max-height:420px;overflow-y:auto;padding:0 6px 8px;scrollbar-width:thin}.ls-content::-webkit-scrollbar{width:3px}.ls-content::-webkit-scrollbar-thumb{background:#333;border-radius:3px}
|
| 16 |
-
.ls-content .matchs-league{list-style:none}.ls-content .matchs-league>li{margin-bottom:8px}.ls-content .title-content{display:flex;align-items:center;gap:6px;padding:4px 6px;background:#222;border-radius:4px;margin-bottom:4px}.ls-content .title-content img{width:16px;height:16px}.ls-content .title-content strong{color:#eee;font-size:11px}.ls-content .match-detail{padding:5px 6px;border-bottom:1px solid #222;cursor:pointer}.ls-content .match-detail:active{background:#222}.ls-content .match{display:flex;flex-wrap:wrap;align-items:center;gap:4px}.ls-content .datetime{width:100%;display:flex;gap:8px;margin-bottom:2px}.ls-content .datetime .round{color:#666;font-size:9px}.ls-content .datetime .match-time{color:#aaa;font-size:9px}.ls-content .teams{display:flex;align-items:center;gap:4px;width:100%}.ls-content .team{display:flex;align-items:center;gap:4px;flex:1;min-width:0}.ls-content .team .name{font-size:11px;color:#ddd;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.ls-content .team .logo img{width:18px;height:18px;object-fit:contain}.ls-content .home-team{justify-content:flex-end;text-align:right}.ls-content .home-team .name{order:-1}.ls-content .away-team{justify-content:flex-start}.ls-content .status{flex:0 0 50px;text-align:center}.ls-content .status a{text-decoration:none;color:#fff;font-weight:700;font-size:12px}.ls-content .status .label{font-size:8px;display:block;color:#888}.ls-content .status .label.live{color:#e74c3c;font-weight:700}.ls-content .status .vs{color:#888;font-size:11px}.ls-content .status .blink{animation:blink 1s infinite}@keyframes blink{50%{opacity:0}}.ls-content .info,.ls-content .btns{display:none}
|
| 17 |
-
.ls-content .leaderboard-item{display:flex;align-items:center;padding:5px 6px;border-bottom:1px solid #222;gap:4px}.ls-content .leaderboard-item .team{display:flex;align-items:center;gap:5px;flex:1;min-width:0}.ls-content .leaderboard-item .team span{color:#888;font-size:10px;min-width:16px}.ls-content .leaderboard-item .team .link{display:flex;align-items:center;gap:4px;text-decoration:none}.ls-content .leaderboard-item .team p{color:#ddd;font-size:11px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.ls-content .leaderboard-item .team img{width:16px;height:16px}.ls-content .leaderboard-item .copy{display:flex;gap:6px;font-size:10px;color:#aaa}.ls-content .leaderboard-item .copy p{min-width:16px;text-align:center}.ls-content .leaderboard-item .copy strong{color:#5cb87a}.ls-content .leaderboard-item .copy .form{display:flex;gap:2px}.ls-content .leaderboard-item .copy .form span{width:12px;height:12px;border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:7px;color:#fff;font-weight:700}.ls-content .bg-green{background:#27ae60}.ls-content .bg-red{background:#e74c3c}.ls-content .bg-gray-5{background:#666}
|
| 18 |
.match-overlay{position:fixed;top:0;left:0;right:0;bottom:0;background:#111;z-index:9999;display:none;flex-direction:column;overflow-y:auto}.match-overlay.active{display:flex}.match-overlay .mo-header{padding:10px;background:#1a1a1a;display:flex;justify-content:space-between;align-items:center;position:sticky;top:0;z-index:1}.match-overlay .mo-header h3{color:#fff;font-size:13px}.match-overlay .mo-close{background:none;border:none;color:#fff;font-size:22px;cursor:pointer}.match-overlay .mo-tabs{display:flex;gap:4px;padding:8px 10px;background:#1a1a1a}.match-overlay .mo-tab{padding:5px 12px;background:#222;border:1px solid #333;border-radius:10px;color:#999;font-size:10px;cursor:pointer}.match-overlay .mo-tab.active{background:#2d8659;border-color:#2d8659;color:#fff}.match-overlay .mo-body{padding:8px;flex:1}.match-overlay .mo-body .time{color:#5cb87a;font-weight:700;font-size:11px;margin-right:6px}.match-overlay .mo-body .description{color:#ccc;font-size:12px;line-height:1.4}.match-overlay .mo-body li{list-style:none;padding:6px 0;border-bottom:1px solid #222}.match-overlay .mo-body .professional-table{width:100%;font-size:10px;border-collapse:collapse}.match-overlay .mo-body .professional-table th{color:#888;padding:4px;text-align:left;border-bottom:1px solid #333}.match-overlay .mo-body .professional-table td{color:#ccc;padding:4px;border-bottom:1px solid #1a1a1a}.match-overlay .mo-body .tab-content{display:none}.match-overlay .mo-body .tab-content.active{display:block}
|
| 19 |
.loading{text-align:center;padding:40px;color:#666;font-size:12px}.section-title{font-size:13px;font-weight:700;color:#5cb87a;margin:8px 0 4px;padding-left:8px;border-left:3px solid #5cb87a}.back-btn{background:rgba(17,17,17,.95);color:#fff;border:none;padding:10px;font-size:12px;cursor:pointer;width:100%;text-align:center;position:sticky;top:0;z-index:50}.article-view{padding:12px 8px 40px;max-width:700px;margin:0 auto}.article-title{font-size:18px;font-weight:800;color:#f0f0f0;line-height:1.3;margin-bottom:8px}.article-summary{background:#1a2a1f;border-left:3px solid #2d8659;padding:10px;margin-bottom:14px;font-weight:600;color:#ccc;font-size:13px;border-radius:0 6px 6px 0}.article-p{font-size:14px;line-height:1.7;color:#ccc;margin-bottom:10px}.article-img{width:100%;border-radius:6px;margin:10px 0}.article-h2{font-size:16px;font-weight:700;color:#eee;margin:16px 0 8px}.article-actions{display:flex;gap:10px;padding:10px 0;border-top:1px solid #333;margin-top:16px;flex-wrap:wrap}.article-actions button{background:#1a1a1a;border:1px solid #333;color:#ccc;padding:6px 12px;border-radius:14px;font-size:11px;cursor:pointer}
|
| 20 |
-
.tiktok-container{width:100%;height:80vh;max-height:680px;min-height:400px;background:#000}.tiktok-feed{height:100%;overflow-y:scroll;scroll-snap-type:y mandatory;scrollbar-width:none}.tiktok-feed::-webkit-scrollbar{display:none}.tiktok-slide{height:80vh;max-height:680px;min-height:400px;scroll-snap-align:start;scroll-snap-stop:always;position:relative;background:#000;display:flex;align-items:center;justify-content:center}.tiktok-slide video{width:100%;height:100%;object-fit:cover}.tiktok-slide.contain-mode video{object-fit:contain}.tiktok-bottom{position:absolute;bottom:0;left:0;right:60px;padding:12px 10px 16px;background:linear-gradient(transparent,rgba(0,0,0,.85));z-index:3}.tiktok-title{color:#fff;font-size:12px;font-weight:600;margin:3px 0 5px;line-height:1.3}.tiktok-
|
| 21 |
</style>
|
| 22 |
</head>
|
| 23 |
<body>
|
|
@@ -28,7 +26,6 @@
|
|
| 28 |
<div id="view-video" class="view"></div>
|
| 29 |
<div id="view-tiktok" class="view"></div>
|
| 30 |
<div id="view-article" class="view"></div>
|
| 31 |
-
<!-- Match Detail Overlay -->
|
| 32 |
<div class="match-overlay" id="match-overlay">
|
| 33 |
<div class="mo-header"><h3 id="mo-title">Chi tiết trận đấu</h3><button class="mo-close" onclick="closeMatch()">✕</button></div>
|
| 34 |
<div class="mo-tabs"><span class="mo-tab active" onclick="loadMatchTab('comm')">Diễn biến</span><span class="mo-tab" onclick="loadMatchTab('stats')">Thống kê</span></div>
|
|
@@ -40,63 +37,43 @@ const LS={get(k){try{return JSON.parse(localStorage.getItem(k))}catch{return nul
|
|
| 40 |
function hid(s){let h=0;for(let i=0;i<s.length;i++){h=((h<<5)-h)+s.charCodeAt(i);h|=0;}return Math.abs(h).toString(36).slice(0,10);}
|
| 41 |
function incV(id){if(_viewed.has(id))return getV(id);_viewed.add(id);let v=(LS.get('v_'+id)||0)+1;LS.set('v_'+id,v);return v;}
|
| 42 |
function getV(id){return LS.get('v_'+id)||0}
|
| 43 |
-
function
|
| 44 |
-
function
|
| 45 |
-
function doShareVideo(title,videoUrl,img,type){const shareUrl=SPACE+'/v?url='+encodeURIComponent(videoUrl)+'&title='+encodeURIComponent(title)+'&img='+encodeURIComponent(img||'')+'&type='+encodeURIComponent(type||'highlights');const aid=hid(videoUrl||title);incS(aid);if(navigator.share)navigator.share({title:'🎬 '+title,url:shareUrl}).catch(()=>{});else navigator.clipboard.writeText(shareUrl).then(()=>alert('Đã sao chép link!')).catch(()=>{});}
|
| 46 |
-
function doShare(title,articleUrl,img){const shareUrl=SPACE+'/s?url='+encodeURIComponent(articleUrl)+'&title='+encodeURIComponent(title)+'&img='+encodeURIComponent(img||'');const aid=hid(articleUrl||title);incS(aid);if(navigator.share)navigator.share({title,url:shareUrl}).catch(()=>{});else navigator.clipboard.writeText(shareUrl).then(()=>alert('Đã sao chép link!')).catch(()=>{});}
|
| 47 |
-
|
| 48 |
-
// ===== MATCH DETAIL =====
|
| 49 |
async function openMatch(eventId){if(!eventId)return;_currentEventId=eventId;document.getElementById('match-overlay').classList.add('active');loadMatchTab('comm');}
|
| 50 |
function closeMatch(){document.getElementById('match-overlay').classList.remove('active');}
|
| 51 |
-
async function loadMatchTab(tab){
|
| 52 |
-
document.querySelectorAll('.mo-tab').forEach(t=>t.classList.remove('active'));
|
| 53 |
-
document.querySelectorAll('.mo-tab').forEach(t=>{if((tab==='comm'&&t.textContent==='Diễn biến')||(tab==='stats'&&t.textContent==='Thống kê'))t.classList.add('active');});
|
| 54 |
-
const el=document.getElementById('mo-body');el.innerHTML='<div class="loading">Đang tải...</div>';
|
| 55 |
-
const endpoint=tab==='stats'?`/api/match/${_currentEventId}/stats`:`/api/match/${_currentEventId}/commentaries`;
|
| 56 |
-
try{const r=await fetch(endpoint);const data=await r.json();el.innerHTML=data.html||'<div class="loading">Không có dữ liệu</div>';}catch(e){el.innerHTML='<div class="loading">Lỗi tải</div>';}}
|
| 57 |
-
|
| 58 |
-
// ===== LIVESCORE =====
|
| 59 |
let _lsTab='live';
|
| 60 |
-
async function loadLivescore(tab){_lsTab=tab;document.querySelectorAll('.ls-tab').forEach(t=>t.classList.remove('active'));document.querySelector(`.ls-tab[data-tab="${tab}"]`)?.classList.add('active');const el=document.getElementById('ls-content');el.innerHTML='<div class="loading" style="padding:20px">Đang tải...</div>';
|
| 61 |
-
let endpoint='/api/livescore/'+tab;
|
| 62 |
-
if(tab.startsWith('bxh_')){endpoint='/api/livescore/standings/'+tab.replace('bxh_','');}
|
| 63 |
-
try{const r=await fetch(endpoint);const data=await r.json();
|
| 64 |
-
if(data.html&&data.html.length>50){el.innerHTML=data.html;
|
| 65 |
-
// Add click handlers to matches
|
| 66 |
-
el.querySelectorAll('.match-detail').forEach(md=>{md.onclick=function(){const link=this.querySelector('.status a');if(link){const href=link.getAttribute('href')||'';const m=href.match(/\/tran-dau\/(\d+)\//);if(m)openMatch(m[1]);}};});
|
| 67 |
-
}else{el.innerHTML='<div class="loading" style="padding:20px">Không có dữ liệu</div>';}}
|
| 68 |
-
catch(e){el.innerHTML='<div class="loading" style="padding:20px">Lỗi tải</div>';}}
|
| 69 |
setInterval(()=>{if(_lsTab==='live')loadLivescore('live');},60000);
|
| 70 |
-
|
| 71 |
-
async function init(){_cats=await fetch('/api/categories').then(r=>r.json());let bar='<div class="cat active" data-cat="home">🏠</div><div class="cat" data-cat="video">🎬 Video</div>';_cats.forEach(c=>{bar+=`<div class="cat" data-cat="${c.id}">${c.name}</div>`;});document.getElementById('cat-bar').innerHTML=bar;document.querySelectorAll('.cat').forEach(t=>{t.onclick=()=>switchCat(t.dataset.cat);});await loadHome();
|
| 72 |
-
const pendingVideo=localStorage.getItem('pending_video');if(pendingVideo){localStorage.removeItem('pending_video');try{const pv=JSON.parse(pendingVideo);if(pv.url)openTikTokByUrl(pv.url,pv.type||'highlights');}catch(e){}}
|
| 73 |
-
const pending=localStorage.getItem('pending_article');if(pending){localStorage.removeItem('pending_article');readArticle(pending,'vne');}}
|
| 74 |
function switchCat(id){document.querySelectorAll('.cat').forEach(x=>x.classList.remove('active'));document.querySelector(`[data-cat="${id}"]`)?.classList.add('active');document.querySelectorAll('.view').forEach(x=>x.classList.remove('active'));document.querySelectorAll('video').forEach(v=>v.pause());if(id==='home')document.getElementById('view-home').classList.add('active');else if(id==='video'){document.getElementById('view-video').classList.add('active');loadVideos();}else{document.getElementById('view-cat').classList.add('active');loadCat(id);}}
|
| 75 |
function showView(id){document.querySelectorAll('.view').forEach(x=>x.classList.remove('active'));document.getElementById(id).classList.add('active');}
|
| 76 |
async function loadHome(){const[news,hl,sh,dantri,featured]=await Promise.all([fetch('/api/homepage').then(r=>r.json()),fetch('/api/highlights').then(r=>r.json()),fetch('/api/shorts').then(r=>r.json()),fetch('/api/dantri_hot').then(r=>r.json()).catch(()=>[]),fetch('/api/livescore/featured').then(r=>r.json()).catch(()=>null)]);let h='';
|
| 77 |
-
//
|
| 78 |
-
if(featured&&featured.home){const statusClass=featured.status==='live'?'':'upcoming';const statusText=featured.status==='live'?`🔴 ${featured.minute||'LIVE'}`:`⏰ ${featured.time}`;
|
| 79 |
-
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 ${statusClass}">${statusText}</div></div>`;}
|
| 80 |
-
// LIVESCORE SECTION
|
| 81 |
h+=`<div class="ls-section"><div class="ls-header"><h3>⚽ Bóng Đá</h3></div><div class="ls-tabs"><span class="ls-tab active" 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" 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>`;
|
| 82 |
-
// DanTri
|
| 83 |
if(dantri&&dantri.length){h+='<div class="slider-wrap"><div class="slider-header"><span class="slider-label">🔥 Tin Nổi Bật</span></div><div class="slider-track">';dantri.forEach(a=>{h+=`<div class="slider-item" onclick="readArticle('${a.link.replace(/'/g,"\\'")}','dantri')"><div class="slider-thumb">${a.img?`<img src="${a.img}">`:''}</div><div class="slider-title">${a.title}</div></div>`;});h+='</div></div>';}
|
| 84 |
-
//
|
| 85 |
-
if(
|
| 86 |
-
if(
|
| 87 |
-
// News
|
| 88 |
-
const groups={};news.forEach(a=>{if(!groups[a.group])groups[a.group]=[];groups[a.group].push(a);});for(const[g,arts] of Object.entries(groups)){h+=`<div class="section-title">${g}</div><div class="grid">`;arts.slice(0,6).forEach(a=>{const bg=a.source==='bbc'?'badge-bbc':'badge-vne';const lb=a.source==='bbc'?'BBC':'VnE';const aid=hid(a.link);h+=`<div class="card" onclick="readArticle('${a.link.replace(/'/g,"\\'")}','${a.source}')"><div class="card-img">${a.img?`<img src="${a.img}">`:''}</div><div class="card-body"><span class="badge ${bg}">${lb}</span><div class="card-title">${a.title}</div></div></div>`;});h+='</div>';}
|
| 89 |
document.getElementById('view-home').innerHTML=h;loadLivescore('live');}
|
| 90 |
async function loadCat(id){const el=document.getElementById('view-cat');el.innerHTML='<div class="loading">Đang tải...</div>';const arts=await fetch('/api/category/'+id).then(r=>r.json());if(!arts.length){el.innerHTML='<div class="loading">Không có tin</div>';return;}let h='<div class="grid">';arts.forEach(a=>{const bg=a.source==='bbc'?'badge-bbc':'badge-vne';h+=`<div class="card" onclick="readArticle('${a.link.replace(/'/g,"\\'")}','${a.source}')"><div class="card-img">${a.img?`<img src="${a.img}">`:''}</div><div class="card-body"><span class="badge ${bg}">${a.source}</span><div class="card-title">${a.title}</div></div></div>`;});h+='</div>';el.innerHTML=h;}
|
| 91 |
-
async function readArticle(url,source){if(source!=='vne'&&source!=='bbc'&&source!=='dantri'){window.open(url,'_blank');return;}showView('view-article');const el=document.getElementById('view-article');el.innerHTML='<div class="loading">Đang tải...</div>';const
|
| 92 |
-
async function loadVideos(){const el=document.getElementById('view-video');if(el.dataset.loaded)return;el.innerHTML='<div class="loading">Đang tải...</div>';const[hl,bdp]=await Promise.all([fetch('/api/highlights').then(r=>r.json()),fetch('/api/bdp_videos').then(r=>r.json())]);let h='<div class="section-title">🎬 Highlight</div><div class="grid">';hl.forEach((a,i)=>{h+=`<div class="card" onclick="openTikTok('highlights',${i})"><div class="card-img">${a.img?`<img src="${a.img}">`:''}<div class="card-play">▶</div></div><div class="card-body"><span class="badge badge-
|
| 93 |
-
async function openTikTokByUrl(targetUrl,type){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>';let articles;if(type==='shorts')articles=await fetch('/api/shorts').then(r=>r.json());else if(type==='highlights')articles=await fetch('/api/highlights').then(r=>r.json());else articles=await fetch('/api/bdp_videos').then(r=>r.json());let startIdx=0;for(let i=0;i<articles.length;i++){if(articles[i].link===targetUrl){startIdx=i;break;}}await buildTikTokPlayer(articles,startIdx,type);}
|
| 94 |
async function openTikTok(type,startIdx){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>';let articles;if(type==='shorts')articles=await fetch('/api/shorts').then(r=>r.json());else if(type==='highlights')articles=await fetch('/api/highlights').then(r=>r.json());else articles=await fetch('/api/bdp_videos').then(r=>r.json());await buildTikTokPlayer(articles,startIdx,type);}
|
| 95 |
-
async function buildTikTokPlayer(articles,startIdx,type){const el=document.getElementById('view-tiktok');const vids=[];const results=await Promise.all(articles.map(async(a,i)=>{try{const r=await fetch('/api/video_url?url='+encodeURIComponent(a.link));const v=await r.json();if(v&&v.src)return{article:a,video:v,idx:i};}catch(e){}return null;}));results.forEach(r=>{if(!r)return;const{article:a,video:v,idx:i}=r;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
function shareVid(i){const v=_tikData[i];if(!v)return;doShareVideo(v.title,v.link||'',v.poster||v.img||'','highlights');}
|
| 97 |
-
function initFeed(){const feed=document.getElementById('tiktok-feed');if(!feed)return;const slides=feed.querySelectorAll('.tiktok-slide');slides.forEach(sl=>{const v=sl.querySelector('video[data-hls]');if(v&&!v._h){v._h=1;const s=v.dataset.hls;if(v.canPlayType('application/vnd.apple.mpegURL'))v.src=s;else if(Hls.isSupported()){const h=new Hls();h.loadSource(s);h.attachMedia(v);}else v.src=s;}});let cur=-1;function act(idx){if(idx===cur)return;slides.forEach((sl,i)=>{const v=sl.querySelector('video');if(i===idx){v.currentTime=0;v.play().catch(()=>{});}else v.pause();});cur=idx;}let sT;feed.addEventListener('scroll',()=>{clearTimeout(sT);sT=setTimeout(()=>{const rect=feed.getBoundingClientRect();const ctr=rect.top+rect.height/2;let best=-1,bestD=1e9;slides.forEach((sl,i)=>{const d=Math.abs(sl.getBoundingClientRect().top+sl.getBoundingClientRect().height/2-ctr);if(d<bestD){bestD=d;best=i;}});if(best>=0)act(best);},150);});setTimeout(()=>act(0),500);slides.forEach(sl=>{const v=sl.querySelector('video');v.addEventListener('click',e=>{e.preventDefault();v.paused?v.play().catch(()=>{}):v.pause();});});}
|
| 98 |
-
function toggleMute(){const f=document.getElementById('tiktok-feed');if(!f)return;const vs=f.querySelectorAll('video');const m=!vs[0]?.muted;vs.forEach(v=>v.muted=m);f.querySelectorAll('.tiktok-unmute').forEach(b=>b.textContent=m?'🔇':'🔊');}
|
| 99 |
-
function seekV(i,s){const sl=document.getElementById('tslide-'+i);if(sl){const v=sl.querySelector('video');if(v)v.currentTime=Math.max(0,v.currentTime+s);}}
|
| 100 |
init();
|
| 101 |
</script>
|
| 102 |
</body>
|
|
|
|
| 10 |
<link rel="canonical" href="https://bep40-vnews.hf.space">
|
| 11 |
<script src="https://cdn.jsdelivr.net/npm/hls.js@1/dist/hls.min.js"></script>
|
| 12 |
<style>
|
| 13 |
+
*{box-sizing:border-box;margin:0;padding:0}body{background:#111;color:#eee;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;overflow-x:hidden}.header{background:linear-gradient(135deg,#0d1117,#1a3a2a 50%,#8b7500);padding:12px;text-align:center}.header h1{color:#fff;font-size:18px;font-weight:800}.header p{color:rgba(255,255,255,.6);font-size:10px;margin-top:2px}.cats{display:flex;overflow-x:auto;background:#1a1a1a;border-bottom:1px solid #333;padding:0 4px;scrollbar-width:none;position:sticky;top:0;z-index:50}.cats::-webkit-scrollbar{display:none}.cat{padding:9px 11px;color:#888;font-size:11px;cursor:pointer;white-space:nowrap;border-bottom:2px solid transparent;flex-shrink:0}.cat.active{color:#5cb87a;border-bottom-color:#5cb87a;font-weight:600}.view{display:none}.view.active{display:block}.grid{display:grid;grid-template-columns:repeat(2,1fr);gap:6px;padding:6px 4px}@media(min-width:600px){.grid{grid-template-columns:repeat(3,1fr)}}.card{background:#1a1a1a;border-radius:8px;overflow:hidden;cursor:pointer;border:1px solid #222}.card:active{transform:scale(.97)}.card-img{position:relative;width:100%;aspect-ratio:16/9;background:#333;overflow:hidden}.card-img img{width:100%;height:100%;object-fit:cover}.card-play{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:28px;height:28px;background:rgba(0,0,0,.5);border-radius:50%;color:#fff;display:flex;align-items:center;justify-content:center;font-size:11px}.card-body{padding:6px 8px}.card-title{font-size:11px;font-weight:600;color:#eee;line-height:1.3;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.badge{font-size:8px;padding:1px 5px;border-radius:3px;font-weight:700;display:inline-block;margin-bottom:2px}.badge-vne{background:#c0392b;color:#fff}.badge-bbc{background:#b80000;color:#fff}.badge-bdp{background:#1a5c35;color:#fff}.badge-fpt{background:#f26522;color:#fff}.badge-dt{background:#1565c0;color:#fff}.slider-wrap{margin:6px 4px;background:#1a1a1a;border-radius:8px;overflow:hidden;border:1px solid #2a2a2a}.slider-header{padding:7px 10px}.slider-label{color:#f0c040;font-size:13px;font-weight:700}.slider-track{display:flex;overflow-x:auto;gap:8px;padding:4px 10px 10px;scrollbar-width:none}.slider-track::-webkit-scrollbar{display:none}.slider-item{flex:0 0 160px;scroll-snap-align:start;cursor:pointer;flex-shrink:0}.slider-thumb{position:relative;width:100%;aspect-ratio:16/9;border-radius:6px;overflow:hidden;background:#333}.slider-thumb img{width:100%;height:100%;object-fit:cover}.slider-title{color:#ccc;font-size:10px;margin-top:3px;line-height:1.2;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.shorts-item{flex:0 0 110px!important}.shorts-thumb{aspect-ratio:3/4!important;border-radius:8px!important}
|
| 14 |
.featured-match{margin:6px 4px;background:linear-gradient(135deg,#1a2a1f,#0d1117);border-radius:10px;padding:12px;border:1px solid #2d8659;cursor:pointer}.featured-match .fm-league{color:#5cb87a;font-size:9px;font-weight:600;text-transform:uppercase;margin-bottom:6px;text-align:center}.featured-match .fm-teams{display:flex;align-items:center;justify-content:center;gap:10px}.featured-match .fm-team{display:flex;flex-direction:column;align-items:center;gap:4px;flex:1}.featured-match .fm-team img{width:32px;height:32px;object-fit:contain}.featured-match .fm-team span{font-size:10px;color:#ccc;text-align:center}.featured-match .fm-score{font-size:22px;font-weight:900;color:#fff;min-width:60px;text-align:center}.featured-match .fm-status{text-align:center;margin-top:6px;font-size:9px;color:#e74c3c;font-weight:600}.featured-match .fm-status.upcoming{color:#f0c040}
|
| 15 |
+
.ls-section{margin:6px 4px;background:#1a1a1a;border-radius:8px;overflow:hidden;border:1px solid #2a2a2a}.ls-header{padding:8px 10px}.ls-header h3{color:#fff;font-size:13px;font-weight:700}.ls-tabs{display:flex;gap:4px;padding:0 10px 8px;overflow-x:auto;scrollbar-width:none}.ls-tabs::-webkit-scrollbar{display:none}.ls-tab{padding:4px 10px;background:#222;border:1px solid #333;border-radius:12px;color:#999;font-size:10px;cursor:pointer;white-space:nowrap;flex-shrink:0}.ls-tab.active{background:#2d8659;border-color:#2d8659;color:#fff;font-weight:600}.ls-content{max-height:420px;overflow-y:auto;padding:0 6px 8px;scrollbar-width:thin}.ls-content::-webkit-scrollbar{width:3px}.ls-content::-webkit-scrollbar-thumb{background:#333;border-radius:3px}.ls-content .matchs-league{list-style:none}.ls-content .matchs-league>li{margin-bottom:8px}.ls-content .title-content{display:flex;align-items:center;gap:6px;padding:4px 6px;background:#222;border-radius:4px;margin-bottom:4px}.ls-content .title-content img{width:16px;height:16px}.ls-content .title-content strong{color:#eee;font-size:11px}.ls-content .match-detail{padding:5px 6px;border-bottom:1px solid #222;cursor:pointer}.ls-content .match-detail:active{background:#222}.ls-content .match{display:flex;flex-wrap:wrap;align-items:center;gap:4px}.ls-content .datetime{width:100%;display:flex;gap:8px;margin-bottom:2px}.ls-content .datetime .round{color:#666;font-size:9px}.ls-content .datetime .match-time{color:#aaa;font-size:9px}.ls-content .teams{display:flex;align-items:center;gap:4px;width:100%}.ls-content .team{display:flex;align-items:center;gap:4px;flex:1;min-width:0}.ls-content .team .name{font-size:11px;color:#ddd;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.ls-content .team .logo img{width:18px;height:18px;object-fit:contain}.ls-content .home-team{justify-content:flex-end;text-align:right}.ls-content .home-team .name{order:-1}.ls-content .away-team{justify-content:flex-start}.ls-content .status{flex:0 0 50px;text-align:center}.ls-content .status a{text-decoration:none;color:#fff;font-weight:700;font-size:12px}.ls-content .status .label{font-size:8px;display:block;color:#888}.ls-content .status .label.live{color:#e74c3c;font-weight:700}.ls-content .status .vs{color:#888;font-size:11px}.ls-content .status .blink{animation:blink 1s infinite}@keyframes blink{50%{opacity:0}}.ls-content .info,.ls-content .btns{display:none}.ls-content .leaderboard-item{display:flex;align-items:center;padding:5px 6px;border-bottom:1px solid #222;gap:4px}.ls-content .leaderboard-item .team{display:flex;align-items:center;gap:5px;flex:1;min-width:0}.ls-content .leaderboard-item .team span{color:#888;font-size:10px;min-width:16px}.ls-content .leaderboard-item .team .link{display:flex;align-items:center;gap:4px;text-decoration:none}.ls-content .leaderboard-item .team p{color:#ddd;font-size:11px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.ls-content .leaderboard-item .team img{width:16px;height:16px}.ls-content .leaderboard-item .copy{display:flex;gap:6px;font-size:10px;color:#aaa}.ls-content .leaderboard-item .copy p{min-width:16px;text-align:center}.ls-content .leaderboard-item .copy strong{color:#5cb87a}.ls-content .leaderboard-item .copy .form{display:flex;gap:2px}.ls-content .leaderboard-item .copy .form span{width:12px;height:12px;border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:7px;color:#fff;font-weight:700}.ls-content .bg-green{background:#27ae60}.ls-content .bg-red{background:#e74c3c}.ls-content .bg-gray-5{background:#666}
|
|
|
|
|
|
|
| 16 |
.match-overlay{position:fixed;top:0;left:0;right:0;bottom:0;background:#111;z-index:9999;display:none;flex-direction:column;overflow-y:auto}.match-overlay.active{display:flex}.match-overlay .mo-header{padding:10px;background:#1a1a1a;display:flex;justify-content:space-between;align-items:center;position:sticky;top:0;z-index:1}.match-overlay .mo-header h3{color:#fff;font-size:13px}.match-overlay .mo-close{background:none;border:none;color:#fff;font-size:22px;cursor:pointer}.match-overlay .mo-tabs{display:flex;gap:4px;padding:8px 10px;background:#1a1a1a}.match-overlay .mo-tab{padding:5px 12px;background:#222;border:1px solid #333;border-radius:10px;color:#999;font-size:10px;cursor:pointer}.match-overlay .mo-tab.active{background:#2d8659;border-color:#2d8659;color:#fff}.match-overlay .mo-body{padding:8px;flex:1}.match-overlay .mo-body .time{color:#5cb87a;font-weight:700;font-size:11px;margin-right:6px}.match-overlay .mo-body .description{color:#ccc;font-size:12px;line-height:1.4}.match-overlay .mo-body li{list-style:none;padding:6px 0;border-bottom:1px solid #222}.match-overlay .mo-body .professional-table{width:100%;font-size:10px;border-collapse:collapse}.match-overlay .mo-body .professional-table th{color:#888;padding:4px;text-align:left;border-bottom:1px solid #333}.match-overlay .mo-body .professional-table td{color:#ccc;padding:4px;border-bottom:1px solid #1a1a1a}.match-overlay .mo-body .tab-content{display:none}.match-overlay .mo-body .tab-content.active{display:block}
|
| 17 |
.loading{text-align:center;padding:40px;color:#666;font-size:12px}.section-title{font-size:13px;font-weight:700;color:#5cb87a;margin:8px 0 4px;padding-left:8px;border-left:3px solid #5cb87a}.back-btn{background:rgba(17,17,17,.95);color:#fff;border:none;padding:10px;font-size:12px;cursor:pointer;width:100%;text-align:center;position:sticky;top:0;z-index:50}.article-view{padding:12px 8px 40px;max-width:700px;margin:0 auto}.article-title{font-size:18px;font-weight:800;color:#f0f0f0;line-height:1.3;margin-bottom:8px}.article-summary{background:#1a2a1f;border-left:3px solid #2d8659;padding:10px;margin-bottom:14px;font-weight:600;color:#ccc;font-size:13px;border-radius:0 6px 6px 0}.article-p{font-size:14px;line-height:1.7;color:#ccc;margin-bottom:10px}.article-img{width:100%;border-radius:6px;margin:10px 0}.article-h2{font-size:16px;font-weight:700;color:#eee;margin:16px 0 8px}.article-actions{display:flex;gap:10px;padding:10px 0;border-top:1px solid #333;margin-top:16px;flex-wrap:wrap}.article-actions button{background:#1a1a1a;border:1px solid #333;color:#ccc;padding:6px 12px;border-radius:14px;font-size:11px;cursor:pointer}
|
| 18 |
+
.tiktok-container{width:100%;height:80vh;max-height:680px;min-height:400px;background:#000}.tiktok-feed{height:100%;overflow-y:scroll;scroll-snap-type:y mandatory;scrollbar-width:none}.tiktok-feed::-webkit-scrollbar{display:none}.tiktok-slide{height:80vh;max-height:680px;min-height:400px;scroll-snap-align:start;scroll-snap-stop:always;position:relative;background:#000;display:flex;align-items:center;justify-content:center}.tiktok-slide video,.tiktok-slide iframe{width:100%;height:100%;object-fit:cover;border:none}.tiktok-slide.contain-mode video{object-fit:contain}.tiktok-bottom{position:absolute;bottom:0;left:0;right:60px;padding:12px 10px 16px;background:linear-gradient(transparent,rgba(0,0,0,.85));z-index:3}.tiktok-title{color:#fff;font-size:12px;font-weight:600;margin:3px 0 5px;line-height:1.3}.tiktok-counter{position:absolute;top:8px;left:8px;background:rgba(0,0,0,.5);color:#fff;font-size:9px;padding:2px 7px;border-radius:8px;z-index:4}.tiktok-right{position:absolute;right:8px;bottom:100px;display:flex;flex-direction:column;align-items:center;gap:14px;z-index:5}.tiktok-right-btn{display:flex;flex-direction:column;align-items:center;gap:2px;cursor:pointer;background:none;border:none;color:#fff}.tiktok-right-btn .icon{width:42px;height:42px;border-radius:50%;background:rgba(255,255,255,.12);display:flex;align-items:center;justify-content:center;font-size:20px}.topbar{display:flex;justify-content:space-between;padding:6px 8px;color:#555;font-size:10px}a.card-link{text-decoration:none;color:inherit}
|
| 19 |
</style>
|
| 20 |
</head>
|
| 21 |
<body>
|
|
|
|
| 26 |
<div id="view-video" class="view"></div>
|
| 27 |
<div id="view-tiktok" class="view"></div>
|
| 28 |
<div id="view-article" class="view"></div>
|
|
|
|
| 29 |
<div class="match-overlay" id="match-overlay">
|
| 30 |
<div class="mo-header"><h3 id="mo-title">Chi tiết trận đấu</h3><button class="mo-close" onclick="closeMatch()">✕</button></div>
|
| 31 |
<div class="mo-tabs"><span class="mo-tab active" onclick="loadMatchTab('comm')">Diễn biến</span><span class="mo-tab" onclick="loadMatchTab('stats')">Thống kê</span></div>
|
|
|
|
| 37 |
function hid(s){let h=0;for(let i=0;i<s.length;i++){h=((h<<5)-h)+s.charCodeAt(i);h|=0;}return Math.abs(h).toString(36).slice(0,10);}
|
| 38 |
function incV(id){if(_viewed.has(id))return getV(id);_viewed.add(id);let v=(LS.get('v_'+id)||0)+1;LS.set('v_'+id,v);return v;}
|
| 39 |
function getV(id){return LS.get('v_'+id)||0}
|
| 40 |
+
function doShareVideo(title,videoUrl,img,type){const shareUrl=SPACE+'/v?url='+encodeURIComponent(videoUrl)+'&title='+encodeURIComponent(title)+'&img='+encodeURIComponent(img||'')+'&type='+encodeURIComponent(type||'highlights');if(navigator.share)navigator.share({title:'🎬 '+title,url:shareUrl}).catch(()=>{});else navigator.clipboard.writeText(shareUrl).then(()=>alert('Đã sao chép link!')).catch(()=>{});}
|
| 41 |
+
function doShare(title,articleUrl,img){const shareUrl=SPACE+'/s?url='+encodeURIComponent(articleUrl)+'&title='+encodeURIComponent(title)+'&img='+encodeURIComponent(img||'');if(navigator.share)navigator.share({title,url:shareUrl}).catch(()=>{});else navigator.clipboard.writeText(shareUrl).then(()=>alert('Đã sao chép link!')).catch(()=>{});}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
async function openMatch(eventId){if(!eventId)return;_currentEventId=eventId;document.getElementById('match-overlay').classList.add('active');loadMatchTab('comm');}
|
| 43 |
function closeMatch(){document.getElementById('match-overlay').classList.remove('active');}
|
| 44 |
+
async function loadMatchTab(tab){document.querySelectorAll('.mo-tab').forEach(t=>t.classList.remove('active'));document.querySelectorAll('.mo-tab').forEach(t=>{if((tab==='comm'&&t.textContent==='Diễn biến')||(tab==='stats'&&t.textContent==='Thống kê'))t.classList.add('active');});const el=document.getElementById('mo-body');el.innerHTML='<div class="loading">Đang tải...</div>';try{const r=await fetch(tab==='stats'?`/api/match/${_currentEventId}/stats`:`/api/match/${_currentEventId}/commentaries`);const data=await r.json();el.innerHTML=data.html||'<div class="loading">Không có dữ liệu</div>';}catch(e){el.innerHTML='<div class="loading">Lỗi tải</div>';}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
let _lsTab='live';
|
| 46 |
+
async function loadLivescore(tab){_lsTab=tab;document.querySelectorAll('.ls-tab').forEach(t=>t.classList.remove('active'));document.querySelector(`.ls-tab[data-tab="${tab}"]`)?.classList.add('active');const el=document.getElementById('ls-content');el.innerHTML='<div class="loading" style="padding:20px">Đang tải...</div>';let endpoint='/api/livescore/'+tab;if(tab.startsWith('bxh_'))endpoint='/api/livescore/standings/'+tab.replace('bxh_','');try{const r=await fetch(endpoint);const data=await r.json();if(data.html&&data.html.length>50){el.innerHTML=data.html;el.querySelectorAll('.match-detail').forEach(md=>{md.onclick=function(){const link=this.querySelector('.status a');if(link){const href=link.getAttribute('href')||'';const m=href.match(/\/tran-dau\/(\d+)\//);if(m)openMatch(m[1]);}}});}else el.innerHTML='<div class="loading" style="padding:20px">Không có dữ liệu</div>';}catch(e){el.innerHTML='<div class="loading" style="padding:20px">Lỗi tải</div>';}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
setInterval(()=>{if(_lsTab==='live')loadLivescore('live');},60000);
|
| 48 |
+
async function init(){_cats=await fetch('/api/categories').then(r=>r.json());let bar='<div class="cat active" data-cat="home">🏠</div><div class="cat" data-cat="video">🎬 Video</div>';_cats.forEach(c=>{bar+=`<div class="cat" data-cat="${c.id}">${c.name}</div>`;});document.getElementById('cat-bar').innerHTML=bar;document.querySelectorAll('.cat').forEach(t=>{t.onclick=()=>switchCat(t.dataset.cat);});await loadHome();}
|
|
|
|
|
|
|
|
|
|
| 49 |
function switchCat(id){document.querySelectorAll('.cat').forEach(x=>x.classList.remove('active'));document.querySelector(`[data-cat="${id}"]`)?.classList.add('active');document.querySelectorAll('.view').forEach(x=>x.classList.remove('active'));document.querySelectorAll('video').forEach(v=>v.pause());if(id==='home')document.getElementById('view-home').classList.add('active');else if(id==='video'){document.getElementById('view-video').classList.add('active');loadVideos();}else{document.getElementById('view-cat').classList.add('active');loadCat(id);}}
|
| 50 |
function showView(id){document.querySelectorAll('.view').forEach(x=>x.classList.remove('active'));document.getElementById(id).classList.add('active');}
|
| 51 |
async function loadHome(){const[news,hl,sh,dantri,featured]=await Promise.all([fetch('/api/homepage').then(r=>r.json()),fetch('/api/highlights').then(r=>r.json()),fetch('/api/shorts').then(r=>r.json()),fetch('/api/dantri_hot').then(r=>r.json()).catch(()=>[]),fetch('/api/livescore/featured').then(r=>r.json()).catch(()=>null)]);let h='';
|
| 52 |
+
if(featured&&featured.home){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>`;}
|
|
|
|
|
|
|
|
|
|
| 53 |
h+=`<div class="ls-section"><div class="ls-header"><h3>⚽ Bóng Đá</h3></div><div class="ls-tabs"><span class="ls-tab active" 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" 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>`;
|
|
|
|
| 54 |
if(dantri&&dantri.length){h+='<div class="slider-wrap"><div class="slider-header"><span class="slider-label">🔥 Tin Nổi Bật</span></div><div class="slider-track">';dantri.forEach(a=>{h+=`<div class="slider-item" onclick="readArticle('${a.link.replace(/'/g,"\\'")}','dantri')"><div class="slider-thumb">${a.img?`<img src="${a.img}">`:''}</div><div class="slider-title">${a.title}</div></div>`;});h+='</div></div>';}
|
| 55 |
+
if(sh&&sh.length){h+='<div class="slider-wrap"><div class="slider-header"><span class="slider-label">📱 Shorts · FPT Bóng Đá</span></div><div class="slider-track">';sh.forEach((a,i)=>{h+=`<div class="slider-item shorts-item" onclick="openTikTok('shorts',${i})"><div class="slider-thumb shorts-thumb">${a.img?`<img src="${a.img}">`:''}<div class="card-play">▶</div></div><div class="slider-title">${a.title}</div></div>`;});h+='</div></div>';}
|
| 56 |
+
if(hl&&hl.length){h+='<div class="slider-wrap"><div class="slider-header"><span class="slider-label">🎬 Highlight · FPT Bóng Đá</span></div><div class="slider-track">';hl.forEach((a,i)=>{h+=`<div class="slider-item" onclick="openTikTok('highlights',${i})"><div class="slider-thumb">${a.img?`<img src="${a.img}">`:''}<div class="card-play">▶</div></div><div class="slider-title">${a.title}</div></div>`;});h+='</div></div>';}
|
| 57 |
+
const groups={};news.forEach(a=>{if(!groups[a.group])groups[a.group]=[];groups[a.group].push(a);});for(const[g,arts] of Object.entries(groups)){h+=`<div class="section-title">${g}</div><div class="grid">`;arts.slice(0,6).forEach(a=>{const bg=a.source==='bbc'?'badge-bbc':'badge-vne';const lb=a.source==='bbc'?'BBC':'VnE';h+=`<div class="card" onclick="readArticle('${a.link.replace(/'/g,"\\'")}','${a.source}')"><div class="card-img">${a.img?`<img src="${a.img}">`:''}</div><div class="card-body"><span class="badge ${bg}">${lb}</span><div class="card-title">${a.title}</div></div></div>`;});h+='</div>';}
|
|
|
|
|
|
|
| 58 |
document.getElementById('view-home').innerHTML=h;loadLivescore('live');}
|
| 59 |
async function loadCat(id){const el=document.getElementById('view-cat');el.innerHTML='<div class="loading">Đang tải...</div>';const arts=await fetch('/api/category/'+id).then(r=>r.json());if(!arts.length){el.innerHTML='<div class="loading">Không có tin</div>';return;}let h='<div class="grid">';arts.forEach(a=>{const bg=a.source==='bbc'?'badge-bbc':'badge-vne';h+=`<div class="card" onclick="readArticle('${a.link.replace(/'/g,"\\'")}','${a.source}')"><div class="card-img">${a.img?`<img src="${a.img}">`:''}</div><div class="card-body"><span class="badge ${bg}">${a.source}</span><div class="card-title">${a.title}</div></div></div>`;});h+='</div>';el.innerHTML=h;}
|
| 60 |
+
async function readArticle(url,source){if(source!=='vne'&&source!=='bbc'&&source!=='dantri'){window.open(url,'_blank');return;}showView('view-article');const el=document.getElementById('view-article');el.innerHTML='<div class="loading">Đang tải...</div>';const data=await fetch('/api/article?url='+encodeURIComponent(url)).then(r=>r.json());if(!data||data.error||!data.body||!data.body.length){el.innerHTML=`<button class="back-btn" onclick="switchCat('home')">← Quay lại</button><div class="loading"><a href="${url}" target="_blank" style="color:#5cb87a">Mở link gốc</a></div>`;return;}let h=`<button class="back-btn" onclick="switchCat('home')">← Quay lại</button><div class="article-view"><h1 class="article-title">${data.title}</h1>`;if(data.summary)h+=`<div class="article-summary">${data.summary}</div>`;data.body.forEach(b=>{if(b.type==='p')h+=`<p class="article-p">${b.text}</p>`;else if(b.type==='img')h+=`<img class="article-img" src="${b.src}">`;else if(b.type==='heading')h+=`<h2 class="article-h2">${b.text}</h2>`;});h+=`<div class="article-actions"><button onclick="doShare('${data.title.replace(/'/g,"\\'")}','${url.replace(/'/g,"\\'")}','')">📤 Chia sẻ</button><button onclick="window.open('${url}','_blank')">🔗 Gốc</button></div></div>`;el.innerHTML=h;window.scrollTo(0,0);}
|
| 61 |
+
async function loadVideos(){const el=document.getElementById('view-video');if(el.dataset.loaded)return;el.innerHTML='<div class="loading">Đang tải...</div>';const[hl,bdp]=await Promise.all([fetch('/api/highlights').then(r=>r.json()),fetch('/api/bdp_videos').then(r=>r.json())]);let h='<div class="section-title">🎬 Highlight · FPT Bóng Đá</div><div class="grid">';hl.forEach((a,i)=>{h+=`<div class="card" onclick="openTikTok('highlights',${i})"><div class="card-img">${a.img?`<img src="${a.img}">`:''}<div class="card-play">▶</div></div><div class="card-body"><span class="badge badge-fpt">FPT</span><div class="card-title">${a.title}</div></div></div>`;});h+='</div>';if(bdp.length){h+='<div class="section-title">⚽ BDP Video</div><div class="grid">';bdp.forEach((a,i)=>{h+=`<div class="card" onclick="openTikTok('bdp',${i})"><div class="card-img">${a.img?`<img src="${a.img}">`:''}<div class="card-play">▶</div></div><div class="card-body"><span class="badge badge-bdp">BDP</span><div class="card-title">${a.title}</div></div></div>`;});h+='</div>';}el.innerHTML=h;el.dataset.loaded='1';}
|
|
|
|
| 62 |
async function openTikTok(type,startIdx){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>';let articles;if(type==='shorts')articles=await fetch('/api/shorts').then(r=>r.json());else if(type==='highlights')articles=await fetch('/api/highlights').then(r=>r.json());else articles=await fetch('/api/bdp_videos').then(r=>r.json());await buildTikTokPlayer(articles,startIdx,type);}
|
| 63 |
+
async function buildTikTokPlayer(articles,startIdx,type){const el=document.getElementById('view-tiktok');const vids=[];const results=await Promise.all(articles.map(async(a,i)=>{try{const r=await fetch('/api/video_url?url='+encodeURIComponent(a.link));const v=await r.json();if(v&&v.src)return{article:a,video:v,idx:i};}catch(e){}return null;}));results.forEach(r=>{if(!r)return;const{article:a,video:v,idx:i}=r;vids.push({...a,...v,_idx:i,_part:0});});vids.sort((a,b)=>a._idx-b._idx);if(!vids.length){el.innerHTML='<div class="loading">Không tìm thấy video</div>';return;}let ti=vids.findIndex(v=>v._idx===startIdx);if(ti<0)ti=0;const ordered=ti>0?[...vids.slice(ti),...vids.slice(0,ti)]:vids;_tikData=ordered;
|
| 64 |
+
let h=`<button class="back-btn" onclick="switchCat('home')">← Quay lại</button><div class="tiktok-container"><div class="tiktok-feed" id="tiktok-feed">`;
|
| 65 |
+
ordered.forEach((v,i)=>{
|
| 66 |
+
const isYT=v.type==='youtube';
|
| 67 |
+
const isHLS=!isYT&&v.src.includes('.m3u8');
|
| 68 |
+
const poster=v.poster?` poster="${v.poster}"`:'';
|
| 69 |
+
const vtag=isYT
|
| 70 |
+
?`<iframe src="${v.src}" allowfullscreen allow="accelerometer;autoplay;clipboard-write;encrypted-media;gyroscope;picture-in-picture"></iframe>`
|
| 71 |
+
:isHLS?`<video playsinline preload="metadata"${poster} data-hls="${v.src}" muted loop></video>`
|
| 72 |
+
:`<video playsinline preload="metadata"${poster} muted loop><source src="${v.src}" type="video/mp4"></video>`;
|
| 73 |
+
h+=`<div class="tiktok-slide" id="tslide-${i}" data-type="${type}">${vtag}<div class="tiktok-bottom"><span class="badge badge-fpt">FPT</span><p class="tiktok-title">${v.title}</p></div><div class="tiktok-right"><button class="tiktok-right-btn" onclick="event.stopPropagation();shareVid(${i})"><div class="icon">📤</div></button></div><span class="tiktok-counter">${i+1}/${ordered.length}</span></div>`;});
|
| 74 |
+
h+='</div></div>';el.innerHTML=h;initFeed();}
|
| 75 |
function shareVid(i){const v=_tikData[i];if(!v)return;doShareVideo(v.title,v.link||'',v.poster||v.img||'','highlights');}
|
| 76 |
+
function initFeed(){const feed=document.getElementById('tiktok-feed');if(!feed)return;const slides=feed.querySelectorAll('.tiktok-slide');slides.forEach(sl=>{const v=sl.querySelector('video[data-hls]');if(v&&!v._h){v._h=1;const s=v.dataset.hls;if(v.canPlayType('application/vnd.apple.mpegURL'))v.src=s;else if(Hls.isSupported()){const h=new Hls();h.loadSource(s);h.attachMedia(v);}else v.src=s;}});let cur=-1;function act(idx){if(idx===cur)return;slides.forEach((sl,i)=>{const v=sl.querySelector('video');if(v){if(i===idx){v.currentTime=0;v.play().catch(()=>{});}else v.pause();}});cur=idx;}let sT;feed.addEventListener('scroll',()=>{clearTimeout(sT);sT=setTimeout(()=>{const rect=feed.getBoundingClientRect();const ctr=rect.top+rect.height/2;let best=-1,bestD=1e9;slides.forEach((sl,i)=>{const d=Math.abs(sl.getBoundingClientRect().top+sl.getBoundingClientRect().height/2-ctr);if(d<bestD){bestD=d;best=i;}});if(best>=0)act(best);},150);});setTimeout(()=>act(0),500);slides.forEach(sl=>{const v=sl.querySelector('video');if(v)v.addEventListener('click',e=>{e.preventDefault();v.paused?v.play().catch(()=>{}):v.pause();});});}
|
|
|
|
|
|
|
| 77 |
init();
|
| 78 |
</script>
|
| 79 |
</body>
|