mirror of
https://gitlab.science.ru.nl/technicie/MarietjeDjango.git
synced 2025-12-09 21:02:24 +01:00
Change time display to (H:)?MM:SS
This commit is contained in:
@ -162,7 +162,7 @@ function updateTime()
|
||||
iteration = (iteration + 1) % 10;
|
||||
if (secondsLeft >= 0)
|
||||
{
|
||||
$('.currentsong .time-left').text(secondsLeft.secondsToHHMMSS());
|
||||
$('.currentsong .time-left').text(secondsLeft.secondsToMMSS());
|
||||
refreshSeconds(secondsLeft + timestamp, timestamp);
|
||||
}
|
||||
|
||||
@ -185,7 +185,7 @@ function renderQueue(playNextAt, now)
|
||||
var artist = song.song.artist.trim() === '' ? '?' : song.song.artist;
|
||||
var title = song.song.title.trim() === '' ? '?' : song.song.title;
|
||||
|
||||
showTime = showTimeToPlay ? (timeToPlay < 0 ? '' : timeToPlay.secondsToHHMMSS()) : (playNextAt < now ? '' : playNextAt.timestampToHHMMSS())
|
||||
showTime = showTimeToPlay ? (timeToPlay < 0 ? '' : timeToPlay.secondsToMMSS()) : (playNextAt < now ? '' : playNextAt.timestampToHHMMSS())
|
||||
|
||||
$('.queuebody:last-child').append('<tr><td class="artist">' + artist
|
||||
+ '</td><td class="title">' + title + '</td><td class="hidden-xs requested-by">' + requestedBy
|
||||
@ -250,7 +250,7 @@ function refreshSeconds(playNextAt, now)
|
||||
var timeToPlay = playNextAt - now;
|
||||
times = $('.plays-at');
|
||||
$.each(queue, function (id, song) {
|
||||
$(times[id]).text(timeToPlay < 0 ? '' : timeToPlay.secondsToHHMMSS());
|
||||
$(times[id]).text(timeToPlay < 0 ? '' : timeToPlay.secondsToMMSS());
|
||||
timeToPlay += parseInt(song.song.duration);
|
||||
});
|
||||
}
|
||||
@ -267,7 +267,7 @@ function getSongs()
|
||||
$.each(songs, function (id, song) {
|
||||
var artist = song.artist.trim() === '' ? '?' : song.artist;
|
||||
var title = song.title.trim() === '' ? '?' : song.title;
|
||||
$('#request-table tbody:last-child').append('<tr><td>' + artist + '</td><td><a href="#" data-song-id="' + song.id + '">' + title + '</a></td><td>' + (song.uploader_name ? song.uploader_name : 'Marietje') + '</td><td>' + song.duration.secondsToHHMMSS() + '</td></tr>');
|
||||
$('#request-table tbody:last-child').append('<tr><td>' + artist + '</td><td><a href="#" data-song-id="' + song.id + '">' + title + '</a></td><td>' + (song.uploader_name ? song.uploader_name : 'Marietje') + '</td><td>' + song.duration.secondsToMMSS() + '</td></tr>');
|
||||
});
|
||||
var pageNumSelect = $('.pagenum');
|
||||
pageNumSelect.empty();
|
||||
@ -316,23 +316,22 @@ if (!Date.now) {
|
||||
}
|
||||
}
|
||||
|
||||
// Edited from http://stackoverflow.com/a/6313008.
|
||||
Number.prototype.secondsToHHMMSS = function () {
|
||||
var sec_num = this; // don't forget the second param
|
||||
var hours = Math.floor(sec_num / 3600);
|
||||
var minutes = Math.floor((sec_num - (hours * 3600)) / 60);
|
||||
var seconds = sec_num - (hours * 3600) - (minutes * 60);
|
||||
// Edited from https://stackoverflow.com/a/6313008.
|
||||
Number.prototype.secondsToMMSS = function () {
|
||||
var hours = Math.floor(this / 3600);
|
||||
var minutes = Math.floor((this - (hours * 3600)) / 60);
|
||||
var seconds = this - (hours * 3600) - (minutes * 60);
|
||||
|
||||
if (hours < 10 && hours >= 0) {
|
||||
hours = '0' + hours;
|
||||
var sep1 = ''
|
||||
if (hours > 0) {
|
||||
hours = hours;
|
||||
sep1 = ':';
|
||||
} else {
|
||||
hours = '';
|
||||
}
|
||||
if (minutes < 10) {
|
||||
minutes = '0' + minutes;
|
||||
}
|
||||
if (seconds < 10) {
|
||||
seconds = '0' + seconds;
|
||||
}
|
||||
return hours + ':' + minutes + ':' + seconds;
|
||||
if (hours > 0 && minutes < 10) minutes = '0' + minutes;
|
||||
if (seconds < 10) seconds = '0' + seconds;
|
||||
return hours + sep1 + minutes + ':' + seconds;
|
||||
}
|
||||
|
||||
Number.prototype.timestampToHHMMSS = function () {
|
||||
|
||||
Reference in New Issue
Block a user