Liga krog3
This commit is contained in:
@@ -1100,6 +1100,8 @@
|
||||
tournamentCells += '<td><span class="tournament-score joker">🃏</span></td>';
|
||||
} else {
|
||||
const score = result.score;
|
||||
const tensCount = result.tens_count || 0;
|
||||
|
||||
// Check if this specific tournament index should be excluded
|
||||
const isExcluded = best4Logic.excludedIndices.includes(participatedTournamentIndex) && best4Logic.allScores.length > 4;
|
||||
const scoreClass = isExcluded ? 'excluded' : 'counted';
|
||||
|
||||
@@ -236,6 +236,44 @@
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.joker-checkbox-wrapper {
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.joker-label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
cursor: pointer;
|
||||
padding: 6px 12px;
|
||||
background: #fff3cd;
|
||||
border: 2px solid #ffc107;
|
||||
border-radius: 8px;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.joker-label:hover {
|
||||
background: #ffc107;
|
||||
border-color: #ff9800;
|
||||
}
|
||||
|
||||
.joker-checkbox-calc {
|
||||
cursor: pointer;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
}
|
||||
|
||||
.joker-checkbox-calc:disabled {
|
||||
cursor: not-allowed;
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
.joker-text {
|
||||
font-size: 0.9rem;
|
||||
font-weight: 600;
|
||||
color: #856404;
|
||||
}
|
||||
|
||||
.participant-status {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -670,6 +708,19 @@
|
||||
<div class="participant-info">
|
||||
<div class="participant-name">{{ participant.name }}</div>
|
||||
<div class="participant-id">ID: {{ player_id }}</div>
|
||||
{% if league_state %}
|
||||
<div class="joker-checkbox-wrapper" onclick="event.stopPropagation()">
|
||||
<label class="joker-label">
|
||||
<input type="checkbox"
|
||||
class="joker-checkbox-calc"
|
||||
id="joker-calc-{{ player_id }}"
|
||||
data-player-id="{{ player_id }}"
|
||||
{% if league_state.participants[player_id|string] and league_state.participants[player_id|string].joker_used %}disabled checked{% endif %}
|
||||
onchange="handleJokerChange({{ player_id }})">
|
||||
<span class="joker-text">🃏 <span data-i18n="league.joker_used">Joker</span></span>
|
||||
</label>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="participant-status">
|
||||
<div class="score-display">
|
||||
@@ -1338,6 +1389,49 @@
|
||||
}
|
||||
}
|
||||
|
||||
// Handle joker checkbox change
|
||||
function handleJokerChange(playerId) {
|
||||
const checkbox = document.getElementById(`joker-calc-${playerId}`);
|
||||
const isChecked = checkbox.checked;
|
||||
|
||||
// If checked, warn user that all scores will be set to zero
|
||||
if (isChecked) {
|
||||
if (confirm('Marking this player as using their Joker will set all their scores to zero. Continue?')) {
|
||||
// Set all scores to zero
|
||||
const participant = results.participants[playerId];
|
||||
if (participant && participant.targets) {
|
||||
Object.keys(participant.targets).forEach(targetId => {
|
||||
const target = participant.targets[targetId];
|
||||
Object.keys(target).forEach(shotKey => {
|
||||
if (shotKey.startsWith('shot')) {
|
||||
target[shotKey] = 0;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
participant.total_score = 0;
|
||||
participant.completed = true; // Mark as completed since joker is used
|
||||
participant.joker_selected = true; // Mark joker as selected in results
|
||||
|
||||
// Update UI
|
||||
updateParticipantTotal(playerId);
|
||||
updateParticipantStatus(playerId);
|
||||
updateParticipantTens(playerId);
|
||||
updateOverallProgress();
|
||||
updateOverallTens();
|
||||
|
||||
// Disable the checkbox so it can't be unchecked
|
||||
checkbox.disabled = true;
|
||||
|
||||
// Save the change
|
||||
savePlayerData(playerId);
|
||||
} else {
|
||||
// User cancelled, uncheck the box
|
||||
checkbox.checked = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Keyboard shortcuts
|
||||
document.addEventListener('keydown', function(event) {
|
||||
if (event.ctrlKey && event.key === 's') {
|
||||
@@ -1352,7 +1446,7 @@
|
||||
// Initialize targets for all players
|
||||
Object.keys(results.participants).forEach(playerId => {
|
||||
initializeTargetsForPlayer(parseInt(playerId));
|
||||
|
||||
|
||||
// Update initial states
|
||||
for (let i = 1; i <= numTargets; i++) {
|
||||
updateTargetGroupStyling(parseInt(playerId), i);
|
||||
@@ -1360,7 +1454,22 @@
|
||||
updateParticipantStatus(parseInt(playerId));
|
||||
updateParticipantTens(parseInt(playerId));
|
||||
});
|
||||
|
||||
|
||||
// Initialize joker checkboxes for league tournaments
|
||||
{% if league_state %}
|
||||
const leagueState = {{ league_state | tojson | safe }};
|
||||
Object.keys(results.participants).forEach(playerId => {
|
||||
const checkbox = document.getElementById(`joker-calc-${playerId}`);
|
||||
if (checkbox && leagueState.participants && leagueState.participants[playerId]) {
|
||||
const participant = leagueState.participants[playerId];
|
||||
if (participant.joker_used) {
|
||||
checkbox.checked = true;
|
||||
checkbox.disabled = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
{% endif %}
|
||||
|
||||
updateOverallProgress();
|
||||
updateOverallTens();
|
||||
|
||||
|
||||
@@ -767,14 +767,22 @@
|
||||
font-weight: bold;
|
||||
transition: all 0.2s ease;
|
||||
min-width: 200px;
|
||||
text-decoration: none;
|
||||
text-decoration: none !important;
|
||||
font-family: Arial, sans-serif;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.action-btn:hover {
|
||||
background: #1e7e34;
|
||||
transform: translateY(-1px);
|
||||
box-shadow: 0 4px 8px rgba(0, 123, 255, 0.3);
|
||||
text-decoration: none !important;
|
||||
}
|
||||
|
||||
.action-btn:focus,
|
||||
.action-btn:active,
|
||||
.action-btn:visited {
|
||||
text-decoration: none !important;
|
||||
}
|
||||
|
||||
.action-btn:disabled {
|
||||
@@ -800,6 +808,16 @@
|
||||
background: #c82333;
|
||||
}
|
||||
|
||||
.action-btn.info {
|
||||
background: #007bff;
|
||||
border-color: #0056b3;
|
||||
}
|
||||
|
||||
.action-btn.info:hover {
|
||||
background: #0056b3;
|
||||
box-shadow: 0 4px 8px rgba(0, 123, 255, 0.4);
|
||||
}
|
||||
|
||||
.player-count {
|
||||
margin: 20px 0;
|
||||
font-size: 1.2rem;
|
||||
@@ -1606,7 +1624,7 @@
|
||||
<input type="checkbox"
|
||||
class="joker-checkbox"
|
||||
id="joker_{{ player_id }}"
|
||||
{% if participant.joker_used %}disabled{% endif %}
|
||||
{% if participant.joker_used %}disabled checked{% endif %}
|
||||
data-player-id="{{ player_id }}">
|
||||
</div>
|
||||
{% endfor %}
|
||||
@@ -1614,6 +1632,11 @@
|
||||
</div>
|
||||
|
||||
<div class="action-buttons">
|
||||
{% if league_state.completed_tournaments|length > 0 %}
|
||||
<a href="/results" class="action-btn info">
|
||||
📊 <span data-i18n="tournament.view_current_results">View Current Standings</span>
|
||||
</a>
|
||||
{% endif %}
|
||||
<button class="action-btn success" onclick="startNextTournament()">
|
||||
🚀 <span data-i18n="league.start_tournament_number">Začni Turnir</span> {{ league_state.current_tournament + 1 }}
|
||||
</button>
|
||||
|
||||
Reference in New Issue
Block a user