Switch get jukebox response to be json and parse appropriately
This commit is contained in:
		
							parent
							
								
									70886bacba
								
							
						
					
					
						commit
						426d2680f7
					
				| 
						 | 
					@ -6,21 +6,22 @@ $query = "SELECT id, songid FROM " . INSTANTQTABLE . " ORDER BY id";
 | 
				
			||||||
$sth = $globaldbh->prepare($query);
 | 
					$sth = $globaldbh->prepare($query);
 | 
				
			||||||
$sth->execute();
 | 
					$sth->execute();
 | 
				
			||||||
$data = array();
 | 
					$data = array();
 | 
				
			||||||
$firstsong = true;
 | 
					$data["jukebox"] = array();
 | 
				
			||||||
while ( $row = $sth->fetch() ) {
 | 
					while ( $row = $sth->fetch() ) {
 | 
				
			||||||
   $id = $row['id'];
 | 
					   $id = $row['id'];
 | 
				
			||||||
   $song = new Song($row['songid']);
 | 
					   $song = new Song($row['songid']);
 | 
				
			||||||
   echo "<div id='juke_{$id}' class='songlist_song_container' onClick='dropJukeboxSong({$id});'>\n";
 | 
					   $curdata = array();
 | 
				
			||||||
   echo "  <div class='songlist_img_container'><img class='songlist_img' src='{$song->getArtFile(ARTURL)}'></div>\n";
 | 
					   $curdata["id"] = $song->getID();
 | 
				
			||||||
   echo "  <div class='songlist_details_container'>\n";
 | 
					   $curdata["arturl"] = $song->getArtFile(ARTURL);
 | 
				
			||||||
   echo "    <p class='nomargin'><span class='playing_label'>Song:</span> {$song->getTitle(HTMLSAFE)}</p>\n";
 | 
					   $curdata["title"] = $song->getTitle(HTMLSAFE);
 | 
				
			||||||
   echo "    <p class='nomargin'><span class='playing_label'>Artist:</span> {$song->getArtist(HTMLSAFE)}</p>\n";
 | 
					   $curdata["artist"] = $song->getArtist(HTMLSAFE);
 | 
				
			||||||
   echo "    <p class='nomargin'><span class='playing_label'>Album:</span> {$song->getAlbum(HTMLSAFE)}</p>\n";
 | 
					   $curdata["album"] = $song->getAlbum(HTMLSAFE);
 | 
				
			||||||
   echo "  </div>\n";
 | 
					   $curdata["year"] = $song->getYear(HTMLSAFE);
 | 
				
			||||||
   echo "</div>\n";
 | 
					   $data['jukebox'][] = $curdata;
 | 
				
			||||||
   echo "<hr class='songlist'>\n";
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					header('Content-Type: application/json');
 | 
				
			||||||
 | 
					echo json_encode($data);
 | 
				
			||||||
exit();
 | 
					exit();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// vim: sw=3 ts=3 ai mouse-=a:
 | 
				
			||||||
?>
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -247,9 +247,9 @@ function getJukeboxList() {
 | 
				
			||||||
      gettingJukeboxList = true;
 | 
					      gettingJukeboxList = true;
 | 
				
			||||||
      $.ajax({
 | 
					      $.ajax({
 | 
				
			||||||
         url: 'ajax/ajax_getjukebox.php',
 | 
					         url: 'ajax/ajax_getjukebox.php',
 | 
				
			||||||
         dataType: 'html',
 | 
					         dataType: 'json',
 | 
				
			||||||
         success: function(data, stat, jqo) {
 | 
					         success: function(data, stat, jqo) {
 | 
				
			||||||
            $('#jukebox_contents').html(data);
 | 
					            $('#jukebox_contents').html(generateSongListHTML("juke", data.jukebox));
 | 
				
			||||||
            gettingSongList = false;
 | 
					            gettingSongList = false;
 | 
				
			||||||
            gettingJukeboxList = false;
 | 
					            gettingJukeboxList = false;
 | 
				
			||||||
         }
 | 
					         }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user