Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,22 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>TV Show Project | My Name (My GitHub username)</title>
<title>TV Show Project | Shafiek Walker (shafiekwalker7861)</title>
<link href="style.css" rel="stylesheet" />
<link rel="icon" href="/favicon.ico" type="image/x-icon" />
</head>

<body>
<div id="root">
</div>
<p id="episode-count"></p>

<main id="root"></main>

<footer>
<p>
Episode data originally provided by
<a href="https://www.tvmaze.com/" target="_blank">TVMaze.com</a>
</p>
</footer>

<!-- Loads a provided function called getAllEpisodes() which returns all episodes -->
<script src="episodes.js"></script>
Expand Down
36 changes: 33 additions & 3 deletions script.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,42 @@
//You can edit ALL of the code here
// You can edit ALL of the code here

function setup() {
const allEpisodes = getAllEpisodes();
makePageForEpisodes(allEpisodes);
}

function makePageForEpisodes(episodeList) {
const rootElem = document.getElementById("root");
rootElem.textContent = `Got ${episodeList.length} episode(s)`;
const episodeCount = document.getElementById("episode-count");

episodeCount.textContent = `Got ${episodeList.length} episode(s)`;

for (const episode of episodeList) {
const episodeName = episode.name;

const seasonNumber = String(episode.season).padStart(2, "0");
const episodeNumber = String(episode.number).padStart(2, "0");
const episodeCode = `S${seasonNumber}E${episodeNumber}`;

const episodeCard = document.createElement("div");
episodeCard.classList.add("episode-card");

const heading = document.createElement("h2");
heading.textContent = `${episodeName} - ${episodeCode}`;

const episodeImage = document.createElement("img");
episodeImage.src = episode.image.medium;
episodeImage.alt = `Image for ${episodeName}`;

const episodeSummary = document.createElement("div");
episodeSummary.innerHTML = episode.summary;

episodeCard.appendChild(heading);
episodeCard.appendChild(episodeImage);
episodeCard.appendChild(episodeSummary);

rootElem.appendChild(episodeCard);
}
}

window.onload = setup;
window.onload = setup;
70 changes: 69 additions & 1 deletion style.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,71 @@
body {
margin: 0;
font-family: Arial, sans-serif;
background: #f4f4f4;
color: #222;
}

#episode-count {
max-width: 1200px;
margin: 20px auto;
padding: 0 20px;
font-weight: bold;
}

#root {
color: red;
max-width: 1200px;
margin: 0 auto;
padding: 20px;
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 24px;
}

.episode-card {
background: white;
border-radius: 10px;
padding: 16px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.episode-card h2 {
font-size: 18px;
text-align: center;
margin-top: 0;
margin-bottom: 16px;
}

.episode-card img {
width: 100%;
height: auto;
display: block;
border-radius: 6px;
}

.episode-card p {
line-height: 1.5;
font-size: 14px;
}

footer {
max-width: 1200px;
margin: 30px auto;
padding: 20px;
text-align: center;
}

footer a {
color: inherit;
}

@media (max-width: 900px) {
#root {
grid-template-columns: repeat(2, 1fr);
}
}

@media (max-width: 600px) {
#root {
grid-template-columns: 1fr;
}
}