177 lines
7.6 KiB
HTML
177 lines
7.6 KiB
HTML
<html>
|
||
<head>
|
||
<title>HKFC Men's C Team - MotM and DotD vote admin</title>
|
||
<link rel="stylesheet" media="screen" href ="/static/css/bootstrap.min.css">
|
||
<link rel="stylesheet" href="/static/css/bootstrap-theme.min.css">
|
||
<meta name="viewport" content = "width=device-width, initial-scale=1.0">
|
||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
||
<script src="/static/js/bootstrap.min.js"></script>
|
||
</head>
|
||
<h2>HKFC Men's C Team MotM and DotD online vote admin page</h2>
|
||
<div style="margin-bottom: 15px;">
|
||
<a href="/admin" class="btn btn-default btn-sm">
|
||
<span class="glyphicon glyphicon-arrow-left"></span> Back to Admin Dashboard
|
||
</a>
|
||
</div>
|
||
{% with messages = get_flashed_messages() %}
|
||
{% if messages %}
|
||
{% for message in messages %}
|
||
<div class="alert alert-warning alert-dismissible" role="alert">
|
||
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||
{{ message }}
|
||
</div>
|
||
{% endfor %}
|
||
{% endif %}
|
||
{% endwith %}
|
||
<body onload="myFunction()">
|
||
|
||
<dl>
|
||
<p>
|
||
{{ form.csrf_token }}
|
||
<b>HKFC C Next Opponent:</b>
|
||
<br/>
|
||
<div class="row">
|
||
<div class="col-xs-12">
|
||
<form class="col-sm-6" method="post" action="/admin/motm">
|
||
<!-- Load Next Fixture Button -->
|
||
<div class="row">
|
||
<div class="col-sm-12">
|
||
<div class="alert alert-info" style="margin-bottom: 15px;">
|
||
<button type="button" class="btn btn-info btn-sm" id="loadFixtureBtn" onclick="loadNextFixture()">
|
||
<span class="glyphicon glyphicon-download-alt"></span> Load Next HKFC C Fixture
|
||
</button>
|
||
<a href="https://hockey.org.hk/MenFixture.asp" target="_blank" class="btn btn-default btn-sm" style="margin-left: 5px;">
|
||
<span class="glyphicon glyphicon-new-window"></span> View HK Hockey Fixtures
|
||
</a>
|
||
<span id="fixtureStatus" style="margin-left: 10px;"></span>
|
||
<div id="fixtureInfo" style="margin-top: 10px; display: none;"></div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class = "row">
|
||
<div class = "col-sm-6">
|
||
<div class="input-group">
|
||
<span class="input-group-addon" id="basic-addon1">Date:</span>
|
||
{{ form.nextMatchDate(class_="form-control", id="nextMatchDate") }}
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</br>
|
||
<div class = "row">
|
||
<div class = "col-sm-9">
|
||
<div class="input-group">
|
||
<span class="input-group-addon" id="basic-addon1">Opposition</span>
|
||
{{ form.nextOppoTeam(class_="form-control", id="nextOppoTeam") }}
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class = "row">
|
||
<div class = "col-sm-6">
|
||
<div class="input-group">
|
||
<span class="input-group-addon" id="basic-addon1">Current Man of the Match:</span>
|
||
{{ form.currMotM(class_="form-control") }}
|
||
</div>
|
||
</div>
|
||
<div class = "col-sm-6">
|
||
<div class="input-group">
|
||
<span class="input-group-addon" id="basic-addon1">Current Dick of the Day:</span>
|
||
{{ form.currDotD(class_="form-control") }}
|
||
</div>
|
||
</div>
|
||
</div>
|
||
{% if not form.currMotM.choices or form.currMotM.choices|length == 0 %}
|
||
<div class="row">
|
||
<div class="col-sm-12">
|
||
<div class="alert alert-warning" style="margin-top: 10px;">
|
||
<small><strong>Note:</strong> No players available for previous MOTM/DotD. This is normal if you haven't set up a match squad yet. You can still save the match details.</small>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
{% endif %}
|
||
<p>
|
||
{{ form.saveButton(class_="btn btn-success") }}
|
||
{{ form.activateButton(class_="btn btn-primary") }}
|
||
<a class="btn btn-danger" href="/" role="button">Cancel</a>
|
||
</p>
|
||
</form>
|
||
<div class="col-sm-4">
|
||
<img src="{{ nextOppoLogo }}" height="90" id="nextOppoLogo"/>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</p>
|
||
</dl>
|
||
|
||
<script>
|
||
function loadNextFixture() {
|
||
// Show loading status
|
||
var statusElement = document.getElementById('fixtureStatus');
|
||
var infoElement = document.getElementById('fixtureInfo');
|
||
var loadBtn = document.getElementById('loadFixtureBtn');
|
||
|
||
statusElement.innerHTML = '<span class="text-info">Loading...</span>';
|
||
loadBtn.disabled = true;
|
||
|
||
// Fetch the next fixture from the API
|
||
fetch('/admin/api/next-fixture')
|
||
.then(response => response.json())
|
||
.then(data => {
|
||
if (data.success) {
|
||
// Update the form fields
|
||
document.getElementById('nextMatchDate').value = data.date;
|
||
document.getElementById('nextOppoTeam').value = data.opponent;
|
||
|
||
// Show fixture information
|
||
let clubInfo = '';
|
||
if (data.opponent_club_info) {
|
||
const club = data.opponent_club_info;
|
||
const confidence = club.match_result ? club.match_result.confidence : 'unknown';
|
||
const matchType = club.match_result ? club.match_result.match_type : 'unknown';
|
||
|
||
clubInfo = '<br><small class="text-muted">';
|
||
clubInfo += 'Club: ' + club.club_name;
|
||
if (club.logo_url) {
|
||
clubInfo += ' | <a href="' + club.logo_url + '" target="_blank">Logo</a>';
|
||
}
|
||
clubInfo += ' | Match: ' + matchType + ' (' + confidence + ')';
|
||
clubInfo += '</small>';
|
||
}
|
||
|
||
infoElement.innerHTML = '<strong>Next Match:</strong> ' +
|
||
data.date_formatted + ' vs ' + data.opponent +
|
||
' (' + (data.is_home ? 'Home' : 'Away') + ' - ' + data.venue + ')' +
|
||
'<br><small>Division: ' + data.division + ' | Time: ' + data.time + '</small>' +
|
||
clubInfo;
|
||
infoElement.style.display = 'block';
|
||
|
||
statusElement.innerHTML = '<span class="text-success">✓ Fixture loaded!</span>';
|
||
|
||
// Clear status message after 3 seconds
|
||
setTimeout(function() {
|
||
statusElement.innerHTML = '';
|
||
}, 3000);
|
||
} else {
|
||
statusElement.innerHTML = '<span class="text-danger">✗ ' + data.message + '</span>';
|
||
infoElement.style.display = 'none';
|
||
}
|
||
loadBtn.disabled = false;
|
||
})
|
||
.catch(error => {
|
||
console.error('Error:', error);
|
||
statusElement.innerHTML = '<span class="text-danger">✗ Error loading fixture</span>';
|
||
infoElement.style.display = 'none';
|
||
loadBtn.disabled = false;
|
||
});
|
||
}
|
||
|
||
// Auto-load fixture on page load
|
||
function myFunction() {
|
||
// Optional: Auto-load the next fixture when the page loads
|
||
// Uncomment the next line if you want this behavior
|
||
// loadNextFixture();
|
||
}
|
||
</script>
|
||
</body>
|
||
</html>
|