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 12:18:06 +00:00

39 lines
749 B
JavaScript

can.Component.extend({
tag: 'mpd-client',
template: can.view('views/app.mustache'),
scope: {
queueSongs: new QueueSong.List(),
status: new can.Map()
},
events: {
init: function(element, options) {
Status.findOne({}, this.updateStatus.bind(this));
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);
}
}
});