Print function correction + player analysis fix and player stats fix
This commit is contained in:
@@ -653,19 +653,19 @@
|
||||
<div class="stat-label">Total Tournaments</div>
|
||||
</div>
|
||||
<div class="stat-card target-40">
|
||||
<span class="stat-icon">🎯</span>
|
||||
<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>
|
||||
<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>
|
||||
<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 class="stat-label">4-Target <br> Tournaments</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<span class="stat-icon">👥</span>
|
||||
@@ -679,11 +679,6 @@
|
||||
<div class="section">
|
||||
<div class="section-title">
|
||||
<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 %}
|
||||
@@ -716,12 +711,6 @@
|
||||
</div>
|
||||
<div class="archive-actions">
|
||||
<a href="/archive/league/{{ league.filename }}" class="action-btn view-btn">🏆 View</a>
|
||||
<button class="action-btn edit-btn" onclick="event.stopPropagation(); editArchive('league', '{{ league.filename }}', {{ league|tojson }})">
|
||||
✏️ Edit
|
||||
</button>
|
||||
<button class="action-btn delete-btn" onclick="event.stopPropagation(); deleteArchive('league', '{{ league.filename }}')">
|
||||
🗑️
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -738,12 +727,7 @@
|
||||
{% if tournaments_40 %}
|
||||
<div class="section">
|
||||
<div class="section-title">
|
||||
<span>🎯 40-Target Tournaments</span>
|
||||
<div class="section-controls">
|
||||
<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>
|
||||
<span>💪 40-Target Tournaments</span>
|
||||
</div>
|
||||
<div class="archive-grid" id="tournaments-40-grid">
|
||||
{% for tournament in tournaments_40 %}
|
||||
@@ -776,12 +760,6 @@
|
||||
</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>
|
||||
@@ -795,12 +773,7 @@
|
||||
{% 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>
|
||||
<span>⚡ 20-Target Tournaments</span>
|
||||
</div>
|
||||
<div class="archive-grid" id="tournaments-20-grid">
|
||||
{% for tournament in tournaments_20 %}
|
||||
@@ -833,12 +806,6 @@
|
||||
</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>
|
||||
@@ -852,12 +819,7 @@
|
||||
{% 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>
|
||||
<span>🎯 4-Target Tournaments</span>
|
||||
</div>
|
||||
<div class="archive-grid" id="tournaments-4-grid">
|
||||
{% for tournament in tournaments_4 %}
|
||||
@@ -890,12 +852,6 @@
|
||||
</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>
|
||||
@@ -910,11 +866,6 @@
|
||||
<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 %}
|
||||
@@ -947,12 +898,6 @@
|
||||
</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>
|
||||
@@ -1067,67 +1012,6 @@
|
||||
);
|
||||
}
|
||||
|
||||
// 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');
|
||||
@@ -1151,30 +1035,6 @@
|
||||
});
|
||||
}
|
||||
|
||||
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
|
||||
function showModal(title, message, confirmCallback) {
|
||||
document.getElementById('modalTitle').textContent = title;
|
||||
@@ -1211,38 +1071,6 @@
|
||||
closeEditModal();
|
||||
}
|
||||
});
|
||||
|
||||
// Initialize page
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
console.log('📚 Enhanced Archive loaded');
|
||||
console.log('🏆 Total Tournaments:', {{ tournaments|length if tournaments 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>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user