mirror of
https://github.com/SoPat712/allstarr.git
synced 2026-02-09 23:55:10 -05:00
Fix Map to Local button by properly escaping JavaScript parameters
- Use JSON.stringify instead of escapeHtml for onclick parameters - Prevents JavaScript syntax errors when track names contain quotes - Fixes button doing nothing when clicked
This commit is contained in:
@@ -1583,7 +1583,12 @@
|
|||||||
} else if (t.isLocal === false) {
|
} else if (t.isLocal === false) {
|
||||||
statusBadge = '<span class="status-badge warning" style="font-size:0.75rem;padding:2px 8px;margin-left:8px;"><span class="status-dot"></span>External</span>';
|
statusBadge = '<span class="status-badge warning" style="font-size:0.75rem;padding:2px 8px;margin-left:8px;"><span class="status-dot"></span>External</span>';
|
||||||
// Add manual map button for external tracks
|
// Add manual map button for external tracks
|
||||||
mapButton = `<button class="small" onclick="openManualMap('${escapeHtml(name)}', ${t.position}, '${escapeHtml(t.title)}', '${escapeHtml(t.artists[0])}', '${t.spotifyId}')" style="margin-left:8px;font-size:0.75rem;padding:4px 8px;">Map to Local</button>`;
|
// Use JSON.stringify to properly escape strings for JavaScript
|
||||||
|
const escapedName = JSON.stringify(name);
|
||||||
|
const escapedTitle = JSON.stringify(t.title);
|
||||||
|
const escapedArtist = JSON.stringify(t.artists[0] || '');
|
||||||
|
const escapedSpotifyId = JSON.stringify(t.spotifyId);
|
||||||
|
mapButton = `<button class="small" onclick="openManualMap(${escapedName}, ${t.position}, ${escapedTitle}, ${escapedArtist}, ${escapedSpotifyId})" style="margin-left:8px;font-size:0.75rem;padding:4px 8px;">Map to Local</button>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return `
|
return `
|
||||||
|
|||||||
Reference in New Issue
Block a user