From cbc3ddf1435c4f0b08bea1b6b13c26da17774848 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20Betn=C3=A9r?= Date: Sun, 6 Mar 2005 09:29:48 +0000 Subject: [PATCH] Fix for songs with empty tags not being displayed in the web UI. --- admin-root/playlist.js | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/admin-root/playlist.js b/admin-root/playlist.js index cf504cca..8b8250b7 100644 --- a/admin-root/playlist.js +++ b/admin-root/playlist.js @@ -99,13 +99,29 @@ function playlistSelect(event) { items = g_req.responseXML.getElementsByTagName('dmap.listingitem'); - for (i=0; i < items.length; i++) { - song = items[i].getElementsByTagName('dmap.itemname').item(0).textContent; + // Have to check if the tag really was returned from the server + if (song = items[i].getElementsByTagName('dmap.itemname').item(0)) { + song = song.textContent; + } else { + song = ''; + } time = ''; //items[i].getElementsByTagName('daap.songtime').item(0).textContent; - artist = items[i].getElementsByTagName('daap.songartist').item(0).textContent; - album = items[i].getElementsByTagName('daap.songalbum').item(0).textContent; - genre = items[i].getElementsByTagName('daap.songgenre').item(0).textContent; + if (artist = items[i].getElementsByTagName('daap.songartist').item(0)) { + artist = artist.textContent; + } else { + artist = ''; + } + if (album = items[i].getElementsByTagName('daap.songalbum').item(0)) { + album = album.textContent; + } else { + album = ''; + } + if (genre = items[i].getElementsByTagName('daap.songgenre').item(0)) { + genre = genre.textContent; + } else { + genre = ''; + } addRow(tableBody,song,time,artist,album,genre); }