summaryrefslogtreecommitdiff
path: root/www/js/rivendell.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/rivendell.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/rivendell.js')
-rw-r--r--www/js/rivendell.js37
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;
};