Files
Sdk_TV_app/templates/index.html
T
bl3kunja-FW 5c7f255a02 Add tournament archives and results for multiple events
- Created JSON files for tournament archives on 2025-07-28 and 2025-07-29, including detailed player scores and shot results.
- Added a new tournament results file summarizing the outcomes of the tournament held on 2025-07-29, including participant scores and completion status.
2025-08-02 15:27:32 +02:00

875 lines
24 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Camera Dashboard</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
html, body {
margin: 0;
padding: 0;
background: black;
height: 100vh;
overflow: hidden;
font-family: Arial, sans-serif;
}
.navbar {
background: white;
color: black;
padding: 10px 20px;
display: flex;
align-items: center;
justify-content: space-between;
border-bottom: 2px solid #ccc;
height: 60px;
box-sizing: border-box;
}
.navbar img.logo {
height: 40px;
}
.navbar-center {
position: absolute;
left: 50%;
transform: translateX(-50%);
text-align: center;
}
/* Tournament Navigation */
.tournament-nav {
display: flex;
align-items: center;
gap: 15px;
}
.round-nav-btn {
background: #f8f9fa;
border: 2px solid #e9ecef;
cursor: pointer;
padding: 12px;
border-radius: 8px;
transition: all 0.2s ease;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
color: #333;
font-weight: bold;
font-size: 1.2rem;
width: 50px;
height: 50px;
display: flex;
align-items: center;
justify-content: center;
}
.round-nav-btn:hover {
background: #e9ecef;
border-color: #007bff;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
transform: translateY(-1px);
color: #007bff;
}
.round-nav-btn:disabled {
opacity: 0.5;
cursor: not-allowed;
transform: none !important;
background: #f8f9fa !important;
border-color: #e9ecef !important;
color: #333 !important;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
}
.current-round-info {
text-align: center;
min-width: 120px;
}
.round-title {
font-size: 1.4rem;
font-weight: bold;
color: #333;
margin-bottom: 2px;
}
.round-progress {
font-size: 0.8rem;
color: #666;
padding: 2px 8px;
background: rgba(0, 123, 255, 0.1);
border-radius: 10px;
border: 1px solid rgba(0, 123, 255, 0.2);
}
/* Regular time/date display */
.datetime .time {
font-size: 1.6rem;
font-weight: bold;
color: #333;
}
.datetime .date {
font-size: 0.9rem;
color: #666;
}
.hamburger-menu {
background: #f8f9fa;
border: 2px solid #e9ecef;
cursor: pointer;
padding: 12px;
display: flex;
flex-direction: column;
justify-content: space-around;
width: 50px;
height: 50px;
border-radius: 8px;
transition: all 0.2s ease;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.hamburger-menu:hover {
background: #e9ecef;
border-color: #007bff;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
transform: translateY(-1px);
}
.hamburger-line {
width: 100%;
height: 3px;
background: #333;
border-radius: 2px;
transition: all 0.3s ease;
}
.hamburger-menu:hover .hamburger-line {
background: #007bff;
}
.grid {
height: calc(100vh - 60px);
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-template-rows: repeat(2, 1fr);
gap: 20px;
padding: 20px;
box-sizing: border-box;
}
.camera-card {
background: #2a2a2a;
border-radius: 12px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
overflow: hidden;
display: flex;
flex-direction: column;
transition: transform 0.2s ease, box-shadow 0.2s ease;
cursor: pointer;
position: relative;
}
.camera-card:hover {
transform: translateY(-2px);
box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}
.card-title {
background: #1a1a1a;
padding: 12px 16px;
font-size: 1.1rem;
font-weight: 600;
color: white;
border-bottom: 1px solid #404040;
text-align: center;
pointer-events: none;
flex-shrink: 0;
}
.stream-wrapper {
position: relative;
width: 100%;
flex: 1;
background: #222;
overflow: hidden;
pointer-events: none;
}
.stream {
width: 100%;
height: 100%;
object-fit: cover;
display: block;
transition: opacity 0.3s ease;
pointer-events: none;
}
/* Tooltip for camera cards */
.camera-card::after {
content: "Click to view fullscreen";
position: absolute;
bottom: 10px;
left: 50%;
transform: translateX(-50%);
background: rgba(0, 0, 0, 0.8);
color: white;
padding: 6px 12px;
border-radius: 4px;
font-size: 0.85rem;
opacity: 0;
visibility: hidden;
transition: all 0.2s ease;
pointer-events: none;
z-index: 10;
}
.camera-card:hover::after {
opacity: 1;
visibility: visible;
transform: translateX(-50%) translateY(-5px);
}
/* Settings Panel */
#overlay {
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
background: rgba(0, 0, 0, 0.5);
z-index: 999;
opacity: 0;
visibility: hidden;
transition: all 0.3s ease;
}
#overlay.active {
opacity: 1;
visibility: visible;
}
.settings-panel {
position: fixed;
top: 0;
right: -400px;
width: 400px;
height: 100vh;
background: white;
z-index: 1000;
box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
transition: right 0.3s ease;
overflow-y: auto;
}
.settings-panel.active {
right: 0;
}
.settings-header {
background: #f8f9fa;
padding: 20px;
border-bottom: 1px solid #e9ecef;
display: flex;
justify-content: space-between;
align-items: center;
}
.settings-header h3 {
margin: 0;
font-size: 1.3rem;
color: #333;
}
.close-btn {
background: none;
border: none;
font-size: 1.5rem;
cursor: pointer;
color: #666;
padding: 4px 8px;
border-radius: 4px;
}
.close-btn:hover {
background: #e9ecef;
color: #333;
}
.settings-content {
padding: 20px;
}
.settings-group {
margin-bottom: 30px;
}
.settings-group h4 {
margin: 0 0 15px 0;
font-size: 1.1rem;
color: #333;
border-bottom: 2px solid #007bff;
padding-bottom: 6px;
}
.nav-link {
display: inline-block;
background: #f8f9fa;
border: 2px solid #e9ecef;
color: #333;
padding: 12px 20px;
border-radius: 8px;
text-decoration: none;
font-weight: bold;
font-size: 0.95rem;
transition: all 0.2s ease;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
margin-bottom: 10px;
display: block;
}
.nav-link:hover {
background: #e9ecef;
border-color: #007bff;
color: #007bff;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
transform: translateY(-1px);
}
.tournament-status-info {
background: #f0f8ff;
border: 2px solid #007bff;
border-radius: 8px;
padding: 15px;
margin: 15px 0;
}
.tournament-status-info p {
margin: 5px 0;
color: #333;
}
.tournament-btn {
background: #007bff !important;
border-color: #0056b3 !important;
color: white !important;
text-align: center;
}
.tournament-btn:hover {
background: #0056b3 !important;
border-color: #004085 !important;
color: white !important;
}
/* Desktop-only styles - mobile users are redirected */
/* Mobile responsive fallback for desktop users on small screens */
@media (max-width: 768px) {
.navbar {
padding: 10px 15px;
flex-direction: column;
gap: 15px;
}
.navbar-controls {
flex-wrap: wrap;
justify-content: center;
}
.grid {
height: calc(100vh - 100px);
grid-template-columns: 1fr;
grid-template-rows: repeat(6, 1fr);
gap: 15px;
padding: 20px;
}
.card-title {
padding: 16px 18px;
font-size: 1.4rem;
font-weight: bold;
}
.settings-panel {
width: 100%;
right: -100%;
}
.tournament-nav {
gap: 10px;
}
.round-nav-btn {
width: 45px;
height: 45px;
padding: 10px;
font-size: 1.1rem;
}
.current-round-info {
min-width: 100px;
}
.round-title {
font-size: 1.2rem;
}
.round-progress {
font-size: 0.75rem;
}
}
@media (max-width: 480px) {
.grid {
padding: 15px;
gap: 12px;
}
.card-title {
padding: 14px 16px;
font-size: 1.2rem;
}
}
</style>
</head>
<body>
<div class="navbar">
<img src="/static/logo.png" alt="Logo" class="logo" onerror="this.style.display='none'" />
<div class="navbar-center">
{% if settings.tournament_active %}
<div class="tournament-nav">
<button class="round-nav-btn" id="prevRoundBtn" onclick="changeRound(-1)" title="Previous Round">
</button>
<div class="current-round-info">
<div class="round-title">🏆 Round <span id="currentRoundNum">{{ settings.current_round }}</span></div>
<div class="round-progress">{{ settings.current_round }} of {{ settings.total_rounds }}</div>
</div>
<button class="round-nav-btn" id="nextRoundBtn" onclick="changeRound(1)" title="Next Round">
</button>
</div>
{% else %}
<div class="datetime">
<div class="time" id="time"></div>
<div class="date" id="date"></div>
</div>
{% endif %}
</div>
<button class="hamburger-menu" id="menuButton" title="Settings">
<div class="hamburger-line"></div>
<div class="hamburger-line"></div>
<div class="hamburger-line"></div>
</button>
</div>
<div id="overlay"></div>
<div class="settings-panel" id="settingsPanel">
<div class="settings-header">
<h3>Camera Settings</h3>
<button class="close-btn" id="closeBtn">&times;</button>
</div>
<div class="settings-content">
{% if settings.tournament_active %}
<div class="settings-group">
<h4>🏆 Active Tournament</h4>
<div class="tournament-status-info">
<p><strong>Current Round:</strong> {{ settings.current_round }} of {{ settings.total_rounds }}</p>
<p>Camera cards show current round players</p>
</div>
<div class="tournament-actions">
<a href="/tournament/draft" class="nav-link tournament-btn" style="font-size: 1.1rem; padding: 15px 20px;">📋 View Full Tournament Draft</a>
<a href="/tournament" class="nav-link tournament-btn" id="manageTournamentLink">⚙️ Manage Tournament</a>
<a href="/results/calculator" class="nav-link tournament-btn">🎯 Results Calculator</a>
<a href="/results" class="nav-link tournament-btn">📊 View Results</a>
</div>
</div>
{% endif %}
<div class="settings-group">
{% if not settings.tournament_active %}
<h4>Navigation</h4>
<a href="/tournament" class="nav-link" id="tournamentModeLink">🏆 Tournament Mode</a>
<h4>Data & Analysis</h4>
<a href="/archive/player-analysis" class="nav-link">👤 Player Analysis</a>
<a href="/archive" class="nav-link" >📚 View Archive</a>
{% endif %}
</div>
{% if not settings.tournament_active %}
<div class="settings-group" id="displayOptionsGroup">
<h4>Display Options</h4>
<div style="margin-bottom: 15px;">
<label style="display: flex; align-items: center; gap: 8px; cursor: pointer;">
<input type="checkbox" id="toggleTitles" {% if settings.display_options.show_titles %}checked{% endif %} onchange="toggleTitles()" style="width: 18px; height: 18px;">
Show Card Titles
</label>
</div>
<div style="margin-bottom: 15px;">
<label style="display: block; margin-bottom: 8px; font-weight: bold; color: #333;">
Title Text Size: <span id="titleSizeValue">{{ settings.display_options.title_size }}</span>rem
</label>
<input type="range"
id="titleSize"
min="0.8"
max="2.5"
step="0.1"
value="{{ settings.display_options.title_size }}"
oninput="adjustTitleSize(this.value)"
style="width: 100%;">
</div>
</div>
<div class="settings-group" id="cameraTitleGroup">
<h4>Camera Titles</h4>
{% for i in range(1, 7) %}
<div style="margin-bottom: 15px;">
<label style="display: block; margin-bottom: 5px; font-weight: bold; color: #333;">Camera {{ i }} Title:</label>
<input type="text"
id="titleInput{{ i }}"
value="{{ settings.camera_titles[i|string] }}"
oninput="updateCardTitle({{ i }})"
style="width: 100%; padding: 8px 12px; border: 2px solid #e9ecef; border-radius: 6px; font-size: 0.9rem;">
</div>
{% endfor %}
</div>
{% endif %}
</div>
</div>
<div class="grid">
{% for i in range(1, 7) %}
<div class="camera-card" onclick="openCameraFullscreen({{ i }})" data-camera-id="{{ i }}">
<div class="card-title" id="cardTitle{{ i }}">{{ settings.camera_titles[i|string] }}</div>
<div class="stream-wrapper">
<img src="{{ streams[i-1].url }}" alt="Camera Stream {{ i }}" class="stream" onerror="this.style.opacity='0.1'">
</div>
</div>
{% endfor %}
</div>
<script>
// Global settings and tournament state
let currentSettings = {{ settings|tojson }};
const tournamentActive = {{ 'true' if settings.tournament_active else 'false' }};
let currentRound = {{ settings.current_round if settings.tournament_active else 1 }};
const totalRounds = {{ settings.total_rounds if settings.tournament_active else 1 }};
function updateRoundNavigation() {
if (tournamentActive) {
const prevBtn = document.getElementById('prevRoundBtn');
const nextBtn = document.getElementById('nextRoundBtn');
const currentRoundNum = document.getElementById('currentRoundNum');
if (prevBtn) prevBtn.disabled = currentRound <= 1;
if (nextBtn) nextBtn.disabled = currentRound >= totalRounds;
if (currentRoundNum) currentRoundNum.textContent = currentRound;
}
}
// Change round function
async function changeRound(direction) {
if (!tournamentActive) return;
const newRound = currentRound + direction;
if (newRound < 1 || newRound > totalRounds) return;
// Disable buttons during request
const prevBtn = document.getElementById('prevRoundBtn');
const nextBtn = document.getElementById('nextRoundBtn');
if (prevBtn) prevBtn.disabled = true;
if (nextBtn) nextBtn.disabled = true;
try {
const response = await fetch(`/api/tournament/round/${newRound}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
}
});
if (response.ok) {
currentRound = newRound;
updateRoundNavigation();
// Reload page to get new round players
setTimeout(() => {
window.location.reload();
}, 300);
} else {
console.error('Failed to change round');
alert('Failed to change round. Please try again.');
updateRoundNavigation();
}
} catch (error) {
console.error('Error changing round:', error);
alert('Error changing round. Please try again.');
updateRoundNavigation();
}
}
// Debounce function
function debounce(func, wait) {
let timeout;
return function executedFunction(...args) {
const later = () => {
clearTimeout(timeout);
func(...args);
};
clearTimeout(timeout);
timeout = setTimeout(later, wait);
};
}
// Save settings to server
async function saveSettings(settingsUpdate) {
try {
const response = await fetch('/api/settings', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(settingsUpdate)
});
if (response.ok) {
const result = await response.json();
if (!tournamentActive) {
currentSettings = result.settings;
}
}
} catch (error) {
console.error('Error saving settings:', error);
}
}
const debouncedSaveSettings = debounce(saveSettings, 500);
// Desktop-only functionality - mobile users are redirected
// Mobile device detection
function isMobileDevice() {
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ||
(window.innerWidth <= 1024 && window.innerHeight <= 1366) ||
('ontouchstart' in window) ||
(navigator.maxTouchPoints > 0);
}
// Update card title
function updateCardTitle(index) {
if (tournamentActive) return;
const input = document.getElementById(`titleInput${index}`);
const cardTitle = document.getElementById(`cardTitle${index}`);
if (input && cardTitle) {
const newTitle = input.value || `Camera ${index}`;
cardTitle.textContent = newTitle;
if (event && event.target === input) {
currentSettings.camera_titles[index.toString()] = newTitle;
debouncedSaveSettings({
camera_titles: {
[index.toString()]: newTitle
}
});
}
}
}
// Toggle titles
function toggleTitles() {
const show = document.getElementById('toggleTitles').checked;
for (let i = 1; i <= 6; i++) {
const cardTitle = document.getElementById(`cardTitle${i}`);
if (cardTitle) {
cardTitle.style.display = show ? 'block' : 'none';
}
}
if (event && event.target === document.getElementById('toggleTitles')) {
currentSettings.display_options.show_titles = show;
debouncedSaveSettings({
display_options: {
show_titles: show
}
});
}
}
// Adjust title size
function adjustTitleSize(size) {
document.getElementById('titleSizeValue').textContent = size;
for (let i = 1; i <= 6; i++) {
const cardTitle = document.getElementById(`cardTitle${i}`);
if (cardTitle) {
cardTitle.style.fontSize = `${size}rem`;
}
}
if (event && event.target === document.getElementById('titleSize')) {
currentSettings.display_options.title_size = parseFloat(size);
debouncedSaveSettings({
display_options: {
title_size: parseFloat(size)
}
});
}
}
// Open camera fullscreen
function openCameraFullscreen(cameraId) {
const customTitle = currentSettings.camera_titles[cameraId.toString()] || `Camera ${cameraId}`;
window.location.href = `/fullscreen/${cameraId}?title=${encodeURIComponent(customTitle)}`;
}
// Apply current settings
function applyCurrentSettings() {
// Apply title visibility
const showTitles = currentSettings.display_options.show_titles;
if (document.getElementById('toggleTitles')) {
document.getElementById('toggleTitles').checked = showTitles;
}
for (let i = 1; i <= 6; i++) {
const cardTitle = document.getElementById(`cardTitle${i}`);
if (cardTitle) {
cardTitle.style.display = showTitles ? 'block' : 'none';
}
}
// Apply title size
const titleSize = currentSettings.display_options.title_size;
if (document.getElementById('titleSizeValue')) {
document.getElementById('titleSizeValue').textContent = titleSize;
}
if (document.getElementById('titleSize')) {
document.getElementById('titleSize').value = titleSize;
}
for (let i = 1; i <= 6; i++) {
const cardTitle = document.getElementById(`cardTitle${i}`);
if (cardTitle) {
cardTitle.style.fontSize = `${titleSize}rem`;
}
}
// Apply card titles
for (let i = 1; i <= 6; i++) {
const cardTitle = document.getElementById(`cardTitle${i}`);
if (cardTitle) {
const title = currentSettings.camera_titles[i.toString()] || `Camera ${i}`;
cardTitle.textContent = title;
}
if (!tournamentActive) {
const input = document.getElementById(`titleInput${i}`);
if (input) {
input.value = currentSettings.camera_titles[i.toString()] || `Camera ${i}`;
}
}
}
}
// Time and date updates
function updateDateTime() {
const now = new Date();
const hours = now.getHours().toString().padStart(2, '0');
const minutes = now.getMinutes().toString().padStart(2, '0');
const day = now.getDate().toString().padStart(2, '0');
const month = (now.getMonth() + 1).toString().padStart(2, '0');
const year = now.getFullYear();
const timeEl = document.getElementById('time');
const dateEl = document.getElementById('date');
if (timeEl) timeEl.textContent = `${hours}:${minutes}`;
if (dateEl) dateEl.textContent = `${day}.${month}.${year}`;
}
// Settings panel functionality
const menuButton = document.getElementById('menuButton');
const settingsPanel = document.getElementById('settingsPanel');
const overlay = document.getElementById('overlay');
const closeBtn = document.getElementById('closeBtn');
function openSettings() {
settingsPanel.classList.add('active');
overlay.classList.add('active');
}
function closeSettings() {
settingsPanel.classList.remove('active');
overlay.classList.remove('active');
}
// Event listeners
if (menuButton) menuButton.addEventListener('click', openSettings);
if (closeBtn) closeBtn.addEventListener('click', closeSettings);
if (overlay) overlay.addEventListener('click', closeSettings);
// Keyboard shortcuts
document.addEventListener('keydown', function(event) {
if (event.key === 'Escape' && settingsPanel.classList.contains('active')) {
closeSettings();
} else if (tournamentActive) {
if (event.key === 'ArrowLeft') {
event.preventDefault();
changeRound(-1);
} else if (event.key === 'ArrowRight') {
event.preventDefault();
changeRound(1);
}
}
});
// Initialize
document.addEventListener('DOMContentLoaded', function() {
updateDateTime();
setInterval(updateDateTime, 1000);
updateRoundNavigation();
applyCurrentSettings();
addTouchFeedback();
});
// Add touch feedback for interactive elements on touch devices
function addTouchFeedback() {
if (isMobileDevice()) {
const touchElements = document.querySelectorAll('.camera-card, .nav-btn');
touchElements.forEach(element => {
element.addEventListener('touchstart', function(e) {
if (!this.disabled) {
this.style.transform = 'scale(0.95) translateY(0)';
this.style.transition = 'transform 0.1s ease';
}
});
element.addEventListener('touchend', function(e) {
if (!this.disabled) {
setTimeout(() => {
this.style.transform = '';
this.style.transition = 'transform 0.2s ease';
}, 100);
}
});
element.addEventListener('touchcancel', function(e) {
if (!this.disabled) {
this.style.transform = '';
this.style.transition = 'transform 0.2s ease';
}
});
});
}
}
</script>
</body>
</html>