summaryrefslogtreecommitdiff
path: root/www/js/musicpools.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/musicpools.js
parent34316ee23f6fd1b13b03209ade06027aa6ba2ca2 (diff)
combine JingleGroupList and Musicpools to GroupList class
Diffstat (limited to 'www/js/musicpools.js')
-rw-r--r--www/js/musicpools.js64
1 files changed, 23 insertions, 41 deletions
diff --git a/www/js/musicpools.js b/www/js/musicpools.js
index 93d4824..f164d13 100644
--- a/www/js/musicpools.js
+++ b/www/js/musicpools.js
@@ -23,76 +23,58 @@
'use strict';
var rivendell = null;
-var musicpools = null;
+var musicpoolsView = null;
function musicpools_init() {
rivendell = new Rivendell.Rivendell(auth_username, auth_token, '/rd-bin/rdxport.cgi');
rivendell.setListDropboxesEndpoint('/rh-bin/listdropboxes.cgi');
- musicpools = new Musicpools();
+
+ var musicpools = new Rivendell.GroupList(rivendell, 'musicpool');
+ musicpoolsView = new MusicpoolsView(musicpools);
}
function musicpools_cleanup() {
rivendell = null;
+ musicpoolsView = null;
}
-// this and jinglegroups are basicly the same
-var Musicpools = function() {
- // todo: get current Pool Id from session like shows?
+var MusicpoolsView = function(model) {
+ this.model = model;
+
this.currentPoolId = sessionStorage.getItem("currentPoolId");
- this.musicpools = [];
- this.fetch();
+
+ var self = this;
+ this.model.fetch(function() {
+ self.updateSelector();
+ });
};
-Musicpools.prototype.getCurrentPool = function() {
- if (this.musicpools.length === 0) {
+MusicpoolsView.prototype.getCurrentPool = function() {
+ if (this.model.groups.length === 0) {
return null;
}
if (this.currentPoolId === null) {
this.currentPoolId = 0;
}
- if (this.currentPoolId > this.musicpools.length) {
+ if (this.currentPoolId > this.model.groups.length) {
this.currentPoolId = 0;
}
- return this.musicpools[this.currentPoolId];
+ return this.model.groups[this.currentPoolId];
};
-Musicpools.prototype.fetch = function() {
+MusicpoolsView.prototype.updateSelector = function() {
var self = this;
+ var $musicpoolSelector = $('#musicpool-selector');
- rivendell.listDropboxes('musicpool', function(groupsXml, status, req) {
- self.musicpools = [];
-
- var dbs = $(groupsXml).find("dropboxList").children();
- dbs.each(function(index, groupXml) {
- var musicpool = new Musicpool(
- $('musicpool-title', groupXml).text(),
- $('musicpool-clock', 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.musicpools.push(musicpool);
- });
-
- self.updateSelector();
- });
-};
-
-Musicpools.prototype.updateSelector = function() {
- $('#musicpool-selector').find('option').remove();
+ $('option', $musicpoolSelector).remove();
// todo: add from list
- $(this.musicpools).each(function(index, musicpool) {
+ $(this.model.groups).each(function(index, musicpool) {
var name = musicpool.title + ' (' + musicpool.clock + ')';
- $('#musicpool-selector').append($('<option>').attr('value', musicpool.title).text(name));
+ $musicpoolSelector.append($('<option>').attr('value', musicpool.title).text(name));
});
- var self = this;
- $('#musicpool-selector').on('change', function() {
+ $musicpoolSelector.on('change', function() {
self.getCurrentPool().render();
});