Split app.js into modular components (state, evaluation, ui, board, data)

This commit is contained in:
2026-05-27 22:55:49 +02:00
parent 8d971dbef9
commit 8758441f65
9 changed files with 667 additions and 695 deletions

View File

@@ -120,9 +120,17 @@ function getLiveGame(laraGames) {
return laraGames.find(game => game.isLive) || null;
}
function getTodaysGames(laraGames) {
const today = new Date();
const yyyy = today.getFullYear();
const mm = String(today.getMonth() + 1).padStart(2, '0');
const dd = String(today.getDate()).padStart(2, '0');
const todayStr = `${yyyy}.${mm}.${dd}`;
return laraGames.filter(game => game.date === todayStr);
}
function getLatestGame(laraGames) {
if (laraGames.length === 0) return null;
// Sort by round number, return the highest round
const sorted = [...laraGames].sort((a, b) => {
const roundA = parseInt(a.round) || 0;
const roundB = parseInt(b.round) || 0;
@@ -134,4 +142,5 @@ function getLatestGame(laraGames) {
window.parsePGN = parsePGN;
window.filterLaraGames = filterLaraGames;
window.getLiveGame = getLiveGame;
window.getTodaysGames = getTodaysGames;
window.getLatestGame = getLatestGame;