From 20d7bc42f591139d638509a2e3aa52d0ef7e283a Mon Sep 17 00:00:00 2001 From: Junior Date: Fri, 18 Apr 2025 14:27:41 -0400 Subject: [PATCH] Switch custom song list to json response --- ajax/ajax_getcustomq.php | 22 ++++++++++++---------- js/minimal.js | 6 +++--- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/ajax/ajax_getcustomq.php b/ajax/ajax_getcustomq.php index 5492742..bc21254 100644 --- a/ajax/ajax_getcustomq.php +++ b/ajax/ajax_getcustomq.php @@ -9,20 +9,22 @@ $sth = $globaldbh->prepare($query); $sth->execute($fields); $data = array(); -$firstsong = true; +$data["customq"] = array(); while ( $row = $sth->fetch() ) { $songid = $row['songid']; $song = new Song($songid); - echo "
\n"; - echo "
\n"; - echo "
\n"; - echo "

Song: {$song->getTitle(HTMLSAFE)}

\n"; - echo "

Artist: {$song->getArtist(HTMLSAFE)}

\n"; - echo "

Album: {$song->getAlbum(HTMLSAFE)}

\n"; - echo "
\n"; - echo "
\n"; - echo "
\n"; + $curdata = array(); + $curdata["id"] = $song->getID(); + $curdata["arturl"] = $song->getArtFile(ARTURL); + $curdata["title"] = $song->getTitle(HTMLSAFE); + $curdata["artist"] = $song->getArtist(HTMLSAFE); + $curdata["album"] = $song->getAlbum(HTMLSAFE); + $curdata["year"] = $song->getYear(HTMLSAFE); + $data['customq'][] = $curdata; } + +header('Content-Type: application/json'); +echo json_encode($data); exit(); diff --git a/js/minimal.js b/js/minimal.js index b201f04..8c7119e 100755 --- a/js/minimal.js +++ b/js/minimal.js @@ -7,7 +7,7 @@ var gettingSongList = false; var gettingJukeboxList = false; var searchTimeout = null; var queueTarget = 0; -var paused = true; +var paused = false; $(document).ready(function() { $('#tabs').tabs({ @@ -262,9 +262,9 @@ function getJukeboxList() { function getCustomQueueList() { $.ajax({ url: 'ajax/ajax_getcustomq.php', - dataType: 'html', + dataType: 'json', success: function(data, stat, jqo) { - $('#customq_contents').html(data); + $('#customq_contents').html(generateSongListHTML("customq", data.customq)); } }); }