Update time only instead of rendering the whole queue every second.

This commit is contained in:
Jim Driessen
2017-09-04 15:34:16 +02:00
parent e8aeb271b9
commit 340b9e330f

View File

@ -158,7 +158,7 @@ function updateTime()
if (secondsLeft >= 0)
{
$('.currentsong .time-left').text(secondsLeft.secondsToHHMMSS());
renderQueue(secondsLeft + timestamp, timestamp);
refreshSeconds(secondsLeft + timestamp, timestamp);
}
// Refresh every ten seconds, or if the song has ended in the last ten
@ -173,7 +173,6 @@ function renderQueue(playNextAt, now)
{
$('.queuebody').empty();
var timeToPlay = playNextAt - now;
var firstSongInQueue = true;
$.each(queue, function (id, song) {
var requestedBy = song.requested_by;
var canDelete = song.can_move_down || canMoveSongs;
@ -238,6 +237,19 @@ function refreshQueue()
});
}
function refreshSeconds(playNextAt, now)
{
if(!showTimeToPlay) {
return;
}
var timeToPlay = playNextAt - now;
times = $('.plays-at');
$.each(queue, function (id, song) {
$(times[id]).text(timeToPlay < 0 ? '' : timeToPlay.secondsToHHMMSS());
timeToPlay += parseInt(song.song.duration);
});
}
function getSongs()
{
var all = $('#search-all').val();