Skip to content

Commit

Permalink
fix: don't mix timeToSec and formatTime; the 1st one returns a time, …
Browse files Browse the repository at this point in the history
…and the 2nd one can beautify it
  • Loading branch information
thorstenhirsch committed Apr 10, 2014
1 parent 4cabfcf commit 2776420
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/js/controllers/audioStreaming.js
Original file line number Diff line number Diff line change
Expand Up @@ -480,8 +480,8 @@ app.audioStreaming = {
};

// time
$('.time-cur', $time).html(app.helpers.secToTime(Math.floor(pos)));
$('.time-total', $time).html(app.helpers.secToTime(Math.floor(dur)));
$('.time-cur', $time).html(app.helpers.formatTime(app.helpers.secToTime(Math.floor(pos))));
$('.time-total', $time).html(app.helpers.formatTime(app.helpers.secToTime(Math.floor(dur))));

//update 100 times per song
if(per != app.audioStreaming.lastPos){
Expand Down
5 changes: 1 addition & 4 deletions src/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,7 @@ $(document).ready(function(){
var minutes = parseInt( totalSec / 60 ) % 60;
var seconds = totalSec % 60;

// return a string with zeros only when we need em
return (hours > 0 ? hours + ":" : "") + //hours
(minutes > 0 ? (hours > 0 && minutes < 10 ? "0" + minutes : minutes) + ":" : (hours > 0 ? "00:" : "")) + //mins
(seconds < 10 ? "0" + seconds : seconds); //seconds
return { hours: hours, minutes: minutes, seconds: seconds }
};


Expand Down
2 changes: 1 addition & 1 deletion src/js/views/playerState.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ app.playerStateView = Backbone.View.extend({
cur = app.helpers.formatTime(data.player.time);
} else if (data.activePlayer === 0){
// Audio
dur = app.helpers.secToTime(parseInt(data.item.duration));
dur = app.helpers.formatTime(app.helpers.secToTime(parseInt(data.item.duration)));
cur = app.helpers.formatTime(data.player.time);
//cur = app.helpers.secToTime(Math.floor((parseInt(data.player.percentage) / 100) * parseInt(data.item.duration)));
}
Expand Down
2 changes: 1 addition & 1 deletion src/js/views/playlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ app.PlaylistItemView = Backbone.View.extend({
model.artistString = (typeof model.artist != 'undefined' && typeof model.artist[0] != 'undefined' ? model.artist[0] : '');

// build song vars
title = 'Track: ' + this.model.track + ' Duration: ' + app.helpers.secToTime(this.model.duration);
title = 'Track: ' + this.model.track + ' Duration: ' + app.helpers.formatTime(app.helpers.secToTime(this.model.duration));
url = '#search/' + (model.albumArtistString !== '' ? model.albumArtistString : model.artistString);
text = (model.artistString !== '' ? model.artistString : model.albumArtistString);

Expand Down

0 comments on commit 2776420

Please sign in to comment.