57 lines
2.3 KiB
HTML
57 lines
2.3 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>{% block title %}FantasyCron{% endblock %}</title>
|
|
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
{% block content %}{% endblock %}
|
|
</div>
|
|
|
|
<!-- App version footer -->
|
|
<footer class="app-footer">
|
|
<div class="version">FantasyCron v{{ app_version }}</div>
|
|
</footer>
|
|
|
|
<script>
|
|
function refreshScores() {
|
|
// Get current page info
|
|
const username = document.querySelector('meta[name="username"]')?.content;
|
|
const week = document.querySelector('meta[name="week"]')?.content;
|
|
|
|
if (username && week) {
|
|
// Fetch updated scores from API
|
|
fetch(`/api/refresh/${username}/${week}`)
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
if (data.league_scores) {
|
|
// Update score displays
|
|
data.league_scores.forEach(league => {
|
|
const userScore = document.getElementById(`user-score-${league.league_id}`);
|
|
const oppScore = document.getElementById(`opp-score-${league.league_id}`);
|
|
|
|
if (userScore) userScore.textContent = league.user_points.toFixed(1);
|
|
if (oppScore) oppScore.textContent = league.opponent_points.toFixed(1);
|
|
});
|
|
}
|
|
})
|
|
.catch(error => console.log('Refresh failed:', error));
|
|
}
|
|
}
|
|
|
|
// Set refresh interval based on game day
|
|
const now = new Date();
|
|
const dayOfWeek = now.getDay();
|
|
const isGameTime = dayOfWeek === 4 || dayOfWeek === 0 || dayOfWeek === 1; // Thu, Sun, Mon
|
|
|
|
if (isGameTime) {
|
|
setInterval(refreshScores, 60000); // Every minute during games
|
|
} else {
|
|
setInterval(refreshScores, 21600000); // Every 6 hours otherwise
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|