2379 lines
64 KiB
HTML
2379 lines
64 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<title data-i18n="scoring.results_calculator">Kalkulator</title>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<link rel="stylesheet" href="/static/css/base.css">
|
|
<link rel="stylesheet" href="/static/css/navbar.css">
|
|
<link rel="stylesheet" href="/static/css/buttons.css">
|
|
<link rel="stylesheet" href="/static/css/components.css">
|
|
<link rel="stylesheet" href="/static/css/responsive.css">
|
|
<style>
|
|
/* ========== LAYOUT FOUNDATION ========== */
|
|
html, body {
|
|
height: 100%;
|
|
margin: 0;
|
|
padding: 0;
|
|
overflow: hidden;
|
|
}
|
|
|
|
body {
|
|
display: flex;
|
|
flex-direction: column;
|
|
height: 100vh;
|
|
}
|
|
|
|
/* ========== NAVBAR (TOP) ========== */
|
|
.navbar {
|
|
flex-shrink: 0;
|
|
z-index: 100;
|
|
}
|
|
|
|
/* ========== CONTENT WRAPPER (MIDDLE - SCROLLABLE) ========== */
|
|
.content-wrapper {
|
|
flex: 1;
|
|
display: flex;
|
|
flex-direction: column;
|
|
overflow: hidden;
|
|
min-height: 0;
|
|
position: relative;
|
|
}
|
|
|
|
.container {
|
|
flex: 1;
|
|
overflow: hidden;
|
|
width: 100%;
|
|
display: flex;
|
|
flex-direction: row;
|
|
align-items: stretch;
|
|
padding: 12px 16px;
|
|
box-sizing: border-box;
|
|
gap: 12px;
|
|
min-height: 0;
|
|
}
|
|
|
|
/* Shared card style */
|
|
.calc-card {
|
|
background: white;
|
|
border-radius: 12px;
|
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
|
display: flex;
|
|
flex-direction: column;
|
|
overflow: hidden;
|
|
min-height: 0;
|
|
}
|
|
|
|
/* Middle column: scoring card + finish card stacked */
|
|
.col-middle {
|
|
flex: 1;
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 12px;
|
|
min-height: 0;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.col-middle .calc-card.scoring-card {
|
|
flex: 1;
|
|
min-height: 0;
|
|
}
|
|
|
|
.header-section {
|
|
display: none;
|
|
}
|
|
|
|
/* Dynamic header colors based on tournament type */
|
|
.header-section.tournament-4_targets {
|
|
background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
|
|
}
|
|
|
|
.header-section.tournament-20_targets {
|
|
background: linear-gradient(135deg, #ff6b6b 0%, #ff8e53 100%);
|
|
}
|
|
|
|
.header-section.tournament-40_targets {
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
}
|
|
|
|
.header-section.tournament-default {
|
|
background: linear-gradient(135deg, #ff6b6b 0%, #ff8e53 100%);
|
|
}
|
|
|
|
.header-section::before {
|
|
content: '';
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
right: 0;
|
|
bottom: 0;
|
|
background: linear-gradient(45deg, rgba(255, 255, 255, 0.1) 0%, transparent 50%, rgba(255, 255, 255, 0.05) 100%);
|
|
pointer-events: none;
|
|
}
|
|
|
|
.header-section * {
|
|
position: relative;
|
|
z-index: 2;
|
|
}
|
|
|
|
.header-logo {
|
|
height: 50px;
|
|
max-width: 140px;
|
|
object-fit: contain;
|
|
margin-bottom: 15px;
|
|
filter: brightness(1.2) contrast(1.1);
|
|
background-color: white;
|
|
padding: 8px;
|
|
border-radius: 6px;
|
|
backdrop-filter: blur(10px);
|
|
border: 1px solid rgba(255, 255, 255, 0.2);
|
|
}
|
|
|
|
.header-title {
|
|
font-size: 1.6rem;
|
|
font-weight: 700;
|
|
color: rgb(255, 255, 255);
|
|
margin-bottom: 8px;
|
|
text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
|
|
}
|
|
|
|
.header-subtitle {
|
|
font-size: 1rem;
|
|
color: rgba(255, 255, 255, 0.95);
|
|
margin-bottom: 15px;
|
|
text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
|
|
}
|
|
|
|
.progress-info {
|
|
display: none;
|
|
}
|
|
|
|
.progress-item {
|
|
text-align: center;
|
|
}
|
|
|
|
.progress-number {
|
|
font-size: 1.4rem;
|
|
font-weight: 700;
|
|
color: #ffffff;
|
|
display: block;
|
|
text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
|
|
}
|
|
|
|
.progress-label {
|
|
font-size: 0.75rem;
|
|
color: rgba(255, 255, 255, 0.9);
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.5px;
|
|
font-weight: 500;
|
|
}
|
|
|
|
.global-actions {
|
|
display: none;
|
|
}
|
|
|
|
.global-btn {
|
|
padding: 12px 24px;
|
|
border: none;
|
|
border-radius: 8px;
|
|
font-size: 1rem;
|
|
font-weight: bold;
|
|
cursor: pointer;
|
|
transition: all 0.2s ease;
|
|
}
|
|
|
|
.fill-all-btn {
|
|
background: #ff6b35;
|
|
color: white;
|
|
padding: 12px 28px;
|
|
border: none;
|
|
border-radius: 6px;
|
|
cursor: pointer;
|
|
font-size: 1rem;
|
|
font-weight: bold;
|
|
transition: all 0.2s ease;
|
|
}
|
|
|
|
.fill-all-btn:hover {
|
|
background: #e55a2b;
|
|
transform: translateY(-2px);
|
|
box-shadow: 0 4px 12px rgba(255, 107, 53, 0.3);
|
|
}
|
|
|
|
.save-all-btn {
|
|
background: #17a2b8;
|
|
color: white;
|
|
}
|
|
|
|
.save-all-btn:hover {
|
|
background: #138496;
|
|
transform: translateY(-1px);
|
|
box-shadow: 0 4px 8px rgba(23, 162, 184, 0.3);
|
|
}
|
|
|
|
.players-search-bar {
|
|
padding: 8px 10px;
|
|
border-bottom: 1px solid #e9ecef;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.players-search-wrap {
|
|
display: flex;
|
|
align-items: center;
|
|
border: 1px solid #dee2e6;
|
|
border-radius: 6px;
|
|
background: white;
|
|
overflow: hidden;
|
|
transition: border-color 0.15s;
|
|
transform: none !important;
|
|
}
|
|
|
|
.players-search-wrap:hover {
|
|
transform: none !important;
|
|
box-shadow: none;
|
|
}
|
|
|
|
.players-search-wrap:focus-within {
|
|
border-color: #28a745;
|
|
}
|
|
|
|
.players-search-input {
|
|
flex: 1;
|
|
border: none !important;
|
|
border-radius: 0 !important;
|
|
box-shadow: none !important;
|
|
padding: 5px 8px;
|
|
font-size: 0.8rem;
|
|
background: transparent;
|
|
outline: none !important;
|
|
min-width: 0;
|
|
width: auto;
|
|
transform: none !important;
|
|
}
|
|
|
|
.players-search-clear {
|
|
width: 26px;
|
|
height: 26px;
|
|
border: none;
|
|
background: transparent;
|
|
cursor: pointer;
|
|
font-size: 0.7rem;
|
|
color: #adb5bd;
|
|
display: none;
|
|
align-items: center;
|
|
justify-content: center;
|
|
flex-shrink: 0;
|
|
transition: color 0.15s;
|
|
padding: 0;
|
|
transform: none !important;
|
|
}
|
|
|
|
.players-search-clear.visible {
|
|
display: flex;
|
|
}
|
|
|
|
.players-search-clear:hover {
|
|
color: #dc3545;
|
|
transform: none !important;
|
|
}
|
|
|
|
.participants-list {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 8px;
|
|
width: 240px;
|
|
flex-shrink: 0;
|
|
box-sizing: border-box;
|
|
padding: 12px;
|
|
overflow-y: auto;
|
|
overflow-x: hidden;
|
|
flex: 1;
|
|
min-height: 0;
|
|
}
|
|
|
|
.participants-list::-webkit-scrollbar {
|
|
width: 8px;
|
|
}
|
|
|
|
.participants-list::-webkit-scrollbar-track {
|
|
background: transparent;
|
|
}
|
|
|
|
.participants-list::-webkit-scrollbar-thumb {
|
|
background: #d1d5db;
|
|
border-radius: 4px;
|
|
}
|
|
|
|
.participants-list::-webkit-scrollbar-thumb:hover {
|
|
background: #9ca3af;
|
|
}
|
|
|
|
/* Participant list item */
|
|
.participant-list-item {
|
|
padding: 10px 12px;
|
|
background: white;
|
|
border: 2px solid #9ca3af;
|
|
border-radius: 4px;
|
|
cursor: pointer;
|
|
transition: all 0.2s ease;
|
|
display: flex;
|
|
flex-direction: row;
|
|
gap: 8px;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
}
|
|
|
|
.participant-list-item:hover {
|
|
background: #f9f9f9;
|
|
}
|
|
|
|
.participant-list-item.active {
|
|
background: #f0f0f0;
|
|
}
|
|
|
|
.participant-list-item.in-progress {
|
|
border-color: #ffc107;
|
|
}
|
|
|
|
.participant-list-item.active.in-progress {
|
|
background: #fff5e6;
|
|
}
|
|
|
|
.participant-list-item.completed {
|
|
border-color: #28a745;
|
|
}
|
|
|
|
.participant-list-item.active.completed {
|
|
background: #e8f5e8;
|
|
}
|
|
|
|
.participant-list-item-content {
|
|
display: flex;
|
|
flex-direction: row;
|
|
gap: 6px;
|
|
align-items: center;
|
|
width: 100%;
|
|
min-width: 0;
|
|
}
|
|
|
|
.participant-list-item-name {
|
|
font-size: 0.85rem;
|
|
font-weight: 700;
|
|
color: #000 !important;
|
|
flex: 1;
|
|
min-width: 0;
|
|
white-space: nowrap;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
}
|
|
|
|
.participant-list-item-score {
|
|
font-size: 0.7rem;
|
|
font-weight: 700;
|
|
color: #28a745 !important;
|
|
min-width: fit-content;
|
|
}
|
|
|
|
.participant-list-item-tens {
|
|
font-size: 0.7rem;
|
|
font-weight: 700;
|
|
color: #ffc107 !important;
|
|
min-width: fit-content;
|
|
}
|
|
|
|
/* Main card panel */
|
|
.main-card-panel {
|
|
flex: 1;
|
|
display: flex;
|
|
flex-direction: column;
|
|
overflow: hidden;
|
|
padding: 0;
|
|
background: transparent;
|
|
min-height: 0;
|
|
gap: 0;
|
|
}
|
|
|
|
.main-card-panel-empty {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
flex: 1;
|
|
color: #999;
|
|
font-size: 1.1rem;
|
|
}
|
|
|
|
.participant-card {
|
|
background: white;
|
|
border-radius: 12px;
|
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
|
|
padding: 0;
|
|
width: 100%;
|
|
border: 2px solid #9ca3af;
|
|
transition: all 0.3s ease;
|
|
box-sizing: border-box;
|
|
display: none;
|
|
flex-direction: column;
|
|
overflow: hidden;
|
|
flex: 1;
|
|
min-height: 0;
|
|
}
|
|
|
|
/* Hide participant card items in list (shown individually) */
|
|
.participants-list .participant-card {
|
|
display: none;
|
|
}
|
|
|
|
/* Show only active card in main panel */
|
|
.main-card-panel .participant-card.active {
|
|
display: flex;
|
|
}
|
|
|
|
.participant-card.completed {
|
|
border-color: #28a745;
|
|
box-shadow: 0 4px 16px rgba(40, 167, 69, 0.15);
|
|
}
|
|
|
|
.participant-card.in-progress {
|
|
border-color: #ffc107;
|
|
box-shadow: 0 6px 24px rgba(255, 193, 7, 0.25);
|
|
}
|
|
|
|
/* Darker styling for selected/active card */
|
|
.main-card-panel .participant-card.active {
|
|
background: #f5f7fa;
|
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
|
}
|
|
|
|
.card-header-top {
|
|
background: white;
|
|
border-bottom: 1px solid #e9ecef;
|
|
display: flex;
|
|
flex-direction: row;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
padding: 14px 16px;
|
|
flex-shrink: 0;
|
|
width: 100%;
|
|
gap: 12px;
|
|
transition: all 0.2s ease;
|
|
}
|
|
|
|
|
|
/* Hide collapse icon */
|
|
.collapse-icon {
|
|
display: none;
|
|
}
|
|
|
|
.header-info {
|
|
display: flex;
|
|
flex-direction: row;
|
|
justify-content: flex-start;
|
|
align-items: center;
|
|
text-align: left;
|
|
width: 100%;
|
|
gap: 20px;
|
|
flex: 1;
|
|
min-width: 0;
|
|
position: relative;
|
|
}
|
|
|
|
.header-info .player-name {
|
|
flex: 0 1 auto;
|
|
min-width: 0;
|
|
}
|
|
|
|
.header-info .player-stats {
|
|
position: absolute;
|
|
left: 50%;
|
|
transform: translateX(-50%);
|
|
flex: 0;
|
|
}
|
|
|
|
.header-actions {
|
|
display: flex;
|
|
gap: 8px;
|
|
width: auto;
|
|
justify-content: flex-end;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.collapse-icon {
|
|
width: 24px;
|
|
height: 24px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
color: #666;
|
|
transition: transform 0.2s ease;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.participant-card.collapsed .collapse-icon {
|
|
transform: rotate(-90deg);
|
|
}
|
|
|
|
.header-btn {
|
|
width: 40px;
|
|
height: 40px;
|
|
padding: 0;
|
|
border: none;
|
|
border-radius: 6px;
|
|
font-size: 1.1rem;
|
|
cursor: pointer;
|
|
transition: all 0.2s ease;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.header-btn.clear-btn {
|
|
background: #dc3545;
|
|
color: white;
|
|
}
|
|
|
|
.header-btn.clear-btn:hover {
|
|
background: #c82333;
|
|
transform: translateY(-1px);
|
|
box-shadow: 0 3px 8px rgba(220, 53, 69, 0.25);
|
|
}
|
|
|
|
.header-btn.zero-fill-btn {
|
|
background: #6c757d;
|
|
color: white;
|
|
}
|
|
|
|
.header-btn.zero-fill-btn:hover {
|
|
background: #5a6268;
|
|
transform: translateY(-1px);
|
|
box-shadow: 0 3px 8px rgba(108, 117, 125, 0.25);
|
|
}
|
|
|
|
.participant-card.completed .card-header-top {
|
|
background: #f0f8f5;
|
|
border-bottom-color: #28a745;
|
|
}
|
|
|
|
.participant-card.completed .card-header-top:hover {
|
|
background: #e8f5e8;
|
|
}
|
|
|
|
.participant-card.in-progress .card-header-top {
|
|
background: #fffbf0;
|
|
border-bottom-color: #ffc107;
|
|
}
|
|
|
|
.participant-card.in-progress .card-header-top:hover {
|
|
background: #fff8e6;
|
|
}
|
|
|
|
.participant-header {
|
|
background: linear-gradient(135deg, #f8f9fa 0%, #f0f1f3 100%);
|
|
border-bottom: 3px solid #e9ecef;
|
|
display: flex;
|
|
flex-direction: column;
|
|
justify-content: center;
|
|
align-items: center;
|
|
padding: 12px 14px;
|
|
flex-shrink: 0;
|
|
text-align: center;
|
|
width: 100%;
|
|
}
|
|
|
|
.participant-card.completed .participant-header {
|
|
background: linear-gradient(135deg, #e8f5e8 0%, #c8e6c9 100%);
|
|
border-right-color: #28a745;
|
|
}
|
|
|
|
.participant-card.in-progress .participant-header {
|
|
background: linear-gradient(135deg, #fffbf0 0%, #fff8e6 100%);
|
|
border-right-color: #ffc107;
|
|
}
|
|
|
|
.participant-targets-wrapper {
|
|
display: flex;
|
|
flex-direction: column;
|
|
flex: 1;
|
|
overflow-y: auto;
|
|
overflow-x: hidden;
|
|
min-height: 0;
|
|
padding: 10px 12px;
|
|
padding-right: 4px;
|
|
gap: 8px;
|
|
transition: all 0.3s ease;
|
|
max-height: 100%;
|
|
}
|
|
|
|
.participant-card.collapsed .participant-targets-wrapper {
|
|
max-height: 0;
|
|
overflow: hidden;
|
|
padding: 0;
|
|
}
|
|
|
|
.participant-targets-wrapper::-webkit-scrollbar {
|
|
width: 12px;
|
|
}
|
|
|
|
.participant-targets-wrapper::-webkit-scrollbar-track {
|
|
background: transparent;
|
|
border-radius: 6px;
|
|
margin-right: 4px;
|
|
}
|
|
|
|
.participant-targets-wrapper::-webkit-scrollbar-thumb {
|
|
border-radius: 6px;
|
|
border: 2px solid white;
|
|
background-clip: padding-box;
|
|
}
|
|
|
|
/* Default neutral scrollbar */
|
|
.participant-card:not(.completed):not(.in-progress) .participant-targets-wrapper::-webkit-scrollbar-thumb {
|
|
background: #9ca3af;
|
|
}
|
|
|
|
.participant-card:not(.completed):not(.in-progress) .participant-targets-wrapper::-webkit-scrollbar-thumb:hover {
|
|
background: #6b7280;
|
|
background-clip: padding-box;
|
|
}
|
|
|
|
/* Scrollbar color for completed cards */
|
|
.participant-card.completed .participant-targets-wrapper::-webkit-scrollbar-thumb {
|
|
background: #28a745;
|
|
}
|
|
|
|
.participant-card.completed .participant-targets-wrapper::-webkit-scrollbar-thumb:hover {
|
|
background: #1f7e34;
|
|
background-clip: padding-box;
|
|
}
|
|
|
|
/* Scrollbar color for in-progress cards */
|
|
.participant-card.in-progress .participant-targets-wrapper::-webkit-scrollbar-thumb {
|
|
background: #ffc107;
|
|
}
|
|
|
|
.participant-card.in-progress .participant-targets-wrapper::-webkit-scrollbar-thumb:hover {
|
|
background: #e0a800;
|
|
background-clip: padding-box;
|
|
}
|
|
|
|
.player-info {
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
gap: 6px;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.player-name {
|
|
font-size: 1.05rem;
|
|
font-weight: 700;
|
|
color: #2c3e50;
|
|
margin: 0;
|
|
letter-spacing: 0.3px;
|
|
text-align: left;
|
|
white-space: nowrap;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
}
|
|
|
|
.player-stats {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 24px;
|
|
font-size: 0.85rem;
|
|
justify-content: center;
|
|
flex: 0 0 auto;
|
|
}
|
|
|
|
.total-score {
|
|
font-size: 1.2rem;
|
|
font-weight: 700;
|
|
color: #28a745 !important;
|
|
text-align: center;
|
|
}
|
|
|
|
.score-label {
|
|
color: #999;
|
|
font-size: 0.65rem;
|
|
text-transform: uppercase;
|
|
font-weight: 600;
|
|
letter-spacing: 0.5px;
|
|
}
|
|
|
|
.tens-count {
|
|
font-size: 1.2rem;
|
|
font-weight: 700;
|
|
color: #ffc107 !important;
|
|
text-align: center;
|
|
}
|
|
|
|
.tens-label {
|
|
color: #999;
|
|
font-size: 0.65rem;
|
|
text-transform: uppercase;
|
|
font-weight: 600;
|
|
letter-spacing: 0.5px;
|
|
}
|
|
|
|
.completion-badge {
|
|
padding: 4px 10px;
|
|
border-radius: 12px;
|
|
font-size: 0.7rem;
|
|
font-weight: 700;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.5px;
|
|
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
|
|
}
|
|
|
|
.badge-done {
|
|
background: #28a745;
|
|
color: white;
|
|
box-shadow: 0 2px 8px rgba(40, 167, 69, 0.3);
|
|
}
|
|
|
|
.badge-pending {
|
|
background: #ffc107;
|
|
color: #856404;
|
|
box-shadow: 0 2px 8px rgba(255, 193, 7, 0.3);
|
|
}
|
|
|
|
.badge-in-progress {
|
|
background: #5a8fd1;
|
|
color: white;
|
|
box-shadow: 0 2px 8px rgba(90, 143, 209, 0.3);
|
|
}
|
|
|
|
.badge-not-started {
|
|
background: #9ca3af;
|
|
color: white;
|
|
box-shadow: 0 2px 6px rgba(156, 163, 175, 0.2);
|
|
}
|
|
|
|
.participant-info {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 15px;
|
|
}
|
|
|
|
.participant-name {
|
|
font-size: 1.4rem;
|
|
font-weight: bold;
|
|
color: #333;
|
|
}
|
|
|
|
.participant-id {
|
|
background: #28a745;
|
|
color: white;
|
|
padding: 6px 15px;
|
|
border-radius: 15px;
|
|
font-size: 0.9rem;
|
|
font-weight: bold;
|
|
}
|
|
|
|
.joker-checkbox-wrapper {
|
|
margin-top: 8px;
|
|
}
|
|
|
|
.joker-label {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
cursor: pointer;
|
|
padding: 6px 12px;
|
|
background: #fff3cd;
|
|
border: 2px solid #ffc107;
|
|
border-radius: 8px;
|
|
transition: all 0.2s ease;
|
|
}
|
|
|
|
.joker-label:hover {
|
|
background: #ffc107;
|
|
border-color: #ff9800;
|
|
}
|
|
|
|
.joker-checkbox-calc {
|
|
cursor: pointer;
|
|
width: 18px;
|
|
height: 18px;
|
|
}
|
|
|
|
.joker-checkbox-calc:disabled {
|
|
cursor: not-allowed;
|
|
opacity: 0.6;
|
|
}
|
|
|
|
.joker-text {
|
|
font-size: 0.9rem;
|
|
font-weight: 600;
|
|
color: #856404;
|
|
}
|
|
|
|
.participant-status {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 15px;
|
|
}
|
|
|
|
.score-display {
|
|
text-align: right;
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 5px;
|
|
}
|
|
|
|
.score-row {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 15px;
|
|
}
|
|
|
|
.total-score {
|
|
text-align: right;
|
|
}
|
|
|
|
.score-number {
|
|
font-size: 1.8rem;
|
|
font-weight: bold;
|
|
color: #28a745;
|
|
}
|
|
|
|
.score-label {
|
|
font-size: 0.8rem;
|
|
color: #666;
|
|
text-transform: uppercase;
|
|
}
|
|
|
|
.tens-count {
|
|
text-align: right;
|
|
}
|
|
|
|
.tens-number {
|
|
font-size: 1.4rem;
|
|
font-weight: bold;
|
|
color: #ffc107;
|
|
}
|
|
|
|
.tens-label {
|
|
font-size: 0.8rem;
|
|
color: #666;
|
|
text-transform: uppercase;
|
|
}
|
|
|
|
.completion-badge {
|
|
padding: 6px 15px;
|
|
border-radius: 15px;
|
|
font-size: 0.9rem;
|
|
font-weight: bold;
|
|
text-transform: uppercase;
|
|
}
|
|
|
|
.badge-completed {
|
|
background: #28a745;
|
|
color: white;
|
|
}
|
|
|
|
.badge-in-progress {
|
|
background: #ffc107;
|
|
color: #856404;
|
|
}
|
|
|
|
.badge-not-started {
|
|
background: #6c757d;
|
|
color: white;
|
|
}
|
|
|
|
.collapse-icon {
|
|
font-size: 1.2rem;
|
|
transition: transform 0.3s ease;
|
|
color: #666;
|
|
}
|
|
|
|
.participant-card.collapsed .collapse-icon {
|
|
transform: rotate(-90deg);
|
|
}
|
|
|
|
.participant-content {
|
|
max-height: 1000px;
|
|
overflow: hidden;
|
|
transition: max-height 0.3s ease;
|
|
}
|
|
|
|
.participant-card.collapsed .participant-content {
|
|
max-height: 0;
|
|
}
|
|
|
|
/* Target grid layout */
|
|
.targets-row {
|
|
display: grid;
|
|
gap: 6px;
|
|
width: 100%;
|
|
padding: 6px 0;
|
|
}
|
|
|
|
/* Grid layouts for different target counts */
|
|
.targets-row.targets-4 {
|
|
grid-template-columns: repeat(2, 1fr);
|
|
}
|
|
|
|
.targets-row.targets-20 {
|
|
grid-template-columns: repeat(5, 1fr);
|
|
}
|
|
|
|
.targets-row.targets-40 {
|
|
grid-template-columns: repeat(8, 1fr);
|
|
}
|
|
|
|
.targets-row .target-group {
|
|
display: flex;
|
|
flex-direction: column;
|
|
width: 100%;
|
|
}
|
|
|
|
.shot-input {
|
|
padding: 8px;
|
|
text-align: center;
|
|
border: 2px solid #ddd;
|
|
border-radius: 4px;
|
|
font-size: 1rem;
|
|
font-weight: 600;
|
|
cursor: pointer;
|
|
transition: all 0.2s ease;
|
|
background-color: #ffffff;
|
|
}
|
|
|
|
.shot-input:focus {
|
|
outline: none;
|
|
border-color: #28a745;
|
|
box-shadow: 0 0 0 2px rgba(40, 167, 69, 0.2);
|
|
}
|
|
|
|
.shot-input.valid {
|
|
border-color: #28a745;
|
|
background: #f0f8f5;
|
|
}
|
|
|
|
.shot-input.ten {
|
|
border-color: #ffc107;
|
|
background: #fff9e6;
|
|
font-weight: bold;
|
|
}
|
|
|
|
.shot-input.empty {
|
|
color: #999;
|
|
}
|
|
|
|
/* Responsive adjustments */
|
|
@media (max-width: 1200px) {
|
|
.targets-row {
|
|
padding: 8px;
|
|
gap: 5px;
|
|
}
|
|
|
|
.target-group {
|
|
min-width: 50px;
|
|
padding: 2px;
|
|
}
|
|
|
|
.shot-input {
|
|
width: 24px;
|
|
padding: 1px;
|
|
font-size: 0.55rem;
|
|
min-height: 16px;
|
|
}
|
|
|
|
.participant-header {
|
|
gap: 15px;
|
|
}
|
|
|
|
.player-name {
|
|
font-size: 1rem;
|
|
}
|
|
}
|
|
|
|
@media (max-width: 768px) {
|
|
.participant-header {
|
|
flex-wrap: wrap;
|
|
gap: 12px;
|
|
padding: 12px;
|
|
}
|
|
|
|
.targets-row {
|
|
width: 100%;
|
|
order: 3;
|
|
padding: 6px;
|
|
margin-top: 8px;
|
|
border-top: 1px solid #e9ecef;
|
|
}
|
|
|
|
.player-info {
|
|
min-width: auto;
|
|
}
|
|
|
|
.completion-badge {
|
|
margin-left: auto;
|
|
}
|
|
|
|
.player-name {
|
|
font-size: 0.9rem;
|
|
}
|
|
|
|
.target-group {
|
|
min-width: 45px;
|
|
padding: 2px;
|
|
}
|
|
|
|
.shot-input {
|
|
width: 22px;
|
|
padding: 1px;
|
|
font-size: 0.5rem;
|
|
min-height: 14px;
|
|
}
|
|
|
|
.target-number {
|
|
font-size: 0.5rem;
|
|
}
|
|
}
|
|
|
|
.target-group {
|
|
border: 1px solid #e9ecef;
|
|
border-radius: 4px;
|
|
background: #f8f9fa;
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 4px;
|
|
padding: 0;
|
|
overflow: hidden;
|
|
transition: all 0.2s ease;
|
|
}
|
|
|
|
.target-group.completed {
|
|
border-color: #28a745;
|
|
background: #f0f8f5;
|
|
box-shadow: 0 2px 6px rgba(40, 167, 69, 0.1);
|
|
}
|
|
|
|
.target-number {
|
|
background: linear-gradient(135deg, #f0f1f3 0%, #e8eaed 100%);
|
|
border-bottom: 1px solid #e9ecef;
|
|
font-size: 0.65rem;
|
|
font-weight: 600;
|
|
color: #495057;
|
|
letter-spacing: 0;
|
|
padding: 3px 4px;
|
|
text-align: center;
|
|
flex-shrink: 0;
|
|
transition: all 0.2s ease;
|
|
}
|
|
|
|
.target-group.completed .target-number {
|
|
background: linear-gradient(135deg, #e8f5e8 0%, #c8e6c9 100%);
|
|
border-bottom-color: #28a745;
|
|
color: #28a745;
|
|
}
|
|
|
|
.shots-container {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 4px;
|
|
padding: 4px;
|
|
flex: 1;
|
|
}
|
|
|
|
.shots-container.shots-5 {
|
|
gap: 3px;
|
|
}
|
|
|
|
.shot-input {
|
|
width: 100%;
|
|
padding: 4px 2px;
|
|
border: 1px solid #ddd;
|
|
border-radius: 3px;
|
|
text-align: center;
|
|
font-size: 0.75rem;
|
|
font-weight: 700;
|
|
color: #333;
|
|
background-color: #ffffff;
|
|
min-height: 24px;
|
|
transition: all 0.2s ease;
|
|
}
|
|
|
|
.shots-container.shots-5 .shot-input {
|
|
min-height: 22px;
|
|
font-size: 0.7rem;
|
|
}
|
|
|
|
.shot-input:focus {
|
|
outline: none;
|
|
border-color: #28a745;
|
|
box-shadow: 0 0 0 1px rgba(40, 167, 69, 0.3);
|
|
}
|
|
|
|
.shot-input.valid {
|
|
border-color: #28a745;
|
|
background: #ffffff;
|
|
}
|
|
|
|
.shot-input.ten {
|
|
border-color: #ffc107;
|
|
background: #ffffff;
|
|
font-weight: 700;
|
|
color: #ffc107;
|
|
}
|
|
|
|
.participant-actions {
|
|
display: flex;
|
|
gap: 6px;
|
|
padding: 8px;
|
|
flex-shrink: 0;
|
|
align-items: center;
|
|
justify-content: center;
|
|
flex-direction: row;
|
|
border-top: 3px solid #e9ecef;
|
|
background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
|
|
width: 100%;
|
|
}
|
|
|
|
.action-btn {
|
|
width: 38px;
|
|
height: 38px;
|
|
padding: 0;
|
|
border: none;
|
|
border-radius: 6px;
|
|
font-size: 0.95rem;
|
|
cursor: pointer;
|
|
transition: all 0.2s ease;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.clear-btn {
|
|
background: #f8f9fa;
|
|
border: 2px solid #dc3545;
|
|
color: #dc3545;
|
|
}
|
|
|
|
.clear-btn:hover {
|
|
background: #dc3545;
|
|
color: white;
|
|
transform: translateY(-1px);
|
|
}
|
|
|
|
.zero-fill-btn {
|
|
background: #f8f9fa;
|
|
border: 2px solid #6c757d;
|
|
color: #6c757d;
|
|
}
|
|
|
|
.zero-fill-btn:hover {
|
|
background: #6c757d;
|
|
color: white;
|
|
transform: translateY(-1px);
|
|
}
|
|
|
|
.auto-fill-btn {
|
|
background: #ffc107;
|
|
color: #856404;
|
|
}
|
|
|
|
.auto-fill-btn:hover {
|
|
background: #e0a800;
|
|
}
|
|
|
|
/* Finish bar - standalone card */
|
|
.finish-section {
|
|
background: #f8f9fa;
|
|
padding: 10px 20px;
|
|
display: flex;
|
|
flex-direction: row;
|
|
justify-content: center;
|
|
align-items: center;
|
|
gap: 15px;
|
|
flex-shrink: 0;
|
|
width: 100%;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
.finish-title {
|
|
display: none;
|
|
}
|
|
|
|
.finish-description {
|
|
display: none;
|
|
}
|
|
|
|
.finish-btn {
|
|
background: #28a745;
|
|
border: none;
|
|
color: white;
|
|
padding: 12px 28px;
|
|
border-radius: 6px;
|
|
cursor: pointer;
|
|
font-size: 1rem;
|
|
font-weight: bold;
|
|
transition: all 0.2s ease;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.finish-btn:hover {
|
|
background: #1e7e34;
|
|
transform: translateY(-2px);
|
|
box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
|
|
}
|
|
|
|
.finish-btn:disabled {
|
|
background: #6c757d;
|
|
cursor: not-allowed;
|
|
transform: none;
|
|
box-shadow: none;
|
|
}
|
|
|
|
.warning-message {
|
|
background: #fff3cd;
|
|
border: 1px solid #ffeaa7;
|
|
color: #856404;
|
|
padding: 12px 15px;
|
|
border-radius: 6px;
|
|
margin: 15px 0;
|
|
}
|
|
|
|
.finish-section .warning-message {
|
|
margin: 0;
|
|
padding: 8px 12px;
|
|
font-size: 0.9rem;
|
|
}
|
|
|
|
/* Loading and saving indicators */
|
|
.saving {
|
|
opacity: 0.7;
|
|
pointer-events: none;
|
|
}
|
|
|
|
.saving::after {
|
|
content: '';
|
|
position: absolute;
|
|
top: 50%;
|
|
left: 50%;
|
|
width: 20px;
|
|
height: 20px;
|
|
margin: -10px 0 0 -10px;
|
|
border: 2px solid #f3f3f3;
|
|
border-top: 2px solid #28a745;
|
|
border-radius: 50%;
|
|
animation: spin 1s linear infinite;
|
|
}
|
|
|
|
@keyframes spin {
|
|
0% { transform: rotate(0deg); }
|
|
100% { transform: rotate(360deg); }
|
|
}
|
|
|
|
/* ========== DRAFT PANEL (right) ========== */
|
|
.draft-panel {
|
|
width: 240px;
|
|
flex-shrink: 0;
|
|
display: flex;
|
|
flex-direction: column;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.draft-panel-header {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
padding: 10px 10px;
|
|
background: #f8f9fa;
|
|
border-bottom: 1px solid #e9ecef;
|
|
border-radius: 12px 12px 0 0;
|
|
flex-shrink: 0;
|
|
gap: 4px;
|
|
}
|
|
|
|
.draft-round-nav {
|
|
background: #f0f1f3;
|
|
border: 2px solid #dee2e6;
|
|
border-radius: 6px;
|
|
cursor: pointer;
|
|
width: 28px;
|
|
height: 28px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
font-weight: bold;
|
|
font-size: 0.9rem;
|
|
color: #333;
|
|
flex-shrink: 0;
|
|
transition: all 0.15s ease;
|
|
}
|
|
|
|
.draft-round-nav:hover:not(:disabled) {
|
|
background: #e9ecef;
|
|
border-color: #28a745;
|
|
color: #28a745;
|
|
}
|
|
|
|
.draft-round-nav:disabled {
|
|
opacity: 0.35;
|
|
cursor: not-allowed;
|
|
}
|
|
|
|
.draft-round-label {
|
|
font-size: 0.78rem;
|
|
font-weight: 700;
|
|
color: #333;
|
|
text-align: center;
|
|
flex: 1;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.draft-positions {
|
|
flex: 1;
|
|
overflow-y: auto;
|
|
padding: 8px;
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 6px;
|
|
}
|
|
|
|
.draft-positions::-webkit-scrollbar { width: 6px; }
|
|
.draft-positions::-webkit-scrollbar-track { background: transparent; }
|
|
.draft-positions::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
|
|
|
|
.draft-position-row {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
padding: 7px 9px;
|
|
background: white;
|
|
border: 2px solid #dee2e6;
|
|
border-radius: 8px;
|
|
cursor: pointer;
|
|
transition: all 0.15s ease;
|
|
}
|
|
|
|
.draft-position-row:hover {
|
|
border-color: #5a8fd1;
|
|
background: #f0f5fc;
|
|
}
|
|
|
|
.draft-position-num {
|
|
width: 26px;
|
|
height: 26px;
|
|
border-radius: 6px;
|
|
background: #5a8fd1;
|
|
color: white;
|
|
font-size: 0.85rem;
|
|
font-weight: 700;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.draft-position-row.empty .draft-position-num {
|
|
background: #9ca3af;
|
|
}
|
|
|
|
.draft-position-name {
|
|
font-size: 0.8rem;
|
|
font-weight: 600;
|
|
color: #2c3e50;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
white-space: nowrap;
|
|
flex: 1;
|
|
min-width: 0;
|
|
}
|
|
|
|
.draft-position-row.empty .draft-position-name {
|
|
color: #adb5bd;
|
|
font-style: italic;
|
|
font-weight: 400;
|
|
}
|
|
|
|
.draft-panel-footer {
|
|
margin-top: auto;
|
|
padding: 12px;
|
|
border-top: 1px solid #e9ecef;
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
}
|
|
|
|
</style>
|
|
<script src="/static/js/i18n.js"></script>
|
|
</head>
|
|
<body>
|
|
<div class="navbar">
|
|
<div class="navbar-title">🎯 <span data-i18n="scoring.results_calculator">Kalkulator</span></div>
|
|
<div class="navbar-controls">
|
|
<a href="/tournament" class="nav-btn">🏆 <span data-i18n="navigation.tournament">Tournament</span></a>
|
|
<a href="/tournament/draft" class="nav-btn">📋 Razpored</a>
|
|
<a href="/results/calculator" class="nav-btn active">🎯 <span data-i18n="navigation.calculator">Kalkulator</span></a>
|
|
<a href="/" class="nav-btn">✕</a>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="content-wrapper">
|
|
<div class="container">
|
|
|
|
<!-- LEFT: Players card -->
|
|
<div class="calc-card" style="width:240px;flex-shrink:0;align-self:stretch;">
|
|
<div class="players-search-bar">
|
|
<div class="players-search-wrap">
|
|
<input class="players-search-input" id="playerSearch" type="text" placeholder="🔍 Iskanje..." oninput="filterPlayers(this.value)">
|
|
<button class="players-search-clear" onclick="clearPlayerSearch()" title="Clear">✕</button>
|
|
</div>
|
|
</div>
|
|
<div class="participants-list" id="participantsList">
|
|
{% for player_id, participant in results.participants.items() %}
|
|
<div class="participant-list-item {{ 'completed' if participant.completed else '' }}" onclick="selectParticipant({{ player_id }})" id="list-item-{{ player_id }}" data-player-id="{{ player_id }}">
|
|
<div class="participant-list-item-content">
|
|
<span class="participant-list-item-name">{{ participant.name }}</span>
|
|
<span class="participant-list-item-score" id="list-score-{{ player_id }}">{{ participant.total_score }}</span>
|
|
<span class="participant-list-item-tens" id="list-tens-{{ player_id }}">0</span>
|
|
</div>
|
|
</div>
|
|
{% endfor %}
|
|
</div>
|
|
</div>
|
|
|
|
<!-- MIDDLE: Scoring card + Finish card -->
|
|
<div style="flex:1;display:flex;flex-direction:column;gap:12px;min-height:0;overflow:hidden;">
|
|
|
|
<!-- Scoring card -->
|
|
<div class="calc-card" style="flex:1;min-height:0;">
|
|
<div class="main-card-panel" id="mainCardPanel">
|
|
<div class="main-card-panel-empty" id="emptyPanel">
|
|
👈 <span data-i18n="general.select">Select a participant</span>
|
|
</div>
|
|
{% for player_id, participant in results.participants.items() %}
|
|
<div class="participant-card {{ 'completed' if participant.completed else 'in-progress' }}" id="card-{{ player_id }}" data-player-id="{{ player_id }}">
|
|
<!-- Card Header on Top -->
|
|
<div class="card-header-top">
|
|
<div class="header-info">
|
|
<div class="player-name">{{ participant.name }}</div>
|
|
<div class="player-stats">
|
|
<div style="display: flex; flex-direction: column; align-items: center;">
|
|
<span class="total-score" id="total-{{ player_id }}">{{ participant.total_score }}</span>
|
|
<span class="score-label" data-i18n="scoring.points">pts</span>
|
|
</div>
|
|
<div style="display: flex; flex-direction: column; align-items: center;">
|
|
<span class="tens-count" id="tens-{{ player_id }}">0</span>
|
|
<span class="tens-label">10s</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="header-actions" onclick="event.stopPropagation();">
|
|
<button class="header-btn clear-btn" onclick="clearParticipant({{ player_id }})" data-i18n-title="scoring.clear_all_scores">
|
|
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
<polyline points="3 6 5 6 21 6"></polyline>
|
|
<path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path>
|
|
<line x1="10" y1="11" x2="10" y2="17"></line>
|
|
<line x1="14" y1="11" x2="14" y2="17"></line>
|
|
</svg>
|
|
</button>
|
|
<button class="header-btn zero-fill-btn" onclick="fillEmptyWithZeros({{ player_id }})" data-i18n-title="scoring.fill_empty_with_zero">
|
|
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
<circle cx="12" cy="12" r="10"></circle>
|
|
<line x1="12" y1="6" x2="12" y2="18"></line>
|
|
<line x1="6" y1="12" x2="18" y2="12"></line>
|
|
</svg>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
<!-- All Targets (scrollable) -->
|
|
<div class="participant-targets-wrapper">
|
|
<div class="targets-row" id="targets-{{ player_id }}">
|
|
<!-- Targets will be populated by JavaScript -->
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endfor %}
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Finish card -->
|
|
<div class="calc-card finish-section">
|
|
<button class="fill-all-btn" onclick="fillAllPlayersRandom()">
|
|
🎲 <span data-i18n="scoring.fill_all_players_random">Fill All Random</span>
|
|
</button>
|
|
<button class="finish-btn" id="finishBtn" onclick="finishTournament()" data-i18n="scoring.finish_tournament_button">🏁 Finish Tournament
|
|
</button>
|
|
</div>
|
|
|
|
</div><!-- end middle column -->
|
|
|
|
<!-- RIGHT: Draft card -->
|
|
{% if tournament and tournament.rounds %}
|
|
<div class="calc-card draft-panel">
|
|
<div class="draft-panel-header">
|
|
<button class="draft-round-nav" id="draftPrevBtn" onclick="draftChangeRound(-1)">←</button>
|
|
<span class="draft-round-label" id="draftRoundLabel">{{ tournament.current_round }} / {{ tournament.total_rounds }}</span>
|
|
<button class="draft-round-nav" id="draftNextBtn" onclick="draftChangeRound(1)">→</button>
|
|
</div>
|
|
<div class="draft-positions" id="draftPositions">
|
|
<!-- populated by JS -->
|
|
</div>
|
|
<div class="draft-panel-footer">
|
|
<button class="nav-btn" id="btnTvDraft" onclick="toggleTvDraft()">📺 Pokaži Razpored</button>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
|
|
</div><!-- end container -->
|
|
</div><!-- end content-wrapper -->
|
|
|
|
<script>
|
|
let results = {{ results|tojson }};
|
|
let saveTimeout = {};
|
|
|
|
// Tournament configuration
|
|
const tournamentType = results.tournament_type || '20_targets';
|
|
let numTargets, shotsPerTarget;
|
|
|
|
// Set tournament parameters
|
|
if (tournamentType === '40_targets') {
|
|
numTargets = 40;
|
|
shotsPerTarget = 2;
|
|
} else if (tournamentType === '4_targets') {
|
|
numTargets = 4;
|
|
shotsPerTarget = 5;
|
|
} else {
|
|
numTargets = 20;
|
|
shotsPerTarget = 2;
|
|
}
|
|
|
|
// Calculate 10s count for a player
|
|
function calculateTensCount(playerId) {
|
|
const playerIdStr = playerId.toString();
|
|
const targets = results.participants[playerIdStr].targets;
|
|
let tensCount = 0;
|
|
|
|
for (let target in targets) {
|
|
const targetData = targets[target];
|
|
for (let i = 1; i <= shotsPerTarget; i++) {
|
|
const shotValue = targetData[`shot${i}`];
|
|
if (shotValue === 10) {
|
|
tensCount++;
|
|
}
|
|
}
|
|
}
|
|
|
|
return tensCount;
|
|
}
|
|
|
|
// Update participant's 10s display
|
|
function updateParticipantTens(playerId) {
|
|
const tensCount = calculateTensCount(playerId);
|
|
|
|
// Update main card display
|
|
const tensElement = document.getElementById(`tens-${playerId}`);
|
|
if (tensElement) {
|
|
tensElement.textContent = tensCount;
|
|
|
|
// Add visual feedback
|
|
tensElement.style.color = '#ffc107';
|
|
setTimeout(() => {
|
|
tensElement.style.color = '';
|
|
}, 300);
|
|
}
|
|
|
|
// Update sidebar 10s count
|
|
const sidebarTensElement = document.getElementById(`list-tens-${playerId}`);
|
|
if (sidebarTensElement) {
|
|
sidebarTensElement.textContent = tensCount;
|
|
}
|
|
}
|
|
|
|
// Update overall 10s count
|
|
function updateOverallTens() {
|
|
let totalTens = 0;
|
|
|
|
for (let playerId in results.participants) {
|
|
totalTens += calculateTensCount(parseInt(playerId));
|
|
}
|
|
|
|
const ttEl = document.getElementById('totalTens'); if (ttEl) ttEl.textContent = totalTens;
|
|
}
|
|
|
|
// Debounce function for auto-saving
|
|
function debounce(func, wait, immediate) {
|
|
var timeout;
|
|
return function() {
|
|
var context = this, args = arguments;
|
|
var later = function() {
|
|
timeout = null;
|
|
if (!immediate) func.apply(context, args);
|
|
};
|
|
var callNow = immediate && !timeout;
|
|
clearTimeout(timeout);
|
|
timeout = setTimeout(later, wait);
|
|
if (callNow) func.apply(context, args);
|
|
};
|
|
}
|
|
|
|
function generateTargetsHTML(playerId) {
|
|
const participant = results.participants[playerId.toString()];
|
|
let html = '';
|
|
|
|
for (let i = 1; i <= numTargets; i++) {
|
|
const targetData = participant.targets[i.toString()] || {};
|
|
|
|
html += `
|
|
<div class="target-group" id="target-group-${playerId}-${i}">
|
|
<div class="target-number">${i}</div>
|
|
<div class="shots-container shots-${shotsPerTarget}">
|
|
`;
|
|
|
|
for (let shot = 1; shot <= shotsPerTarget; shot++) {
|
|
const shotKey = `shot${shot}`;
|
|
const value = targetData[shotKey];
|
|
const displayValue = value !== null && value !== undefined ? value : '';
|
|
|
|
html += `
|
|
<input type="number"
|
|
class="shot-input ${value === 10 ? 'ten' : ''}"
|
|
id="shot${shot}-${playerId}-${i}"
|
|
data-player="${playerId}"
|
|
data-target="${i}"
|
|
data-shot="${shot}"
|
|
min="0"
|
|
max="10"
|
|
value="${displayValue}"
|
|
placeholder="Strel ${shot}"
|
|
oninput="updateScore(${playerId}, ${i}, ${shot}, this.value)">
|
|
`;
|
|
}
|
|
|
|
html += `
|
|
</div>
|
|
</div>
|
|
`;
|
|
}
|
|
|
|
return html;
|
|
}
|
|
|
|
function initializeTargetsForPlayer(playerId) {
|
|
const targetsContainer = document.getElementById(`targets-${playerId}`);
|
|
if (targetsContainer) {
|
|
targetsContainer.className = `targets-row targets-${numTargets}`;
|
|
targetsContainer.innerHTML = generateTargetsHTML(playerId);
|
|
}
|
|
}
|
|
|
|
function toggleParticipant(playerId) {
|
|
const card = document.getElementById(`card-${playerId}`);
|
|
card.classList.toggle('collapsed');
|
|
}
|
|
|
|
function selectParticipant(playerId) {
|
|
// Remove active class from all list items and cards
|
|
document.querySelectorAll('.participant-list-item').forEach(item => {
|
|
item.classList.remove('active');
|
|
});
|
|
document.querySelectorAll('.participant-card').forEach(card => {
|
|
card.classList.remove('active');
|
|
});
|
|
|
|
// Add active class to selected item and card
|
|
const listItem = document.getElementById(`list-item-${playerId}`);
|
|
const card = document.getElementById(`card-${playerId}`);
|
|
|
|
if (listItem) listItem.classList.add('active');
|
|
if (card) card.classList.add('active');
|
|
|
|
// Hide empty panel if shown
|
|
const emptyPanel = document.getElementById('emptyPanel');
|
|
if (emptyPanel) emptyPanel.style.display = 'none';
|
|
}
|
|
|
|
function updateScore(playerId, targetNum, shotNum, value) {
|
|
const playerIdStr = playerId.toString();
|
|
const targetStr = targetNum.toString();
|
|
|
|
// Parse input - allow empty string, treat as null/undefined for completion check
|
|
let numValue = null;
|
|
if (value !== '' && value !== null && value !== undefined) {
|
|
numValue = parseInt(value);
|
|
if (isNaN(numValue)) numValue = null;
|
|
else numValue = Math.max(0, Math.min(10, numValue)); // Clamp between 0-10
|
|
}
|
|
|
|
// Update the input field with clamped value
|
|
const input = document.getElementById(`shot${shotNum}-${playerId}-${targetNum}`);
|
|
if (input && numValue !== null && input.value !== numValue.toString()) {
|
|
input.value = numValue;
|
|
}
|
|
|
|
// Update local data
|
|
if (!results.participants[playerIdStr]) {
|
|
console.error('Player not found:', playerIdStr);
|
|
return;
|
|
}
|
|
if (!results.participants[playerIdStr].targets[targetStr]) {
|
|
// Initialize target with all shots as null
|
|
const target = {};
|
|
for (let i = 1; i <= shotsPerTarget; i++) {
|
|
target[`shot${i}`] = null;
|
|
}
|
|
results.participants[playerIdStr].targets[targetStr] = target;
|
|
}
|
|
|
|
results.participants[playerIdStr].targets[targetStr][`shot${shotNum}`] = numValue;
|
|
|
|
// Update target group styling
|
|
updateTargetGroupStyling(playerId, targetNum);
|
|
|
|
// Recalculate totals
|
|
updateParticipantTotal(playerId);
|
|
updateParticipantTens(playerId);
|
|
updateParticipantStatus(playerId);
|
|
updateOverallProgress();
|
|
updateOverallTens();
|
|
|
|
// Visual feedback for input - highlight 10s
|
|
if (input) {
|
|
input.classList.remove('valid', 'ten');
|
|
if (numValue !== null) {
|
|
if (numValue === 10) {
|
|
input.classList.add('ten');
|
|
} else {
|
|
input.classList.add('valid');
|
|
}
|
|
}
|
|
}
|
|
|
|
// Auto-save with debounce
|
|
clearTimeout(saveTimeout[playerId]);
|
|
saveTimeout[playerId] = setTimeout(() => {
|
|
saveParticipant(playerId, true);
|
|
}, 1000);
|
|
}
|
|
|
|
function updateTargetGroupStyling(playerId, targetNum) {
|
|
const playerIdStr = playerId.toString();
|
|
const targetStr = targetNum.toString();
|
|
const targetGroup = document.getElementById(`target-group-${playerId}-${targetNum}`);
|
|
|
|
if (targetGroup && results.participants[playerIdStr].targets[targetStr]) {
|
|
const targetData = results.participants[playerIdStr].targets[targetStr];
|
|
|
|
// Check if all shots are completed
|
|
let allCompleted = true;
|
|
for (let i = 1; i <= shotsPerTarget; i++) {
|
|
const shotValue = targetData[`shot${i}`];
|
|
if (shotValue === null || shotValue === undefined) {
|
|
allCompleted = false;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (allCompleted) {
|
|
targetGroup.classList.add('completed');
|
|
} else {
|
|
targetGroup.classList.remove('completed');
|
|
}
|
|
}
|
|
}
|
|
|
|
function updateParticipantTotal(playerId) {
|
|
const playerIdStr = playerId.toString();
|
|
const targets = results.participants[playerIdStr].targets;
|
|
let total = 0;
|
|
|
|
for (let target in targets) {
|
|
const targetData = targets[target];
|
|
for (let i = 1; i <= shotsPerTarget; i++) {
|
|
const shotValue = targetData[`shot${i}`];
|
|
total += (shotValue !== null && shotValue !== undefined ? shotValue : 0);
|
|
}
|
|
}
|
|
|
|
results.participants[playerIdStr].total_score = total;
|
|
|
|
// Update main card display
|
|
const totalElement = document.getElementById(`total-${playerId}`);
|
|
if (totalElement) {
|
|
totalElement.textContent = total;
|
|
|
|
// Add visual feedback
|
|
totalElement.style.color = '#28a745';
|
|
setTimeout(() => {
|
|
totalElement.style.color = '';
|
|
}, 300);
|
|
}
|
|
|
|
// Update sidebar score
|
|
const sidebarScoreElement = document.getElementById(`list-score-${playerId}`);
|
|
if (sidebarScoreElement) {
|
|
sidebarScoreElement.textContent = total;
|
|
}
|
|
}
|
|
|
|
function updateParticipantStatus(playerId) {
|
|
const playerIdStr = playerId.toString();
|
|
const targets = results.participants[playerIdStr].targets;
|
|
const card = document.getElementById(`card-${playerId}`);
|
|
|
|
let completedTargets = 0;
|
|
let totalShots = 0;
|
|
|
|
for (let target in targets) {
|
|
const targetData = targets[target];
|
|
let targetCompleted = true;
|
|
|
|
for (let i = 1; i <= shotsPerTarget; i++) {
|
|
const shotValue = targetData[`shot${i}`];
|
|
|
|
// Count shots that have been entered (including 0)
|
|
if (shotValue !== null && shotValue !== undefined) {
|
|
totalShots++;
|
|
} else {
|
|
targetCompleted = false;
|
|
}
|
|
}
|
|
|
|
if (targetCompleted) {
|
|
completedTargets++;
|
|
}
|
|
}
|
|
|
|
const isCompleted = completedTargets === numTargets;
|
|
const isInProgress = totalShots > 0 && !isCompleted;
|
|
|
|
results.participants[playerIdStr].completed = isCompleted;
|
|
|
|
// Update card styling based on status
|
|
if (card) {
|
|
card.classList.remove('completed', 'in-progress');
|
|
if (isCompleted) {
|
|
card.classList.add('completed');
|
|
} else if (isInProgress) {
|
|
card.classList.add('in-progress');
|
|
}
|
|
}
|
|
|
|
// Update sidebar styling based on status
|
|
const listItem = document.getElementById(`list-item-${playerId}`);
|
|
if (listItem) {
|
|
listItem.classList.remove('completed', 'in-progress');
|
|
if (isCompleted) {
|
|
listItem.classList.add('completed');
|
|
} else if (isInProgress) {
|
|
listItem.classList.add('in-progress');
|
|
}
|
|
}
|
|
}
|
|
|
|
function updateOverallProgress() {
|
|
let completedCount = 0;
|
|
let totalShots = 0;
|
|
|
|
for (let playerId in results.participants) {
|
|
const participant = results.participants[playerId];
|
|
if (participant.completed) {
|
|
completedCount++;
|
|
}
|
|
|
|
for (let target in participant.targets) {
|
|
const targetData = participant.targets[target];
|
|
for (let i = 1; i <= shotsPerTarget; i++) {
|
|
const shotValue = targetData[`shot${i}`];
|
|
if (shotValue !== null && shotValue !== undefined) totalShots++;
|
|
}
|
|
}
|
|
}
|
|
|
|
const ccEl = document.getElementById('completedCount'); if (ccEl) ccEl.textContent = completedCount;
|
|
const tsEl = document.getElementById('totalShots'); if (tsEl) tsEl.textContent = totalShots;
|
|
|
|
// Update finish button state
|
|
const finishBtn = document.getElementById('finishBtn');
|
|
const allCompleted = completedCount === Object.keys(results.participants).length;
|
|
|
|
if (finishBtn) {
|
|
finishBtn.disabled = !allCompleted;
|
|
}
|
|
}
|
|
|
|
async function saveParticipant(playerId, silent = false) {
|
|
try {
|
|
const playerIdStr = playerId.toString();
|
|
const participantData = results.participants[playerIdStr];
|
|
|
|
const response = await fetch(`/api/results/participant/${playerId}`, {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
},
|
|
body: JSON.stringify({
|
|
targets: participantData.targets
|
|
})
|
|
});
|
|
|
|
if (!response.ok) {
|
|
throw new Error('Failed to save');
|
|
}
|
|
} catch (error) {
|
|
console.error('Error saving participant:', error);
|
|
if (!silent) {
|
|
alert('Failed to save participant data. Please try again.');
|
|
}
|
|
}
|
|
}
|
|
|
|
async function saveAllPlayers() {
|
|
try {
|
|
const playerIds = Object.keys(results.participants);
|
|
for (const playerId of playerIds) {
|
|
await saveParticipant(parseInt(playerId), true);
|
|
}
|
|
} catch (error) {
|
|
console.error('Error saving all players:', error);
|
|
alert('Failed to save all player data. Please try again.');
|
|
}
|
|
}
|
|
|
|
function clearParticipant(playerId) {
|
|
if (!confirm('Are you sure you want to clear all scores for this participant?')) {
|
|
return;
|
|
}
|
|
|
|
const playerIdStr = playerId.toString();
|
|
|
|
// Clear all inputs
|
|
for (let i = 1; i <= numTargets; i++) {
|
|
for (let shot = 1; shot <= shotsPerTarget; shot++) {
|
|
const shotInput = document.getElementById(`shot${shot}-${playerId}-${i}`);
|
|
if (shotInput) {
|
|
shotInput.value = '';
|
|
shotInput.classList.remove('valid', 'ten');
|
|
}
|
|
}
|
|
|
|
// Update data
|
|
const target = {};
|
|
for (let shot = 1; shot <= shotsPerTarget; shot++) {
|
|
target[`shot${shot}`] = null;
|
|
}
|
|
results.participants[playerIdStr].targets[i.toString()] = target;
|
|
|
|
// Update target group styling
|
|
updateTargetGroupStyling(playerId, i);
|
|
}
|
|
|
|
updateParticipantTotal(playerId);
|
|
updateParticipantTens(playerId);
|
|
updateParticipantStatus(playerId);
|
|
updateOverallProgress();
|
|
updateOverallTens();
|
|
|
|
// Save changes
|
|
saveParticipant(playerId);
|
|
}
|
|
|
|
function fillEmptyWithZeros(playerId) {
|
|
const playerIdStr = playerId.toString();
|
|
let changedCount = 0;
|
|
|
|
// Fill all empty entries with 0
|
|
for (let i = 1; i <= numTargets; i++) {
|
|
const target = results.participants[playerIdStr].targets[i.toString()] || {};
|
|
|
|
for (let shot = 1; shot <= shotsPerTarget; shot++) {
|
|
const shotInput = document.getElementById(`shot${shot}-${playerId}-${i}`);
|
|
|
|
// Only fill if empty
|
|
if ((target[`shot${shot}`] === null || target[`shot${shot}`] === undefined) && shotInput && shotInput.value === '') {
|
|
shotInput.value = 0;
|
|
shotInput.classList.remove('ten');
|
|
shotInput.classList.add('valid');
|
|
changedCount++;
|
|
|
|
// Update data
|
|
if (!results.participants[playerIdStr].targets[i.toString()]) {
|
|
results.participants[playerIdStr].targets[i.toString()] = {};
|
|
}
|
|
results.participants[playerIdStr].targets[i.toString()][`shot${shot}`] = 0;
|
|
}
|
|
}
|
|
|
|
// Update target group styling
|
|
updateTargetGroupStyling(playerId, i);
|
|
}
|
|
|
|
if (changedCount > 0) {
|
|
updateParticipantTotal(playerId);
|
|
updateParticipantTens(playerId);
|
|
updateParticipantStatus(playerId);
|
|
updateOverallProgress();
|
|
updateOverallTens();
|
|
saveParticipant(playerId, true);
|
|
}
|
|
}
|
|
|
|
function autoFillDemo(playerId) {
|
|
if (!confirm('Fill with random demo scores? This will overwrite existing data.')) {
|
|
return;
|
|
}
|
|
|
|
fillPlayerRandom(playerId);
|
|
saveParticipant(playerId);
|
|
}
|
|
|
|
function fillPlayerRandom(playerId) {
|
|
const playerIdStr = playerId.toString();
|
|
let fillCount = 0;
|
|
|
|
// Fill with random scores (0-10) - all fields will be filled
|
|
for (let i = 1; i <= numTargets; i++) {
|
|
const target = {};
|
|
|
|
for (let shot = 1; shot <= shotsPerTarget; shot++) {
|
|
const randomScore = Math.floor(Math.random() * 11);
|
|
const inputId = `shot${shot}-${playerId}-${i}`;
|
|
const shotInput = document.getElementById(inputId);
|
|
|
|
if (shotInput) {
|
|
shotInput.value = randomScore;
|
|
shotInput.classList.remove('valid', 'ten');
|
|
if (randomScore === 10) {
|
|
shotInput.classList.add('ten');
|
|
} else {
|
|
shotInput.classList.add('valid');
|
|
}
|
|
fillCount++;
|
|
}
|
|
target[`shot${shot}`] = randomScore;
|
|
}
|
|
|
|
// Update data
|
|
results.participants[playerIdStr].targets[i.toString()] = target;
|
|
|
|
// Update target group styling
|
|
updateTargetGroupStyling(playerId, i);
|
|
}
|
|
|
|
console.log(`Player ${playerId}: filled ${fillCount} inputs`);
|
|
updateParticipantTotal(playerId);
|
|
updateParticipantTens(playerId);
|
|
updateParticipantStatus(playerId);
|
|
updateOverallProgress();
|
|
updateOverallTens();
|
|
}
|
|
|
|
async function fillAllPlayersRandom() {
|
|
if (!confirm('Fill ALL players with random demo scores? This will overwrite all existing data and enable tournament finish.')) {
|
|
return;
|
|
}
|
|
|
|
try {
|
|
// Fill all players with random data
|
|
const playerIds = Object.keys(results.participants);
|
|
for (const playerId of playerIds) {
|
|
fillPlayerRandom(parseInt(playerId));
|
|
}
|
|
|
|
// Save all players
|
|
for (const playerId of playerIds) {
|
|
await saveParticipant(parseInt(playerId), true);
|
|
}
|
|
|
|
} catch (error) {
|
|
console.error('Error filling all players:', error);
|
|
alert('Failed to fill all players: ' + error.message);
|
|
}
|
|
}
|
|
|
|
async function finishTournament() {
|
|
const allCompleted = Object.values(results.participants).every(p => p.completed);
|
|
|
|
if (!allCompleted) {
|
|
alert('Please complete scoring for all participants before finishing the tournament.');
|
|
return;
|
|
}
|
|
|
|
if (!confirm('Are you sure you want to finish the tournament? This will finalize all results and make them viewable.')) {
|
|
return;
|
|
}
|
|
|
|
const finishBtn = document.getElementById('finishBtn');
|
|
finishBtn.disabled = true;
|
|
const originalText = finishBtn.innerHTML;
|
|
const originalI18n = finishBtn.getAttribute('data-i18n');
|
|
finishBtn.removeAttribute('data-i18n');
|
|
finishBtn.innerHTML = '🔄 Finishing Tournament...';
|
|
|
|
try {
|
|
const response = await fetch('/api/results/finish', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
}
|
|
});
|
|
|
|
if (response.ok) {
|
|
const responseData = await response.json();
|
|
|
|
// Determine where to redirect based on tournament type and archive
|
|
let redirectUrl = '/results';
|
|
|
|
// Priority 1: If league finished, redirect to league archive
|
|
if (responseData.league_archived && responseData.league_archive_filename) {
|
|
redirectUrl = `/archive/league/${responseData.league_archive_filename}`;
|
|
}
|
|
// Priority 2: If standalone tournament, redirect to tournament archive
|
|
else if (responseData.archived && responseData.archive_filename) {
|
|
redirectUrl = `/archive/tournament/${responseData.archive_filename}`;
|
|
}
|
|
// Priority 3: If league tournament (not final), show league standings
|
|
else if (responseData.league && !responseData.league_finished) {
|
|
redirectUrl = '/results'; // This will show league standings with current tournament
|
|
}
|
|
|
|
// Always show results after tournament finishes
|
|
alert('Tournament finished successfully! Showing results...');
|
|
setTimeout(() => {
|
|
window.location.href = redirectUrl;
|
|
}, 1000);
|
|
} else {
|
|
const error = await response.json();
|
|
throw new Error(error.message || 'Failed to finish tournament');
|
|
}
|
|
} catch (error) {
|
|
console.error('Error finishing tournament:', error);
|
|
alert('Failed to finish tournament: ' + error.message);
|
|
finishBtn.disabled = false;
|
|
finishBtn.innerHTML = originalText;
|
|
if (originalI18n) {
|
|
finishBtn.setAttribute('data-i18n', originalI18n);
|
|
}
|
|
}
|
|
}
|
|
|
|
// Handle joker checkbox change
|
|
function handleJokerChange(playerId) {
|
|
const checkbox = document.getElementById(`joker-calc-${playerId}`);
|
|
const isChecked = checkbox.checked;
|
|
|
|
// If checked, warn user that all scores will be set to zero
|
|
if (isChecked) {
|
|
if (confirm('Marking this player as using their Joker will set all their scores to zero. Continue?')) {
|
|
// Set all scores to zero
|
|
const participant = results.participants[playerId];
|
|
if (participant && participant.targets) {
|
|
Object.keys(participant.targets).forEach(targetId => {
|
|
const target = participant.targets[targetId];
|
|
Object.keys(target).forEach(shotKey => {
|
|
if (shotKey.startsWith('shot')) {
|
|
target[shotKey] = 0;
|
|
}
|
|
});
|
|
});
|
|
}
|
|
participant.total_score = 0;
|
|
participant.completed = true; // Mark as completed since joker is used
|
|
participant.joker_selected = true; // Mark joker as selected in results
|
|
|
|
// Update UI
|
|
updateParticipantTotal(playerId);
|
|
updateParticipantStatus(playerId);
|
|
updateParticipantTens(playerId);
|
|
updateOverallProgress();
|
|
updateOverallTens();
|
|
|
|
// Disable the checkbox so it can't be unchecked
|
|
checkbox.disabled = true;
|
|
|
|
// Save the change
|
|
savePlayerData(playerId);
|
|
} else {
|
|
// User cancelled, uncheck the box
|
|
checkbox.checked = false;
|
|
}
|
|
}
|
|
}
|
|
|
|
// ── PLAYER SEARCH ────────────────────────────────────────────────────────
|
|
function filterPlayers(query) {
|
|
const q = query.trim().toLowerCase();
|
|
const clearBtn = document.querySelector('.players-search-clear');
|
|
if (clearBtn) clearBtn.classList.toggle('visible', q.length > 0);
|
|
document.querySelectorAll('.participant-list-item').forEach(item => {
|
|
const name = item.querySelector('.participant-list-item-name').textContent.toLowerCase();
|
|
item.style.display = (!q || name.includes(q)) ? '' : 'none';
|
|
});
|
|
}
|
|
|
|
function clearPlayerSearch() {
|
|
const input = document.getElementById('playerSearch');
|
|
input.value = '';
|
|
filterPlayers('');
|
|
input.focus();
|
|
}
|
|
|
|
// ── DRAFT PANEL ──────────────────────────────────────────────────────────
|
|
{% if tournament and tournament.rounds %}
|
|
const draftRounds = {{ tournament.rounds | tojson }};
|
|
let draftCurrentRound = {{ tournament.current_round }};
|
|
const draftTotalRounds = {{ tournament.total_rounds }};
|
|
|
|
function renderDraftPanel() {
|
|
const round = draftRounds.find(r => r.round_number === draftCurrentRound);
|
|
const positions = document.getElementById('draftPositions');
|
|
const label = document.getElementById('draftRoundLabel');
|
|
const prevBtn = document.getElementById('draftPrevBtn');
|
|
const nextBtn = document.getElementById('draftNextBtn');
|
|
|
|
if (!positions || !label) return;
|
|
|
|
label.textContent = `${draftCurrentRound} / ${draftTotalRounds}`;
|
|
if (prevBtn) prevBtn.disabled = draftCurrentRound <= 1;
|
|
if (nextBtn) nextBtn.disabled = draftCurrentRound >= draftTotalRounds;
|
|
|
|
const players = round ? round.players : [];
|
|
let html = '';
|
|
for (let pos = 1; pos <= 6; pos++) {
|
|
const player = players[pos - 1];
|
|
if (player) {
|
|
html += `<div class="draft-position-row" onclick="selectParticipant(${player.id})">
|
|
<div class="draft-position-num">${pos}</div>
|
|
<div class="draft-position-name">${player.name}</div>
|
|
</div>`;
|
|
} else {
|
|
html += `<div class="draft-position-row empty">
|
|
<div class="draft-position-num">${pos}</div>
|
|
<div class="draft-position-name">—</div>
|
|
</div>`;
|
|
}
|
|
}
|
|
positions.innerHTML = html;
|
|
}
|
|
|
|
async function draftChangeRound(direction) {
|
|
const newRound = draftCurrentRound + direction;
|
|
if (newRound < 1 || newRound > draftTotalRounds) return;
|
|
|
|
const prevBtn = document.getElementById('draftPrevBtn');
|
|
const nextBtn = document.getElementById('draftNextBtn');
|
|
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) {
|
|
draftCurrentRound = newRound;
|
|
}
|
|
} catch (e) {
|
|
console.error('Round change failed:', e);
|
|
}
|
|
renderDraftPanel();
|
|
}
|
|
// TV draft toggle
|
|
let currentTvView = 'cameras';
|
|
|
|
function updateTvDraftBtn(view) {
|
|
currentTvView = view;
|
|
const btn = document.getElementById('btnTvDraft');
|
|
if (!btn) return;
|
|
btn.style.background = (view === 'draft') ? '#28a745' : '';
|
|
btn.style.color = (view === 'draft') ? 'white' : '';
|
|
btn.style.borderColor = (view === 'draft') ? '#1e7e34' : '';
|
|
btn.textContent = (view === 'draft') ? '📺 Skrij Razpored' : '📺 Pokaži Razpored';
|
|
}
|
|
|
|
async function toggleTvDraft() {
|
|
const newView = currentTvView === 'draft' ? 'cameras' : 'draft';
|
|
try {
|
|
await fetch('/api/tv/view', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ view: newView })
|
|
});
|
|
updateTvDraftBtn(newView);
|
|
} catch (e) { console.error(e); }
|
|
}
|
|
|
|
fetch('/api/dashboard/state').then(r => r.json()).then(d => updateTvDraftBtn(d.tv_view || 'cameras')).catch(() => {});
|
|
{% endif %}
|
|
|
|
// Keyboard shortcuts
|
|
document.addEventListener('keydown', function(event) {
|
|
if (event.ctrlKey && event.key === 's') {
|
|
event.preventDefault();
|
|
saveAllPlayers();
|
|
}
|
|
});
|
|
|
|
// Initialize
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
|
|
// Initialize targets for all players
|
|
Object.keys(results.participants).forEach(playerId => {
|
|
initializeTargetsForPlayer(parseInt(playerId));
|
|
|
|
// Update initial states
|
|
for (let i = 1; i <= numTargets; i++) {
|
|
updateTargetGroupStyling(parseInt(playerId), i);
|
|
}
|
|
updateParticipantStatus(parseInt(playerId));
|
|
updateParticipantTens(parseInt(playerId));
|
|
});
|
|
|
|
// Initialize joker checkboxes for league tournaments
|
|
{% if league_state %}
|
|
const leagueState = {{ league_state | tojson | safe }};
|
|
Object.keys(results.participants).forEach(playerId => {
|
|
const checkbox = document.getElementById(`joker-calc-${playerId}`);
|
|
if (checkbox && leagueState.participants && leagueState.participants[playerId]) {
|
|
const participant = leagueState.participants[playerId];
|
|
if (participant.joker_used) {
|
|
checkbox.checked = true;
|
|
checkbox.disabled = true;
|
|
}
|
|
}
|
|
});
|
|
{% endif %}
|
|
|
|
updateOverallProgress();
|
|
updateOverallTens();
|
|
|
|
// Initialize draft panel
|
|
{% if tournament and tournament.rounds %}
|
|
renderDraftPanel();
|
|
{% endif %}
|
|
|
|
// Add input validation and navigation
|
|
document.addEventListener('input', function(e) {
|
|
if (e.target.classList.contains('shot-input')) {
|
|
if (e.target.value !== '') {
|
|
const value = parseInt(e.target.value);
|
|
const clampedValue = Math.max(0, Math.min(10, isNaN(value) ? 0 : value));
|
|
if (e.target.value !== clampedValue.toString()) {
|
|
e.target.value = clampedValue;
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
document.addEventListener('keydown', function(e) {
|
|
if (e.target.classList.contains('shot-input') && e.key === 'Enter') {
|
|
const inputs = Array.from(document.querySelectorAll('.shot-input'));
|
|
const currentIndex = inputs.indexOf(e.target);
|
|
const nextInput = inputs[currentIndex + 1];
|
|
if (nextInput) {
|
|
nextInput.focus();
|
|
nextInput.select();
|
|
}
|
|
}
|
|
});
|
|
});
|
|
</script>
|
|
</body>
|
|
</html> |