1
0
mirror of https://github.com/danbee/mpd-client synced 2025-03-04 08:39:09 +00:00
mpd-client/assets/js/components/app.js
2014-01-08 11:19:17 +00:00

40 lines
803 B
JavaScript

can.Component.extend({
tag: 'mpd-client',
template: can.view('views/app.mustache'),
scope: {
queueSongs: new QueueSong.List(),
status: new Status
},
events: {
init: function(element, options) {
Status.findOne({}, this.updateStatus.bind(this));
this.scope.attr('events', new Events(this.scope));
this.fetch();
},
fetch: function() {
var self = this;
QueueSong.findAll().then(function(songs) {
self.update(songs);
});
},
updateStatus: function(result) {
this.scope.attr('status', result);
},
update: function(songs) {
this.scope.attr('queueSongs', songs);
},
'{scope.status} change': function() {
this.scope.attr('queueSongs').updatePlaying(this.scope.status.song);
}
}
});