Show recent/upcoming NHL games from ESPN
This commit is contained in:
parent
3e5521501a
commit
45a7e5d296
82
static/upcoming-nhl-games.html
Normal file
82
static/upcoming-nhl-games.html
Normal file
|
@ -0,0 +1,82 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Upcoming NHL Games | BannerGen</title>
|
||||
<link href="bootstrap.min.css" rel="stylesheet">
|
||||
<style>
|
||||
img {
|
||||
max-width: 100%;
|
||||
padding: 1em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
|
||||
<div class="container">
|
||||
<a class="navbar-brand" href="../">BannerGen</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
||||
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" aria-current="page" href="../">Home</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" href="upcoming-nhl-games.html">Upcoming NHL Games</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="../about.html">About</a>
|
||||
</li>
|
||||
<!-- <li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
Dropdown
|
||||
</a>
|
||||
<ul class="dropdown-menu" aria-labelledby="navbarDropdown">
|
||||
<li><a class="dropdown-item" href="#">Action</a></li>
|
||||
<li><a class="dropdown-item" href="#">Another action</a></li>
|
||||
<li><hr class="dropdown-divider"></li>
|
||||
<li><a class="dropdown-item" href="#">Something else here</a></li>
|
||||
</ul>
|
||||
</li> -->
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div class="container my-5">
|
||||
<h1>Upcoming NHL Games</h1>
|
||||
<div id="upcoming-games"></div>
|
||||
</div>
|
||||
</body>
|
||||
<script>
|
||||
(async function(){
|
||||
const scoreboard_res = await fetch("https://site.api.espn.com/apis/site/v2/sports/hockey/nhl/scoreboard");
|
||||
const scoreboard_data = await scoreboard_res.json();
|
||||
|
||||
const events_res = await fetch("https://site.api.espn.com/apis/site/v2/sports/hockey/nhl/events");
|
||||
const events_data = await events_res.json();
|
||||
|
||||
const upcoming_games_div = document.getElementById('upcoming-games')
|
||||
for (const event of scoreboard_data.events) {
|
||||
const competition = event.competitions[0];
|
||||
console.log(competition);
|
||||
const params = new URLSearchParams({
|
||||
left_logo: competition.competitors[0].team.logo,
|
||||
right_logo: competition.competitors[1].team.logo,
|
||||
left_color: competition.competitors[0].team.color,
|
||||
right_color: competition.competitors[1].team.color,
|
||||
});
|
||||
|
||||
const a = document.createElement('a');
|
||||
a.href = event.links[0].href;
|
||||
const img = document.createElement('img');
|
||||
img.src = "../generate/image.png?" + params;
|
||||
a.appendChild(img);
|
||||
upcoming_games_div.appendChild(a);
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
</html>
|
|
@ -18,6 +18,9 @@
|
|||
<li class="nav-item">
|
||||
<a class="nav-link" aria-current="page" href="./">Home</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="static/upcoming-nhl-games.html">Upcoming NHL Games</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" href="about.html">About</a>
|
||||
</li>
|
||||
|
|
|
@ -18,6 +18,9 @@
|
|||
<li class="nav-item">
|
||||
<a class="nav-link active" aria-current="page" href="./">Home</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="static/upcoming-nhl-games.html">Upcoming NHL Games</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="about.html">About</a>
|
||||
</li>
|
||||
|
|
Loading…
Reference in a new issue