summaryrefslogtreecommitdiff
path: root/www/js/musicpools.js
diff options
context:
space:
mode:
authorPeterTheOne <petertheone@gmail.com>2016-01-29 00:09:17 (GMT)
committerPeterTheOne <petertheone@gmail.com>2016-01-29 00:09:17 (GMT)
commite0ad0c1481387e73b1d2b00c0c35d7ef85db2dff (patch)
tree2eadd8af2046166e42caf7bee97459da3dd97a90 /www/js/musicpools.js
parent1ef5a5a1aac0e562c0b3b81c0cb7eb5997b02bd5 (diff)
jingles: use Rivendell.Cart and Cut classes with Views, etc.
validate html, move rivendell.js init to apps.js, cleanup importer, add update event to fetch functions instead of success callback.
Diffstat (limited to 'www/js/musicpools.js')
-rw-r--r--www/js/musicpools.js31
1 files changed, 5 insertions, 26 deletions
diff --git a/www/js/musicpools.js b/www/js/musicpools.js
index ce8e81a..2ccd27f 100644
--- a/www/js/musicpools.js
+++ b/www/js/musicpools.js
@@ -24,14 +24,10 @@
var Rivendell = Rivendell || {};
-var rivendell = null;
var importer = null;
var musicpoolsView = null;
function musicpools_init() {
- rivendell = new Rivendell.Rivendell(auth_username, auth_token, '/rd-bin/rdxport.cgi');
- rivendell.setListDropboxesEndpoint('/rh-bin/listdropboxes.cgi');
-
importer = new Rivendell.Importer();
var musicpools = new Rivendell.GroupList(rivendell);
@@ -51,13 +47,14 @@ Rivendell.MusicpoolsView = function(model) {
this.currentPoolId = sessionStorage.getItem('currentPoolId');
var self = this;
- this.model.fetch('musicpool', function() {
+ $(this.model).on('update', function() {
$(self.model.groups).each(function(index, musicpool) {
var musicpoolView = new Rivendell.MusicpoolView(musicpool);
self.musicpoolViews.push(musicpoolView);
});
self.updateSelector();
});
+ this.model.fetch('musicpool');
};
Rivendell.MusicpoolsView.prototype.setCurrentPoolId = function(currentPoolId) {
@@ -134,7 +131,7 @@ Rivendell.MusicpoolView = function(model) {
Rivendell.MusicpoolView.prototype.render = function() {
var self = this;
- this.model.fetchCarts(function() {
+ $(this.model).on('update', function() {
self.$el = $('#hiddenTemplates .musicpoolTemplate').clone().removeClass('musicpoolTemplate');
$('#app-musicpools .musicpoolContainer').html(self.$el);
@@ -143,29 +140,11 @@ Rivendell.MusicpoolView.prototype.render = function() {
// todo
/*$('.uploadButton', self.$el).on('click', function() {
- importer.showUploadModal(self.model);
+ importer.openModal(self.model);
});*/
});
-};
-
-Rivendell.Musicpool.prototype.fetchCarts = function(success) {
- var self = this;
- rivendell.listCarts(this.groupName, 1, function(cartsXml, status, req) {
- self.carts = [];
-
- var dbs = $('cartList', cartsXml).children();
- dbs.each(function(index, cartXml) {
- var cart = new Rivendell.Cart(cartXml, self);
-
- var cuts = $('cutList', cartXml).children();
- cart.cuts.push(new Rivendell.Cut(cuts[0], cart));
-
- self.carts.push(cart);
- });
-
- success();
- });
+ this.model.fetchCarts();
};
Rivendell.MusicpoolCutView = function(model) {