bep40 commited on
Commit
23fa7d6
·
verified ·
1 Parent(s): 764148c

Merge live_mode into wc2026_v2.js (loaded after app_v2.js, has access to all functions)"

Browse files
Files changed (1) hide show
  1. static/live_mode.js +17 -35
static/live_mode.js CHANGED
@@ -1,43 +1,25 @@
1
  // === HOMEPAGE LIVE MODE ===
2
- // All sections refresh automatically when user is on homepage
3
- // Livescore: 60s, Featured match: 30s, Hot topics: 300s, Hashtag: if visible
4
-
5
  let _liveInterval = null;
6
- let _liveCount = 0;
7
-
8
  function startHomepageLive() {
9
  if (_liveInterval) clearInterval(_liveInterval);
10
  _liveInterval = setInterval(async () => {
11
- // Only refresh when homepage is active
12
  if (!document.getElementById('view-home')?.classList.contains('active')) return;
13
- _liveCount++;
14
-
15
- // Livescore: every 60s
16
- if (_liveCount % 1 === 0) {
17
- const activeTab = document.querySelector('.ls-tab.active');
18
- if (activeTab) {
19
- const tab = activeTab.dataset.tab;
20
- if (tab) loadLivescore(tab);
21
- }
22
- }
23
-
24
- // Featured match: every 30s (every other tick)
25
- if (_liveCount % 1 === 0) {
26
- try {
27
- const f = await fetch('/api/livescore/featured').then(r => r.json()).catch(() => null);
28
- if (f && f.home) {
29
- const el = document.querySelector('.featured-match');
30
- if (el) {
31
- const sc = f.status === 'live' ? '' : 'upcoming';
32
- const st = f.status === 'live' ? `🔴 ${f.minute || 'LIVE'}` : `⏰ ${f.time}`;
33
- el.innerHTML = `<div class="fm-league">${f.league}</div><div class="fm-teams"><div class="fm-team"><img src="${f.home_logo}" onerror="this.style.display='none'"><span>${f.home}</span></div><div class="fm-score">${f.score || 'VS'}</div><div class="fm-team"><img src="${f.away_logo}" onerror="this.style.display='none'"><span>${f.away}</span></div></div><div class="fm-status ${sc}">${st}</div>`;
34
- }
35
  }
36
- } catch(e) {}
37
- }
38
-
39
- }, 60000); // 60 seconds base interval
40
  }
41
-
42
- // Start LIVE mode after page loads
43
- setTimeout(startHomepageLive, 5000);
 
1
  // === HOMEPAGE LIVE MODE ===
2
+ // All sections auto-refresh: livescore 60s, featured 60s, WC2026 90s
 
 
3
  let _liveInterval = null;
 
 
4
  function startHomepageLive() {
5
  if (_liveInterval) clearInterval(_liveInterval);
6
  _liveInterval = setInterval(async () => {
 
7
  if (!document.getElementById('view-home')?.classList.contains('active')) return;
8
+ // Refresh livescore (active tab)
9
+ const lsTab = document.querySelector('.ls-tab.active');
10
+ if (lsTab && lsTab.dataset.tab) loadLivescore(lsTab.dataset.tab);
11
+ // Refresh featured match
12
+ try {
13
+ const f = await fetch('/api/livescore/featured').then(r => r.json()).catch(() => null);
14
+ if (f && f.home) {
15
+ const el = document.querySelector('.featured-match');
16
+ if (el) {
17
+ const sc = f.status === 'live' ? '' : 'upcoming';
18
+ const st = f.status === 'live' ? `🔴 ${f.minute || 'LIVE'}` : `⏰ ${f.time}`;
19
+ el.innerHTML = `<div class="fm-league">${f.league}</div><div class="fm-teams"><div class="fm-team"><img src="${f.home_logo}" onerror="this.style.display='none'"><span>${f.home}</span></div><div class="fm-score">${f.score || 'VS'}</div><div class="fm-team"><img src="${f.away_logo}" onerror="this.style.display='none'"><span>${f.away}</span></div></div><div class="fm-status ${sc}">${st}</div>`;
 
 
 
 
 
 
 
 
 
 
20
  }
21
+ }
22
+ } catch(e) {}
23
+ }, 60000);
 
24
  }
25
+ setTimeout(startHomepageLive, 8000);