From 9e06dc73f311baebb16f553ef04e3044ccec4cfc Mon Sep 17 00:00:00 2001 From: mandip sanger Date: Wed, 19 Aug 2026 14:58:54 +0100 Subject: [PATCH 1/3] level 100 --- script.js | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 2 deletions(-) diff --git a/script.js b/script.js index 87a7de8..a223a87 100644 --- a/script.js +++ b/script.js @@ -1,4 +1,5 @@ -//You can edit ALL of the code here +// You can edit ALL of the code here + function setup() { const allEpisodes = getAllEpisodes(); makePageForEpisodes(allEpisodes); @@ -6,7 +7,64 @@ function setup() { function makePageForEpisodes(episodeList) { const rootElem = document.getElementById("root"); - rootElem.textContent = `Got ${episodeList.length} episode(s)`; + + // Clear previous content + rootElem.innerHTML = ""; + + // 1. Show total number of episodes + const header = document.createElement("h2"); + header.textContent = `Got ${episodeList.length} episode(s)`; + rootElem.appendChild(header); + + // 2. Loop through each episode + episodeList.forEach(function (episode) { + const container = document.createElement("div"); + + // Episode title + const title = document.createElement("h3"); + title.textContent = episode.name; + container.appendChild(title); + + // Episode code: S02E07 + const episodeCode = document.createElement("p"); + + const season = String(episode.season).padStart(2, "0"); + const number = String(episode.number).padStart(2, "0"); + + episodeCode.textContent = `S${season}E${number}`; + + container.appendChild(episodeCode); + + // 3. Show medium-size image + const image = document.createElement("img"); + + if (episode.image && episode.image.medium) { + image.src = episode.image.medium; + image.alt = episode.name; + } + + container.appendChild(image); + + // Episode summary + const summary = document.createElement("p"); + summary.innerHTML = episode.summary || "No summary available."; + + container.appendChild(summary); + + // Add episode to page + rootElem.appendChild(container); + }); + + // 4. Link to TVMaze + const source = document.createElement("p"); + + const link = document.createElement("a"); + link.href = "https://www.tvmaze.com/"; + link.textContent = "Data provided by TVMaze"; + link.target = "_blank"; + + source.appendChild(link); + rootElem.appendChild(source); } window.onload = setup; From 3a93aa64e9cf828d98f0cf51199d5b66c2f28a64 Mon Sep 17 00:00:00 2001 From: mandip sanger Date: Wed, 19 Aug 2026 15:08:24 +0100 Subject: [PATCH 2/3] update html with template --- index.html | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index 9a400d1..8f37f0a 100644 --- a/index.html +++ b/index.html @@ -3,17 +3,29 @@ - TV Show Project | My Name (My GitHub username) + TV Show Project | Mandip Sanger (mandipsanger) + +
+ From e0be520a783b4c5815e71ef8bfbf11d1cf2a8e4f Mon Sep 17 00:00:00 2001 From: mandip sanger Date: Fri, 21 Aug 2026 13:26:48 +0100 Subject: [PATCH 3/3] level300 --- index.html | 4 ---- script.js | 29 +++++++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/index.html b/index.html index 8f37f0a..5d64c4d 100644 --- a/index.html +++ b/index.html @@ -23,10 +23,6 @@

Episode code

- - - - diff --git a/script.js b/script.js index a223a87..e578745 100644 --- a/script.js +++ b/script.js @@ -1,8 +1,33 @@ // You can edit ALL of the code here +const API_URL = "https://api.tvmaze.com/shows/82/episodes"; + function setup() { - const allEpisodes = getAllEpisodes(); - makePageForEpisodes(allEpisodes); + const rootElem = document.getElementById("root"); + + // Show loading message while waiting for data + rootElem.innerHTML = "

Loading episodes, please wait...

"; + + // Fetch the episodes ONCE + fetch(API_URL) + .then(function (response) { + if (!response.ok) { + throw new Error("Failed to load episodes"); + } + + return response.json(); + }) + .then(function (allEpisodes) { + makePageForEpisodes(allEpisodes); + }) + .catch(function (error) { + // Show error message to the user + rootElem.innerHTML = + "

Sorry, we could not load the episodes.

" + + "

Please try again later.

"; + + console.error(error); + }); } function makePageForEpisodes(episodeList) {