diff options
Diffstat (limited to 'www/js/jingles.js')
-rw-r--r-- | www/js/jingles.js | 53 |
1 files changed, 11 insertions, 42 deletions
diff --git a/www/js/jingles.js b/www/js/jingles.js index e13f218..c633339 100644 --- a/www/js/jingles.js +++ b/www/js/jingles.js @@ -23,59 +23,28 @@ 'use strict'; var rivendell = null; -var jinglesGroupList = null; +var groupList = null; var importer = null; function jingles_init() { rivendell = new Rivendell.Rivendell(auth_username, auth_token, '/rd-bin/rdxport.cgi'); rivendell.setListDropboxesEndpoint('/rh-bin/listdropboxes.cgi'); importer = new Importer(); - jinglesGroupList = new JingleGroupList(); - jinglesGroupList.fetch(); + + groupList = new Rivendell.GroupList(rivendell, 'jingle'); + // todo: move this elsewhere? + $('#app-jingles .groups').html(''); + groupList.fetch(); } function jingles_cleanup() { - if (jinglesGroupList) { - jinglesGroupList.destroy(); - jinglesGroupList = null; + if (groupList) { + groupList.destroy(); + groupList = null; } rivendell = null; } -var JingleGroupList = function() { - this.groups = []; -}; - -JingleGroupList.prototype.fetch = function() { - this.groups = []; - $('#app-jingles .groups').html(''); - - var self = this; - rivendell.listDropboxes('jingle', function(groupsXml, status, req) { - var dbs = $(groupsXml).find("dropboxList").children(); - dbs.each(function(index, groupXml) { - var jingleGroup = new JingleGroup( - $('jingle-title', groupXml).text(), - $('group', groupXml).text(), - $('group-description', groupXml).text(), - $('group-low-cart', groupXml).text(), - $('group-high-cart', groupXml).text(), - $('normalization-level', groupXml).text(), - $('autotrim-level', groupXml).text() - ); - - self.groups.push(jingleGroup); - }); - }); -}; - -JingleGroupList.prototype.destroy = function() { - // todo: implement - $(this.groups).each(function(index, group) { - group.destroy(); - }); -}; - var JingleGroup = function(title, groupName, description, lowcart, highcart, normlevel, trimlevel) { this.title = title; this.groupName = groupName; @@ -212,8 +181,8 @@ JingleCut.prototype.move = function() { var self = this; var destinationCart = this.cartNumber; // todo: make this work for multiple groups - if (jinglesGroupList.groups.length === 2) { - $(jinglesGroupList.groups).each(function(index, group) { + if (groupList.groups.length === 2) { + $(groupList.groups).each(function(index, group) { if (self.active) { if (self.cartNumber !== group.mainCart.number) { destinationCart = group.mainCart; |