Spaces:
Running
Running
Fix wc2026_v2.js: render fixtures as infographic images (from tienphong.vn)"
Browse files- static/wc2026_v2.js +32 -43
static/wc2026_v2.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
| 1 |
-
// === WORLD CUP 2026 - Render
|
| 2 |
-
// Fixtures rendered from structured JSON (no raw HTML = no broken fonts/CSS)
|
| 3 |
-
// BXH/Stats still use bongda.com.vn pre-rendered HTML (with inline CSS override)
|
| 4 |
|
| 5 |
let _wc2026Data = null;
|
| 6 |
let _wcRefreshInterval = null;
|
| 7 |
|
| 8 |
-
const
|
| 9 |
-
.wc-bongda-content{font-size:12px;color:#ddd;max-height:
|
| 10 |
.wc-bongda-content *{color:#ddd!important;border-color:#1a3a5a!important}
|
| 11 |
.wc-bongda-content a{color:#8ab4d8!important;text-decoration:none!important}
|
| 12 |
.wc-bongda-content table{width:100%;border-collapse:collapse;font-size:11px;background:transparent!important}
|
|
@@ -17,17 +15,19 @@ const WC_CSS = `<style>
|
|
| 17 |
.wc-bongda-content ul{list-style:none;padding:0;margin:0}
|
| 18 |
.wc-bongda-content li{padding:6px;border-bottom:1px solid #1a2a3a}
|
| 19 |
.wc-bongda-content .title-content{display:flex;gap:6px;align-items:center;background:#0d1a2a;border-radius:4px;margin:4px 0;padding:5px 8px}
|
| 20 |
-
.wc-bongda-content .title-content strong{color:#8ab4d8!important}
|
| 21 |
-
.wc-bongda-content .match-
|
| 22 |
-
.wc-bongda-content .
|
| 23 |
-
.wc-bongda-content .teams{display:flex;width:100%;align-items:center;gap:4px}
|
| 24 |
-
.wc-bongda-content .team{flex:1;display:flex;align-items:center;gap:4px}
|
| 25 |
.wc-bongda-content .team .name{font-size:11px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
| 26 |
.wc-bongda-content .home-team{justify-content:flex-end;text-align:right}
|
| 27 |
.wc-bongda-content .status{flex:0 0 54px;text-align:center}
|
| 28 |
-
.wc-bongda-content .status a{font-weight:800;font-size:12px
|
| 29 |
.wc-bongda-content .info,.wc-bongda-content .btns{display:none!important}
|
| 30 |
-
.wc-bongda-content strong{color:#f0c040!important}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
</style>`;
|
| 32 |
|
| 33 |
function switchWCTab(tab) {
|
|
@@ -57,7 +57,7 @@ function renderWCNews(el) {
|
|
| 57 |
if (ni < news.length) combined.push({...news[ni++], _type: 'news'});
|
| 58 |
if (ri < road.length) combined.push({...road[ri++], _type: 'road'});
|
| 59 |
}
|
| 60 |
-
if (!combined.length) { el.innerHTML = '<div class="loading">Đang cập nhật...</div>'; return; }
|
| 61 |
let h = '<div class="wc-news-grid">';
|
| 62 |
combined.slice(0, 20).forEach(a => {
|
| 63 |
const badge = a._type === 'road' ? '<span class="badge badge-wc">Đường tới WC</span>' : '<span class="badge badge-fpt">Tin WC</span>';
|
|
@@ -71,39 +71,29 @@ function renderWCNews(el) {
|
|
| 71 |
|
| 72 |
function renderWCFixtures(el) {
|
| 73 |
const d = _wc2026Data.fixtures || {};
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
el.innerHTML = '<div class="loading">Chưa có lịch thi đấu World Cup 2026<br><small style="color:#6a9fca">Giải khởi tranh 11/06/2026</small></div>';
|
| 78 |
-
return;
|
| 79 |
}
|
| 80 |
-
|
| 81 |
-
// Render matches with own CSS (no external fonts)
|
| 82 |
-
let h = '<div style="max-height:400px;overflow-y:auto">';
|
| 83 |
-
let currentGroup = '';
|
| 84 |
-
matches.forEach(m => {
|
| 85 |
-
if (m.group && m.group !== currentGroup) {
|
| 86 |
-
currentGroup = m.group;
|
| 87 |
-
h += `<div style="font-size:11px;font-weight:800;color:#8ab4d8;padding:8px 0 4px;border-bottom:1px solid #1a3a5a;margin-top:6px">${esc(m.group)}</div>`;
|
| 88 |
-
}
|
| 89 |
-
const isLive = (m.score || '').includes('-') && m.score !== 'vs';
|
| 90 |
-
h += `<div style="display:flex;align-items:center;padding:8px 4px;border-bottom:1px solid #0d1a2a;${isLive?'background:#0d1520;':''}">`;
|
| 91 |
-
h += `<div style="flex:1;text-align:right;font-size:11px;color:#eee;padding-right:6px">${esc(m.home)}</div>`;
|
| 92 |
-
h += `<div style="min-width:50px;text-align:center;font-weight:900;font-size:12px;color:${isLive?'#f0c040':'#fff'};background:#1a2a3a;border-radius:4px;padding:3px 6px">${esc(m.score || 'vs')}</div>`;
|
| 93 |
-
h += `<div style="flex:1;font-size:11px;color:#eee;padding-left:6px">${esc(m.away)}</div>`;
|
| 94 |
-
if (m.time) h += `<div style="font-size:9px;color:#6a9fca;min-width:60px;text-align:right">${esc(m.time)}</div>`;
|
| 95 |
-
h += '</div>';
|
| 96 |
-
});
|
| 97 |
-
h += '</div>';
|
| 98 |
-
h += `<div style="font-size:9px;color:#555;padding:6px;text-align:center">Nguồn: ${esc(d.source || 'vietnamnet/thethaovanhoa')}</div>`;
|
| 99 |
-
el.innerHTML = h;
|
| 100 |
}
|
| 101 |
|
| 102 |
function renderWCStandings(el) {
|
| 103 |
const d = _wc2026Data.standings || {};
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
el.innerHTML = WC_CSS + '<div class="wc-bongda-content">' + html + '</div>';
|
| 107 |
el.querySelectorAll('a').forEach(a => a.addEventListener('click', e => e.preventDefault()));
|
| 108 |
} else {
|
| 109 |
el.innerHTML = '<div class="loading">Chưa có BXH World Cup 2026<br><small style="color:#6a9fca">Giải khởi tranh 11/06/2026</small></div>';
|
|
@@ -112,9 +102,8 @@ function renderWCStandings(el) {
|
|
| 112 |
|
| 113 |
function renderWCStats(el) {
|
| 114 |
const d = _wc2026Data.stats || {};
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
el.innerHTML = WC_CSS + '<div class="wc-bongda-content">' + html + '</div>';
|
| 118 |
el.querySelectorAll('a').forEach(a => a.addEventListener('click', e => e.preventDefault()));
|
| 119 |
} else {
|
| 120 |
el.innerHTML = '<div class="loading">Chưa có thống kê World Cup 2026<br><small style="color:#6a9fca">Giải khởi tranh 11/06/2026</small></div>';
|
|
|
|
| 1 |
+
// === WORLD CUP 2026 - Render + LIVE refresh ===
|
|
|
|
|
|
|
| 2 |
|
| 3 |
let _wc2026Data = null;
|
| 4 |
let _wcRefreshInterval = null;
|
| 5 |
|
| 6 |
+
const WC_INLINE_CSS = `<style>
|
| 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 a{color:#8ab4d8!important;text-decoration:none!important}
|
| 10 |
.wc-bongda-content table{width:100%;border-collapse:collapse;font-size:11px;background:transparent!important}
|
|
|
|
| 15 |
.wc-bongda-content ul{list-style:none;padding:0;margin:0}
|
| 16 |
.wc-bongda-content li{padding:6px;border-bottom:1px solid #1a2a3a}
|
| 17 |
.wc-bongda-content .title-content{display:flex;gap:6px;align-items:center;background:#0d1a2a;border-radius:4px;margin:4px 0;padding:5px 8px}
|
| 18 |
+
.wc-bongda-content .title-content strong{font-size:11px;color:#8ab4d8!important}
|
| 19 |
+
.wc-bongda-content .match,.wc-bongda-content .teams{display:flex;align-items:center;gap:4px}
|
| 20 |
+
.wc-bongda-content .team{flex:1;display:flex;align-items:center;gap:4px;min-width:0}
|
|
|
|
|
|
|
| 21 |
.wc-bongda-content .team .name{font-size:11px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
| 22 |
.wc-bongda-content .home-team{justify-content:flex-end;text-align:right}
|
| 23 |
.wc-bongda-content .status{flex:0 0 54px;text-align:center}
|
| 24 |
+
.wc-bongda-content .status a{font-weight:800;font-size:12px}
|
| 25 |
.wc-bongda-content .info,.wc-bongda-content .btns{display:none!important}
|
| 26 |
+
.wc-bongda-content strong,.wc-bongda-content b{color:#f0c040!important}
|
| 27 |
+
.wc-bongda-content h3,.wc-bongda-content h4{color:#8ab4d8!important;font-size:12px;padding:6px 0}
|
| 28 |
+
.wc-fixtures-images{display:flex;flex-direction:column;gap:8px;max-height:450px;overflow-y:auto;padding:4px}
|
| 29 |
+
.wc-fixtures-images img{width:100%;border-radius:6px;display:block}
|
| 30 |
+
.wc-fixtures-images .wc-img-caption{font-size:10px;color:#6a9fca;text-align:center;padding:2px 0}
|
| 31 |
</style>`;
|
| 32 |
|
| 33 |
function switchWCTab(tab) {
|
|
|
|
| 57 |
if (ni < news.length) combined.push({...news[ni++], _type: 'news'});
|
| 58 |
if (ri < road.length) combined.push({...road[ri++], _type: 'road'});
|
| 59 |
}
|
| 60 |
+
if (!combined.length) { el.innerHTML = '<div class="loading">Đang cập nhật tin tức...</div>'; return; }
|
| 61 |
let h = '<div class="wc-news-grid">';
|
| 62 |
combined.slice(0, 20).forEach(a => {
|
| 63 |
const badge = a._type === 'road' ? '<span class="badge badge-wc">Đường tới WC</span>' : '<span class="badge badge-fpt">Tin WC</span>';
|
|
|
|
| 71 |
|
| 72 |
function renderWCFixtures(el) {
|
| 73 |
const d = _wc2026Data.fixtures || {};
|
| 74 |
+
// New format: images array (infographic from tienphong.vn)
|
| 75 |
+
if (d.type === 'infographic' && d.images && d.images.length) {
|
| 76 |
+
let h = WC_INLINE_CSS + '<div class="wc-fixtures-images">';
|
| 77 |
+
h += '<div style="font-size:11px;color:#8ab4d8;padding:4px 0;text-align:center">📅 Lịch thi đấu World Cup 2026 (giờ Việt Nam) — Nguồn: Tiền Phong</div>';
|
| 78 |
+
d.images.forEach(img => {
|
| 79 |
+
h += `<img src="${esc(img.src)}" alt="${esc(img.alt)}" loading="lazy" onerror="this.style.display='none'">`;
|
| 80 |
+
if (img.alt) h += `<div class="wc-img-caption">${esc(img.alt)}</div>`;
|
| 81 |
+
});
|
| 82 |
+
h += '</div>';
|
| 83 |
+
el.innerHTML = h;
|
| 84 |
+
} else if (d.html && d.html.length > 50) {
|
| 85 |
+
// Fallback: raw HTML
|
| 86 |
+
el.innerHTML = WC_INLINE_CSS + '<div class="wc-bongda-content">' + d.html + '</div>';
|
| 87 |
+
el.querySelectorAll('a').forEach(a => a.addEventListener('click', e => e.preventDefault()));
|
| 88 |
+
} else {
|
| 89 |
el.innerHTML = '<div class="loading">Chưa có lịch thi đấu World Cup 2026<br><small style="color:#6a9fca">Giải khởi tranh 11/06/2026</small></div>';
|
|
|
|
| 90 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
}
|
| 92 |
|
| 93 |
function renderWCStandings(el) {
|
| 94 |
const d = _wc2026Data.standings || {};
|
| 95 |
+
if (d.html && d.html.length > 50) {
|
| 96 |
+
el.innerHTML = WC_INLINE_CSS + '<div class="wc-bongda-content">' + d.html + '</div>';
|
|
|
|
| 97 |
el.querySelectorAll('a').forEach(a => a.addEventListener('click', e => e.preventDefault()));
|
| 98 |
} else {
|
| 99 |
el.innerHTML = '<div class="loading">Chưa có BXH World Cup 2026<br><small style="color:#6a9fca">Giải khởi tranh 11/06/2026</small></div>';
|
|
|
|
| 102 |
|
| 103 |
function renderWCStats(el) {
|
| 104 |
const d = _wc2026Data.stats || {};
|
| 105 |
+
if (d.html && d.html.length > 50) {
|
| 106 |
+
el.innerHTML = WC_INLINE_CSS + '<div class="wc-bongda-content">' + d.html + '</div>';
|
|
|
|
| 107 |
el.querySelectorAll('a').forEach(a => a.addEventListener('click', e => e.preventDefault()));
|
| 108 |
} else {
|
| 109 |
el.innerHTML = '<div class="loading">Chưa có thống kê World Cup 2026<br><small style="color:#6a9fca">Giải khởi tranh 11/06/2026</small></div>';
|