summaryrefslogtreecommitdiff
path: root/www
diff options
context:
space:
mode:
Diffstat (limited to 'www')
-rw-r--r--www/js/jingles.js4
-rw-r--r--www/js/musicpools.js87
-rw-r--r--www/js/rivendell.js79
-rw-r--r--www/js/rivendell.rh.js18
4 files changed, 101 insertions, 87 deletions
diff --git a/www/js/jingles.js b/www/js/jingles.js
index 5c3c39a..65063bf 100644
--- a/www/js/jingles.js
+++ b/www/js/jingles.js
@@ -52,7 +52,7 @@ function jingles_cleanup() {
var JingleGroup = function(groupName, description, lowcart, highcart, normlevel, trimlevel, title) {
if (arguments.length = 1) {
Rivendell.Group.call(this, groupName);
- this.title = $('jingle-title', this.groupXml).text();
+ this.title = $('jingle-title', this.xml).text();
} else {
Rivendell.Group.call(this, groupName, description, lowcart, highcart, normlevel, trimlevel);
this.title = title;
@@ -179,7 +179,9 @@ var JingleCut = function(cart, cartNumber, name, description, active) {
this.number = name.substr(-3);
this.name = name;
this.description = description;
+
this.active = active;
+
this.$el = null;
};
diff --git a/www/js/musicpools.js b/www/js/musicpools.js
index abb6679..ce8e81a 100644
--- a/www/js/musicpools.js
+++ b/www/js/musicpools.js
@@ -35,7 +35,7 @@ function musicpools_init() {
importer = new Rivendell.Importer();
var musicpools = new Rivendell.GroupList(rivendell);
- musicpoolsView = new MusicpoolsView(musicpools);
+ musicpoolsView = new Rivendell.MusicpoolsView(musicpools);
}
function musicpools_cleanup() {
@@ -44,41 +44,49 @@ function musicpools_cleanup() {
rivendell = null;
}
-var MusicpoolsView = function(model) {
+Rivendell.MusicpoolsView = function(model) {
this.model = model;
+ this.musicpoolViews = [];
this.currentPoolId = sessionStorage.getItem('currentPoolId');
var self = this;
this.model.fetch('musicpool', function() {
+ $(self.model.groups).each(function(index, musicpool) {
+ var musicpoolView = new Rivendell.MusicpoolView(musicpool);
+ self.musicpoolViews.push(musicpoolView);
+ });
self.updateSelector();
});
};
-MusicpoolsView.prototype.setCurrentPoolId = function(currentPoolId) {
+Rivendell.MusicpoolsView.prototype.setCurrentPoolId = function(currentPoolId) {
this.currentPoolId = currentPoolId;
sessionStorage.setItem('currentPoolId', this.currentPoolId);
};
-MusicpoolsView.prototype.getCurrentPool = function() {
+Rivendell.MusicpoolsView.prototype.getCurrentPoolView = function() {
if (this.model.groups.length === 0) {
return null;
}
+ if (this.musicpoolViews.length === 0) {
+ return null;
+ }
if (this.currentPoolId === null) {
this.setCurrentPoolId(this.model.groups[0].clock);
}
var self = this;
- var musicpoolFound = null;
- $(this.model.groups).each(function(index, musicpool) {
- if (musicpool.clock === self.currentPoolId) {
- musicpoolFound = musicpool;
+ var musicpoolViewFound = null;
+ $(this.musicpoolViews).each(function(index, musicpoolView) {
+ if (musicpoolView.model.clock === self.currentPoolId) {
+ musicpoolViewFound = musicpoolView;
return true;
}
});
- return musicpoolFound;
+ return musicpoolViewFound;
};
-MusicpoolsView.prototype.updateSelector = function() {
+Rivendell.MusicpoolsView.prototype.updateSelector = function() {
var self = this;
var $musicpoolSelector = $('#musicpool-selector');
@@ -97,69 +105,61 @@ MusicpoolsView.prototype.updateSelector = function() {
$musicpoolSelector.on('change', function() {
self.setCurrentPoolId($('option:selected', $musicpoolSelector).attr('value'));
- self.getCurrentPool().render();
+ self.getCurrentPoolView().render();
});
- this.getCurrentPool().render();
+ this.getCurrentPoolView().render();
};
// this and jinglegroup are basicly the same thing
-var Musicpool = function(groupName, description, lowcart, highcart, normlevel, trimlevel, title, clock) {
+Rivendell.Musicpool = function(groupName, description, lowcart, highcart, normlevel, trimlevel, title, clock) {
if (arguments.length === 1) {
Rivendell.Group.call(this, groupName);
- this.title = $('musicpool-title', this.groupXml).text();
- this.clock = $('musicpool-clock', this.groupXml).text();
+ this.title = $('musicpool-title', this.xml).text();
+ this.clock = $('musicpool-clock', this.xml).text();
} else {
Rivendell.Group.call(this, groupName, description, lowcart, highcart, normlevel, trimlevel);
this.title = title;
this.clock = clock;
}
+};
+Rivendell.Musicpool.prototype = Object.create(Rivendell.Group.prototype);
+Rivendell.Musicpool.prototype.constructor = Rivendell.Musicpool;
- this.carts = [];
+Rivendell.MusicpoolView = function(model) {
+ this.model = model;
this.$el = null;
};
-Musicpool.prototype = Object.create(Rivendell.Group.prototype);
-Musicpool.prototype.constructor = Musicpool;
-Musicpool.prototype.render = function() {
+Rivendell.MusicpoolView.prototype.render = function() {
var self = this;
- this.fetchCarts(function() {
+ this.model.fetchCarts(function() {
self.$el = $('#hiddenTemplates .musicpoolTemplate').clone().removeClass('musicpoolTemplate');
$('#app-musicpools .musicpoolContainer').html(self.$el);
- $('h2', self.$el).html(self.title);
+ $('h2', self.$el).html(self.model.title);
$('table tbody tr', self.$el).remove();
// todo
/*$('.uploadButton', self.$el).on('click', function() {
- importer.showUploadModal(self);
+ importer.showUploadModal(self.model);
});*/
});
};
-Musicpool.prototype.fetchCarts = function(success) {
+Rivendell.Musicpool.prototype.fetchCarts = function(success) {
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 MusicpoolCart(
- $('number', cartXml).text(),
- $('title', cartXml).text(),
- $('groupName', cartXml).text(),
- self
- );
+ var cart = new Rivendell.Cart(cartXml, self);
var cuts = $('cutList', cartXml).children();
- cart.cut = new MusicpoolCut(
- cart,
- cart.number,
- $('cutName', cuts[0]).find().text(),
- $('description', cuts[0]).find().text()
- );
+ cart.cuts.push(new Rivendell.Cut(cuts[0], cart));
self.carts.push(cart);
});
@@ -168,21 +168,8 @@ Musicpool.prototype.fetchCarts = function(success) {
});
};
-var MusicpoolCart = function(number, title, groupName, group) {
- this.number = number;
- this.title = title;
- this.groupName = groupName;
- this.group = group;
-
- this.cut = null;
-};
-
-var MusicpoolCut = function(cart, cartNumber, name, description) {
- this.cart = cart;
- this.cartNumber = cartNumber;
- this.number = name.substr(-3);
- this.name = name;
- this.description = description;
+Rivendell.MusicpoolCutView = function(model) {
+ this.model = model;
this.$el = null;
};
diff --git a/www/js/rivendell.js b/www/js/rivendell.js
index 70546dc..24ef2c7 100644
--- a/www/js/rivendell.js
+++ b/www/js/rivendell.js
@@ -37,7 +37,7 @@ Rivendell.Rivendell.prototype.listLog = function(name, success) {
PASSWORD: this.token,
NAME: name
};
- return $.post(this.rdxportEndpoint, command, success, "xml");
+ return $.post(this.rdxportEndpoint, command, success, 'xml');
};
Rivendell.Rivendell.prototype.listLogs = function(success) {
@@ -49,7 +49,7 @@ Rivendell.Rivendell.prototype.listLogs = function(success) {
/*SERVICE_NAME: serviceName,
TRACKABLE: trackable*/
};
- return $.post(this.rdxportEndpoint, command, success, "xml");
+ return $.post(this.rdxportEndpoint, command, success, 'xml');
};
Rivendell.Rivendell.prototype.listServices = function(success) {
@@ -60,7 +60,7 @@ Rivendell.Rivendell.prototype.listServices = function(success) {
//todo: fix optionals
/*TRACKABLE: trackable*/
};
- return $.post(this.rdxportEndpoint, command, success, "xml");
+ return $.post(this.rdxportEndpoint, command, success, 'xml');
};
Rivendell.Rivendell.prototype.listGroups = function(success) {
@@ -69,7 +69,7 @@ Rivendell.Rivendell.prototype.listGroups = function(success) {
LOGIN_NAME: this.username,
PASSWORD: this.token
};
- return $.post(this.rdxportEndpoint, command, success, "xml");
+ return $.post(this.rdxportEndpoint, command, success, 'xml');
};
Rivendell.Rivendell.prototype.listGroup = function(groupName, success) {
@@ -79,7 +79,7 @@ Rivendell.Rivendell.prototype.listGroup = function(groupName, success) {
PASSWORD: this.token,
GROUP_NAME: groupName
};
- return $.post(this.rdxportEndpoint, command, success, "xml");
+ return $.post(this.rdxportEndpoint, command, success, 'xml');
};
Rivendell.Rivendell.prototype.listCarts = function(groupName, includeCuts, success) {
@@ -90,7 +90,7 @@ Rivendell.Rivendell.prototype.listCarts = function(groupName, includeCuts, succe
GROUP_NAME: groupName,
INCLUDE_CUTS: includeCuts
};
- return $.post(this.rdxportEndpoint, command, success, "xml");
+ return $.post(this.rdxportEndpoint, command, success, 'xml');
};
Rivendell.Rivendell.prototype.listCart = function(cartNumber, includeCuts, success) {
@@ -113,7 +113,7 @@ Rivendell.Rivendell.prototype.addCart = function(groupName, type, cartNumber, su
TYPE: type,
CART_NUMBER: cartNumber
};
- return $.post(this.rdxportEndpoint, command, success, "xml");
+ return $.post(this.rdxportEndpoint, command, success, 'xml');
};
Rivendell.Rivendell.prototype.editCart = function(cartNumber, options, success) {
@@ -121,7 +121,7 @@ Rivendell.Rivendell.prototype.editCart = function(cartNumber, options, success)
options.LOGIN_NAME = this.username;
options.PASSWORD = this.token;
options.CART_NUMBER = cartNumber;
- return $.post(this.rdxportEndpoint, options, success, "xml");
+ return $.post(this.rdxportEndpoint, options, success, 'xml');
};
Rivendell.Rivendell.prototype.removeCart = function(cartNumber, success) {
@@ -131,7 +131,7 @@ Rivendell.Rivendell.prototype.removeCart = function(cartNumber, success) {
PASSWORD: this.token,
CART_NUMBER: cartNumber
};
- return $.post(this.rdxportEndpoint, command, success, "xml");
+ return $.post(this.rdxportEndpoint, command, success, 'xml');
};
Rivendell.Rivendell.prototype.listCuts = function(cartNumber, success) {
@@ -171,7 +171,7 @@ Rivendell.Rivendell.prototype.editCut = function(cartNumber, cutNumber, options,
options.PASSWORD = this.token;
options.CART_NUMBER = cartNumber;
options.CUT_NUMBER = cutNumber;
- return $.post(this.rdxportEndpoint, options, success, "xml");
+ return $.post(this.rdxportEndpoint, options, success, 'xml');
};
Rivendell.Rivendell.prototype.addAndEditCut = function(cartNumber, options, success) {
@@ -362,16 +362,16 @@ Rivendell.GroupList.prototype.destroy = function() {
};
Rivendell.Group = function(groupName, description, lowcart, highcart, normlevel, trimlevel) {
- this.groupXml = null;
+ this.xml = null;
if (arguments.length === 1) {
- this.groupXml = groupName;
- this.groupName = $('group', this.groupXml).text();
- this.description = $('group-description', this.groupXml).text();
- this.lowcart = $('group-low-cart', this.groupXml).text();
- this.highcart = $('group-high-cart', this.groupXml).text();
- this.normlevel = $('normalization-level', this.groupXml).text();
- this.trimlevel = $('autotrim-level', this.groupXml).text();
+ this.xml = arguments[0];
+ this.groupName = $('group', this.xml).text();
+ this.description = $('group-description', this.xml).text();
+ this.lowcart = $('group-low-cart', this.xml).text();
+ this.highcart = $('group-high-cart', this.xml).text();
+ this.normlevel = $('normalization-level', this.xml).text();
+ this.trimlevel = $('autotrim-level', this.xml).text();
} else {
this.groupName = groupName;
this.description = description;
@@ -380,19 +380,44 @@ Rivendell.Group = function(groupName, description, lowcart, highcart, normlevel,
this.normlevel = normlevel;
this.trimlevel = trimlevel;
}
+
+ this.carts = [];
};
Rivendell.Cart = function(number, title, groupName, group) {
- this.number = number;
- this.title = title;
- this.groupName = groupName;
- this.group = group;
+ this.xml = null;
+
+ if (arguments.length === 2) {
+ this.xml = arguments[0];
+ this.number = $('number', this.xml).text();
+ this.title = $('title', this.xml).text();
+ this.groupName = $('groupName', this.xml).text();
+ this.group = arguments[1];
+ } else {
+ this.number = number;
+ this.title = title;
+ this.groupName = groupName;
+ this.group = group;
+ }
+
+ this.cuts = [];
};
-Rivendell.Cut = function(cart, cartNumber, name, description) {
- this.cart = cart;
- this.cartNumber = cartNumber;
+Rivendell.Cut = function(name, description, cart) {
+ this.xml = null;
+
+ if (arguments.length === 2) {
+ this.xml = arguments[0];
+ this.name = $('cutName', this.xml).text();
+ this.description = $('description', this.xml).text();
+ this.cart = arguments[1];
+ } else {
+ this.name = name;
+ this.description = description;
+ this.cart = cart;
+ }
this.number = name.substr(-3);
- this.name = name;
- this.description = description;
+ this.cartNumber = cart.number;
+
+
};
diff --git a/www/js/rivendell.rh.js b/www/js/rivendell.rh.js
index dde1fda..5268cc1 100644
--- a/www/js/rivendell.rh.js
+++ b/www/js/rivendell.rh.js
@@ -88,10 +88,10 @@ Rivendell.GroupList.prototype.fetch = function(type, success) {
group = new JingleGroup(groupXml);
break;
case 'musicpool':
- group = new Musicpool(groupXml);
+ group = new Rivendell.Musicpool(groupXml);
break;
default:
- group = new Rivendell(groupXml);
+ group = new Rivendell.Group(groupXml);
break;
}
@@ -126,15 +126,15 @@ Rivendell.Musicgrid.prototype.fetch = function(success) {
};
Rivendell.MusicgridClock = function(name, color, title, dow, hour) {
- this.clockXml = null;
+ this.xml = null;
if (arguments.length === 1) {
- this.clockXml = name;
- this.name = $('name', this.clockXml).text();
- this.color = $('color', this.clockXml).text();
- this.title = $('title', this.clockXml).text();
- this.dow = $(this.clockXml).attr('dow');
- this.hour = $(this.clockXml).attr('hour');
+ this.xml = arguments[0];
+ this.name = $('name', this.xml).text();
+ this.color = $('color', this.xml).text();
+ this.title = $('title', this.xml).text();
+ this.dow = $(this.xml).attr('dow');
+ this.hour = $(this.xml).attr('hour');
} else {
this.name = name;
this.color = color;