mirror of
https://github.com/danbee/mpd-client
synced 2025-03-04 08:39:09 +00:00
36 lines
783 B
JavaScript
36 lines
783 B
JavaScript
var Status = can.Model.extend({
|
|
|
|
findOne: 'GET /api/status'
|
|
|
|
}, {
|
|
|
|
playing: function() {
|
|
return this.attr('state') === 'play'
|
|
},
|
|
|
|
playingOrPaused: function() {
|
|
return (this.attr('state') === 'play' || this.attr('state') === 'pause');
|
|
},
|
|
|
|
showTrackProgress: can.compute(function() {
|
|
return (this.playingOrPaused() && this.attr('time') != undefined);
|
|
}),
|
|
|
|
formattedElapsedTime: function() {
|
|
if (this.attr('time') != undefined) {
|
|
return timeHelpers.formatLength(this.attr('time')[0])
|
|
}
|
|
},
|
|
|
|
formattedTotalTime: function() {
|
|
if (this.attr('time') != undefined) {
|
|
return timeHelpers.formatLength(this.attr('time')[1])
|
|
}
|
|
},
|
|
|
|
markerPosition: function() {
|
|
return (this.attr('time')[0] / this.attr('time')[1]) * 100
|
|
}
|
|
|
|
});
|