function create_music_card(item) { var artist = "ari melody"; if (item.artists) { artist = item.artists.join(", "); } let card = document.createElement('a'); card.href = `/music/${item.id}`; card.classList.add("music"); card.id = item.id; card.innerHTML = `
${item.title} artwork

${item.title}

${artist}

${item.type}

`; return card; } document.querySelectorAll("h2.question").forEach(element => { element.onclick = (e) => { const url = `${window.location.protocol}//${window.location.host}${window.location.pathname}#${e.target.id}`; window.location = url; }; }); document.querySelectorAll('blockquote').forEach( element => { element.onclick = (e) => { navigator.clipboard.writeText(e.target.innerText); console.log('copied quote contents to clipboard!\n\n' + e.target.innerText); } } ); fetch('/music.json') .then(res => { if (!res.ok) { throw new Error(`Failed to download music data! ${res.status}`); } return res.json(); }) .then(music => { let music_container = document.getElementById('music-container'); for (index in music) { let item = music[index]; let dom = create_music_card(item); music_container.append(dom); }; });