diff options
Diffstat (limited to 'www/js/rivendell.js')
-rw-r--r-- | www/js/rivendell.js | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/www/js/rivendell.js b/www/js/rivendell.js index 24ef2c7..89cf471 100644 --- a/www/js/rivendell.js +++ b/www/js/rivendell.js @@ -384,6 +384,26 @@ Rivendell.Group = function(groupName, description, lowcart, highcart, normlevel, this.carts = []; }; +Rivendell.Group.prototype.fetchCarts = function() { + 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(); + cuts.each(function(index, cut) { + cart.cuts.push(new Rivendell.Cut(cut, cart)); + }); + + self.carts.push(cart); + }); + $(self).trigger('update'); + }); +}; + Rivendell.Cart = function(number, title, groupName, group) { this.xml = null; @@ -403,6 +423,19 @@ Rivendell.Cart = function(number, title, groupName, group) { this.cuts = []; }; +Rivendell.Cart.prototype.addCut = function(cut) { + this.cuts.push(cut); +}; + +Rivendell.Cart.prototype.removeCut = function(cut) { + var self = this; + $.each(this.cuts, function(index, currentCut){ + if(currentCut === cut) { + self.cuts.splice(index, 1); + } + }); +}; + Rivendell.Cut = function(name, description, cart) { this.xml = null; @@ -416,8 +449,8 @@ Rivendell.Cut = function(name, description, cart) { this.description = description; this.cart = cart; } - this.number = name.substr(-3); - this.cartNumber = cart.number; + this.number = this.name.substr(-3); + this.cartNumber = this.cart.number; }; |