aboutsummaryrefslogtreecommitdiff
path: root/static/index.js
diff options
context:
space:
mode:
authorTim Keller <tjk@tjkeller.xyz>2026-05-21 11:43:53 -0500
committerTim Keller <tjk@tjkeller.xyz>2026-05-21 11:43:53 -0500
commitdcd004dabbed3a35cb4f59e94712f358528ead87 (patch)
tree01ee9d5a27efcd6922323a095007f6e8ae212985 /static/index.js
parentd4f8fc15b7e6a2204e8dda92a083684d93a5fa59 (diff)
downloadembedtube-dcd004dabbed3a35cb4f59e94712f358528ead87.tar.xz
embedtube-dcd004dabbed3a35cb4f59e94712f358528ead87.zip
check if tags exist before trying to populate them and remove new tags div if no tags exist
Diffstat (limited to 'static/index.js')
-rw-r--r--static/index.js7
1 files changed, 5 insertions, 2 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