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
26 changes: 20 additions & 6 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,33 @@
<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 | Rahwa Zeslus Haile</title>
<link href="style.css" rel="stylesheet" />
<link rel="icon" href="/favicon.ico" type="image/x-icon" />
</head>

<body>
<div id="root">
</div>

<template id="episode-template">
<div class="episode-card">
<a href="#" target="_blank" rel="noopener">
<div class="episode-header shadow-box">
<span class="episode-name"></span> - <span class="episode-code"></span>
</div>
<img src="" alt="TV Show Image" />
</a>
<div class="episode-summary"></div>
</div>
</template>

<!-- Loads a provided function called getAllEpisodes() which returns all episodes -->
<script src="episodes.js"></script>
<div id="root"></div>

<footer>
Data originally from
<a href="https://tvmaze.com/" target="_blank" rel="noopener">TVMaze.com</a>
</footer>

<!-- Loads YOUR javascript code -->
<script src="episodes.js"></script>
<script src="script.js"></script>
</body>
</html>
38 changes: 34 additions & 4 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
function setup() {
const allEpisodes = getAllEpisodes();
makePageForEpisodes(allEpisodes);
populateDropdown(allEpisodes);
setupSearch(allEpisodes);
setupDropdown(allEpisodes);
}

function makePageForEpisodes(episodeList) {
const rootElem = document.getElementById("root");
rootElem.textContent = `Got ${episodeList.length} episode(s)`;
function zeroPad(num) {
return num.toString().padStart(2, "0");
}

function makePageForEpisodes(episodes) {
const root = document.getElementById("root");
root.innerHTML = "";

const template = document.getElementById("episode-template");

episodes.forEach((ep) => {
const episodeCode = `S${zeroPad(ep.season)}E${zeroPad(ep.number)}`;
const clone = template.content.cloneNode(true);

clone.querySelector("a").href = ep.url;
clone.querySelector(".episode-name").textContent = ep.name;
clone.querySelector(".episode-code").textContent = episodeCode;

const img = clone.querySelector("img");
img.src = ep.image.medium;
img.alt = `Image from ${ep.name}`;

clone.querySelector(".episode-summary").innerHTML = ep.summary;

root.appendChild(clone);
});

const count = document.getElementById("episodeCount");
count.textContent = `Displaying ${episodes.length} episode(s)`;
}



window.onload = setup;
78 changes: 77 additions & 1 deletion style.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,79 @@
body {
font-family: Arial, sans-serif;
margin: 0;
background: #f7f7f7;
padding: 1rem;
}

#controls {
display: flex;
flex-wrap: wrap;
gap: 1rem;
align-items: center;
justify-content: space-between;
padding: 1rem;
background: #ffffff;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
margin-bottom: 1rem;
}

#searchInput,
#episodeSelect {
padding: 0.5rem;
font-size: 1rem;
max-width: 300px;
width: 100%;
}

#episodeCount {
font-weight: bold;
font-size: 1rem;
margin-left: auto;
white-space: nowrap;
}

#root {
color: red;
display: flex;
flex-wrap: wrap;
gap: 1.5rem;
justify-content: center;
}

.episode-card {
background: white;
border-radius: 8px;
overflow: hidden;
max-width: 300px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

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

.episode-header {
padding: 0.75rem;
background: #1e1e1e;
color: white;
font-size: 1rem;
font-weight: bold;
text-align: center;
}

.shadow-box {
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
}

.episode-summary {
padding: 0.75rem;
font-size: 0.9rem;
}

footer {
text-align: center;
margin-top: 2rem;
padding: 1rem;
font-size: 0.9rem;
}