diff options
author | Peter Grassberger <petertheone@gmail.com> | 2016-02-10 05:00:16 (GMT) |
---|---|---|
committer | Peter Grassberger <petertheone@gmail.com> | 2016-02-10 05:00:16 (GMT) |
commit | 8ce69bbc3ef2974ab1bc4b02b5320827a1ae9935 (patch) | |
tree | 7824611556568eb191228ab7f4a6b154eef123f1 /www/js/rdxport.js | |
parent | 6f2d7a5dd61746a114488151cda132e032b10bb1 (diff) |
shows rewrite (import still missing)
Diffstat (limited to 'www/js/rdxport.js')
-rw-r--r-- | www/js/rdxport.js | 58 |
1 files changed, 57 insertions, 1 deletions
diff --git a/www/js/rdxport.js b/www/js/rdxport.js index 91944ac..35c1b7d 100644 --- a/www/js/rdxport.js +++ b/www/js/rdxport.js @@ -359,6 +359,8 @@ Rivendell.GroupList = function(rivendell) { Rivendell.Group = function(groupName, description, lowcart, highcart, normlevel, trimlevel) { this.xml = null; + // looks strange but child somehow can't do use $(this) otherwise. + this.$this = $(this); if (arguments.length === 1) { this.xml = arguments[0]; @@ -378,10 +380,16 @@ Rivendell.Group = function(groupName, description, lowcart, highcart, normlevel, } this.carts = []; + this.cartsByNumber = {}; +}; + +Rivendell.Group.prototype.getCartByNumber = function(number) { + return this.cartsByNumber[number] ? this.cartsByNumber[number] : null; }; Rivendell.Group.prototype.addCart = function(cart) { this.carts.push(cart); + this.cartsByNumber[cart.number] = cart; }; Rivendell.Group.prototype.removeCart = function(cart) { @@ -391,12 +399,14 @@ Rivendell.Group.prototype.removeCart = function(cart) { self.carts.splice(index, 1); } }); + delete this.cartsByNumber[cart.number]; }; Rivendell.Group.prototype.fetchCarts = function() { var self = this; rivendell.listCarts(this.groupName, 1, function(cartsXml, status, req) { self.carts = []; + self.cartsByNumber = {}; var dbs = $('cartList', cartsXml).children(); dbs.each(function(index, cartXml) { @@ -407,12 +417,58 @@ Rivendell.Group.prototype.fetchCarts = function() { cart.cuts.push(new Rivendell.Cut(cut, cart)); }); - self.carts.push(cart); + self.addCart(cart); }); $(self).trigger('update'); }); }; +Rivendell.Log = function(line, id, type, cartType, cartNumber, cutNumber, groupName, groupColor, title, group) { + /*this.xml = null; + + if (arguments.length === 2) { + this.xml = arguments[0]; + this.line = $('line', this.xml).text(); + this.id = $('id', this.xml).text(); + this.type = $('type', this.xml).text(); + this.cartType = $('cartType', this.xml).text(); + this.cartNumber = $('cartNumber', this.xml).text(); + this.cutNumber = $('cutNumber', this.xml).text(); + this.groupName = $('groupName', this.xml).text(); + this.groupColor = $('groupColor', this.xml).text(); + this.title = $('title', this.xml).text(); + this.group = arguments[1]; + } else {*/ + this.line = line; + this.id = id; + this.type = type; + this.cartType = cartType; + this.cartNumber = cartNumber; + this.cutNumber = cutNumber; + this.groupName = groupName; + this.groupColor = groupColor; + this.title = title; + this.group = group; + //} +}; + +Rivendell.Log.newFromXml = function(xml, group) { + var log = new Rivendell.Log( + $('line', xml).text(), + $('id', xml).text(), + $('type', xml).text(), + $('cartType', xml).text(), + $('cartNumber', xml).text(), + $('cutNumber', xml).text(), + $('groupName', xml).text(), + $('groupColor', xml).text(), + $('title', xml).text(), + group + ); + log.xml = xml; + return log; +}; + Rivendell.Cart = function(number, title, groupName, group) { this.xml = null; |