Split app.js into modular components (state, evaluation, ui, board, data)
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user