1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/** @jsxImportSource npm:hono@3/jsx */
import { Hono } from "npm:hono";
const app = new Hono();
const players = {
"Mike Trout": { team: "Los Angeles Angels", salary: 35450000, stadium: "Angel Stadium", hotDogPrice: 6.5 },
"Gerrit Cole": { team: "New York Yankees", salary: 36000000, stadium: "Yankee Stadium", hotDogPrice: 6 },
"Mookie Betts": { team: "Los Angeles Dodgers", salary: 27000000, stadium: "Dodger Stadium", hotDogPrice: 6.75 },
"Manny Machado": { team: "San Diego Padres", salary: 32000000, stadium: "Petco Park", hotDogPrice: 6.5 },
"Francisco Lindor": { team: "New York Mets", salary: 34100000, stadium: "Citi Field", hotDogPrice: 6.5 },
"Aaron Judge": { team: "New York Yankees", salary: 40000000, stadium: "Yankee Stadium", hotDogPrice: 6 },
"Fernando Tatis Jr.": { team: "San Diego Padres", salary: 34000000, stadium: "Petco Park", hotDogPrice: 6.5 },
"Jacob deGrom": { team: "Texas Rangers", salary: 37000000, stadium: "Globe Life Field", hotDogPrice: 5.5 },
"Shohei Ohtani": { team: "Los Angeles Angels", salary: 30000000, stadium: "Angel Stadium", hotDogPrice: 6.5 },
"Bryce Harper": { team: "Philadelphia Phillies", salary: 27000000, stadium: "Citizens Bank Park", hotDogPrice: 6 },
"Juan Soto": { team: "San Diego Padres", salary: 23000000, stadium: "Petco Park", hotDogPrice: 6.5 },
"Ronald Acuña Jr.": { team: "Atlanta Braves", salary: 17000000, stadium: "Truist Park", hotDogPrice: 5 },
"José Altuve": { team: "Houston Astros", salary: 29000000, stadium: "Minute Maid Park", hotDogPrice: 5.5 },
"Freddie Freeman": { team: "Los Angeles Dodgers", salary: 27000000, stadium: "Dodger Stadium", hotDogPrice: 6.75 },
"Nolan Arenado": { team: "St. Louis Cardinals", salary: 35000000, stadium: "Busch Stadium", hotDogPrice: 5 },
"Justin Verlander": { team: "New York Mets", salary: 43000000, stadium: "Citi Field", hotDogPrice: 6.5 },
"Paul Goldschmidt": { team: "St. Louis Cardinals", salary: 26000000, stadium: "Busch Stadium", hotDogPrice: 5 },
"Trea Turner": { team: "Philadelphia Phillies", salary: 30000000, stadium: "Citizens Bank Park", hotDogPrice: 6 },
"Corey Seager": { team: "Texas Rangers", salary: 32000000, stadium: "Globe Life Field", hotDogPrice: 5.5 },
"Yadier Molina": { team: "St. Louis Cardinals", salary: 10000000, stadium: "Busch Stadium", hotDogPrice: 5 },
};
app.get("/", (c) => {
const playerOptions = Object.keys(players).map(player => `<option value="${player}">${player}</option>`).join("");
return c.html(`
<html>
<head>
<title>What's that in hot dogs?</title>
<style>
body {}
</style>
</head>
<body>
<h1>What's that in hot dogs?</h1>
<form action="/result" method="get">
<label for="player">Choose a player:</label>
<select name="player" id="player">
${playerOptions}
</select>
<button type="submit">Calculate</button>
</form>
<footer>
<p>Made with <a href="https://www.val.town/v/dthyresson/whatsThatInHotDogs">Val.town</a> where you can read what this is <a href="https://www.val.town/v/dthyresson/whatsThatInHotDogs">all about</a>.</p>
</footer>
</body>
</html>
`);
});
app.get("/result", (c) => {
const playerName = c.req.query("player");
const player = players[playerName];
if (!player) {
return c.html("<h1>Player not found</h1>");
}
const numberOfHotDogs = player.salary / player.hotDogPrice;
const hotDogEmojis = Math.round(numberOfHotDogs / 100000);
const emojis = "🌭".repeat(hotDogEmojis);
return c.html(`
<html>
<head>
<title>${playerName} - Hot Dogs</title>
<style>
body {}
table {
width: 90%;
margin: 20px auto;
border-collapse: collapse;
}
table, th, td {
border: 1px solid black;
}
th, td {
padding: 10px;
text-align: center;
}
</style>
</head>
<body>
<h1>What's that in hot dogs?</h1>
<h2>${playerName} can buy ${numberOfHotDogs.toLocaleString()} hot dogs!</h2>
<h3>${emojis}</h3>
<h4>1 x 🌭 = $100,000</h4>
<table>
<tr>
<th>Player</th>
<th>Team</th>
<th>Stadium</th>
<th>Salary</th>
<th>Hot Dog Price</th>
</tr>