@@ -365,6 +365,17 @@ window.viewEventDetails = function(eventIndex) {
365365 }
366366} ;
367367
368+ /**
369+ * Updates the Spotify player to search for a specific artist
370+ * @param {string } artistName - The artist name to search for
371+ */
372+ window . updateSpotifyPlayer = function ( artistName ) {
373+ const spotifyPlayer = document . getElementById ( 'spotify-player' ) ;
374+ if ( spotifyPlayer ) {
375+ spotifyPlayer . src = `https://open.spotify.com/embed/search/${ encodeURIComponent ( artistName ) } ` ;
376+ }
377+ } ;
378+
368379/**
369380 * Gets the user's location and displays it on the map
370381 */
@@ -660,21 +671,51 @@ class Events {
660671 const ageInfo = costDetailsParts [ 0 ] || 'N/A' ;
661672 const artistsInfo = costDetailsParts [ 1 ] || 'TBA' ;
662673
663- // Convert artist names to Spotify search links
664- const artistLinks = artistsInfo === 'TBA' ? 'TBA' :
665- artistsInfo . split ( ',' ) . map ( artist => {
666- const trimmedArtist = artist . trim ( ) ;
667- const spotifySearchUrl = `https://open.spotify.com/search/${ encodeURIComponent ( trimmedArtist ) } ` ;
668- return `<a href="${ spotifySearchUrl } " target="_blank">${ trimmedArtist } </a>` ;
674+ // Check if artists are valid (not TBA, TBD, or empty)
675+ const hasValidArtists = artistsInfo &&
676+ artistsInfo . trim ( ) !== '' &&
677+ artistsInfo . toUpperCase ( ) !== 'TBA' &&
678+ artistsInfo . toUpperCase ( ) !== 'TBD' ;
679+
680+ let artistsHTML = '' ;
681+ let spotifyPlayerHTML = '' ;
682+
683+ if ( hasValidArtists ) {
684+ const artists = artistsInfo . split ( ',' ) . map ( artist => artist . trim ( ) ) ;
685+ const firstArtist = artists [ 0 ] ;
686+
687+ // Create artist links with speaker icons
688+ artistsHTML = artists . map ( ( artist , index ) => {
689+ const speakerIcon = `<svg class="speaker-icon" width="14" height="14" viewBox="0 0 24 24" fill="currentColor" style="vertical-align: middle; cursor: pointer; margin-left: 4px;" onclick="event.preventDefault(); event.stopPropagation(); updateSpotifyPlayer('${ artist . replace ( / ' / g, "\\'" ) } ')">
690+ <path d="M3 9v6h4l5 5V4L7 9H3zm13.5 3c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02zM14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77z"/>
691+ </svg>` ;
692+ return `<a href="https://open.spotify.com/search/${ encodeURIComponent ( artist ) } " target="_blank">${ artist } </a>${ speakerIcon } ` ;
669693 } ) . join ( ', ' ) ;
694+
695+ // Create Spotify embed player
696+ spotifyPlayerHTML = `
697+ <iframe id="spotify-player"
698+ style="border-radius: 12px; margin-top: 10px;"
699+ src="https://open.spotify.com/embed/search/${ encodeURIComponent ( firstArtist ) } "
700+ width="100%"
701+ height="152"
702+ frameBorder="0"
703+ allowfullscreen=""
704+ allow="autoplay; clipboard-write; encrypted-media; fullscreen; picture-in-picture"
705+ loading="lazy">
706+ </iframe>
707+ ` ;
708+ }
670709
671710 content . innerHTML = `
672711 <div class="info-header">
673712 <p><strong>Genres:</strong> ${ event . categories . map ( category => `<a onclick="filter({category:'${ category } '})">${ category } </a>` ) . join ( ', ' ) } </p>
674- <p><strong>Artists:</strong> ${ artistLinks } </p>
713+ ${ hasValidArtists ? ` <p><strong>Artists:</strong> ${ artistsHTML } </p>` : '' }
675714 <p><strong>Age:</strong> ${ ageInfo } </p>
676715 </div>
716+ ${ spotifyPlayerHTML }
677717 ` ;
718+
678719 this . cachedInfoWindow . setContent ( content ) ;
679720 }
680721 return this . cachedInfoWindow ;
0 commit comments