I'll help you create a simple web app to display your college baseball game predictions. Here's a complete solution that reads JSON data and displays the simulation results in a clean interface.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>College Baseball Game Predictions</title>
<style>
body {
font-family: Arial, sans-serif;
max-width: 1200px;
margin: 0 auto;
padding: 20px;
background-color: #f5f5f5;
}
h1 {
color: #333;
text-align: center;
}
.file-input-container {
text-align: center;
margin-bottom: 30px;
padding: 20px;
background-color: white;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.game-container {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
gap: 20px;
margin-top: 20px;
}
.game-card {
background-color: white;
border-radius: 8px;
padding: 20px;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.matchup {
font-size: 1.2em;
font-weight: bold;
text-align: center;
margin-bottom: 15px;
color: #2c3e50;
}
.team-stats {
display: flex;
justify-content: space-between;
margin-bottom: 15px;
}
.team {
text-align: center;
flex: 1;
}
.team-name {
font-weight: bold;
margin-bottom: 5px;
}
.win-percentage {
font-size: 2em;
color: #27ae60;
margin: 10px 0;
}
.wins-count {
color: #666;
font-size: 0.9em;
}
.vs {
display: flex;
align-items: center;
justify-content: center;
font-weight: bold;
color: #999;
padding: 0 10px;
}
.simulation-info {
text-align: center;
color: #666;
font-size: 0.9em;
margin-top: 15px;
padding-top: 15px;
border-top: 1px solid #eee;
}
.winner {
background-color: #e8f5e9;
}
.loser {
background-color: #ffebee;
}
input[type="file"] {
padding: 10px;
font-size: 16px;
}
.error {
color: #e74c3c;
text-align: center;
margin-top: 20px;
}
</style>
</head>
<body>
<h1>College Baseball Game Predictions</h1>
<div class="file-input-container">
<label for="fileInput">Select JSON file with game predictions:</label>
<input type="file" id="fileInput" accept=".json">
</div>
<div id="gamesContainer" class="game-container"></div>
<div id="errorContainer"></div>
<script>
document.getElementById('fileInput').addEventListener('change', handleFileSelect);
function handleFileSelect(event) {
const file = event.target.files[0];
if (!file) return;
const reader = new FileReader();
reader.onload = function(e) {
try {
const data = JSON.parse(e.target.result);
displayPredictions(data);
} catch (error) {
showError('Error parsing JSON file: ' + error.message);
}
};
reader.readAsText(file);
}
function displayPredictions(games) {
const container = document.getElementById('gamesContainer');
container.innerHTML = '';
games.forEach(game => {
const gameCard = createGameCard(game);
container.appendChild(gameCard);
});
}
function createGameCard(game) {
// Calculate wins for each team
const team1Wins = game.simulations.filter(sim => sim.winner === game.team1).length;
const team2Wins = game.simulations.filter(sim => sim.winner === game.team2).length;
const totalSims = game.simulations.length;
const team1WinPct = ((team1Wins / totalSims) * 100).toFixed(1);
const team2WinPct = ((team2Wins / totalSims) * 100).toFixed(1);
const card = document.createElement('div');
card.className = 'game-card';
card.innerHTML = `
<div class="matchup">${game.team1} vs ${game.team2}</div>
<div class="team-stats">
<div class="team ${team1Wins > team2Wins ? 'winner' : 'loser'}">
<div class="team-name">${game.team1}</div>
<div class="win-percentage">${team1WinPct}%</div>
<div class="wins-count">${team1Wins} wins</div>
</div>
<div class="vs">VS</div>
<div class="team ${team2Wins > team1Wins ? 'winner' : 'loser'}">
<div class="team-name">${game.team2}</div>
<div class="win-percentage">${team2WinPct}%</div>
<div class="wins-count">${team2Wins} wins</div>
</div>
</div>
<div class="simulation-info">
Based on ${totalSims} simulations
</div>
`;
return card;
}
function showError(message) {
const errorContainer = document.getElementById('errorContainer');
errorContainer.innerHTML = `<div class="error">${message}</div>`;
}
</script>
</body>
</html>
This web app expects a JSON file with the following structure:
[
{
"team1": "UCLA",
"team2": "USC",
"simulations": [
{"winner": "UCLA"},
{"winner": "USC"},
{"winner": "UCLA"},
...
]
},
{
"team1": "Stanford",
"team2": "Cal",
"simulations": [
{"winner": "Stanford"},
{"winner": "Stanford"},
{"winner": "Cal"},
...
]
}
]
The app features:
- File upload functionality for JSON input
- Clean card-based layout for each game
- Win percentage calculations based on simulation results
- Visual highlighting of the predicted winner (green background) vs loser (red background)
- Responsive grid layout that adapts to different screen sizes
- Shows the number of wins and total simulations for transparency
To use it:
- Save the HTML code to a file (e.g.,
baseball-predictions.html)
- Open it in a web browser
- Click "Choose File" and select your JSON file with the game predictions
- The predictions will be displayed automatically
The app will calculate win percentages for each team based on the simulation results and display them in an easy-to-read format.