Skip to content

Commit a84c864

Browse files
Dean SoferDean Sofer
authored andcommitted
Embedded spotify player
1 parent 94a8669 commit a84c864

File tree

2 files changed

+59
-7
lines changed

2 files changed

+59
-7
lines changed

19hz/map.js

Lines changed: 48 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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;

style.css

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,17 @@ html, body, #map-canvas {
129129
.atcb-initialized {
130130
margin: 10px auto;
131131
}
132+
.speaker-icon {
133+
color: #1db954;
134+
transition: color 0.2s, transform 0.1s;
135+
&:hover {
136+
color: #1ed760;
137+
transform: scale(1.1);
138+
}
139+
&:active {
140+
transform: scale(0.95);
141+
}
142+
}
132143
}
133144

134145
/* google.maps.InfoWindow Body */

0 commit comments

Comments
 (0)