Refactoring fixes and adding functionality back

This commit is contained in:
2025-10-07 22:03:36 +08:00
parent d5350aa4cb
commit a6febae8a8
17 changed files with 458 additions and 298 deletions
+47 -57
View File
@@ -38,6 +38,7 @@
</div>
<!-- Random Comment -->
{% if comment and comment != "No comments added yet" %}
<div class="row mb-4">
<div class="col-12">
<div class="card">
@@ -47,28 +48,27 @@
</h5>
</div>
<div class="card-body">
{% for item in comment %}
<blockquote class="blockquote text-center">
<p class="mb-0">
<i class="fas fa-quote-left text-muted me-2"></i>
<em>{{ item.comment }}</em>
<i class="fas fa-quote-right text-muted ms-2"></i>
</p>
</blockquote>
{% endfor %}
<blockquote class="blockquote text-center">
<p class="mb-0">
<i class="fas fa-quote-left text-muted me-2"></i>
<em>{{ comment }}</em>
<i class="fas fa-quote-right text-muted ms-2"></i>
</p>
</blockquote>
</div>
</div>
</div>
</div>
{% endif %}
<!-- Voting Forms -->
<div class="row">
<div class="col-lg-6 mb-4">
<!-- Man of the Match -->
<div class="col-lg-8 mx-auto mb-4">
<!-- Vote for MOTM and DotD -->
<div class="card h-100">
<div class="card-header bg-success text-white">
<h5 class="card-title mb-0">
<i class="fas fa-trophy me-2"></i>Man of the Match
<i class="fas fa-vote-yea me-2"></i>Vote for MOTM and DotD
</h5>
</div>
<div class="card-body">
@@ -79,7 +79,7 @@
<div class="mb-3">
<label for="motmSelect" class="form-label">Select Player:</label>
<select class="form-select" id="motmSelect" name="motmSelect" required>
<select class="form-select" id="motmSelect" name="motmVote" required>
<option value="">Choose a player...</option>
{% for player in data %}
<option value="{{ player.playernumber }}">{{ player.playerforenames }} {{ player.playersurname }}
@@ -89,45 +89,26 @@
</select>
</div>
<div class="mb-3">
<label for="dotdSelect" class="form-label">Dick of the Day:</label>
<select class="form-select" id="dotdSelect" name="dotdVote" required>
<option value="">Choose a player...</option>
{% for player in data %}
<option value="{{ player.playernumber }}">{{ player.playerforenames }} {{ player.playersurname }}
{% if player.playernickname %}"{{ player.playernickname }}"{% endif %}
</option>
{% endfor %}
</select>
</div>
<div class="mb-3">
<label for="motmComment" class="form-label">Optional Comment:</label>
<textarea class="form-control" id="motmComment" name="motmComment" rows="3" placeholder="Share your thoughts about the match..."></textarea>
</div>
<div class="d-grid">
<button type="submit" class="btn btn-success btn-lg">
<i class="fas fa-vote-yea me-2"></i>Submit MOTM Vote
</button>
</div>
</form>
</div>
</div>
</div>
<div class="col-lg-6 mb-4">
<!-- Dick of the Day -->
<div class="card h-100">
<div class="card-header bg-warning text-dark">
<h5 class="card-title mb-0">
<i class="fas fa-award me-2"></i>Dick of the Day
</h5>
</div>
<div class="card-body">
<form method="post" action="/motm/dotd-thanks" id="dotdForm">
{{ form.csrf_token }}
<input type="hidden" id="matchNumber" name="matchNumber" value="{{ matchNumber }}">
<input type="hidden" id="oppo" name="oppo" value="{{ oppo }}">
<div class="mb-3">
<label for="dotdSelect" class="form-label">Select Player:</label>
<select class="form-select" id="dotdSelect" name="dotdSelect" required>
<option value="">Choose a player...</option>
{% for player in data %}
<option value="{{ player.playernumber }}">{{ player.playerforenames }} {{ player.playersurname }}
{% if player.playernickname %}"{{ player.playernickname }}"{% endif %}
</option>
{% endfor %}
</select>
</div>
<div class="d-grid">
<button type="submit" class="btn btn-warning btn-lg">
<i class="fas fa-vote-yea me-2"></i>Submit DotD Vote
<i class="fas fa-vote-yea me-2"></i>Submit Votes
</button>
</div>
</form>
@@ -198,18 +179,27 @@
<script>
$(document).ready(function() {
// Form validation
$('#motmForm, #dotdForm').on('submit', function(e) {
const selectElement = $(this).find('select');
if (!selectElement.val()) {
$('#motmForm').on('submit', function(e) {
const motmSelect = $('#motmSelect');
const dotdSelect = $('#dotdSelect');
if (!motmSelect.val()) {
e.preventDefault();
alert('Please select a player before submitting your vote.');
selectElement.focus();
alert('Please select a player for Man of the Match.');
motmSelect.focus();
return false;
}
if (!dotdSelect.val()) {
e.preventDefault();
alert('Please select a player for Dick of the Day.');
dotdSelect.focus();
return false;
}
});
// Add loading state to buttons
$('#motmForm, #dotdForm').on('submit', function() {
// Add loading state to button
$('#motmForm').on('submit', function() {
const button = $(this).find('button[type="submit"]');
const originalText = button.html();
button.html('<span class="loading-spinner"></span> Submitting...').prop('disabled', true);