summaryrefslogtreecommitdiff
path: root/www/js/jingles.js
diff options
context:
space:
mode:
authorPeterTheOne <petertheone@gmail.com>2016-01-28 17:15:10 (GMT)
committerPeterTheOne <petertheone@gmail.com>2016-01-28 17:15:10 (GMT)
commitc84b446a7ace4f672e6cd0b4679df3e614bd2f70 (patch)
tree4d63b70ab5ea3649ec2f5032e9a326fb7390dc7a /www/js/jingles.js
parent34316ee23f6fd1b13b03209ade06027aa6ba2ca2 (diff)
combine JingleGroupList and Musicpools to GroupList class
Diffstat (limited to 'www/js/jingles.js')
-rw-r--r--www/js/jingles.js53
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;