Public
Edited
Dec 8, 2023
1 fork
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// pick the video from dataset: random or most recent by date...or selection
selectedVid = {
button

// if table selection, show that
if (table) return table
// get random index
const shuffleIndex = Math.floor(Math.random() * ytVids.length)
return sortType == radioOptions[0]
? ytVids.sort((a,b) => new Date(b.date) - new Date(a.date))[0]
: ytVids[shuffleIndex]
}
Insert cell
/**
* Take YoutTube link and get back the embed string
*/
function getYTEmbedString(link) {
// split up link, get only relevant bit
const separated = link.split("/")
const cleanedSlug = separated.slice(-1)[0].match(/^[a-zA-Z0-9-_]+/)[0]
return cleanedSlug
}
Insert cell
radioOptions = ["Most Recent Vid", "Random Vid"]
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more