Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CYF Glasgow | Iakub Dubachev | TV-show | Level 100 #20

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
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
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:8080",
"webRoot": "${workspaceFolder}"
}
]
}
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<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 | Iakub Dubachev (IakubDubachev)</title>
<link href="style.css" rel="stylesheet" />
<link rel="icon" href="/favicon.ico" type="image/x-icon" />
</head>
Expand Down
52 changes: 50 additions & 2 deletions script.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,60 @@
//You can edit ALL of the code here
function setup() {
const allEpisodes = getAllEpisodes();
makePageForEpisodes(allEpisodes);
}

// Function to render all episodes on the page
function makePageForEpisodes(episodeList) {
const rootElem = document.getElementById("root");
rootElem.textContent = `Got ${episodeList.length} episode(s)`;
rootElem.innerHTML = ''; // Clear any existing content

const episodeCount = document.createElement('p');
episodeCount.textContent = `Got ${episodeList.length} episode(s)`;
rootElem.appendChild(episodeCount);

// Create a container for episodes
const episodeContainer = document.createElement('div');
episodeContainer.id = 'episode-container';
rootElem.appendChild(episodeContainer);

episodeList.forEach((episode) => {
const episodeCard = document.createElement('div');
episodeCard.className = 'episode-card';

// Episode Title with Episode Code
const episodeTitle = document.createElement('h3');
episodeTitle.textContent = `${formatEpisodeCode(episode.season, episode.number)} - ${episode.name}`;

// Episode Image
const episodeImage = document.createElement('img');
episodeImage.src = episode.image?.medium || 'placeholder.jpg';
episodeImage.alt = episode.name;

// Episode Summary
const episodeSummary = document.createElement('p');
episodeSummary.innerHTML = episode.summary || 'No summary available.';

// Link to TVMaze episode page
const episodeLink = document.createElement('a');
episodeLink.href = episode.url;
episodeLink.target = '_blank';
episodeLink.textContent = 'View on TVMaze';

// Append elements to the episode card
episodeCard.appendChild(episodeTitle);
episodeCard.appendChild(episodeImage);
episodeCard.appendChild(episodeSummary);
episodeCard.appendChild(episodeLink);

// Add episode card to container
episodeContainer.appendChild(episodeCard);
});
}

// Format the episode code (e.g., S02E07)
function formatEpisodeCode(season, number) {
return `S${String(season).padStart(2, '0')}E${String(number).padStart(2, '0')}`;
}

// Run the setup when the page loads
window.onload = setup;
45 changes: 43 additions & 2 deletions style.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,44 @@
#root {
color: red;
#episode-container {
display: flex;
flex-wrap: wrap;
gap: 1rem;
justify-content: center;
margin-top: 1rem;
}

.episode-card {
border: 1px solid #ccc;
border-radius: 5px;
padding: 1rem;
max-width: 300px;
text-align: center;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.episode-card img {
max-width: 100%;
border-radius: 5px;
}

.episode-card h3 {
font-size: 1rem;
margin: 0.5rem 0;
}

.episode-card p {
font-size: 0.9rem;
margin: 0.5rem 0;
}

.episode-card a {
text-decoration: none;
color: #0077cc;
font-weight: bold;
}

p {
text-align: center;
font-size: 1.2rem;
font-weight: bold;
}