diff --git a/ajax/ajax_listsongs.php b/ajax/ajax_listsongs.php index 430373c..29ffdeb 100644 --- a/ajax/ajax_listsongs.php +++ b/ajax/ajax_listsongs.php @@ -31,9 +31,9 @@ system("HOME=" . WEBUSERHOMEDIR . " && ../scripts/homeaudio_togglemute.pl -show" $data['muted'] = ($retval == 0) ? false : true; $data['currentsong'] = array("art"=>"", "title"=>"", "artist"=>"", "album"=>"", "year"=>""); $data['songhistory'] = array(); -$data['songlist'] = ""; if ( $row = $sth->fetch(PDO::FETCH_ASSOC) ) { $song = new Song($row['songid']); + $data['currentsong']["id"] = $song->getID(); $data['currentsong']["arturl"] = $song->getArtFile(ARTURL); $data['currentsong']["title"] = $song->getTitle(HTMLSAFE); $data['currentsong']["artist"] = $song->getArtist(HTMLSAFE); @@ -43,21 +43,13 @@ if ( $row = $sth->fetch(PDO::FETCH_ASSOC) ) { while ( $row = $sth->fetch() ) { $song = new Song($row['songid']); $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['songhistory'][] = $curdata; - $data['songlist'] .= "
\n"; - $data['songlist'] .= "
\n"; - $data['songlist'] .= "
\n"; - $data['songlist'] .= "

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

\n"; - $data['songlist'] .= "

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

\n"; - $data['songlist'] .= "

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

\n"; - $data['songlist'] .= "
\n"; - $data['songlist'] .= "
\n"; - $data['songlist'] .= "
\n"; } header('Content-Type: application/json'); diff --git a/css/minimal.css b/css/minimal.css index 229de45..2a62232 100644 --- a/css/minimal.css +++ b/css/minimal.css @@ -228,6 +228,12 @@ div.songlist_details_container { margin-left: 0.25em; float: left; } +div.songlist_details_container p { + margin: 0px; +} +div.songlist_details_container span { + font-weight: bold; +} hr.songlist { width: 65%; } diff --git a/js/minimal.js b/js/minimal.js index a185ebb..0ef2fef 100755 --- a/js/minimal.js +++ b/js/minimal.js @@ -7,6 +7,7 @@ var gettingSongList = false; var gettingJukeboxList = false; var searchTimeout = null; var queueTarget = 0; +var paused = true; $(document).ready(function() { $('#tabs').tabs({ @@ -57,7 +58,7 @@ $(document).ready(function() { toggleMute($(this), 'show'); getSongList(); getQueueTarget(); - refreshTimerObj = setInterval('getSongList()', 10000); + refreshTimerObj = setInterval('doIntervalQuery()', 10000); //document.documentElement.requestFullscreen(); }); @@ -180,6 +181,32 @@ function updateChristmasButton(active) { } } +function doIntervalQuery() { + if ( paused ) return; + getSongList(); +} + +function togglePause() { + paused = !paused; + console.log("Paused: " + (paused) ? "True" : "False"); +} + +function generateSongListHTML(type, songs) { + var body = ""; + songs.forEach(function(item, index, arr) { + body += "
"; + body += "
"; + body += "
"; + body += "

Title: " + item.title + "

"; + body += "

Artist: " + item.artist + "

"; + body += "

Album: " + item.album + "

"; + body += "
"; + body += "
"; + body += "
"; + }); + return body; +} + function getSongList() { gettingSongList = true; $.ajax({ @@ -195,7 +222,7 @@ function getSongList() { $('#playing_artist').html(data.currentsong.artist); $('#playing_album').html(data.currentsong.album); $('#playing_year').html(data.currentsong.year); - $('#history_contents').html(data.songlist); + $('#history_contents').html(generateSongListHTML("hist", data.songhistory)); updateChristmasButton(data.christmas); updateMuteButton(data.muted); $('#christmas_freq').val(data.christmasfreq);