added new tournament mode.
This commit is contained in:
@@ -299,7 +299,17 @@ def create_results_structure(tournament_data):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
tournament_type = tournament_data.get('tournament_type', '20_targets')
|
tournament_type = tournament_data.get('tournament_type', '20_targets')
|
||||||
num_targets = 40 if tournament_type == '40_targets' else 20
|
|
||||||
|
# Determine target count and shots per target
|
||||||
|
if tournament_type == '40_targets':
|
||||||
|
num_targets = 40
|
||||||
|
shots_per_target = 2
|
||||||
|
elif tournament_type == '4_targets':
|
||||||
|
num_targets = 4
|
||||||
|
shots_per_target = 5
|
||||||
|
else: # 20_targets (default)
|
||||||
|
num_targets = 20
|
||||||
|
shots_per_target = 2
|
||||||
|
|
||||||
results = {
|
results = {
|
||||||
'tournament_id': tournament_data.get('created_at', datetime.now().isoformat()),
|
'tournament_id': tournament_data.get('created_at', datetime.now().isoformat()),
|
||||||
@@ -320,9 +330,18 @@ def create_results_structure(tournament_data):
|
|||||||
|
|
||||||
for player in all_players:
|
for player in all_players:
|
||||||
player_id = str(player['id'])
|
player_id = str(player['id'])
|
||||||
|
|
||||||
|
# Create target structure based on tournament type
|
||||||
|
targets = {}
|
||||||
|
for i in range(1, num_targets + 1):
|
||||||
|
target = {}
|
||||||
|
for j in range(1, shots_per_target + 1):
|
||||||
|
target[f'shot{j}'] = None
|
||||||
|
targets[str(i)] = target
|
||||||
|
|
||||||
results['participants'][player_id] = {
|
results['participants'][player_id] = {
|
||||||
'name': player['name'],
|
'name': player['name'],
|
||||||
'targets': {str(i): {'shot1': None, 'shot2': None} for i in range(1, num_targets + 1)},
|
'targets': targets,
|
||||||
'total_score': 0,
|
'total_score': 0,
|
||||||
'completed': False
|
'completed': False
|
||||||
}
|
}
|
||||||
@@ -333,19 +352,17 @@ def calculate_total_score(targets):
|
|||||||
"""Calculate total score from targets, treating None as 0"""
|
"""Calculate total score from targets, treating None as 0"""
|
||||||
total = 0
|
total = 0
|
||||||
for target in targets.values():
|
for target in targets.values():
|
||||||
shot1 = target.get('shot1')
|
for shot_key, shot_value in target.items():
|
||||||
shot2 = target.get('shot2')
|
if shot_key.startswith('shot') and shot_value is not None:
|
||||||
total += (shot1 if shot1 is not None else 0)
|
total += shot_value
|
||||||
total += (shot2 if shot2 is not None else 0)
|
|
||||||
return total
|
return total
|
||||||
|
|
||||||
def is_participant_completed(targets):
|
def is_participant_completed(targets):
|
||||||
"""Check if a participant has completed all targets (all shots entered, including 0s)"""
|
"""Check if a participant has completed all targets (all shots entered, including 0s)"""
|
||||||
for target in targets.values():
|
for target in targets.values():
|
||||||
shot1 = target.get('shot1')
|
for shot_key, shot_value in target.items():
|
||||||
shot2 = target.get('shot2')
|
if shot_key.startswith('shot') and shot_value is None:
|
||||||
if shot1 is None or shot2 is None:
|
return False
|
||||||
return False
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def calculate_league_final_scores(league_data):
|
def calculate_league_final_scores(league_data):
|
||||||
@@ -749,6 +766,8 @@ def get_all_players_from_archives():
|
|||||||
|
|
||||||
return players_list
|
return players_list
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Add these routes after the existing routes in app.py
|
# Add these routes after the existing routes in app.py
|
||||||
|
|
||||||
# Add this to your app.py file to integrate the modern archive system
|
# Add this to your app.py file to integrate the modern archive system
|
||||||
@@ -875,15 +894,17 @@ def api_get_archive_stats():
|
|||||||
'leagues': [1, 1, 2, 1, 2, 1]
|
'leagues': [1, 1, 2, 1, 2, 1]
|
||||||
}
|
}
|
||||||
|
|
||||||
# Calculate tournament type distribution
|
# Calculate tournament type distribution - now includes 4_targets
|
||||||
type_distribution = {'20_targets': 0, '40_targets': 0}
|
type_distribution = {'20_targets': 0, '40_targets': 0, '4_targets': 0}
|
||||||
for tournament in tournaments:
|
for tournament in tournaments:
|
||||||
tournament_type = tournament.get('tournament_type', '20_targets')
|
tournament_type = tournament.get('tournament_type', '20_targets')
|
||||||
type_distribution[tournament_type] += 1
|
if tournament_type in type_distribution:
|
||||||
|
type_distribution[tournament_type] += 1
|
||||||
|
|
||||||
for league in leagues:
|
for league in leagues:
|
||||||
league_type = league.get('tournament_type', '20_targets')
|
league_type = league.get('tournament_type', '20_targets')
|
||||||
type_distribution[league_type] += 1
|
if league_type in type_distribution:
|
||||||
|
type_distribution[league_type] += 1
|
||||||
|
|
||||||
stats = {
|
stats = {
|
||||||
'overview': {
|
'overview': {
|
||||||
@@ -894,15 +915,14 @@ def api_get_archive_stats():
|
|||||||
},
|
},
|
||||||
'activity_data': activity_data,
|
'activity_data': activity_data,
|
||||||
'type_distribution': {
|
'type_distribution': {
|
||||||
'labels': ['20 Targets', '40 Targets'],
|
'labels': ['20 Targets', '40 Targets', '4 Targets'],
|
||||||
'data': [type_distribution['20_targets'], type_distribution['40_targets']]
|
'data': [type_distribution['20_targets'], type_distribution['40_targets'], type_distribution['4_targets']]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return jsonify({'status': 'success', 'stats': stats})
|
return jsonify({'status': 'success', 'stats': stats})
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return jsonify({'status': 'error', 'message': str(e)}), 500
|
return jsonify({'status': 'error', 'message': str(e)}), 500
|
||||||
|
|
||||||
@app.route('/api/archive/player/<int:player_id>/performance', methods=['GET'])
|
@app.route('/api/archive/player/<int:player_id>/performance', methods=['GET'])
|
||||||
def api_get_player_performance(player_id):
|
def api_get_player_performance(player_id):
|
||||||
"""API endpoint to get player performance data for charts"""
|
"""API endpoint to get player performance data for charts"""
|
||||||
@@ -1629,8 +1649,7 @@ def start_league():
|
|||||||
try:
|
try:
|
||||||
data = request.get_json()
|
data = request.get_json()
|
||||||
tournament_type = data.get('tournament_type', '20_targets')
|
tournament_type = data.get('tournament_type', '20_targets')
|
||||||
|
if tournament_type not in ['20_targets', '40_targets', '4_targets']:
|
||||||
if tournament_type not in ['20_targets', '40_targets']:
|
|
||||||
return jsonify({'status': 'error', 'message': 'Invalid tournament type'}), 400
|
return jsonify({'status': 'error', 'message': 'Invalid tournament type'}), 400
|
||||||
|
|
||||||
players_data = load_players()
|
players_data = load_players()
|
||||||
@@ -1741,7 +1760,7 @@ def start_tournament():
|
|||||||
data = request.get_json() or {}
|
data = request.get_json() or {}
|
||||||
tournament_type = data.get('tournament_type', '20_targets')
|
tournament_type = data.get('tournament_type', '20_targets')
|
||||||
|
|
||||||
if tournament_type not in ['20_targets', '40_targets']:
|
if tournament_type not in ['20_targets', '40_targets', '4_targets']:
|
||||||
return jsonify({'status': 'error', 'message': 'Invalid tournament type'}), 400
|
return jsonify({'status': 'error', 'message': 'Invalid tournament type'}), 400
|
||||||
|
|
||||||
players_data = load_players()
|
players_data = load_players()
|
||||||
@@ -1869,6 +1888,13 @@ def finish_tournament():
|
|||||||
results['tournament_finished'] = True
|
results['tournament_finished'] = True
|
||||||
results['finished_at'] = datetime.now().isoformat()
|
results['finished_at'] = datetime.now().isoformat()
|
||||||
|
|
||||||
|
# Define total shots per participant for each tournament type
|
||||||
|
total_shots_per_participant = {
|
||||||
|
'20_targets': 40, # 20 targets × 2 shots
|
||||||
|
'40_targets': 80, # 40 targets × 2 shots
|
||||||
|
'4_targets': 20 # 4 targets × 5 shots
|
||||||
|
}
|
||||||
|
|
||||||
league_finished = False # Track if league finished
|
league_finished = False # Track if league finished
|
||||||
|
|
||||||
# Update league state if this is a league tournament
|
# Update league state if this is a league tournament
|
||||||
@@ -1901,13 +1927,21 @@ def finish_tournament():
|
|||||||
'joker': True
|
'joker': True
|
||||||
})
|
})
|
||||||
|
|
||||||
|
# Calculate total shots correctly for any tournament type
|
||||||
|
tournament_type = results.get('tournament_type', '20_targets')
|
||||||
|
shots_per_participant = total_shots_per_participant.get(tournament_type, 40)
|
||||||
|
total_shots_fired = len(results['participants']) * shots_per_participant
|
||||||
|
|
||||||
# Add to completed tournaments
|
# Add to completed tournaments
|
||||||
league_state['completed_tournaments'].append({
|
league_state['completed_tournaments'].append({
|
||||||
'tournament_number': tournament_number,
|
'tournament_number': tournament_number,
|
||||||
|
'tournament_type': tournament_type,
|
||||||
'finished_at': datetime.now().isoformat(),
|
'finished_at': datetime.now().isoformat(),
|
||||||
'results_summary': {
|
'results_summary': {
|
||||||
'participants': len(results['participants']),
|
'participants': len(results['participants']),
|
||||||
'total_shots': len(results['participants']) * (40 if results.get('tournament_type') == '40_targets' else 20) * 2
|
'shots_per_participant': shots_per_participant,
|
||||||
|
'total_shots': total_shots_fired,
|
||||||
|
'format_description': get_tournament_format_description(tournament_type)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -1920,7 +1954,7 @@ def finish_tournament():
|
|||||||
calculate_league_final_scores(league_state)
|
calculate_league_final_scores(league_state)
|
||||||
|
|
||||||
league_finished = True
|
league_finished = True
|
||||||
print("League finished!")
|
print(f"League finished! Final tournament was {tournament_type} format.")
|
||||||
|
|
||||||
save_league_state(league_state)
|
save_league_state(league_state)
|
||||||
|
|
||||||
@@ -1928,9 +1962,11 @@ def finish_tournament():
|
|||||||
archive_success = False
|
archive_success = False
|
||||||
if not league_state: # Only archive standalone tournaments
|
if not league_state: # Only archive standalone tournaments
|
||||||
archive_success = archive_tournament(tournament_state, results)
|
archive_success = archive_tournament(tournament_state, results)
|
||||||
print(f"Standalone tournament archived: {archive_success}")
|
tournament_type = results.get('tournament_type', '20_targets')
|
||||||
|
print(f"Standalone {tournament_type} tournament archived: {archive_success}")
|
||||||
else:
|
else:
|
||||||
print("League tournament - not archiving individual tournament")
|
tournament_type = results.get('tournament_type', '20_targets')
|
||||||
|
print(f"League {tournament_type} tournament - not archiving individual tournament")
|
||||||
|
|
||||||
# Archive the league if it just finished
|
# Archive the league if it just finished
|
||||||
league_archive_success = False
|
league_archive_success = False
|
||||||
@@ -1952,7 +1988,9 @@ def finish_tournament():
|
|||||||
'status': 'success',
|
'status': 'success',
|
||||||
'results': results,
|
'results': results,
|
||||||
'archived': archive_success,
|
'archived': archive_success,
|
||||||
'league_archived': league_archive_success if league_finished else None
|
'league_archived': league_archive_success if league_finished else None,
|
||||||
|
'tournament_type': results.get('tournament_type', '20_targets'),
|
||||||
|
'tournament_format': get_tournament_format_description(results.get('tournament_type', '20_targets'))
|
||||||
}
|
}
|
||||||
|
|
||||||
if league_state:
|
if league_state:
|
||||||
@@ -1967,6 +2005,15 @@ def finish_tournament():
|
|||||||
print(f"Error finishing tournament: {e}")
|
print(f"Error finishing tournament: {e}")
|
||||||
return jsonify({'status': 'error', 'message': str(e)}), 400
|
return jsonify({'status': 'error', 'message': str(e)}), 400
|
||||||
|
|
||||||
|
|
||||||
|
def get_tournament_format_description(tournament_type):
|
||||||
|
"""Get human-readable description of tournament format"""
|
||||||
|
format_descriptions = {
|
||||||
|
'20_targets': '20 Targets (2 shots each)',
|
||||||
|
'40_targets': '40 Targets (2 shots each)',
|
||||||
|
'4_targets': '4 Targets (5 shots each)'
|
||||||
|
}
|
||||||
|
return format_descriptions.get(tournament_type, '20 Targets (2 shots each)')
|
||||||
@app.route('/api/results', methods=['GET'])
|
@app.route('/api/results', methods=['GET'])
|
||||||
def get_results():
|
def get_results():
|
||||||
"""API endpoint to get current results"""
|
"""API endpoint to get current results"""
|
||||||
@@ -2115,5 +2162,7 @@ def get_camera_titles():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
return jsonify({'status': 'error', 'message': str(e)}), 400
|
return jsonify({'status': 'error', 'message': str(e)}), 400
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
app.run(host='0.0.0.0', port=5000, debug=True)
|
app.run(host='0.0.0.0', port=5000, debug=True)
|
||||||
@@ -137,9 +137,42 @@
|
|||||||
margin-bottom: 15px;
|
margin-bottom: 15px;
|
||||||
border-bottom: 3px solid #007bff;
|
border-bottom: 3px solid #007bff;
|
||||||
padding-bottom: 5px;
|
padding-bottom: 5px;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Compact Stats Overview */
|
.section-controls {
|
||||||
|
display: flex;
|
||||||
|
gap: 10px;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-btn {
|
||||||
|
background: #f8f9fa;
|
||||||
|
border: 1px solid #dee2e6;
|
||||||
|
padding: 6px 12px;
|
||||||
|
border-radius: 6px;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-btn.active {
|
||||||
|
background: #007bff;
|
||||||
|
color: white;
|
||||||
|
border-color: #007bff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-btn:hover {
|
||||||
|
background: #e9ecef;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-btn.active:hover {
|
||||||
|
background: #0056b3;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Enhanced Stats Overview */
|
||||||
.stats-overview {
|
.stats-overview {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
|
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
|
||||||
@@ -181,7 +214,20 @@
|
|||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Compact Archive Grid */
|
/* Target-specific stat cards */
|
||||||
|
.stat-card.target-40 {
|
||||||
|
border-left: 4px solid #dc3545;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-card.target-20 {
|
||||||
|
border-left: 4px solid #ffc107;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-card.target-4 {
|
||||||
|
border-left: 4px solid #28a745;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Enhanced Archive Grid */
|
||||||
.archive-grid {
|
.archive-grid {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
|
grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
|
||||||
@@ -221,6 +267,22 @@
|
|||||||
background: #fff3cd;
|
background: #fff3cd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.archive-card.tournament-40 .archive-header {
|
||||||
|
background: #f8d7da;
|
||||||
|
}
|
||||||
|
|
||||||
|
.archive-card.tournament-20 .archive-header {
|
||||||
|
background: #fff3cd;
|
||||||
|
}
|
||||||
|
|
||||||
|
.archive-card.tournament-4 .archive-header {
|
||||||
|
background: #d1edff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.archive-card.tournament-other .archive-header {
|
||||||
|
background: #f8f9fa;
|
||||||
|
}
|
||||||
|
|
||||||
.archive-title {
|
.archive-title {
|
||||||
font-size: 1.2rem;
|
font-size: 1.2rem;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
@@ -251,6 +313,21 @@
|
|||||||
color: #856404;
|
color: #856404;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.badge-40-targets {
|
||||||
|
background: #dc3545;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.badge-20-targets {
|
||||||
|
background: #ffc107;
|
||||||
|
color: #856404;
|
||||||
|
}
|
||||||
|
|
||||||
|
.badge-4-targets {
|
||||||
|
background: #17a2b8;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
.archive-content {
|
.archive-content {
|
||||||
padding: 15px 20px;
|
padding: 15px 20px;
|
||||||
}
|
}
|
||||||
@@ -283,23 +360,28 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 10px;
|
gap: 8px;
|
||||||
padding-top: 12px;
|
padding-top: 12px;
|
||||||
border-top: 1px solid #f0f0f0;
|
border-top: 1px solid #f0f0f0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.view-btn {
|
.action-btn {
|
||||||
background: #007bff;
|
|
||||||
border: none;
|
border: none;
|
||||||
color: white;
|
padding: 8px 12px;
|
||||||
padding: 8px 16px;
|
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
font-size: 0.85rem;
|
font-size: 0.8rem;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
transition: all 0.2s ease;
|
transition: all 0.2s ease;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.view-btn {
|
||||||
|
background: #007bff;
|
||||||
|
color: white;
|
||||||
|
flex: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.view-btn:hover {
|
.view-btn:hover {
|
||||||
@@ -307,16 +389,18 @@
|
|||||||
transform: translateY(-1px);
|
transform: translateY(-1px);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.edit-btn {
|
||||||
|
background: #28a745;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.edit-btn:hover {
|
||||||
|
background: #1e7e34;
|
||||||
|
}
|
||||||
|
|
||||||
.delete-btn {
|
.delete-btn {
|
||||||
background: #dc3545;
|
background: #dc3545;
|
||||||
border: none;
|
|
||||||
color: white;
|
color: white;
|
||||||
padding: 6px 12px;
|
|
||||||
border-radius: 6px;
|
|
||||||
cursor: pointer;
|
|
||||||
font-size: 0.75rem;
|
|
||||||
font-weight: bold;
|
|
||||||
transition: all 0.2s ease;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.delete-btn:hover {
|
.delete-btn:hover {
|
||||||
@@ -342,7 +426,7 @@
|
|||||||
opacity: 0.5;
|
opacity: 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Confirmation Modal */
|
/* Modal Styles */
|
||||||
.modal-overlay {
|
.modal-overlay {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: 0;
|
top: 0;
|
||||||
@@ -364,18 +448,20 @@
|
|||||||
visibility: visible;
|
visibility: visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
.confirmation-modal {
|
.modal {
|
||||||
background: white;
|
background: white;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
max-width: 400px;
|
max-width: 500px;
|
||||||
width: 90%;
|
width: 90%;
|
||||||
|
max-height: 80vh;
|
||||||
|
overflow-y: auto;
|
||||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
|
||||||
transform: scale(0.9);
|
transform: scale(0.9);
|
||||||
transition: transform 0.2s ease;
|
transition: transform 0.2s ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
.modal-overlay.active .confirmation-modal {
|
.modal-overlay.active .modal {
|
||||||
transform: scale(1);
|
transform: scale(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -383,7 +469,7 @@
|
|||||||
font-size: 1.1rem;
|
font-size: 1.1rem;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
color: #333;
|
color: #333;
|
||||||
margin-bottom: 10px;
|
margin-bottom: 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.modal-message {
|
.modal-message {
|
||||||
@@ -396,6 +482,7 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
gap: 10px;
|
gap: 10px;
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
|
margin-top: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.modal-btn {
|
.modal-btn {
|
||||||
@@ -425,6 +512,64 @@
|
|||||||
background: #c82333;
|
background: #c82333;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.modal-btn.primary {
|
||||||
|
background: #007bff;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-btn.primary:hover {
|
||||||
|
background: #0056b3;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Edit Form Styles */
|
||||||
|
.edit-form {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-group {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-label {
|
||||||
|
font-weight: bold;
|
||||||
|
color: #333;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-input {
|
||||||
|
padding: 8px 12px;
|
||||||
|
border: 1px solid #ddd;
|
||||||
|
border-radius: 4px;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-input:focus {
|
||||||
|
outline: none;
|
||||||
|
border-color: #007bff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-select {
|
||||||
|
padding: 8px 12px;
|
||||||
|
border: 1px solid #ddd;
|
||||||
|
border-radius: 4px;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
background: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-select:focus {
|
||||||
|
outline: none;
|
||||||
|
border-color: #007bff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Hidden class for filtering */
|
||||||
|
.hidden {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
/* Mobile responsive */
|
/* Mobile responsive */
|
||||||
@media (max-width: 768px) {
|
@media (max-width: 768px) {
|
||||||
.navbar {
|
.navbar {
|
||||||
@@ -468,9 +613,19 @@
|
|||||||
gap: 8px;
|
gap: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.view-btn {
|
.action-btn {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.section-title {
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section-controls {
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
@@ -485,37 +640,54 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<!-- Stats Overview -->
|
<!-- Enhanced Stats Overview -->
|
||||||
<div class="stats-overview">
|
<div class="stats-overview">
|
||||||
<div class="stat-card">
|
|
||||||
<span class="stat-icon">🏆</span>
|
|
||||||
<div class="stat-value">{{ stats.total_tournaments }}</div>
|
|
||||||
<div class="stat-label">Standalone Tournaments</div>
|
|
||||||
</div>
|
|
||||||
<div class="stat-card">
|
<div class="stat-card">
|
||||||
<span class="stat-icon">🎖️</span>
|
<span class="stat-icon">🎖️</span>
|
||||||
<div class="stat-value">{{ stats.total_leagues }}</div>
|
<div class="stat-value">{{ leagues|length if leagues else 0 }}</div>
|
||||||
<div class="stat-label">Completed Leagues</div>
|
<div class="stat-label">Completed Leagues</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="stat-card">
|
<div class="stat-card">
|
||||||
<span class="stat-icon">👥</span>
|
<span class="stat-icon">🏆</span>
|
||||||
<div class="stat-value">{{ stats.total_players }}</div>
|
<div class="stat-value">{{ tournaments|length if tournaments else 0 }}</div>
|
||||||
<div class="stat-label">Active Players</div>
|
<div class="stat-label">Total Tournaments</div>
|
||||||
|
</div>
|
||||||
|
<div class="stat-card target-40">
|
||||||
|
<span class="stat-icon">🎯</span>
|
||||||
|
<div class="stat-value">{{ tournaments|selectattr('tournament_type', 'equalto', '40_targets')|list|length if tournaments else 0 }}</div>
|
||||||
|
<div class="stat-label">40-Target Tournaments</div>
|
||||||
|
</div>
|
||||||
|
<div class="stat-card target-20">
|
||||||
|
<span class="stat-icon">🏹</span>
|
||||||
|
<div class="stat-value">{{ tournaments|selectattr('tournament_type', 'equalto', '20_targets')|list|length if tournaments else 0 }}</div>
|
||||||
|
<div class="stat-label">20-Target Tournaments</div>
|
||||||
|
</div>
|
||||||
|
<div class="stat-card target-4">
|
||||||
|
<span class="stat-icon">🎪</span>
|
||||||
|
<div class="stat-value">{{ tournaments|selectattr('tournament_type', 'equalto', '4_targets')|list|length if tournaments else 0 }}</div>
|
||||||
|
<div class="stat-label">4-Target Tournaments</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="stat-card">
|
<div class="stat-card">
|
||||||
<span class="stat-icon">📊</span>
|
<span class="stat-icon">👥</span>
|
||||||
<div class="stat-value">{{ stats.total_matches }}</div>
|
<div class="stat-value">{{ stats.total_players if stats else 0 }}</div>
|
||||||
<div class="stat-label">Total Competitions</div>
|
<div class="stat-label">Active Players</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Leagues Section -->
|
<!-- Leagues Section -->
|
||||||
{% if leagues %}
|
{% if leagues %}
|
||||||
<div class="section">
|
<div class="section">
|
||||||
<h2 class="section-title">🎖️ League Championships</h2>
|
<div class="section-title">
|
||||||
<div class="archive-grid">
|
<span>🎖️ League Championships</span>
|
||||||
|
<div class="section-controls">
|
||||||
|
<button class="filter-btn active" onclick="filterLeagues('all')">All</button>
|
||||||
|
<button class="filter-btn" onclick="filterLeagues('completed')">Completed</button>
|
||||||
|
<button class="filter-btn" onclick="filterLeagues('recent')">Recent</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="archive-grid" id="leagues-grid">
|
||||||
{% for league in leagues %}
|
{% for league in leagues %}
|
||||||
<div class="archive-card league" onclick="viewLeague('{{ league.filename }}')">
|
<div class="archive-card league" data-status="{{ 'completed' if league.completed_tournaments == league.total_tournaments else 'incomplete' }}" data-date="{{ league.archived_at }}" onclick="viewLeague('{{ league.filename }}')">
|
||||||
<div class="archive-header">
|
<div class="archive-header">
|
||||||
<div>
|
<div>
|
||||||
<div class="archive-title">League Championship</div>
|
<div class="archive-title">League Championship</div>
|
||||||
@@ -543,9 +715,12 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="archive-actions">
|
<div class="archive-actions">
|
||||||
<a href="/archive/league/{{ league.filename }}" class="view-btn">🏆 View Results</a>
|
<a href="/archive/league/{{ league.filename }}" class="action-btn view-btn">🏆 View</a>
|
||||||
<button class="delete-btn" onclick="event.stopPropagation(); deleteArchive('league', '{{ league.filename }}')">
|
<button class="action-btn edit-btn" onclick="event.stopPropagation(); editArchive('league', '{{ league.filename }}', {{ league|tojson }})">
|
||||||
🗑️ Delete
|
✏️ Edit
|
||||||
|
</button>
|
||||||
|
<button class="action-btn delete-btn" onclick="event.stopPropagation(); deleteArchive('league', '{{ league.filename }}')">
|
||||||
|
🗑️
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -555,16 +730,198 @@
|
|||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<!-- Standalone Tournaments Section -->
|
<!-- Tournaments Section - Organized by Target Count -->
|
||||||
{% if tournaments %}
|
{% if tournaments %}
|
||||||
|
|
||||||
|
<!-- 40-Target Tournaments -->
|
||||||
|
{% set tournaments_40 = tournaments|selectattr('tournament_type', 'equalto', '40_targets')|list %}
|
||||||
|
{% if tournaments_40 %}
|
||||||
<div class="section">
|
<div class="section">
|
||||||
<h2 class="section-title">🏆 Standalone Tournaments</h2>
|
<div class="section-title">
|
||||||
<div class="archive-grid">
|
<span>🎯 40-Target Tournaments</span>
|
||||||
{% for tournament in tournaments %}
|
<div class="section-controls">
|
||||||
<div class="archive-card tournament" onclick="viewTournament('{{ tournament.filename }}')">
|
<button class="filter-btn active" onclick="filterTournaments('40', 'all')">All</button>
|
||||||
|
<button class="filter-btn" onclick="filterTournaments('40', 'finished')">Finished</button>
|
||||||
|
<button class="filter-btn" onclick="filterTournaments('40', 'recent')">Recent</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="archive-grid" id="tournaments-40-grid">
|
||||||
|
{% for tournament in tournaments_40 %}
|
||||||
|
<div class="archive-card tournament-40" data-status="{{ 'finished' if tournament.tournament_finished else 'incomplete' }}" data-date="{{ tournament.archived_at }}" data-targets="40" onclick="viewTournament('{{ tournament.filename }}')">
|
||||||
<div class="archive-header">
|
<div class="archive-header">
|
||||||
<div>
|
<div>
|
||||||
<div class="archive-title">Single Tournament</div>
|
<div class="archive-title">40-Target Tournament</div>
|
||||||
|
<div class="archive-subtitle">{{ tournament.created_at[:10] if tournament.created_at != 'Unknown' else 'Unknown Date' }}</div>
|
||||||
|
</div>
|
||||||
|
<span class="archive-badge badge-40-targets">40 Targets</span>
|
||||||
|
</div>
|
||||||
|
<div class="archive-content">
|
||||||
|
<div class="archive-info">
|
||||||
|
<div class="info-item">
|
||||||
|
<span class="info-icon">👥</span>
|
||||||
|
<span class="info-value">{{ tournament.participants_count }} players</span>
|
||||||
|
</div>
|
||||||
|
<div class="info-item">
|
||||||
|
<span class="info-icon">🎯</span>
|
||||||
|
<span class="info-value">{{ tournament.tournament_type.replace('_', ' ')|title }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="info-item">
|
||||||
|
<span class="info-icon">📅</span>
|
||||||
|
<span class="info-value">{{ tournament.archived_at[:10] if tournament.archived_at != 'Unknown' else 'Unknown Date' }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="info-item">
|
||||||
|
<span class="info-icon">🏁</span>
|
||||||
|
<span class="info-value">{{ 'Finished' if tournament.tournament_finished else 'Incomplete' }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="archive-actions">
|
||||||
|
<a href="/archive/tournament/{{ tournament.filename }}" class="action-btn view-btn">📊 View</a>
|
||||||
|
<button class="action-btn edit-btn" onclick="event.stopPropagation(); editArchive('tournament', '{{ tournament.filename }}', {{ tournament|tojson }})">
|
||||||
|
✏️ Edit
|
||||||
|
</button>
|
||||||
|
<button class="action-btn delete-btn" onclick="event.stopPropagation(); deleteArchive('tournament', '{{ tournament.filename }}')">
|
||||||
|
🗑️
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<!-- 20-Target Tournaments -->
|
||||||
|
{% set tournaments_20 = tournaments|selectattr('tournament_type', 'equalto', '20_targets')|list %}
|
||||||
|
{% if tournaments_20 %}
|
||||||
|
<div class="section">
|
||||||
|
<div class="section-title">
|
||||||
|
<span>🏹 20-Target Tournaments</span>
|
||||||
|
<div class="section-controls">
|
||||||
|
<button class="filter-btn active" onclick="filterTournaments('20', 'all')">All</button>
|
||||||
|
<button class="filter-btn" onclick="filterTournaments('20', 'finished')">Finished</button>
|
||||||
|
<button class="filter-btn" onclick="filterTournaments('20', 'recent')">Recent</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="archive-grid" id="tournaments-20-grid">
|
||||||
|
{% for tournament in tournaments_20 %}
|
||||||
|
<div class="archive-card tournament-20" data-status="{{ 'finished' if tournament.tournament_finished else 'incomplete' }}" data-date="{{ tournament.archived_at }}" data-targets="20" onclick="viewTournament('{{ tournament.filename }}')">
|
||||||
|
<div class="archive-header">
|
||||||
|
<div>
|
||||||
|
<div class="archive-title">20-Target Tournament</div>
|
||||||
|
<div class="archive-subtitle">{{ tournament.created_at[:10] if tournament.created_at != 'Unknown' else 'Unknown Date' }}</div>
|
||||||
|
</div>
|
||||||
|
<span class="archive-badge badge-20-targets">20 Targets</span>
|
||||||
|
</div>
|
||||||
|
<div class="archive-content">
|
||||||
|
<div class="archive-info">
|
||||||
|
<div class="info-item">
|
||||||
|
<span class="info-icon">👥</span>
|
||||||
|
<span class="info-value">{{ tournament.participants_count }} players</span>
|
||||||
|
</div>
|
||||||
|
<div class="info-item">
|
||||||
|
<span class="info-icon">🎯</span>
|
||||||
|
<span class="info-value">{{ tournament.tournament_type.replace('_', ' ')|title }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="info-item">
|
||||||
|
<span class="info-icon">📅</span>
|
||||||
|
<span class="info-value">{{ tournament.archived_at[:10] if tournament.archived_at != 'Unknown' else 'Unknown Date' }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="info-item">
|
||||||
|
<span class="info-icon">🏁</span>
|
||||||
|
<span class="info-value">{{ 'Finished' if tournament.tournament_finished else 'Incomplete' }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="archive-actions">
|
||||||
|
<a href="/archive/tournament/{{ tournament.filename }}" class="action-btn view-btn">📊 View</a>
|
||||||
|
<button class="action-btn edit-btn" onclick="event.stopPropagation(); editArchive('tournament', '{{ tournament.filename }}', {{ tournament|tojson }})">
|
||||||
|
✏️ Edit
|
||||||
|
</button>
|
||||||
|
<button class="action-btn delete-btn" onclick="event.stopPropagation(); deleteArchive('tournament', '{{ tournament.filename }}')">
|
||||||
|
🗑️
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<!-- 4-Target Tournaments -->
|
||||||
|
{% set tournaments_4 = tournaments|selectattr('tournament_type', 'equalto', '4_targets')|list %}
|
||||||
|
{% if tournaments_4 %}
|
||||||
|
<div class="section">
|
||||||
|
<div class="section-title">
|
||||||
|
<span>🎪 4-Target Tournaments</span>
|
||||||
|
<div class="section-controls">
|
||||||
|
<button class="filter-btn active" onclick="filterTournaments('4', 'all')">All</button>
|
||||||
|
<button class="filter-btn" onclick="filterTournaments('4', 'finished')">Finished</button>
|
||||||
|
<button class="filter-btn" onclick="filterTournaments('4', 'recent')">Recent</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="archive-grid" id="tournaments-4-grid">
|
||||||
|
{% for tournament in tournaments_4 %}
|
||||||
|
<div class="archive-card tournament-4" data-status="{{ 'finished' if tournament.tournament_finished else 'incomplete' }}" data-date="{{ tournament.archived_at }}" data-targets="4" onclick="viewTournament('{{ tournament.filename }}')">
|
||||||
|
<div class="archive-header">
|
||||||
|
<div>
|
||||||
|
<div class="archive-title">4-Target Tournament</div>
|
||||||
|
<div class="archive-subtitle">{{ tournament.created_at[:10] if tournament.created_at != 'Unknown' else 'Unknown Date' }}</div>
|
||||||
|
</div>
|
||||||
|
<span class="archive-badge badge-4-targets">4 Targets</span>
|
||||||
|
</div>
|
||||||
|
<div class="archive-content">
|
||||||
|
<div class="archive-info">
|
||||||
|
<div class="info-item">
|
||||||
|
<span class="info-icon">👥</span>
|
||||||
|
<span class="info-value">{{ tournament.participants_count }} players</span>
|
||||||
|
</div>
|
||||||
|
<div class="info-item">
|
||||||
|
<span class="info-icon">🎯</span>
|
||||||
|
<span class="info-value">{{ tournament.tournament_type.replace('_', ' ')|title }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="info-item">
|
||||||
|
<span class="info-icon">📅</span>
|
||||||
|
<span class="info-value">{{ tournament.archived_at[:10] if tournament.archived_at != 'Unknown' else 'Unknown Date' }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="info-item">
|
||||||
|
<span class="info-icon">🏁</span>
|
||||||
|
<span class="info-value">{{ 'Finished' if tournament.tournament_finished else 'Incomplete' }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="archive-actions">
|
||||||
|
<a href="/archive/tournament/{{ tournament.filename }}" class="action-btn view-btn">📊 View</a>
|
||||||
|
<button class="action-btn edit-btn" onclick="event.stopPropagation(); editArchive('tournament', '{{ tournament.filename }}', {{ tournament|tojson }})">
|
||||||
|
✏️ Edit
|
||||||
|
</button>
|
||||||
|
<button class="action-btn delete-btn" onclick="event.stopPropagation(); deleteArchive('tournament', '{{ tournament.filename }}')">
|
||||||
|
🗑️
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<!-- Other/Unknown Target Count Tournaments -->
|
||||||
|
{% set tournaments_other = tournaments|rejectattr('tournament_type', 'in', ['4_targets', '20_targets', '40_targets'])|list %}
|
||||||
|
{% if tournaments_other %}
|
||||||
|
<div class="section">
|
||||||
|
<div class="section-title">
|
||||||
|
<span>🏆 Other Tournaments</span>
|
||||||
|
<div class="section-controls">
|
||||||
|
<button class="filter-btn active" onclick="filterTournaments('other', 'all')">All</button>
|
||||||
|
<button class="filter-btn" onclick="filterTournaments('other', 'finished')">Finished</button>
|
||||||
|
<button class="filter-btn" onclick="filterTournaments('other', 'recent')">Recent</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="archive-grid" id="tournaments-other-grid">
|
||||||
|
{% for tournament in tournaments_other %}
|
||||||
|
<div class="archive-card tournament-other" data-status="{{ 'finished' if tournament.tournament_finished else 'incomplete' }}" data-date="{{ tournament.archived_at }}" data-targets="other" onclick="viewTournament('{{ tournament.filename }}')">
|
||||||
|
<div class="archive-header">
|
||||||
|
<div>
|
||||||
|
<div class="archive-title">Tournament ({{ tournament.tournament_type or 'Unknown' }})</div>
|
||||||
<div class="archive-subtitle">{{ tournament.created_at[:10] if tournament.created_at != 'Unknown' else 'Unknown Date' }}</div>
|
<div class="archive-subtitle">{{ tournament.created_at[:10] if tournament.created_at != 'Unknown' else 'Unknown Date' }}</div>
|
||||||
</div>
|
</div>
|
||||||
<span class="archive-badge badge-tournament">Tournament</span>
|
<span class="archive-badge badge-tournament">Tournament</span>
|
||||||
@@ -589,9 +946,12 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="archive-actions">
|
<div class="archive-actions">
|
||||||
<a href="/archive/tournament/{{ tournament.filename }}" class="view-btn">📊 View Results</a>
|
<a href="/archive/tournament/{{ tournament.filename }}" class="action-btn view-btn">📊 View</a>
|
||||||
<button class="delete-btn" onclick="event.stopPropagation(); deleteArchive('tournament', '{{ tournament.filename }}')">
|
<button class="action-btn edit-btn" onclick="event.stopPropagation(); editArchive('tournament', '{{ tournament.filename }}', {{ tournament|tojson }})">
|
||||||
🗑️ Delete
|
✏️ Edit
|
||||||
|
</button>
|
||||||
|
<button class="action-btn delete-btn" onclick="event.stopPropagation(); deleteArchive('tournament', '{{ tournament.filename }}')">
|
||||||
|
🗑️
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -601,6 +961,8 @@
|
|||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<!-- Empty State -->
|
<!-- Empty State -->
|
||||||
{% if not leagues and not tournaments %}
|
{% if not leagues and not tournaments %}
|
||||||
<div class="section">
|
<div class="section">
|
||||||
@@ -616,7 +978,7 @@
|
|||||||
|
|
||||||
<!-- Confirmation Modal -->
|
<!-- Confirmation Modal -->
|
||||||
<div class="modal-overlay" id="confirmationModal">
|
<div class="modal-overlay" id="confirmationModal">
|
||||||
<div class="confirmation-modal">
|
<div class="modal">
|
||||||
<div class="modal-title" id="modalTitle">Confirm Action</div>
|
<div class="modal-title" id="modalTitle">Confirm Action</div>
|
||||||
<div class="modal-message" id="modalMessage">Are you sure you want to proceed?</div>
|
<div class="modal-message" id="modalMessage">Are you sure you want to proceed?</div>
|
||||||
<div class="modal-buttons">
|
<div class="modal-buttons">
|
||||||
@@ -626,8 +988,48 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Edit Modal -->
|
||||||
|
<div class="modal-overlay" id="editModal">
|
||||||
|
<div class="modal">
|
||||||
|
<div class="modal-title" id="editModalTitle">Edit Archive</div>
|
||||||
|
<form class="edit-form" id="editForm">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">Archive Name</label>
|
||||||
|
<input type="text" class="form-input" id="editName" placeholder="Enter archive name">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">Format Type</label>
|
||||||
|
<select class="form-select" id="editType">
|
||||||
|
<option value="single_elimination">Single Elimination</option>
|
||||||
|
<option value="double_elimination">Double Elimination</option>
|
||||||
|
<option value="round_robin">Round Robin</option>
|
||||||
|
<option value="swiss">Swiss System</option>
|
||||||
|
<option value="league">League Championship</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="form-group" id="targetCountGroup">
|
||||||
|
<label class="form-label">Target Format</label>
|
||||||
|
<select class="form-select" id="editTargetCount">
|
||||||
|
<option value="4_targets">4 Targets (5 shots each)</option>
|
||||||
|
<option value="20_targets">20 Targets (2 shots each)</option>
|
||||||
|
<option value="40_targets">40 Targets (2 shots each)</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="form-label">Notes</label>
|
||||||
|
<input type="text" class="form-input" id="editNotes" placeholder="Add notes about this tournament">
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<div class="modal-buttons">
|
||||||
|
<button class="modal-btn cancel" onclick="closeEditModal()">Cancel</button>
|
||||||
|
<button class="modal-btn primary" onclick="saveEdit()">Save Changes</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
let pendingAction = null;
|
let pendingAction = null;
|
||||||
|
let editingItem = null;
|
||||||
|
|
||||||
// Navigation functions
|
// Navigation functions
|
||||||
function viewTournament(filename) {
|
function viewTournament(filename) {
|
||||||
@@ -638,6 +1040,7 @@
|
|||||||
window.location.href = `/archive/league/${filename}`;
|
window.location.href = `/archive/league/${filename}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Delete function
|
||||||
async function deleteArchive(type, filename) {
|
async function deleteArchive(type, filename) {
|
||||||
showModal(
|
showModal(
|
||||||
'Delete Archive',
|
'Delete Archive',
|
||||||
@@ -664,6 +1067,114 @@
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Edit function
|
||||||
|
function editArchive(type, filename, data) {
|
||||||
|
editingItem = { type, filename, data };
|
||||||
|
|
||||||
|
document.getElementById('editModalTitle').textContent = `Edit ${type.charAt(0).toUpperCase() + type.slice(1)}`;
|
||||||
|
document.getElementById('editName').value = data.name || `${type} - ${data.created_at?.substring(0, 10) || 'Unknown'}`;
|
||||||
|
|
||||||
|
// For format type, use a default since this isn't typically stored
|
||||||
|
document.getElementById('editType').value = type === 'league' ? 'league' : 'single_elimination';
|
||||||
|
document.getElementById('editNotes').value = data.notes || '';
|
||||||
|
|
||||||
|
// Show/hide target count field - both tournaments and leagues have tournament_type
|
||||||
|
const targetCountGroup = document.getElementById('targetCountGroup');
|
||||||
|
if (type === 'tournament' || type === 'league') {
|
||||||
|
targetCountGroup.style.display = 'flex';
|
||||||
|
document.getElementById('editTargetCount').value = data.tournament_type || '20_targets';
|
||||||
|
} else {
|
||||||
|
targetCountGroup.style.display = 'none';
|
||||||
|
}
|
||||||
|
|
||||||
|
document.getElementById('editModal').classList.add('active');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save edit function
|
||||||
|
async function saveEdit() {
|
||||||
|
if (!editingItem) return;
|
||||||
|
|
||||||
|
const updatedData = {
|
||||||
|
name: document.getElementById('editName').value,
|
||||||
|
notes: document.getElementById('editNotes').value
|
||||||
|
};
|
||||||
|
|
||||||
|
// For both tournaments and leagues, save the tournament_type (target format)
|
||||||
|
if (editingItem.type === 'tournament' || editingItem.type === 'league') {
|
||||||
|
updatedData.tournament_type = document.getElementById('editTargetCount').value;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await fetch(`/api/archive/update/${editingItem.type}/${editingItem.filename}`, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
body: JSON.stringify(updatedData)
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = await response.json();
|
||||||
|
|
||||||
|
if (result.status === 'success') {
|
||||||
|
alert('Archive updated successfully');
|
||||||
|
location.reload();
|
||||||
|
} else {
|
||||||
|
alert('Error updating archive: ' + result.message);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
alert('Error updating archive: ' + error.message);
|
||||||
|
}
|
||||||
|
|
||||||
|
closeEditModal();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Filtering functions
|
||||||
|
function filterLeagues(filter) {
|
||||||
|
const cards = document.querySelectorAll('#leagues-grid .archive-card');
|
||||||
|
const buttons = document.querySelectorAll('#leagues-grid').parentElement.querySelectorAll('.filter-btn');
|
||||||
|
|
||||||
|
// Update active button
|
||||||
|
buttons.forEach(btn => btn.classList.remove('active'));
|
||||||
|
event.target.classList.add('active');
|
||||||
|
|
||||||
|
// Filter cards
|
||||||
|
cards.forEach(card => {
|
||||||
|
const isCompleted = card.dataset.status === 'completed';
|
||||||
|
const date = new Date(card.dataset.date);
|
||||||
|
const isRecent = (Date.now() - date.getTime()) < (30 * 24 * 60 * 60 * 1000); // Last 30 days
|
||||||
|
|
||||||
|
let show = true;
|
||||||
|
if (filter === 'completed' && !isCompleted) show = false;
|
||||||
|
if (filter === 'recent' && !isRecent) show = false;
|
||||||
|
|
||||||
|
card.classList.toggle('hidden', !show);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function filterTournaments(targetCount, filter) {
|
||||||
|
const gridId = targetCount === 'other' ? 'tournaments-other-grid' : `tournaments-${targetCount}-grid`;
|
||||||
|
const cards = document.querySelectorAll(`#${gridId} .archive-card`);
|
||||||
|
const section = document.querySelector(`#${gridId}`).closest('.section');
|
||||||
|
const buttons = section.querySelectorAll('.filter-btn');
|
||||||
|
|
||||||
|
// Update active button
|
||||||
|
buttons.forEach(btn => btn.classList.remove('active'));
|
||||||
|
event.target.classList.add('active');
|
||||||
|
|
||||||
|
// Filter cards
|
||||||
|
cards.forEach(card => {
|
||||||
|
const isFinished = card.dataset.status === 'finished';
|
||||||
|
const date = new Date(card.dataset.date);
|
||||||
|
const isRecent = (Date.now() - date.getTime()) < (30 * 24 * 60 * 60 * 1000); // Last 30 days
|
||||||
|
|
||||||
|
let show = true;
|
||||||
|
if (filter === 'finished' && !isFinished) show = false;
|
||||||
|
if (filter === 'recent' && !isRecent) show = false;
|
||||||
|
|
||||||
|
card.classList.toggle('hidden', !show);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Modal functions
|
// Modal functions
|
||||||
function showModal(title, message, confirmCallback) {
|
function showModal(title, message, confirmCallback) {
|
||||||
document.getElementById('modalTitle').textContent = title;
|
document.getElementById('modalTitle').textContent = title;
|
||||||
@@ -677,6 +1188,11 @@
|
|||||||
pendingAction = null;
|
pendingAction = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function closeEditModal() {
|
||||||
|
document.getElementById('editModal').classList.remove('active');
|
||||||
|
editingItem = null;
|
||||||
|
}
|
||||||
|
|
||||||
function confirmAction() {
|
function confirmAction() {
|
||||||
if (pendingAction) {
|
if (pendingAction) {
|
||||||
pendingAction();
|
pendingAction();
|
||||||
@@ -690,11 +1206,42 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
document.getElementById('editModal').addEventListener('click', function(e) {
|
||||||
|
if (e.target === this) {
|
||||||
|
closeEditModal();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Initialize page
|
// Initialize page
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
console.log('📚 Archive loaded');
|
console.log('📚 Enhanced Archive loaded');
|
||||||
console.log('🏆 Tournaments:', {{ tournaments|length if tournaments else 0 }});
|
console.log('🏆 Total Tournaments:', {{ tournaments|length if tournaments else 0 }});
|
||||||
console.log('🎖️ Leagues:', {{ leagues|length if leagues else 0 }});
|
console.log('🎖️ Leagues:', {{ leagues|length if leagues else 0 }});
|
||||||
|
|
||||||
|
{% if tournaments %}
|
||||||
|
const tournaments = {{ tournaments|tojson }};
|
||||||
|
console.log('Tournament data sample:', tournaments[0] || 'No tournaments');
|
||||||
|
|
||||||
|
// Count tournaments by type
|
||||||
|
const tournaments40 = tournaments.filter(t => t.tournament_type === '40_targets');
|
||||||
|
const tournaments20 = tournaments.filter(t => t.tournament_type === '20_targets');
|
||||||
|
const tournaments4 = tournaments.filter(t => t.tournament_type === '4_targets');
|
||||||
|
const tournamentsOther = tournaments.filter(t => !['4_targets', '20_targets', '40_targets'].includes(t.tournament_type));
|
||||||
|
|
||||||
|
console.log('🎯 40-Target Tournaments:', tournaments40.length);
|
||||||
|
console.log('🏹 20-Target Tournaments:', tournaments20.length);
|
||||||
|
console.log('🎪 4-Target Tournaments:', tournaments4.length);
|
||||||
|
console.log('🏆 Other Tournaments:', tournamentsOther.length);
|
||||||
|
|
||||||
|
// Log tournament types for debugging
|
||||||
|
const tournamentTypes = [...new Set(tournaments.map(t => t.tournament_type))];
|
||||||
|
console.log('Available tournament types:', tournamentTypes);
|
||||||
|
{% else %}
|
||||||
|
console.log('🎯 40-Target Tournaments: 0');
|
||||||
|
console.log('🏹 20-Target Tournaments: 0');
|
||||||
|
console.log('🎪 4-Target Tournaments: 0');
|
||||||
|
console.log('🏆 Other Tournaments: 0');
|
||||||
|
{% endif %}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@@ -23,14 +23,13 @@
|
|||||||
.navbar {
|
.navbar {
|
||||||
background: white;
|
background: white;
|
||||||
color: black;
|
color: black;
|
||||||
padding: 10px 20px;
|
padding: 15px 25px;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
border-bottom: 2px solid #ccc;
|
border-bottom: 2px solid #ccc;
|
||||||
height: 60px;
|
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
||||||
box-sizing: border-box;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
.navbar-title {
|
.navbar-title {
|
||||||
font-size: 1.8rem;
|
font-size: 1.8rem;
|
||||||
|
|||||||
@@ -22,17 +22,14 @@
|
|||||||
|
|
||||||
/* Enhanced Navigation Bar */
|
/* Enhanced Navigation Bar */
|
||||||
.navbar {
|
.navbar {
|
||||||
background: rgba(255, 255, 255, 0.95);
|
background: white;
|
||||||
backdrop-filter: blur(10px);
|
|
||||||
color: black;
|
color: black;
|
||||||
padding: 12px 25px;
|
padding: 15px 25px;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
border-bottom: 2px solid rgba(102, 126, 234, 0.3);
|
border-bottom: 2px solid #ccc;
|
||||||
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
|
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
||||||
height: 60px;
|
|
||||||
flex-shrink: 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.navbar-title {
|
.navbar-title {
|
||||||
|
|||||||
+356
-138
@@ -128,6 +128,7 @@
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
gap: 30px;
|
gap: 30px;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
|
margin-bottom: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.progress-item {
|
.progress-item {
|
||||||
@@ -146,6 +147,46 @@
|
|||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.global-actions {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 15px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
margin-top: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.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;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fill-all-btn:hover {
|
||||||
|
background: #e55a2b;
|
||||||
|
transform: translateY(-1px);
|
||||||
|
box-shadow: 0 4px 8px 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);
|
||||||
|
}
|
||||||
|
|
||||||
.participants-list {
|
.participants-list {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@@ -296,26 +337,58 @@
|
|||||||
|
|
||||||
.targets-grid {
|
.targets-grid {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
|
|
||||||
gap: 10px;
|
gap: 10px;
|
||||||
margin-bottom: 20px;
|
margin-bottom: 20px;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Responsive adjustments for 20 targets */
|
/* Grid layouts for different target counts */
|
||||||
|
.targets-grid.targets-4 {
|
||||||
|
grid-template-columns: repeat(4, 1fr);
|
||||||
|
}
|
||||||
|
|
||||||
|
.targets-grid.targets-20 {
|
||||||
|
grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
|
||||||
|
}
|
||||||
|
|
||||||
|
.targets-grid.targets-40 {
|
||||||
|
grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Responsive adjustments */
|
||||||
@media (max-width: 768px) {
|
@media (max-width: 768px) {
|
||||||
.targets-grid {
|
.targets-grid.targets-20 {
|
||||||
grid-template-columns: repeat(5, 1fr);
|
grid-template-columns: repeat(5, 1fr);
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.targets-grid.targets-40 {
|
||||||
|
grid-template-columns: repeat(8, 1fr);
|
||||||
|
gap: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.targets-grid.targets-4 {
|
||||||
|
grid-template-columns: repeat(2, 1fr);
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 480px) {
|
@media (max-width: 480px) {
|
||||||
.targets-grid {
|
.targets-grid.targets-20 {
|
||||||
grid-template-columns: repeat(4, 1fr);
|
grid-template-columns: repeat(4, 1fr);
|
||||||
gap: 6px;
|
gap: 6px;
|
||||||
padding: 15px;
|
padding: 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.targets-grid.targets-40 {
|
||||||
|
grid-template-columns: repeat(6, 1fr);
|
||||||
|
gap: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.targets-grid.targets-4 {
|
||||||
|
grid-template-columns: repeat(2, 1fr);
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.target-group {
|
.target-group {
|
||||||
@@ -344,6 +417,10 @@
|
|||||||
gap: 3px;
|
gap: 3px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.shots-container.shots-5 {
|
||||||
|
gap: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
.shot-input {
|
.shot-input {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: 6px;
|
padding: 6px;
|
||||||
@@ -354,6 +431,11 @@
|
|||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.shots-container.shots-5 .shot-input {
|
||||||
|
padding: 4px;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
}
|
||||||
|
|
||||||
.shot-input:focus {
|
.shot-input:focus {
|
||||||
outline: none;
|
outline: none;
|
||||||
border-color: #007bff;
|
border-color: #007bff;
|
||||||
@@ -482,6 +564,15 @@
|
|||||||
.progress-info {
|
.progress-info {
|
||||||
gap: 20px;
|
gap: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.global-actions {
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.global-btn {
|
||||||
|
min-width: 200px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Loading and saving indicators */
|
/* Loading and saving indicators */
|
||||||
@@ -522,7 +613,15 @@
|
|||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="header-section">
|
<div class="header-section">
|
||||||
<div class="header-title">🎯 Tournament Scoring</div>
|
<div class="header-title">🎯 Tournament Scoring</div>
|
||||||
<div class="header-subtitle">Enter scores for each participant (20 targets, 2 shots each). Score 0 = miss.</div>
|
<div class="header-subtitle" id="tournamentSubtitle">
|
||||||
|
{% if results.tournament_type == '40_targets' %}
|
||||||
|
Enter scores for each participant (40 targets, 2 shots each). Score 0 = miss.
|
||||||
|
{% elif results.tournament_type == '4_targets' %}
|
||||||
|
Enter scores for each participant (4 targets, 5 shots each). Score 0 = miss.
|
||||||
|
{% else %}
|
||||||
|
Enter scores for each participant (20 targets, 2 shots each). Score 0 = miss.
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="progress-info">
|
<div class="progress-info">
|
||||||
<div class="progress-item">
|
<div class="progress-item">
|
||||||
@@ -538,6 +637,12 @@
|
|||||||
<div class="progress-label">Total Shots</div>
|
<div class="progress-label">Total Shots</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="global-actions">
|
||||||
|
<button class="global-btn fill-all-btn" onclick="fillAllPlayersRandom()">
|
||||||
|
🎲 Fill All Players Random
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="participants-list">
|
<div class="participants-list">
|
||||||
@@ -567,44 +672,13 @@
|
|||||||
<div class="participant-content">
|
<div class="participant-content">
|
||||||
<div class="targets-section">
|
<div class="targets-section">
|
||||||
<div class="targets-grid" id="targets-{{ player_id }}">
|
<div class="targets-grid" id="targets-{{ player_id }}">
|
||||||
{% for i in range(1, 21) %}
|
<!-- Targets will be populated by JavaScript based on tournament type -->
|
||||||
<div class="target-group" id="target-group-{{ player_id }}-{{ i }}">
|
|
||||||
<div class="target-number">{{ i }}</div>
|
|
||||||
<div class="shots-container">
|
|
||||||
<input type="number"
|
|
||||||
class="shot-input"
|
|
||||||
id="shot1-{{ player_id }}-{{ i }}"
|
|
||||||
data-player="{{ player_id }}"
|
|
||||||
data-target="{{ i }}"
|
|
||||||
data-shot="1"
|
|
||||||
min="0"
|
|
||||||
max="10"
|
|
||||||
value="{% if participant.targets[i|string].shot1 is not none %}{{ participant.targets[i|string].shot1 }}{% endif %}"
|
|
||||||
placeholder="S1"
|
|
||||||
oninput="updateScore({{ player_id }}, {{ i }}, 1, this.value)">
|
|
||||||
<input type="number"
|
|
||||||
class="shot-input"
|
|
||||||
id="shot2-{{ player_id }}-{{ i }}"
|
|
||||||
data-player="{{ player_id }}"
|
|
||||||
data-target="{{ i }}"
|
|
||||||
data-shot="2"
|
|
||||||
min="0"
|
|
||||||
max="10"
|
|
||||||
value="{% if participant.targets[i|string].shot2 is not none %}{{ participant.targets[i|string].shot2 }}{% endif %}"
|
|
||||||
placeholder="S2"
|
|
||||||
oninput="updateScore({{ player_id }}, {{ i }}, 2, this.value)">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="participant-actions">
|
<div class="participant-actions">
|
||||||
<button class="action-btn clear-btn" onclick="clearParticipant({{ player_id }})">
|
<button class="action-btn clear-btn" onclick="clearParticipant({{ player_id }})">
|
||||||
🗑️ Clear All
|
🗑️ Clear All
|
||||||
</button>
|
</button>
|
||||||
<button class="action-btn auto-fill-btn" onclick="autoFillDemo({{ player_id }})">
|
|
||||||
🎲 Demo Fill
|
|
||||||
</button>
|
|
||||||
<button class="action-btn save-btn" onclick="saveParticipant({{ player_id }})">
|
<button class="action-btn save-btn" onclick="saveParticipant({{ player_id }})">
|
||||||
💾 Save Progress
|
💾 Save Progress
|
||||||
</button>
|
</button>
|
||||||
@@ -633,6 +707,24 @@
|
|||||||
let results = {{ results|tojson }};
|
let results = {{ results|tojson }};
|
||||||
let saveTimeout = {};
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`Tournament config: ${numTargets} targets, ${shotsPerTarget} shots each`);
|
||||||
|
|
||||||
// Debounce function for auto-saving
|
// Debounce function for auto-saving
|
||||||
function debounce(func, wait, immediate) {
|
function debounce(func, wait, immediate) {
|
||||||
var timeout;
|
var timeout;
|
||||||
@@ -649,6 +741,56 @@
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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"
|
||||||
|
id="shot${shot}-${playerId}-${i}"
|
||||||
|
data-player="${playerId}"
|
||||||
|
data-target="${i}"
|
||||||
|
data-shot="${shot}"
|
||||||
|
min="0"
|
||||||
|
max="10"
|
||||||
|
value="${displayValue}"
|
||||||
|
placeholder="S${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-grid targets-${numTargets}`;
|
||||||
|
targetsContainer.innerHTML = generateTargetsHTML(playerId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function toggleParticipant(playerId) {
|
function toggleParticipant(playerId) {
|
||||||
const card = document.getElementById(`card-${playerId}`);
|
const card = document.getElementById(`card-${playerId}`);
|
||||||
card.classList.toggle('collapsed');
|
card.classList.toggle('collapsed');
|
||||||
@@ -678,7 +820,12 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!results.participants[playerIdStr].targets[targetStr]) {
|
if (!results.participants[playerIdStr].targets[targetStr]) {
|
||||||
results.participants[playerIdStr].targets[targetStr] = {shot1: null, shot2: null};
|
// 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;
|
results.participants[playerIdStr].targets[targetStr][`shot${shotNum}`] = numValue;
|
||||||
@@ -711,13 +858,19 @@
|
|||||||
const targetGroup = document.getElementById(`target-group-${playerId}-${targetNum}`);
|
const targetGroup = document.getElementById(`target-group-${playerId}-${targetNum}`);
|
||||||
|
|
||||||
if (targetGroup && results.participants[playerIdStr].targets[targetStr]) {
|
if (targetGroup && results.participants[playerIdStr].targets[targetStr]) {
|
||||||
const shot1 = results.participants[playerIdStr].targets[targetStr].shot1;
|
const targetData = results.participants[playerIdStr].targets[targetStr];
|
||||||
const shot2 = results.participants[playerIdStr].targets[targetStr].shot2;
|
|
||||||
|
|
||||||
// Target is completed if both shots have been entered (including 0)
|
// Check if all shots are completed
|
||||||
const isCompleted = shot1 !== null && shot1 !== undefined && shot2 !== null && shot2 !== undefined;
|
let allCompleted = true;
|
||||||
|
for (let i = 1; i <= shotsPerTarget; i++) {
|
||||||
|
const shotValue = targetData[`shot${i}`];
|
||||||
|
if (shotValue === null || shotValue === undefined) {
|
||||||
|
allCompleted = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (isCompleted) {
|
if (allCompleted) {
|
||||||
targetGroup.classList.add('completed');
|
targetGroup.classList.add('completed');
|
||||||
} else {
|
} else {
|
||||||
targetGroup.classList.remove('completed');
|
targetGroup.classList.remove('completed');
|
||||||
@@ -731,10 +884,11 @@
|
|||||||
let total = 0;
|
let total = 0;
|
||||||
|
|
||||||
for (let target in targets) {
|
for (let target in targets) {
|
||||||
const shot1 = targets[target].shot1;
|
const targetData = targets[target];
|
||||||
const shot2 = targets[target].shot2;
|
for (let i = 1; i <= shotsPerTarget; i++) {
|
||||||
total += (shot1 !== null && shot1 !== undefined ? shot1 : 0);
|
const shotValue = targetData[`shot${i}`];
|
||||||
total += (shot2 !== null && shot2 !== undefined ? shot2 : 0);
|
total += (shotValue !== null && shotValue !== undefined ? shotValue : 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
results.participants[playerIdStr].total_score = total;
|
results.participants[playerIdStr].total_score = total;
|
||||||
@@ -762,33 +916,30 @@
|
|||||||
let totalShots = 0;
|
let totalShots = 0;
|
||||||
|
|
||||||
for (let target in targets) {
|
for (let target in targets) {
|
||||||
const shot1 = targets[target].shot1;
|
const targetData = targets[target];
|
||||||
const shot2 = targets[target].shot2;
|
let targetCompleted = true;
|
||||||
|
|
||||||
// Count shots that have been entered (including 0)
|
for (let i = 1; i <= shotsPerTarget; i++) {
|
||||||
if (shot1 !== null && shot1 !== undefined) totalShots++;
|
const shotValue = targetData[`shot${i}`];
|
||||||
if (shot2 !== null && shot2 !== undefined) totalShots++;
|
|
||||||
|
|
||||||
// Target is completed if both shots have been entered
|
// Count shots that have been entered (including 0)
|
||||||
if (shot1 !== null && shot1 !== undefined && shot2 !== null && shot2 !== undefined) {
|
if (shotValue !== null && shotValue !== undefined) {
|
||||||
|
totalShots++;
|
||||||
|
} else {
|
||||||
|
targetCompleted = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (targetCompleted) {
|
||||||
completedTargets++;
|
completedTargets++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const isCompleted = completedTargets === 20;
|
const isCompleted = completedTargets === numTargets;
|
||||||
const isInProgress = totalShots > 0 && !isCompleted;
|
const isInProgress = totalShots > 0 && !isCompleted;
|
||||||
|
|
||||||
results.participants[playerIdStr].completed = isCompleted;
|
results.participants[playerIdStr].completed = isCompleted;
|
||||||
|
|
||||||
// Debug logging
|
|
||||||
console.log(`Player ${playerId} status:`, {
|
|
||||||
completedTargets,
|
|
||||||
totalShots,
|
|
||||||
isCompleted,
|
|
||||||
isInProgress,
|
|
||||||
sampleTarget: targets['1']
|
|
||||||
});
|
|
||||||
|
|
||||||
// Update card styling
|
// Update card styling
|
||||||
card.classList.remove('completed', 'in-progress');
|
card.classList.remove('completed', 'in-progress');
|
||||||
if (isCompleted) {
|
if (isCompleted) {
|
||||||
@@ -814,8 +965,10 @@
|
|||||||
|
|
||||||
for (let target in participant.targets) {
|
for (let target in participant.targets) {
|
||||||
const targetData = participant.targets[target];
|
const targetData = participant.targets[target];
|
||||||
if (targetData.shot1 !== null && targetData.shot1 !== undefined) totalShots++;
|
for (let i = 1; i <= shotsPerTarget; i++) {
|
||||||
if (targetData.shot2 !== null && targetData.shot2 !== undefined) totalShots++;
|
const shotValue = targetData[`shot${i}`];
|
||||||
|
if (shotValue !== null && shotValue !== undefined) totalShots++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -881,6 +1034,36 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function saveAllPlayers() {
|
||||||
|
const saveAllBtn = document.querySelector('.save-all-btn');
|
||||||
|
const originalText = saveAllBtn.textContent;
|
||||||
|
saveAllBtn.textContent = '💾 Saving All...';
|
||||||
|
saveAllBtn.disabled = true;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const playerIds = Object.keys(results.participants);
|
||||||
|
for (const playerId of playerIds) {
|
||||||
|
await saveParticipant(parseInt(playerId), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show success feedback
|
||||||
|
saveAllBtn.textContent = '✅ All Saved!';
|
||||||
|
saveAllBtn.style.background = '#28a745';
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
saveAllBtn.textContent = originalText;
|
||||||
|
saveAllBtn.style.background = '';
|
||||||
|
saveAllBtn.disabled = false;
|
||||||
|
}, 2000);
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error saving all players:', error);
|
||||||
|
alert('Failed to save all player data. Please try again.');
|
||||||
|
saveAllBtn.textContent = originalText;
|
||||||
|
saveAllBtn.disabled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function clearParticipant(playerId) {
|
function clearParticipant(playerId) {
|
||||||
if (!confirm('Are you sure you want to clear all scores for this participant?')) {
|
if (!confirm('Are you sure you want to clear all scores for this participant?')) {
|
||||||
return;
|
return;
|
||||||
@@ -889,15 +1072,18 @@
|
|||||||
const playerIdStr = playerId.toString();
|
const playerIdStr = playerId.toString();
|
||||||
|
|
||||||
// Clear all inputs
|
// Clear all inputs
|
||||||
for (let i = 1; i <= 20; i++) {
|
for (let i = 1; i <= numTargets; i++) {
|
||||||
const shot1Input = document.getElementById(`shot1-${playerId}-${i}`);
|
for (let shot = 1; shot <= shotsPerTarget; shot++) {
|
||||||
const shot2Input = document.getElementById(`shot2-${playerId}-${i}`);
|
const shotInput = document.getElementById(`shot${shot}-${playerId}-${i}`);
|
||||||
|
if (shotInput) shotInput.value = '';
|
||||||
if (shot1Input) shot1Input.value = '';
|
}
|
||||||
if (shot2Input) shot2Input.value = '';
|
|
||||||
|
|
||||||
// Update data
|
// Update data
|
||||||
results.participants[playerIdStr].targets[i.toString()] = {shot1: null, shot2: null};
|
const target = {};
|
||||||
|
for (let shot = 1; shot <= shotsPerTarget; shot++) {
|
||||||
|
target[`shot${shot}`] = null;
|
||||||
|
}
|
||||||
|
results.participants[playerIdStr].targets[i.toString()] = target;
|
||||||
|
|
||||||
// Update target group styling
|
// Update target group styling
|
||||||
updateTargetGroupStyling(playerId, i);
|
updateTargetGroupStyling(playerId, i);
|
||||||
@@ -916,24 +1102,27 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fillPlayerRandom(playerId);
|
||||||
|
saveParticipant(playerId);
|
||||||
|
}
|
||||||
|
|
||||||
|
function fillPlayerRandom(playerId) {
|
||||||
const playerIdStr = playerId.toString();
|
const playerIdStr = playerId.toString();
|
||||||
|
|
||||||
// Fill with random scores (0-10) - all fields will be filled
|
// Fill with random scores (0-10) - all fields will be filled
|
||||||
for (let i = 1; i <= 20; i++) {
|
for (let i = 1; i <= numTargets; i++) {
|
||||||
const shot1 = Math.floor(Math.random() * 11);
|
const target = {};
|
||||||
const shot2 = Math.floor(Math.random() * 11);
|
|
||||||
|
|
||||||
const shot1Input = document.getElementById(`shot1-${playerId}-${i}`);
|
for (let shot = 1; shot <= shotsPerTarget; shot++) {
|
||||||
const shot2Input = document.getElementById(`shot2-${playerId}-${i}`);
|
const randomScore = Math.floor(Math.random() * 11);
|
||||||
|
const shotInput = document.getElementById(`shot${shot}-${playerId}-${i}`);
|
||||||
|
|
||||||
if (shot1Input) shot1Input.value = shot1;
|
if (shotInput) shotInput.value = randomScore;
|
||||||
if (shot2Input) shot2Input.value = shot2;
|
target[`shot${shot}`] = randomScore;
|
||||||
|
}
|
||||||
|
|
||||||
// Update data
|
// Update data
|
||||||
results.participants[playerIdStr].targets[i.toString()] = {
|
results.participants[playerIdStr].targets[i.toString()] = target;
|
||||||
shot1: shot1,
|
|
||||||
shot2: shot2
|
|
||||||
};
|
|
||||||
|
|
||||||
// Update target group styling
|
// Update target group styling
|
||||||
updateTargetGroupStyling(playerId, i);
|
updateTargetGroupStyling(playerId, i);
|
||||||
@@ -942,9 +1131,64 @@
|
|||||||
updateParticipantTotal(playerId);
|
updateParticipantTotal(playerId);
|
||||||
updateParticipantStatus(playerId);
|
updateParticipantStatus(playerId);
|
||||||
updateOverallProgress();
|
updateOverallProgress();
|
||||||
|
}
|
||||||
|
|
||||||
// Save changes
|
async function fillAllPlayersRandom() {
|
||||||
saveParticipant(playerId);
|
if (!confirm('Fill ALL players with random demo scores? This will overwrite all existing data and enable tournament finish.')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const fillAllBtn = document.querySelector('.fill-all-btn');
|
||||||
|
const originalText = fillAllBtn.textContent;
|
||||||
|
fillAllBtn.textContent = '🎲 Filling All...';
|
||||||
|
fillAllBtn.disabled = true;
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show success feedback
|
||||||
|
fillAllBtn.textContent = '✅ All Filled!';
|
||||||
|
fillAllBtn.style.background = '#28a745';
|
||||||
|
|
||||||
|
// Show notification
|
||||||
|
const notification = document.createElement('div');
|
||||||
|
notification.style.cssText = `
|
||||||
|
position: fixed;
|
||||||
|
top: 20px;
|
||||||
|
right: 20px;
|
||||||
|
background: #28a745;
|
||||||
|
color: white;
|
||||||
|
padding: 15px 25px;
|
||||||
|
border-radius: 8px;
|
||||||
|
z-index: 1000;
|
||||||
|
font-weight: bold;
|
||||||
|
box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
|
||||||
|
`;
|
||||||
|
notification.textContent = '🎯 All players filled with random scores! Tournament ready to finish.';
|
||||||
|
document.body.appendChild(notification);
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
document.body.removeChild(notification);
|
||||||
|
fillAllBtn.textContent = originalText;
|
||||||
|
fillAllBtn.style.background = '';
|
||||||
|
fillAllBtn.disabled = false;
|
||||||
|
}, 4000);
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error filling all players:', error);
|
||||||
|
alert('Failed to fill all players. Please try again.');
|
||||||
|
fillAllBtn.textContent = originalText;
|
||||||
|
fillAllBtn.disabled = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function finishTournament() {
|
async function finishTournament() {
|
||||||
@@ -993,77 +1237,51 @@
|
|||||||
document.addEventListener('keydown', function(event) {
|
document.addEventListener('keydown', function(event) {
|
||||||
if (event.ctrlKey && event.key === 's') {
|
if (event.ctrlKey && event.key === 's') {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
// Save all participants
|
saveAllPlayers();
|
||||||
Object.keys(results.participants).forEach(playerId => {
|
|
||||||
saveParticipant(parseInt(playerId), true);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Show feedback
|
|
||||||
const feedback = document.createElement('div');
|
|
||||||
feedback.style.cssText = `
|
|
||||||
position: fixed;
|
|
||||||
top: 20px;
|
|
||||||
right: 20px;
|
|
||||||
background: #28a745;
|
|
||||||
color: white;
|
|
||||||
padding: 10px 20px;
|
|
||||||
border-radius: 6px;
|
|
||||||
z-index: 1000;
|
|
||||||
font-weight: bold;
|
|
||||||
`;
|
|
||||||
feedback.textContent = '💾 All progress saved!';
|
|
||||||
document.body.appendChild(feedback);
|
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
document.body.removeChild(feedback);
|
|
||||||
}, 3000);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Initialize
|
// Initialize
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
// Debug: Log initial results structure
|
|
||||||
console.log('Initial results structure:', results);
|
console.log('Initial results structure:', results);
|
||||||
console.log('Sample participant targets:', results.participants[Object.keys(results.participants)[0]]?.targets);
|
console.log(`Tournament type: ${tournamentType}, Targets: ${numTargets}, Shots per target: ${shotsPerTarget}`);
|
||||||
|
|
||||||
// Update initial states
|
// Initialize targets for all players
|
||||||
Object.keys(results.participants).forEach(playerId => {
|
Object.keys(results.participants).forEach(playerId => {
|
||||||
for (let i = 1; i <= 20; i++) {
|
initializeTargetsForPlayer(parseInt(playerId));
|
||||||
|
|
||||||
|
// Update initial states
|
||||||
|
for (let i = 1; i <= numTargets; i++) {
|
||||||
updateTargetGroupStyling(parseInt(playerId), i);
|
updateTargetGroupStyling(parseInt(playerId), i);
|
||||||
}
|
}
|
||||||
updateParticipantStatus(parseInt(playerId));
|
updateParticipantStatus(parseInt(playerId));
|
||||||
});
|
});
|
||||||
|
|
||||||
updateOverallProgress();
|
updateOverallProgress();
|
||||||
|
|
||||||
// Add input validation
|
// Add input validation and navigation
|
||||||
document.querySelectorAll('.shot-input').forEach(input => {
|
document.addEventListener('input', function(e) {
|
||||||
input.addEventListener('blur', function() {
|
if (e.target.classList.contains('shot-input')) {
|
||||||
if (this.value !== '') {
|
if (e.target.value !== '') {
|
||||||
const value = parseInt(this.value);
|
const value = parseInt(e.target.value);
|
||||||
const clampedValue = Math.max(0, Math.min(10, isNaN(value) ? 0 : value));
|
const clampedValue = Math.max(0, Math.min(10, isNaN(value) ? 0 : value));
|
||||||
if (this.value !== clampedValue.toString()) {
|
if (e.target.value !== clampedValue.toString()) {
|
||||||
this.value = clampedValue;
|
e.target.value = clampedValue;
|
||||||
// Trigger update
|
|
||||||
const playerId = parseInt(this.dataset.player);
|
|
||||||
const targetNum = parseInt(this.dataset.target);
|
|
||||||
const shotNum = parseInt(this.dataset.shot);
|
|
||||||
updateScore(playerId, targetNum, shotNum, clampedValue);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Handle Enter key to move to next input
|
document.addEventListener('keydown', function(e) {
|
||||||
input.addEventListener('keydown', function(e) {
|
if (e.target.classList.contains('shot-input') && e.key === 'Enter') {
|
||||||
if (e.key === 'Enter') {
|
const inputs = Array.from(document.querySelectorAll('.shot-input'));
|
||||||
const inputs = Array.from(document.querySelectorAll('.shot-input'));
|
const currentIndex = inputs.indexOf(e.target);
|
||||||
const currentIndex = inputs.indexOf(this);
|
const nextInput = inputs[currentIndex + 1];
|
||||||
const nextInput = inputs[currentIndex + 1];
|
if (nextInput) {
|
||||||
if (nextInput) {
|
nextInput.focus();
|
||||||
nextInput.focus();
|
nextInput.select();
|
||||||
nextInput.select();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log('🎯 Results Calculator initialized');
|
console.log('🎯 Results Calculator initialized');
|
||||||
|
|||||||
+787
-400
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user