Spaces:
Running
Running
Restore static/app_v2.js from 0cc342c
Browse files- static/app_v2.js +18 -18
static/app_v2.js
CHANGED
|
@@ -21,22 +21,22 @@ async function loadHome(){
|
|
| 21 |
+'<div class="ai-compose"><div class="ai-compose-title">🤖 AI viết bài</div><div class="ai-compose-row"><input id="topic-input" placeholder="Nhập chủ đề..."><button onclick="searchTopic()">Tìm nguồn</button></div><div class="ai-compose-row"><input id="url-input" placeholder="Dán URL bài viết..."><button class="secondary" onclick="rewriteUrl()">Rewrite</button></div><div id="hot-topics" class="hot-topic-row"></div></div>'
|
| 22 |
+'<div id="hashtag-box"></div>'
|
| 23 |
+'<div class="ls-section"><div class="ls-header"><h3>⚽ Livescore</h3></div><div class="ls-tabs"><span class="ls-tab active" data-tab="today" onclick="loadLivescore(\'today\')">📅 Hôm nay</span><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" 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></div><div class="ls-content" id="ls-content"><div class="loading">Đang tải...</div></div></div>'
|
| 24 |
-
|
| 25 |
+'<div id="home-after-wc"></div>';
|
| 26 |
|
| 27 |
const afterEl = homeEl.querySelector('#home-after-wc');
|
| 28 |
|
| 29 |
loadLivescore('today');
|
| 30 |
-
|
| 31 |
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
_fetchWithTimeout('/api/
|
| 37 |
-
_fetchWithTimeout('/api/
|
| 38 |
-
_fetchWithTimeout('/api/
|
| 39 |
-
_fetchWithTimeout('/api/
|
| 40 |
]).then(results => results.map(r => r.status === 'fulfilled' ? r.value : null));
|
| 41 |
|
| 42 |
if(featuredData && featuredData.home){
|
|
@@ -46,15 +46,19 @@ async function loadHome(){
|
|
| 46 |
if(area) area.innerHTML=`<div class="featured-match" onclick="openMatch('${featuredData.event_id}')"><div class="fm-league">${featuredData.league}</div><div class="fm-teams"><div class="fm-team"><img src="${featuredData.home_logo}" onerror="this.style.display='none'"><span>${featuredData.home}</span></div><div class="fm-score">${featuredData.score||'VS'}</div><div class="fm-team"><img src="${featuredData.away_logo}" onerror="this.style.display='none'"><span>${featuredData.away}</span></div></div><div class="fm-status ${sc}">${st}</div></div>`;
|
| 47 |
}
|
| 48 |
|
|
|
|
| 49 |
_wallPosts = (wallData && wallData.posts) || [];
|
| 50 |
_hlLeagueData = hlLeagues || {};
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
|
|
|
|
| 52 |
_renderWallIn(afterEl);
|
| 53 |
_renderHLIn(afterEl);
|
| 54 |
if(aiData && aiData.length) _renderSlidesIn('ai-articles','Ứng dụng AI','🤖',aiData,afterEl);
|
| 55 |
}
|
| 56 |
-
window.loadHome = loadHome;
|
| 57 |
-
|
| 58 |
|
| 59 |
function _renderSlidesIn(key, label, emoji, vids, afterEl){
|
| 60 |
if(!vids||!vids.length||!afterEl) return;
|
|
@@ -212,6 +216,7 @@ function prependWallPost(post){
|
|
| 212 |
|
| 213 |
let _shortsData=[];
|
| 214 |
let _wallPosts=[];
|
|
|
|
| 215 |
let _currentView='home';
|
| 216 |
let _currentEventId=null;
|
| 217 |
let _currentMatchUrl=null;
|
|
@@ -332,9 +337,4 @@ async function loadCat(id){const el=document.getElementById('view-cat');el.inner
|
|
| 332 |
fetch('/api/storage_status').then(r=>r.json()).then(j=>{if(!j.persistent){const home=document.getElementById('view-home');if(home){const w=document.createElement('div');w.className='storage-warn';w.innerHTML='⚠️ Persistent Storage chưa bật.';home.prepend(w)}}}).catch(()=>{});
|
| 333 |
(function(){try{var hash=window.location.hash;if(hash&&hash.length>1){var articleUrl=decodeURIComponent(hash.substring(1));if(articleUrl.startsWith('http')){history.replaceState(null,'',window.location.pathname);setTimeout(function(){if(typeof readArticle==='function')readArticle(articleUrl);},1500);}}}catch(e){}})();
|
| 334 |
(function(){try{const pa=localStorage.getItem('pending_article');const pv=localStorage.getItem('pending_video');if(pa){localStorage.removeItem('pending_article');setTimeout(()=>{if(typeof readArticle==='function')readArticle(pa);},1500);}if(pv){localStorage.removeItem('pending_video');try{const v=JSON.parse(pv);if(v&&v.url)setTimeout(()=>{window.open(v.url,'_blank')},1500);}catch(e){}}}catch(e){}})();
|
| 335 |
-
|
| 336 |
-
if(document.readyState==='loading'){
|
| 337 |
-
document.addEventListener('DOMContentLoaded',function(){if(typeof window.loadHome==='function')window.loadHome();});
|
| 338 |
-
}else{
|
| 339 |
-
if(typeof window.loadHome==='function')window.loadHome();
|
| 340 |
-
}
|
|
|
|
| 21 |
+'<div class="ai-compose"><div class="ai-compose-title">🤖 AI viết bài</div><div class="ai-compose-row"><input id="topic-input" placeholder="Nhập chủ đề..."><button onclick="searchTopic()">Tìm nguồn</button></div><div class="ai-compose-row"><input id="url-input" placeholder="Dán URL bài viết..."><button class="secondary" onclick="rewriteUrl()">Rewrite</button></div><div id="hot-topics" class="hot-topic-row"></div></div>'
|
| 22 |
+'<div id="hashtag-box"></div>'
|
| 23 |
+'<div class="ls-section"><div class="ls-header"><h3>⚽ Livescore</h3></div><div class="ls-tabs"><span class="ls-tab active" data-tab="today" onclick="loadLivescore(\'today\')">📅 Hôm nay</span><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" 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></div><div class="ls-content" id="ls-content"><div class="loading">Đang tải...</div></div></div>'
|
| 24 |
+
+'<div id="wc2026-live-section" class="wc2026-section"><div class="wc-header"><h2>🏆 World Cup 2026</h2><span class="wc-live-badge">● LIVE</span></div><div class="wc-tabs"><span class="wc-tab active" onclick="switchWCTab(\'news\')">📰 Tin tức</span><span class="wc-tab" onclick="switchWCTab(\'fixtures\')">📅 Lịch thi đấu</span><span class="wc-tab" onclick="switchWCTab(\'standings\')">🏆 BXH</span><span class="wc-tab" onclick="switchWCTab(\'highlights\')">🎬 Highlight</span><span class="wc-tab" onclick="switchWCTab(\'shorts\')">📱 Shorts</span><span class="wc-tab" onclick="switchWCTab(\'stats\')">📊 Thống kê</span></div><div class="wc-content" id="wc-content"><div class="loading">Đang tải World Cup 2026...</div></div></div>'
|
| 25 |
+'<div id="home-after-wc"></div>';
|
| 26 |
|
| 27 |
const afterEl = homeEl.querySelector('#home-after-wc');
|
| 28 |
|
| 29 |
loadLivescore('today');
|
| 30 |
+
loadHotTopics();
|
| 31 |
|
| 32 |
+
const [featuredData, shortsData, wallData, hlLeagues, aiData, wcData, vtvShortsData] = await Promise.allSettled([
|
| 33 |
+
_fetchWithTimeout('/api/livescore/featured', 5000),
|
| 34 |
+
_fetchWithTimeout('/api/shorts', 8000),
|
| 35 |
+
_fetchWithTimeout('/api/wall', 5000),
|
| 36 |
+
_fetchWithTimeout('/api/highlights/leagues', 10000),
|
| 37 |
+
_fetchWithTimeout('/api/genk_ai', 8000),
|
| 38 |
+
_fetchWithTimeout('/api/wc2026', 8000),
|
| 39 |
+
_fetchWithTimeout('/api/shorts/vtvnamo?count=50', 12000),
|
| 40 |
]).then(results => results.map(r => r.status === 'fulfilled' ? r.value : null));
|
| 41 |
|
| 42 |
if(featuredData && featuredData.home){
|
|
|
|
| 46 |
if(area) area.innerHTML=`<div class="featured-match" onclick="openMatch('${featuredData.event_id}')"><div class="fm-league">${featuredData.league}</div><div class="fm-teams"><div class="fm-team"><img src="${featuredData.home_logo}" onerror="this.style.display='none'"><span>${featuredData.home}</span></div><div class="fm-score">${featuredData.score||'VS'}</div><div class="fm-team"><img src="${featuredData.away_logo}" onerror="this.style.display='none'"><span>${featuredData.away}</span></div></div><div class="fm-status ${sc}">${st}</div></div>`;
|
| 47 |
}
|
| 48 |
|
| 49 |
+
_shortsData = shortsData || [];
|
| 50 |
_wallPosts = (wallData && wallData.posts) || [];
|
| 51 |
_hlLeagueData = hlLeagues || {};
|
| 52 |
+
_wc2026Data = wcData;
|
| 53 |
+
_wcShortsData = vtvShortsData || [];
|
| 54 |
+
|
| 55 |
+
if(wcData) switchWCTab('news');
|
| 56 |
|
| 57 |
+
_renderShortsIn(afterEl);
|
| 58 |
_renderWallIn(afterEl);
|
| 59 |
_renderHLIn(afterEl);
|
| 60 |
if(aiData && aiData.length) _renderSlidesIn('ai-articles','Ứng dụng AI','🤖',aiData,afterEl);
|
| 61 |
}
|
|
|
|
|
|
|
| 62 |
|
| 63 |
function _renderSlidesIn(key, label, emoji, vids, afterEl){
|
| 64 |
if(!vids||!vids.length||!afterEl) return;
|
|
|
|
| 216 |
|
| 217 |
let _shortsData=[];
|
| 218 |
let _wallPosts=[];
|
| 219 |
+
let _wcShortsData=[];
|
| 220 |
let _currentView='home';
|
| 221 |
let _currentEventId=null;
|
| 222 |
let _currentMatchUrl=null;
|
|
|
|
| 337 |
fetch('/api/storage_status').then(r=>r.json()).then(j=>{if(!j.persistent){const home=document.getElementById('view-home');if(home){const w=document.createElement('div');w.className='storage-warn';w.innerHTML='⚠️ Persistent Storage chưa bật.';home.prepend(w)}}}).catch(()=>{});
|
| 338 |
(function(){try{var hash=window.location.hash;if(hash&&hash.length>1){var articleUrl=decodeURIComponent(hash.substring(1));if(articleUrl.startsWith('http')){history.replaceState(null,'',window.location.pathname);setTimeout(function(){if(typeof readArticle==='function')readArticle(articleUrl);},1500);}}}catch(e){}})();
|
| 339 |
(function(){try{const pa=localStorage.getItem('pending_article');const pv=localStorage.getItem('pending_video');if(pa){localStorage.removeItem('pending_article');setTimeout(()=>{if(typeof readArticle==='function')readArticle(pa);},1500);}if(pv){localStorage.removeItem('pending_video');try{const v=JSON.parse(pv);if(v&&v.url)setTimeout(()=>{window.open(v.url,'_blank')},1500);}catch(e){}}}catch(e){}})();
|
| 340 |
+
if(document.readyState==='loading'){document.addEventListener('DOMContentLoaded',function(){if(typeof loadHome==='function')loadHome();});}else{if(typeof loadHome==='function')loadHome();}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|