bep40 commited on
Commit
c05e0be
·
verified ·
1 Parent(s): ecfd19f

Upload static/wc2026_v2.js with huggingface_hub

Browse files
Files changed (1) hide show
  1. static/wc2026_v2.js +39 -7
static/wc2026_v2.js CHANGED
@@ -114,11 +114,12 @@ async function renderWCHighlights(el){
114
  el.innerHTML='<div class="loading">Đang tải highlight World Cup...</div>';
115
  try{
116
  // Use new WC highlights API (from xemlaibongda.top JSON API)
117
- const[wc,fr]=await Promise.all([
118
  fetch('/api/wc2026/highlights').then(r=>r.json()).catch(()=>[]),
119
  fetch('/api/highlights/friendly').then(r=>r.json()).catch(()=>[])
120
  ]);
121
- const wcArr = Array.isArray(wc)?wc:[];
 
122
  const frArr = Array.isArray(fr)?fr:[];
123
  const all=[...wcArr.map((v,j)=>({...v,_league:'WC',_li:j})),...frArr.map((v,j)=>({...v,_league:'Friendly',_li:j}))];
124
  if(!all.length){el.innerHTML='<div class="loading">Chưa có highlight World Cup</div>';return;}
@@ -127,16 +128,47 @@ async function renderWCHighlights(el){
127
  all.slice(0,30).forEach((v,i)=>{
128
  const league=v._league==='WC'?'world-cup':'friendly';
129
  const badge=v._league==='WC'?'🌍 WC':'🤝';
130
- const clickUrl = v.link || (v.src ? v.src : '');
131
- h+=`<div style="cursor:pointer;border-radius:6px;overflow:hidden;background:#0a1520" onclick="openHighlightFeed('${league}',${v._li},'${esc(clickUrl)}')">`;
132
- h+=`<div style="position:relative;aspect-ratio:16/9;background:#1a2a3a">${v.img?`<img src="${esc(v.img)}" style="width:100%;height:100%;object-fit:cover">`:''}<div class="card-play">▶</div></div>`;
133
- h+=`<div style="padding:4px 6px"><span style="font-size:8px;color:#f0c040">${badge}</span><div style="font-size:10px;color:#ccc;line-height:1.2;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden">${esc(v.title)}</div></div>`;
 
 
 
134
  h+='</div>';
135
  });
136
- h+='</div>';el.innerHTML=h;
 
 
 
137
  }catch(e){el.innerHTML='<div class="loading">Lỗi tải highlight</div>';}
138
  }
139
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
140
  // === LIVE AUTO-REFRESH (90s) ===
141
  function startWCLiveRefresh(){
142
  if(_wcRefreshInterval)clearInterval(_wcRefreshInterval);
 
114
  el.innerHTML='<div class="loading">Đang tải highlight World Cup...</div>';
115
  try{
116
  // Use new WC highlights API (from xemlaibongda.top JSON API)
117
+ const[wcRaw,fr]=await Promise.all([
118
  fetch('/api/wc2026/highlights').then(r=>r.json()).catch(()=>[]),
119
  fetch('/api/highlights/friendly').then(r=>r.json()).catch(()=>[])
120
  ]);
121
+ // The API returns {success, data, pagination, context}
122
+ const wcArr = Array.isArray(wcRaw)?wcRaw:(wcRaw && wcRaw.data ? wcRaw.data : []);
123
  const frArr = Array.isArray(fr)?fr:[];
124
  const all=[...wcArr.map((v,j)=>({...v,_league:'WC',_li:j})),...frArr.map((v,j)=>({...v,_league:'Friendly',_li:j}))];
125
  if(!all.length){el.innerHTML='<div class="loading">Chưa có highlight World Cup</div>';return;}
 
128
  all.slice(0,30).forEach((v,i)=>{
129
  const league=v._league==='WC'?'world-cup':'friendly';
130
  const badge=v._league==='WC'?'🌍 WC':'🤝';
131
+ const clickUrl = v.src || v.link || '';
132
+ const thumb = v.img || v.thumbnail_url || '';
133
+ const dt = v.date || '';
134
+ const title = v.title || '';
135
+ h+=`<div style="cursor:pointer;border-radius:6px;overflow:hidden;background:#0a1520" onclick="openWCHighlight(${i})">`;
136
+ h+=`<div style="position:relative;aspect-ratio:16/9;background:#1a2a3a">${thumb?`<img src="${esc(thumb)}" style="width:100%;height:100%;object-fit:cover" onerror="this.style.display='none'">`:''}<div class="card-play">▶</div>${dt?`<div style="position:absolute;bottom:4px;left:4px;background:rgba(0,0,0,.7);color:#fff;font-size:8px;padding:1px 4px;border-radius:3px">${esc(dt)}</div>`:''}</div>`;
137
+ h+=`<div style="padding:4px 6px"><span style="font-size:8px;color:#f0c040">${badge}</span><div style="font-size:10px;color:#ccc;line-height:1.2;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden">${esc(title)}</div></div>`;
138
  h+='</div>';
139
  });
140
+ h+='</div>';
141
+ // Store WC data globally for openWCHighlight to access
142
+ _wcHighlights = all;
143
+ el.innerHTML=h;
144
  }catch(e){el.innerHTML='<div class="loading">Lỗi tải highlight</div>';}
145
  }
146
 
147
+ // === OPEN WC HIGHLIGHT DIRECTLY (skip /api/video_url) ===
148
+ let _wcHighlights = [];
149
+ function openWCHighlight(idx){
150
+ const v = _wcHighlights[idx];
151
+ if(!v) return;
152
+ showView('view-tiktok');
153
+ const el = document.getElementById('view-tiktok');
154
+ const ordered = [..._wcHighlights.slice(idx), ..._wcHighlights.slice(0, idx)];
155
+ let h=`<button class="back-btn" onclick="switchCat('home')">← World Cup Highlights</button><div class="tiktok-container"><div class="tiktok-feed" id="tiktok-feed">`;
156
+ ordered.forEach((vv,i)=>{
157
+ const src = vv.src || vv.link || '';
158
+ const isHLS = src.includes('.m3u8');
159
+ const thumb = vv.img || vv.thumbnail_url || '';
160
+ const poster = thumb ? ` poster="${esc(thumb)}"` : '';
161
+ const vtag = isHLS ? `<video playsinline preload="none"${poster} data-hls="${esc(src)}" loop controls></video>` : `<video playsinline preload="none"${poster} loop controls><source src="${esc(src)}" type="video/mp4"></video>`;
162
+ const badge = vv._league==='WC'?'🌍 WC':'🤝';
163
+ const dt = vv.date||'';
164
+ const shareUrl = vv.link || vv.src || '';
165
+ h += buildTikTokSlide({vtag,title:vv.title||'',badge,badgeClass:'badge-fpt',videoId:'wc-'+i,idx:i,total:ordered.length,shareUrl});
166
+ });
167
+ h+='</div></div>';
168
+ el.innerHTML=h;
169
+ initTikTokFeed();
170
+ }
171
+
172
  // === LIVE AUTO-REFRESH (90s) ===
173
  function startWCLiveRefresh(){
174
  if(_wcRefreshInterval)clearInterval(_wcRefreshInterval);