summaryrefslogtreecommitdiff
path: root/www
diff options
context:
space:
mode:
Diffstat (limited to 'www')
-rw-r--r--www/index.html2
-rw-r--r--www/js/musicpools.js4
-rw-r--r--www/js/rdxport.js58
-rw-r--r--www/js/rdxport.rh.js6
-rw-r--r--www/js/shows.js281
5 files changed, 321 insertions, 30 deletions
diff --git a/www/index.html b/www/index.html
index 7b63a38..d6599f8 100644
--- a/www/index.html
+++ b/www/index.html
@@ -137,7 +137,7 @@
<label class="control-label" for="show-selector">
<h3>Sendung auswählen</h3>
</label>&nbsp;&nbsp;
- <select id="show-selector" class="main-selector" onchange="shows_showSelected()">
+ <select id="show-selector" class="main-selector">
</select>
</form>
</div>
diff --git a/www/js/musicpools.js b/www/js/musicpools.js
index e77c23c..28fcabb 100644
--- a/www/js/musicpools.js
+++ b/www/js/musicpools.js
@@ -187,8 +187,6 @@ Rivendell.MusicpoolCartView = function(model) {
};
Rivendell.MusicpoolCartView.prototype.render = function() {
- var number = this.model.number;
-
var length = '-';
var imported = '-';
var playcnt = '-';
@@ -218,7 +216,7 @@ Rivendell.MusicpoolCartView.prototype.render = function() {
this.$el = $('<tr>')
.attr('id', 'musicpool-' + this.model.number)
- .append($('<td>').text(number))
+ .append($('<td>').text(this.model.number))
.append($('<td>').text(this.model.title))
.append($('<td>').text(this.model.artist))
.append($('<td>').text(this.model.album))
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;
diff --git a/www/js/rdxport.rh.js b/www/js/rdxport.rh.js
index a80e6de..3c1bdfe 100644
--- a/www/js/rdxport.rh.js
+++ b/www/js/rdxport.rh.js
@@ -92,9 +92,9 @@ Rivendell.GroupList.prototype.fetch = function(type) {
dbs.each(function(index, groupXml) {
var group = null;
switch ($('type', groupXml).text()) {
- /*case 'show':
- // todo
- break;*/
+ case 'show':
+ group = new Rivendell.Show(groupXml);
+ break;
case 'jingle':
group = new Rivendell.JingleGroup(groupXml);
break;
diff --git a/www/js/shows.js b/www/js/shows.js
index 84d49a5..91c4bc0 100644
--- a/www/js/shows.js
+++ b/www/js/shows.js
@@ -24,12 +24,266 @@
var Rivendell = Rivendell || {};
-var shows_currentid = null;
+/*var shows_currentid = null;
var shows_list = [];
var shows_current;
var shows_group_carts = {};
-var shows_log_carts = [];
-var shows_clock;
+var shows_log_carts = [];*/
+
+var showListView = null;
+
+function shows_init() {
+ /*shows_currentid = sessionStorage.getItem("shows_currentid");
+ shows_list = [];
+ rivendell.listDropboxes('show', shows_updateList);*/
+
+ var showList = new Rivendell.GroupList(rivendell);
+ showListView = new Rivendell.ShowListView(showList);
+
+ drawClock('Do, 1.1.1970', '00:00:00', 0);
+ clock_add_callback(drawClock);
+}
+
+function shows_cleanup() {
+ $('#show-carts tbody').find('tr').remove();
+ /*sessionStorage.removeItem("shows_currentid");
+ shows_currentid = null;
+ shows_list = [];
+ shows_group_carts = {};
+ shows_log_carts = [];*/
+}
+
+Rivendell.ShowListView = function(model) {
+ this.model = model;
+
+ this.showViews = [];
+ this.currentShowId = sessionStorage.getItem('currentShowId');
+
+ var self = this;
+ $(this.model).on('update', function() {
+ $(self.model.groups).each(function(index, show) {
+ var showView = new Rivendell.ShowView(show);
+ self.showViews.push(showView);
+ });
+ self.updateSelector();
+ });
+ this.model.fetch('show');
+};
+
+Rivendell.ShowListView.prototype.setCurrentShowId = function(currentShowId) {
+ this.currentShowId = currentShowId;
+ sessionStorage.setItem('currentShowId', this.currentShowId);
+};
+
+Rivendell.ShowListView.prototype.getCurrentShowView = function() {
+ if (this.model.groups.length === 0) {
+ return null;
+ }
+ if (this.showViews.length === 0) {
+ return null;
+ }
+ if (this.currentShowId === null) {
+ this.setCurrentShowId(this.model.groups[0].id);
+ }
+ var self = this;
+ var showViewFound = null;
+ $(this.showViews).each(function(index, showView) {
+ if (showView.model.id === self.currentShowId) {
+ showViewFound = showView;
+ return true;
+ }
+ });
+ return showViewFound;
+};
+
+Rivendell.ShowListView.prototype.updateSelector = function() {
+ var self = this;
+ var $showSelector = $('#show-selector');
+
+ $showSelector.off();
+ $('option', $showSelector).remove();
+
+ $(this.model.groups).each(function(index, show) {
+ var name = show.title + ' (' + show.rhythm + ', ' + weekday[show.dayofweek] + ', ' + show.starttime + ', ' + show.length + ' Min.)';
+ $showSelector.append($('<option>').attr('value', show.id).text(name));
+ });
+
+ if (this.currentShowId === null) {
+ this.setCurrentShowId(this.model.groups[0].id);
+ }
+ $('option[value="' + this.currentShowId + '"]', $showSelector).attr('selected', 'selected');
+
+ $showSelector.on('change', function() {
+ self.setCurrentShowId($('option:selected', $showSelector).attr('value'));
+ self.getCurrentShowView().model.fetchCartsAndLogs();
+ });
+
+ this.getCurrentShowView().model.fetchCartsAndLogs();
+};
+
+Rivendell.Show = function(groupName, description, lowcart, highcart, normlevel, trimlevel,
+ id, title, log, rhythm, dayofweek, starttime, length) {
+ if (arguments.length = 1) {
+ Rivendell.Group.call(this, groupName);
+ this.id = $('show-id', this.xml).text();
+ this.title = $('show-title', this.xml).text();
+ this.log = $('show-log', this.xml).text();
+ this.rhythm = $('show-rhythm', this.xml).text();
+ this.dayofweek = $('show-dayofweek', this.xml).text();
+ this.starttime = $('show-starttime', this.xml).text();
+ this.length = $('show-length', this.xml).text();
+ } else {
+ Rivendell.Group.call(this, groupName, description, lowcart, highcart, normlevel, trimlevel);
+ this.id = id;
+ this.title = title;
+ this.log = log;
+ this.rhythm = rhythm;
+ this.dayofweek = dayofweek;
+ this.starttime = starttime;
+ this.length = length;
+ }
+
+ this.logs = [];
+};
+Rivendell.Show.prototype = Object.create(Rivendell.Group.prototype);
+Rivendell.Show.prototype.constructor = Rivendell.Show;
+
+Rivendell.Show.prototype.fetchCartsAndLogs = function() {
+ var self = this;
+
+ var lcd = rivendell.listLog(this.log, function(logsXml, status, req) {
+ self.logs = [];
+
+ var loglines = $('logList', logsXml).children();
+ loglines.each(function(index, logXml) {
+ var log = Rivendell.Log.newFromXml(logXml, self);
+ if(log.cartNumber >= self.lowcart &&
+ log.cartNumber <= self.highcart) {
+ self.logs.push(log);
+ }
+ });
+ });
+
+ var gcd = rivendell.listCarts(this.groupName, 1, function(cartsXml, status, req) {
+ self.carts = [];
+
+ var dbs = $('cartList', cartsXml).children();
+ dbs.each(function(index, cartXml) {
+ var cart = new Rivendell.Cart(cartXml, self);
+
+ var cuts = $('cutList', cartXml).children();
+ cuts.each(function(index, cut) {
+ cart.cuts.push(new Rivendell.Cut(cut, cart));
+ });
+
+ self.addCart(cart);
+ });
+ });
+
+ $.when(lcd, gcd).done(function(lcres, gcres) {
+ if(lcres[1] == 'success' && gcres[1] == 'success') {
+ self.$this.trigger('update');
+ }
+ });
+};
+
+Rivendell.ShowView = function(model) {
+ this.model = model;
+ this.cartViews = [];
+
+ this.$el = null;
+
+ var self = this;
+ this.model.$this.on('update', function() {
+ self.render();
+ });
+};
+
+Rivendell.ShowView.prototype.render = function() {
+ $('#show-title').text(this.model.title);
+ $('#show-dow').text(weekday[this.model.dayofweek]);
+ $('#show-rhythm').text(this.model.rhythm);
+ $('#show-starttime').text(this.model.starttime);
+ $('#show-length').text(this.model.length + ' Min.');
+
+ var $tableBody = $('#app-shows table tbody');
+ $('tr', $tableBody).remove();
+
+ var self = this;
+ this.cartViews = [];
+ $(this.model.logs).each(function(index, log) {
+ var cart = self.model.getCartByNumber(log.cartNumber);
+ if (cart) {
+ var cartView = new Rivendell.ShowCartView(cart);
+ self.cartViews.push(cartView);
+ cartView.render();
+
+ $('#app-shows table > tbody').append(cartView.$el);
+ } else {
+ var cart = new Rivendell.Cart(log.cartNumber, '-', '-', null);
+ var cartView = new Rivendell.ShowCartView(cart);
+ cartView.renderEmpty();
+ $('#app-shows table > tbody').append(cartView.$el);
+ }
+ });
+};
+
+Rivendell.ShowCartView = function(model) {
+ this.model = model;
+
+ this.$spinner = null;
+ this.$el = $('<tr>');
+};
+
+Rivendell.ShowCartView.prototype.render = function() {
+ var $deleteButton = $('<button class="btn btn-danger btn-xs"><span class="glyphicon glyphicon-trash"></span>&nbsp;&nbsp;Löschen</button>');
+
+ var self = this;
+ $deleteButton.on('click', function() {
+ self.delete();
+ });
+
+ this.$spinner = $('#hiddenTemplates .spinnerTemplate').clone().removeClass('spinnerTemplate');
+
+ var cut = this.model.cuts[0];
+ this.$el = this.$el.empty()
+ .attr('id', 'show-cart-' + this.model.number)
+ .append($('<td>').text(this.model.number))
+ .append($('<td>').text(this.model.title))
+ .append($('<td>').text(msToTimeString(Number(cut.length))))
+ .append($('<td>').text(format_datetime(new Date(cut.originDatetime))))
+ .append($('<td>').text(cut.playCounter))
+ .append($('<td>').text(format_datetime(new Date(cut.lastPlayDatetime))))
+ .append($('<td>').css('text-align', 'center').append($deleteButton));
+};
+
+Rivendell.ShowCartView.prototype.renderEmpty = function() {
+ var buttons = '<button class="btn btn-primary btn-xs">' +
+ '<span class="glyphicon glyphicon-upload"></span>&nbsp;&nbsp;Importieren</button>';
+
+ this.$el = this.$el.empty()
+ .attr('id', 'show-cart-' + this.model.number)
+ .append($('<td>').text(this.model.number))
+ .append($('<td>').text('-'))
+ .append($('<td>').text('-'))
+ .append($('<td>').text('-'))
+ .append($('<td>').text('-'))
+ .append($('<td>').text('-'))
+ .append($('<td>').css('text-align', 'center').append(buttons));
+};
+
+Rivendell.ShowCartView.prototype.delete = function() {
+ $('td:last', this.$el).html(this.$spinner);
+
+ var self = this;
+ rivendell.removeCart(this.model.number, function() {
+ self.model.group.removeCart(self.model);
+ self.renderEmpty();
+ });
+};
+
+
+
function shows_deleteCart(cart) {
rivendell.removeCart(cart, function() {
@@ -226,7 +480,7 @@ function shows_redrawCartEntry(cart) {
$('#show-cart-' + cart).replaceWith(shows_newCartEntry(cart));
}
-function shows_updateCartListing() {
+/*function shows_updateCartListing() {
$('#show-carts tbody').find('tr').remove();
shows_log_carts.forEach(function(elem) {
$('#show-carts > tbody:last').append(shows_newCartEntry(elem));
@@ -323,21 +577,4 @@ function shows_updateList(data, status, req) {
});
$('#show-selector').val(shows_currentid);
shows_showSelected();
-}
-
-function shows_init() {
- shows_currentid = sessionStorage.getItem("shows_currentid");
- shows_list = [];
- rivendell.listDropboxes('show', shows_updateList);
- drawClock('Do, 1.1.1970', '00:00:00', 0);
- clock_add_callback(drawClock);
-}
-
-function shows_cleanup() {
- $('#show-carts tbody').find('tr').remove();
- sessionStorage.removeItem("shows_currentid");
- shows_currentid = null;
- shows_list = [];
- shows_group_carts = {};
- shows_log_carts = [];
-}
+}*/