Spaces:
Running
Running
Update wc2026_v2.js: fixtures now returns html from dantri (not infographic images)"
Browse files- static/wc2026_v2.js +38 -70
static/wc2026_v2.js
CHANGED
|
@@ -1,36 +1,35 @@
|
|
| 1 |
// === WORLD CUP 2026 - Render + LIVE refresh ===
|
|
|
|
| 2 |
|
| 3 |
let _wc2026Data = null;
|
| 4 |
let _wcRefreshInterval = null;
|
| 5 |
|
| 6 |
-
const
|
| 7 |
.wc-bongda-content{font-size:12px;color:#ddd;max-height:450px;overflow-y:auto;padding:4px}
|
| 8 |
-
.wc-bongda-content *{color:#ddd!important;border-color:#1a3a5a!important}
|
|
|
|
| 9 |
.wc-bongda-content table{width:100%;border-collapse:collapse;font-size:11px}
|
| 10 |
-
.wc-bongda-content th{background:#0d1a2a!important;color:#6a9fca!important;padding:6px 4px;font-size:10px}
|
| 11 |
.wc-bongda-content td{padding:5px 4px;border-bottom:1px solid #0d1a2a!important}
|
| 12 |
-
.wc-bongda-content tr:hover{background:#0d1a2a!important}
|
| 13 |
-
.wc-bongda-content img{width:
|
| 14 |
.wc-bongda-content ul{list-style:none;padding:0;margin:0}
|
| 15 |
-
.wc-bongda-content li{padding:6px;border-bottom:1px solid #1a2a3a}
|
| 16 |
-
.wc-bongda-content
|
| 17 |
-
.wc-bongda-content .
|
| 18 |
-
.wc-bongda-content strong{color:#f0c040!important}
|
| 19 |
-
.wc-
|
| 20 |
-
.wc-
|
| 21 |
-
.wc-
|
| 22 |
-
.wc-
|
| 23 |
-
.wc-
|
| 24 |
-
.wc-
|
| 25 |
-
.wc-
|
| 26 |
-
.wc-
|
| 27 |
-
.wc-
|
| 28 |
-
.wc-
|
| 29 |
-
.wc-
|
| 30 |
-
.wc-
|
| 31 |
-
.wc-fix-table .td-venue{color:#777;font-size:9px;max-width:80px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
| 32 |
-
.wc-fix-table .td-score{background:#1a3a1f;color:#5cb87a;font-weight:900;border-radius:4px;padding:2px 6px}
|
| 33 |
-
.wc-fix-empty{text-align:center;padding:30px;color:#6a9fca;font-size:12px}
|
| 34 |
</style>`;
|
| 35 |
|
| 36 |
function switchWCTab(tab) {
|
|
@@ -51,6 +50,17 @@ function switchWCTab(tab) {
|
|
| 51 |
else if (tab === 'stats') renderWCStats(el);
|
| 52 |
}
|
| 53 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
function renderWCNews(el) {
|
| 55 |
const news = _wc2026Data.news || [];
|
| 56 |
const road = _wc2026Data.road || [];
|
|
@@ -60,7 +70,7 @@ function renderWCNews(el) {
|
|
| 60 |
if (ni < news.length) combined.push({...news[ni++], _type: 'news'});
|
| 61 |
if (ri < road.length) combined.push({...road[ri++], _type: 'road'});
|
| 62 |
}
|
| 63 |
-
if (!combined.length) { el.innerHTML = '<div class="loading">Đang cập nhật...</div>'; return; }
|
| 64 |
let h = '<div class="wc-news-grid">';
|
| 65 |
combined.slice(0, 20).forEach(a => {
|
| 66 |
const badge = a._type === 'road' ? '<span class="badge badge-wc">Đường tới WC</span>' : '<span class="badge badge-fpt">Tin WC</span>';
|
|
@@ -73,57 +83,15 @@ function renderWCNews(el) {
|
|
| 73 |
}
|
| 74 |
|
| 75 |
function renderWCFixtures(el) {
|
| 76 |
-
|
| 77 |
-
const groups = d.groups || [];
|
| 78 |
-
|
| 79 |
-
if (!groups.length) {
|
| 80 |
-
el.innerHTML = WC_CSS + '<div class="wc-fix-empty">⏳ Đang cập nhật lịch thi đấu World Cup 2026...<br><small>Giải khởi tranh 11/06/2026 • 104 trận</small></div>';
|
| 81 |
-
return;
|
| 82 |
-
}
|
| 83 |
-
|
| 84 |
-
let h = WC_CSS + '<div class="wc-fix-scroll">';
|
| 85 |
-
groups.forEach(g => {
|
| 86 |
-
h += '<div class="wc-fix-group">';
|
| 87 |
-
h += `<div class="wc-fix-group-header">🏆 ${esc(g.group)}</div>`;
|
| 88 |
-
h += '<table class="wc-fix-table"><thead><tr><th>Ngày</th><th>Giờ</th><th colspan="3">Trận đấu</th><th>Sân</th></tr></thead><tbody>';
|
| 89 |
-
(g.matches || []).forEach(m => {
|
| 90 |
-
const scoreCell = m.score && m.score !== 'vs' && m.score !== ''
|
| 91 |
-
? `<td class="td-vs"><span class="td-score">${esc(m.score)}</span></td>`
|
| 92 |
-
: '<td class="td-vs">vs</td>';
|
| 93 |
-
h += `<tr>
|
| 94 |
-
<td class="td-date">${esc(m.date)}</td>
|
| 95 |
-
<td class="td-time">${esc(m.time)}</td>
|
| 96 |
-
<td class="td-home">${esc(m.home)}</td>
|
| 97 |
-
${scoreCell}
|
| 98 |
-
<td class="td-away">${esc(m.away)}</td>
|
| 99 |
-
<td class="td-venue">${esc(m.venue || '')}</td>
|
| 100 |
-
</tr>`;
|
| 101 |
-
});
|
| 102 |
-
h += '</tbody></table></div>';
|
| 103 |
-
});
|
| 104 |
-
h += `<div style="text-align:center;padding:8px;font-size:9px;color:#555">Nguồn: Tiền Phong • Tổng: ${d.total_matches || 0} trận</div>`;
|
| 105 |
-
h += '</div>';
|
| 106 |
-
el.innerHTML = h;
|
| 107 |
}
|
| 108 |
|
| 109 |
function renderWCStandings(el) {
|
| 110 |
-
|
| 111 |
-
if (d.html && d.html.length > 50) {
|
| 112 |
-
el.innerHTML = WC_CSS + '<div class="wc-bongda-content">' + d.html + '</div>';
|
| 113 |
-
el.querySelectorAll('a').forEach(a => a.addEventListener('click', e => e.preventDefault()));
|
| 114 |
-
} else {
|
| 115 |
-
el.innerHTML = WC_CSS + '<div class="wc-fix-empty">⏳ Chưa có BXH World Cup 2026<br><small>Giải khởi tranh 11/06/2026</small></div>';
|
| 116 |
-
}
|
| 117 |
}
|
| 118 |
|
| 119 |
function renderWCStats(el) {
|
| 120 |
-
|
| 121 |
-
if (d.html && d.html.length > 50) {
|
| 122 |
-
el.innerHTML = WC_CSS + '<div class="wc-bongda-content">' + d.html + '</div>';
|
| 123 |
-
el.querySelectorAll('a').forEach(a => a.addEventListener('click', e => e.preventDefault()));
|
| 124 |
-
} else {
|
| 125 |
-
el.innerHTML = WC_CSS + '<div class="wc-fix-empty">⏳ Chưa có thống kê World Cup 2026<br><small>Giải khởi tranh 11/06/2026</small></div>';
|
| 126 |
-
}
|
| 127 |
}
|
| 128 |
|
| 129 |
// === LIVE AUTO-REFRESH ===
|
|
|
|
| 1 |
// === WORLD CUP 2026 - Render + LIVE refresh ===
|
| 2 |
+
// Fixtures + BXH from dantri.com.vn/the-thao/world-cup/
|
| 3 |
|
| 4 |
let _wc2026Data = null;
|
| 5 |
let _wcRefreshInterval = null;
|
| 6 |
|
| 7 |
+
const WC_INLINE_CSS = `<style>
|
| 8 |
.wc-bongda-content{font-size:12px;color:#ddd;max-height:450px;overflow-y:auto;padding:4px}
|
| 9 |
+
.wc-bongda-content,.wc-bongda-content *{color:#ddd!important;border-color:#1a3a5a!important;background-color:transparent!important}
|
| 10 |
+
.wc-bongda-content a{color:#8ab4d8!important;text-decoration:none!important}
|
| 11 |
.wc-bongda-content table{width:100%;border-collapse:collapse;font-size:11px}
|
| 12 |
+
.wc-bongda-content th{background:#0d1a2a!important;color:#6a9fca!important;padding:6px 4px;font-size:10px;text-align:left}
|
| 13 |
.wc-bongda-content td{padding:5px 4px;border-bottom:1px solid #0d1a2a!important}
|
| 14 |
+
.wc-bongda-content tr:hover td{background:#0d1a2a!important}
|
| 15 |
+
.wc-bongda-content img{width:20px;height:20px;vertical-align:middle;margin:0 3px}
|
| 16 |
.wc-bongda-content ul{list-style:none;padding:0;margin:0}
|
| 17 |
+
.wc-bongda-content li{padding:6px 4px;border-bottom:1px solid #1a2a3a}
|
| 18 |
+
.wc-bongda-content li:hover{background:#0d1a2a!important}
|
| 19 |
+
.wc-bongda-content h1,.wc-bongda-content h2,.wc-bongda-content h3,.wc-bongda-content h4{color:#8ab4d8!important;font-size:13px;padding:8px 0 4px;margin:0;border-bottom:1px solid #1a3a5a}
|
| 20 |
+
.wc-bongda-content strong,.wc-bongda-content b{color:#f0c040!important}
|
| 21 |
+
.wc-bongda-content .match-detail{padding:6px;border-bottom:1px solid #1a2a3a;cursor:pointer}
|
| 22 |
+
.wc-bongda-content .match-detail:hover{background:#0d1a2a!important}
|
| 23 |
+
.wc-bongda-content .title-content{display:flex;gap:6px;align-items:center;background:#0d1a2a!important;border-radius:4px;margin:4px 0;padding:5px 8px}
|
| 24 |
+
.wc-bongda-content .title-content strong{font-size:11px;color:#8ab4d8!important}
|
| 25 |
+
.wc-bongda-content .teams{display:flex;width:100%;align-items:center;gap:4px}
|
| 26 |
+
.wc-bongda-content .team{flex:1;display:flex;align-items:center;gap:4px;min-width:0}
|
| 27 |
+
.wc-bongda-content .team .name{font-size:11px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
| 28 |
+
.wc-bongda-content .home-team{justify-content:flex-end;text-align:right}
|
| 29 |
+
.wc-bongda-content .status{flex:0 0 50px;text-align:center}
|
| 30 |
+
.wc-bongda-content .status a{font-weight:800;font-size:12px}
|
| 31 |
+
.wc-bongda-content .info,.wc-bongda-content .btns,.wc-bongda-content .ads,.wc-bongda-content .banner{display:none!important}
|
| 32 |
+
.wc-bongda-content p{margin:4px 0;line-height:1.4}
|
|
|
|
|
|
|
|
|
|
| 33 |
</style>`;
|
| 34 |
|
| 35 |
function switchWCTab(tab) {
|
|
|
|
| 50 |
else if (tab === 'stats') renderWCStats(el);
|
| 51 |
}
|
| 52 |
|
| 53 |
+
function _wcRenderHTML(el, data, emptyMsg) {
|
| 54 |
+
const html = data?.html || '';
|
| 55 |
+
if (html && html.length > 100) {
|
| 56 |
+
el.innerHTML = WC_INLINE_CSS + '<div class="wc-bongda-content">' + html + '</div>';
|
| 57 |
+
// Disable navigation links
|
| 58 |
+
el.querySelectorAll('a').forEach(a => a.addEventListener('click', e => e.preventDefault()));
|
| 59 |
+
} else {
|
| 60 |
+
el.innerHTML = `<div class="loading">${emptyMsg}<br><small style="color:#6a9fca">Nguồn: dantri.com.vn</small></div>`;
|
| 61 |
+
}
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
function renderWCNews(el) {
|
| 65 |
const news = _wc2026Data.news || [];
|
| 66 |
const road = _wc2026Data.road || [];
|
|
|
|
| 70 |
if (ni < news.length) combined.push({...news[ni++], _type: 'news'});
|
| 71 |
if (ri < road.length) combined.push({...road[ri++], _type: 'road'});
|
| 72 |
}
|
| 73 |
+
if (!combined.length) { el.innerHTML = '<div class="loading">Đang cập nhật tin tức...</div>'; return; }
|
| 74 |
let h = '<div class="wc-news-grid">';
|
| 75 |
combined.slice(0, 20).forEach(a => {
|
| 76 |
const badge = a._type === 'road' ? '<span class="badge badge-wc">Đường tới WC</span>' : '<span class="badge badge-fpt">Tin WC</span>';
|
|
|
|
| 83 |
}
|
| 84 |
|
| 85 |
function renderWCFixtures(el) {
|
| 86 |
+
_wcRenderHTML(el, _wc2026Data.fixtures, 'Đang tải lịch thi đấu World Cup 2026...');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
}
|
| 88 |
|
| 89 |
function renderWCStandings(el) {
|
| 90 |
+
_wcRenderHTML(el, _wc2026Data.standings, 'Đang tải BXH World Cup 2026...');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
}
|
| 92 |
|
| 93 |
function renderWCStats(el) {
|
| 94 |
+
_wcRenderHTML(el, _wc2026Data.stats, 'Chưa có thống kê World Cup 2026');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
}
|
| 96 |
|
| 97 |
// === LIVE AUTO-REFRESH ===
|