Newest Main page regreshing. Updated calculator. Removed unused stuff.
This commit is contained in:
@@ -842,9 +842,10 @@
|
||||
<div class="navbar-title">🎖️ <span data-i18n="league.league_results">League Results</span></div>
|
||||
</div>
|
||||
<div class="navbar-controls">
|
||||
<a href="/" class="nav-btn">📺 <span data-i18n="navigation.dashboard">Dashboard</span></a>
|
||||
<button class="nav-btn" onclick="exportLeagueJSON()">💾 <span data-i18n="general.export">Export JSON</span></button>
|
||||
<button class="nav-btn" onclick="window.print()">🖨️ <span data-i18n="general.print">Print</span></button>
|
||||
<button class="nav-btn" id="btnTvView" onclick="toggleTvView()" title="Preklopi pogled na TV zaslonu">📺</button>
|
||||
<a href="/" class="nav-btn">✕</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1284,6 +1285,59 @@
|
||||
window.print();
|
||||
}
|
||||
});
|
||||
|
||||
// ── TV VIEW TOGGLE ────────────────────────────────────────────────────────
|
||||
const isTvDisplay = new URLSearchParams(window.location.search).get('tv') === '1';
|
||||
let currentTvView = 'results';
|
||||
|
||||
function updateTvViewBtn(view) {
|
||||
currentTvView = view;
|
||||
const btn = document.getElementById('btnTvView');
|
||||
if (!btn) return;
|
||||
btn.style.background = (view === 'results') ? '#28a745' : '';
|
||||
btn.style.color = (view === 'results') ? 'white' : '';
|
||||
btn.style.borderColor = (view === 'results') ? '#1e7e34' : '';
|
||||
}
|
||||
|
||||
async function toggleTvView() {
|
||||
const newView = currentTvView === 'results' ? 'cameras' : 'results';
|
||||
try {
|
||||
const payload = { view: newView };
|
||||
if (newView === 'results') {
|
||||
// Pass the current page path so the TV follows to this league archive, not a tournament archive
|
||||
payload.tv_url = window.location.pathname;
|
||||
}
|
||||
await fetch('/api/tv/view', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(payload)
|
||||
});
|
||||
updateTvViewBtn(newView);
|
||||
if (isTvDisplay && newView === 'cameras') {
|
||||
window.location.href = '/';
|
||||
}
|
||||
} catch (e) { console.error(e); }
|
||||
}
|
||||
|
||||
// Poll to stay in sync and follow back-redirect when in TV mode
|
||||
setInterval(async () => {
|
||||
if (document.visibilityState !== 'visible') return;
|
||||
try {
|
||||
const r = await fetch('/api/dashboard/state');
|
||||
if (!r.ok) return;
|
||||
const d = await r.json();
|
||||
updateTvViewBtn(d.tv_view || 'cameras');
|
||||
if (isTvDisplay && d.tv_view !== 'results') {
|
||||
if (d.tv_view === 'draft' && d.tournament_active) {
|
||||
window.location.href = '/tournament/draft?tv=1';
|
||||
} else {
|
||||
window.location.href = '/';
|
||||
}
|
||||
}
|
||||
} catch (e) {}
|
||||
}, 3000);
|
||||
|
||||
fetch('/api/dashboard/state').then(r => r.json()).then(d => updateTvViewBtn(d.tv_view || 'cameras')).catch(() => {});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user