Switch search songs to a json response
This commit is contained in:
parent
20d7bc42f5
commit
ba1c7afa65
|
@ -10,18 +10,22 @@ if ( isset($_REQUEST['searchfor']) ) {
|
|||
|
||||
$songs = Song::getSearchList($searchfor);
|
||||
|
||||
$data = array();
|
||||
$data["search"] = array();
|
||||
|
||||
foreach ( $songs as $song ) {
|
||||
echo "<div id='search_{$song->getID()}' class='songlist_song_container' onClick='addSongToQueue({$song->getID()});'>\n";
|
||||
echo " <div class='songlist_img_container'><img class='songlist_img' src='{$song->getArtFile(ARTURL)}'></div>\n";
|
||||
echo " <div class='songlist_details_container'>\n";
|
||||
echo " <p class='nomargin'><span class='playing_label'>Song:</span> {$song->getTitle(HTMLSAFE)}</p>\n";
|
||||
echo " <p class='nomargin'><span class='playing_label'>Artist:</span> {$song->getArtist(HTMLSAFE)}</p>\n";
|
||||
echo " <p class='nomargin'><span class='playing_label'>Album:</span> {$song->getAlbum(HTMLSAFE)}</p>\n";
|
||||
echo " </div>\n";
|
||||
echo "</div>\n";
|
||||
echo "<hr class='songlist'>\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['search'][] = $curdata;
|
||||
}
|
||||
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode($data);
|
||||
exit();
|
||||
|
||||
|
||||
?>
|
||||
// vim: sw=3 ts=3 et ai:
|
||||
|
|
|
@ -275,10 +275,10 @@ function executeSearch() {
|
|||
if ( searchfor.length < 4 ) return false;
|
||||
$.ajax({
|
||||
url: 'ajax/ajax_searchsongs.php',
|
||||
dataType: 'html',
|
||||
dataType: 'json',
|
||||
data: {searchfor: searchfor},
|
||||
success: function(data, stat, jqo) {
|
||||
$('#search_contents').html(data);
|
||||
$('#search_contents').html(generateSongListHTML("search", data.search));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user