diff options
| author | Tim Keller <tjk@tjkeller.xyz> | 2026-05-21 11:43:53 -0500 |
|---|---|---|
| committer | Tim Keller <tjk@tjkeller.xyz> | 2026-05-21 11:43:53 -0500 |
| commit | dcd004dabbed3a35cb4f59e94712f358528ead87 (patch) | |
| tree | 01ee9d5a27efcd6922323a095007f6e8ae212985 | |
| parent | d4f8fc15b7e6a2204e8dda92a083684d93a5fa59 (diff) | |
| download | embedtube-dcd004dabbed3a35cb4f59e94712f358528ead87.tar.xz embedtube-dcd004dabbed3a35cb4f59e94712f358528ead87.zip | |
check if tags exist before trying to populate them and remove new tags div if no tags exist
| -rw-r--r-- | static/index.js | 7 | ||||
| -rw-r--r-- | templates/watch.html | 6 |
2 files changed, 9 insertions, 4 deletions
diff --git a/static/index.js b/static/index.js index c753e3f..275e68b 100644 --- a/static/index.js +++ b/static/index.js @@ -2,6 +2,7 @@ const titleBar = document.getElementById("title") const buttonDetails = document.getElementById("toggle-details") const divDetails = document.getElementById("details") +const divTags = document.getElementById("details-tags") const buttonComments = document.getElementById("toggle-comments") const divComments = document.getElementById("comments") const commentTemplate = document.getElementById("template-comment") @@ -108,14 +109,16 @@ async function toggleDetails() { if (detailsLoaded) return toggleVis(divDetails) - // data const data = await getApiReq(`/details?id=${player.playerInfo.videoData.video_id}`) // pop const fieldElements = fillFields(data, divDetails) fieldElements.author.href = `https://www.youtube.com/channel/${data.channel}` - fieldElements.tags.textContent = data.tags.join(", ") + if (data.tags) + fieldElements.tags.textContent = data.tags.join(", ") + else + divTags.remove() // done detailsLoaded = true diff --git a/templates/watch.html b/templates/watch.html index 9849bba..2842547 100644 --- a/templates/watch.html +++ b/templates/watch.html @@ -20,8 +20,10 @@ <span><a data-f="author"></a> @ <time data-f="published"></time></span><br> <span><span data-f="views"></span> Views => 👍 <span data-f="likes"></span> => <span data-f="comments"></span> Comments</span><br><br> <div data-f="description" data-anchor>No description has been added to this video.</div> - <h4>Tags:</h4> - <div data-f="tags" data-skip></div> + <div id="details-tags"> + <h4>Tags:</h4> + <div data-f="tags" data-skip></div> + </div> </div> <div id="comments" style="display:none"> <h3>Comments:</h3> |
