refactor musicbrainz badge
This commit is contained in:
parent
22eb62bb77
commit
2d97d5c7d2
2 changed files with 8 additions and 43 deletions
|
|
@ -91,6 +91,9 @@ let artistsSearchController = null;
|
||||||
let artistCompletionController = null; // Track ongoing completion check to cancel when navigating away
|
let artistCompletionController = null; // Track ongoing completion check to cancel when navigating away
|
||||||
let similarArtistsController = null; // Track ongoing similar artists stream to cancel when navigating away
|
let similarArtistsController = null; // Track ongoing similar artists stream to cancel when navigating away
|
||||||
|
|
||||||
|
// --- MusicBrainz Integration Constants ---
|
||||||
|
const MUSICBRAINZ_LOGO_URL = 'https://upload.wikimedia.org/wikipedia/commons/thumb/9/9e/MusicBrainz_Logo_%282016%29.svg/500px-MusicBrainz_Logo_%282016%29.svg.png';
|
||||||
|
|
||||||
// --- Wishlist Modal Persistence State Management ---
|
// --- Wishlist Modal Persistence State Management ---
|
||||||
const WishlistModalState = {
|
const WishlistModalState = {
|
||||||
// Track if wishlist modal was visible before page refresh
|
// Track if wishlist modal was visible before page refresh
|
||||||
|
|
@ -20014,10 +20017,9 @@ function createArtistCardHTML(artist) {
|
||||||
// Check for MusicBrainz ID
|
// Check for MusicBrainz ID
|
||||||
let mbIconHTML = '';
|
let mbIconHTML = '';
|
||||||
if (artist.musicbrainz_id) {
|
if (artist.musicbrainz_id) {
|
||||||
const mbLogoUrl = 'https://upload.wikimedia.org/wikipedia/commons/thumb/9/9e/MusicBrainz_Logo_%282016%29.svg/500px-MusicBrainz_Logo_%282016%29.svg.png'; // Use official SVG logo
|
|
||||||
mbIconHTML = `
|
mbIconHTML = `
|
||||||
<div class="mb-card-icon" title="View on MusicBrainz" onclick="event.stopPropagation(); window.open('https://musicbrainz.org/artist/${artist.musicbrainz_id}', '_blank')">
|
<div class="mb-card-icon" title="View on MusicBrainz" onclick="event.stopPropagation(); window.open('https://musicbrainz.org/artist/${artist.musicbrainz_id}', '_blank')">
|
||||||
<img src="${mbLogoUrl}" style="width: 20px; height: auto; display: block;">
|
<img src="${MUSICBRAINZ_LOGO_URL}" style="width: 20px; height: auto; display: block;">
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
@ -21144,13 +21146,8 @@ function updateArtistDetailHeader(artist) {
|
||||||
if (nameElement) {
|
if (nameElement) {
|
||||||
nameElement.textContent = artist.name;
|
nameElement.textContent = artist.name;
|
||||||
|
|
||||||
// DEBUG: Log the artist object to check for MBID
|
|
||||||
console.log(`🔍 [DEBUG] Updating header for ${artist.name}`, artist);
|
|
||||||
console.log(`🔍 [DEBUG] MBID present?`, artist.musicbrainz_id);
|
|
||||||
|
|
||||||
// Add MusicBrainz link if available
|
// Add MusicBrainz link if available
|
||||||
if (artist.musicbrainz_id) {
|
if (artist.musicbrainz_id) {
|
||||||
console.log('✅ [DEBUG] Adding MusicBrainz link to header');
|
|
||||||
// Remove existing MB link if any
|
// Remove existing MB link if any
|
||||||
const existingMb = nameElement.parentNode.querySelector('.mb-link-btn');
|
const existingMb = nameElement.parentNode.querySelector('.mb-link-btn');
|
||||||
if (existingMb) existingMb.remove();
|
if (existingMb) existingMb.remove();
|
||||||
|
|
@ -25178,10 +25175,7 @@ function createLibraryArtistCard(artist) {
|
||||||
const mbIcon = document.createElement('div');
|
const mbIcon = document.createElement('div');
|
||||||
mbIcon.className = 'mb-card-icon';
|
mbIcon.className = 'mb-card-icon';
|
||||||
mbIcon.title = 'View on MusicBrainz';
|
mbIcon.title = 'View on MusicBrainz';
|
||||||
|
mbIcon.innerHTML = `<img src="${MUSICBRAINZ_LOGO_URL}" style="width: 20px; height: auto; display: block;">`;
|
||||||
// Use official SVG logo
|
|
||||||
const mbLogoUrl = 'https://upload.wikimedia.org/wikipedia/commons/thumb/9/9e/MusicBrainz_Logo_%282016%29.svg/500px-MusicBrainz_Logo_%282016%29.svg.png';
|
|
||||||
mbIcon.innerHTML = `<img src="${mbLogoUrl}" style="width: 20px; height: auto; display: block;">`;
|
|
||||||
|
|
||||||
mbIcon.onclick = (e) => {
|
mbIcon.onclick = (e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
|
@ -25430,15 +25424,6 @@ function updateArtistDetailPageHeader(artistName) {
|
||||||
const mainTitle = document.getElementById("artist-info-name");
|
const mainTitle = document.getElementById("artist-info-name");
|
||||||
if (mainTitle) {
|
if (mainTitle) {
|
||||||
mainTitle.textContent = artistName;
|
mainTitle.textContent = artistName;
|
||||||
|
|
||||||
// Try to find the artist object in memory to get the MBID
|
|
||||||
// We can look at the data passed to populateArtistDetailPage if this function accepted the full object
|
|
||||||
// Or access the state if it was saved
|
|
||||||
|
|
||||||
// Actually, let's look at how this is invoked. It's called from loadArtistDetailData which has the full 'data' object.
|
|
||||||
// But this function only accepts 'artistName'.
|
|
||||||
// We should query the state or modify the function signature.
|
|
||||||
// For now, let's try to find the MB link element and update it if we can find the artist in data.
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -25447,18 +25432,9 @@ function updateArtistDetailPageHeaderWithData(artist) {
|
||||||
const mainTitle = document.getElementById("artist-detail-name");
|
const mainTitle = document.getElementById("artist-detail-name");
|
||||||
|
|
||||||
if (mainTitle) {
|
if (mainTitle) {
|
||||||
console.log('✅ [DEBUG] Updating header for:', artist.name);
|
|
||||||
// We assume textContent is set by updateArtistHeroSection, so we just APPEND the link
|
|
||||||
// But to be safe, we can ensure name is there.
|
|
||||||
// If we run AFTER populateArtistDetailPage, textContent is already set.
|
|
||||||
|
|
||||||
// If we reset textContent here, we might lose other formatting?
|
|
||||||
// artist-detail-name usually just contains text.
|
|
||||||
mainTitle.textContent = artist.name;
|
mainTitle.textContent = artist.name;
|
||||||
|
|
||||||
if (artist.musicbrainz_id) {
|
if (artist.musicbrainz_id) {
|
||||||
console.log('✅ [DEBUG] Adding MusicBrainz link to DETAIL page header for', artist.name);
|
|
||||||
|
|
||||||
// Remove existing link if any (to prevent duplicates)
|
// Remove existing link if any (to prevent duplicates)
|
||||||
const existingMb = mainTitle.querySelector('.mb-link-btn');
|
const existingMb = mainTitle.querySelector('.mb-link-btn');
|
||||||
if (existingMb) existingMb.remove();
|
if (existingMb) existingMb.remove();
|
||||||
|
|
@ -25468,11 +25444,9 @@ function updateArtistDetailPageHeaderWithData(artist) {
|
||||||
mbLink.href = `https://musicbrainz.org/artist/${artist.musicbrainz_id}`;
|
mbLink.href = `https://musicbrainz.org/artist/${artist.musicbrainz_id}`;
|
||||||
mbLink.target = '_blank';
|
mbLink.target = '_blank';
|
||||||
mbLink.title = 'View on MusicBrainz';
|
mbLink.title = 'View on MusicBrainz';
|
||||||
// Use the specific logo requested by user
|
|
||||||
const mbLogoUrl = "https://upload.wikimedia.org/wikipedia/commons/thumb/9/9e/MusicBrainz_Logo_%282016%29.svg/500px-MusicBrainz_Logo_%282016%29.svg.png";
|
|
||||||
|
|
||||||
mbLink.innerHTML = `
|
mbLink.innerHTML = `
|
||||||
<img src="${mbLogoUrl}" style="height: 24px; width: auto; vertical-align: middle; display: inline-block;">
|
<img src="${MUSICBRAINZ_LOGO_URL}" style="height: 24px; width: auto; vertical-align: middle; display: inline-block;">
|
||||||
<span style="color:rgba(255,255,255,0.9); margin-left:10px; font-size: 13px; font-weight: 600; vertical-align: middle;">View on MusicBrainz</span>
|
<span style="color:rgba(255,255,255,0.9); margin-left:10px; font-size: 13px; font-weight: 600; vertical-align: middle;">View on MusicBrainz</span>
|
||||||
`;
|
`;
|
||||||
mbLink.style.padding = '5px 14px';
|
mbLink.style.padding = '5px 14px';
|
||||||
|
|
@ -25731,28 +25705,19 @@ function createReleaseCard(release) {
|
||||||
card.setAttribute("data-release-id", release.id || "");
|
card.setAttribute("data-release-id", release.id || "");
|
||||||
card.setAttribute("data-spotify-id", release.spotify_id || "");
|
card.setAttribute("data-spotify-id", release.spotify_id || "");
|
||||||
|
|
||||||
// DEBUG: Log release to check for MBID
|
|
||||||
// console.log(`🔍 [DEBUG] Release: ${release.title}`, release);
|
|
||||||
|
|
||||||
// Add MusicBrainz icon if available
|
// Add MusicBrainz icon if available
|
||||||
let mbIcon = null;
|
let mbIcon = null;
|
||||||
if (release.musicbrainz_release_id) {
|
if (release.musicbrainz_release_id) {
|
||||||
console.log(`✅ [DEBUG] Adding MB icon for release: ${release.title}`);
|
|
||||||
const mbLogoUrl = "https://upload.wikimedia.org/wikipedia/commons/thumb/9/9e/MusicBrainz_Logo_%282016%29.svg/500px-MusicBrainz_Logo_%282016%29.svg.png";
|
|
||||||
mbIcon = document.createElement("div");
|
mbIcon = document.createElement("div");
|
||||||
mbIcon.className = "mb-card-icon";
|
mbIcon.className = "mb-card-icon";
|
||||||
mbIcon.title = "View on MusicBrainz";
|
mbIcon.title = "View on MusicBrainz";
|
||||||
// Use image instead of text
|
mbIcon.innerHTML = `<img src="${MUSICBRAINZ_LOGO_URL}" style="width: 20px; height: auto; display: block;">`;
|
||||||
mbIcon.innerHTML = `<img src="${mbLogoUrl}" style="width: 20px; height: auto; display: block;">`;
|
|
||||||
mbIcon.onclick = (e) => {
|
mbIcon.onclick = (e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
window.open(`https://musicbrainz.org/release/${release.musicbrainz_release_id}`, '_blank');
|
window.open(`https://musicbrainz.org/release/${release.musicbrainz_release_id}`, '_blank');
|
||||||
};
|
};
|
||||||
// Will append last
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Create image
|
// Create image
|
||||||
const imageContainer = document.createElement("div");
|
const imageContainer = document.createElement("div");
|
||||||
if (release.image_url && release.image_url.trim() !== "") {
|
if (release.image_url && release.image_url.trim() !== "") {
|
||||||
|
|
|
||||||
|
|
@ -21785,4 +21785,4 @@ body {
|
||||||
transform: scale(1.1);
|
transform: scale(1.1);
|
||||||
background: #d466a9;
|
background: #d466a9;
|
||||||
opacity: 1 !important;
|
opacity: 1 !important;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue