Untitled
function displayEpisodes(episodes) { const episodeList = document.getElementById("episode-list"); if (!episodeList) { console.error("Element with ID 'episode-list' not found."); return; } episodeList.innerHTML = ""; if (Array.isArray(episodes) && episodes.length > 0) { episodes.forEach((episode, index) => { const listItem = document.createElement("div"); listItem.className = "list-group-item episode-card"; listItem.innerHTML = ` <div> <h5 class="mb-1">${episode.title}</h5> <small>${formatDuration(episode.duration)}</small> </div> <button class="btn btn-primary btn-sm" onclick="playEpisode(${index})">Play</button> `; episodeList.appendChild(listItem); }); } else { episodeList.innerHTML = "<div class='list-group-item'>No episodes available</div>"; console.error("Invalid episodes data"); } }
Leave a Comment