summaryrefslogtreecommitdiff
path: root/www
diff options
context:
space:
mode:
authorPeterTheOne <petertheone@gmail.com>2016-01-28 20:29:46 (GMT)
committerPeterTheOne <petertheone@gmail.com>2016-01-28 20:29:46 (GMT)
commita3d085734454a66955bcc2c642b0a4f7bf5d2b92 (patch)
treed290b36b2eb96d6350ec31e02e2a9e2f0c93b14c /www
parent7aa6781c617b91e3ed28d528428087f11131daac (diff)
fix musicgrid bugs, create Rivendell.Group class, refactor
Diffstat (limited to 'www')
-rw-r--r--www/js/apps.js8
-rw-r--r--www/js/auth.js18
-rw-r--r--www/js/clock.js4
-rw-r--r--www/js/jingles.js24
-rw-r--r--www/js/musicgrid.js74
-rw-r--r--www/js/musicpools.js28
-rw-r--r--www/js/rivendell.js48
-rw-r--r--www/js/rivendell.rh.js83
-rw-r--r--www/js/shows.js11
-rw-r--r--www/js/utils.js6
10 files changed, 189 insertions, 115 deletions
diff --git a/www/js/apps.js b/www/js/apps.js
index 4f71a9c..12aba8f 100644
--- a/www/js/apps.js
+++ b/www/js/apps.js
@@ -20,7 +20,11 @@
* along with rhwebimport. If not, see <http://www.gnu.org/licenses/>.
*/
-var apps_current;
+'use strict';
+
+var Rivendell = Rivendell || {};
+
+var apps_current = null;
function apps_select(app) {
$('.container').removeClass('fullWidth');
@@ -117,5 +121,5 @@ function apps_cleanup() {
$(window).off('popstate');
- delete apps_current;
+ apps_current = null;
}
diff --git a/www/js/auth.js b/www/js/auth.js
index 2624b98..f830a0a 100644
--- a/www/js/auth.js
+++ b/www/js/auth.js
@@ -20,9 +20,13 @@
* along with rhwebimport. If not, see <http://www.gnu.org/licenses/>.
*/
-var auth_username;
-var auth_fullname;
-var auth_token;
+'use strict';
+
+var Rivendell = Rivendell || {};
+
+var auth_username = null;
+var auth_fullname = null;
+var auth_token = null;
function auth_loginSuccess(data) {
if (data.status == 'OK') {
@@ -46,7 +50,7 @@ function auth_loginSuccess(data) {
}
function auth_loginError(req, status, error) {
- message = req.status + ': ' + error;
+ var message = req.status + ': ' + error;
if(req.status == 401) {
message = "Benutzer und/oder Passwort sind falsch!";
}
@@ -93,13 +97,13 @@ function auth_init() {
function auth_cleanup() {
sessionStorage.removeItem("auth_username");
- delete auth_username;
+ auth_username = null;
$("#username").val('').focus();
sessionStorage.removeItem("auth_fullname");
- delete auth_fullname;
+ auth_fullname = null;
sessionStorage.removeItem("auth_token");
- delete auth_token;
+ auth_token = null;
$("#password").val('');
}
diff --git a/www/js/clock.js b/www/js/clock.js
index c616ec4..d3817c4 100644
--- a/www/js/clock.js
+++ b/www/js/clock.js
@@ -20,6 +20,10 @@
* along with rhwebimport. If not, see <http://www.gnu.org/licenses/>.
*/
+'use strict';
+
+var Rivendell = Rivendell || {};
+
function Clock() {
this.draw_callbacks = $.Callbacks('unique');
diff --git a/www/js/jingles.js b/www/js/jingles.js
index a8bec1e..5c3c39a 100644
--- a/www/js/jingles.js
+++ b/www/js/jingles.js
@@ -22,6 +22,8 @@
'use strict';
+var Rivendell = Rivendell || {};
+
var rivendell = null;
var importer = null;
var groupList = null;
@@ -32,10 +34,10 @@ function jingles_init() {
importer = new Rivendell.Importer();
- groupList = new Rivendell.GroupList(rivendell, 'jingle');
+ groupList = new Rivendell.GroupList(rivendell);
// todo: move this elsewhere?
$('#app-jingles .groups').html('');
- groupList.fetch();
+ groupList.fetch('jingle');
}
function jingles_cleanup() {
@@ -47,14 +49,14 @@ function jingles_cleanup() {
rivendell = null;
}
-var JingleGroup = function(title, groupName, description, lowcart, highcart, normlevel, trimlevel) {
- this.title = title;
- this.groupName = groupName;
- this.description = description;
- this.lowcart = lowcart;
- this.highcart = highcart;
- this.normlevel = normlevel;
- this.trimlevel = trimlevel;
+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();
+ } else {
+ Rivendell.Group.call(this, groupName, description, lowcart, highcart, normlevel, trimlevel);
+ this.title = title;
+ }
this.mainCart = null;
this.deactivateCart = null;
@@ -64,6 +66,8 @@ var JingleGroup = function(title, groupName, description, lowcart, highcart, nor
this.render();
this.fetchCarts();
};
+JingleGroup.prototype = Object.create(Rivendell.Group.prototype);
+JingleGroup.prototype.constructor = JingleGroup;
JingleGroup.prototype.fetchCarts = function() {
var self = this;
diff --git a/www/js/musicgrid.js b/www/js/musicgrid.js
index 29e639e..221f489 100644
--- a/www/js/musicgrid.js
+++ b/www/js/musicgrid.js
@@ -22,52 +22,43 @@
'use strict';
+var Rivendell = Rivendell || {};
+
var rivendell = null;
-var musicgrid = null;
+var musicgridView = null;
+var musicpoolModal = null;
function musicgrid_init() {
rivendell = new Rivendell.Rivendell(auth_username, auth_token, '/rd-bin/rdxport.cgi');
rivendell.setListDropboxesEndpoint('/rh-bin/listdropboxes.cgi');
rivendell.setMusicgridEndpoint('/rh-bin/musicgrid.cgi');
- musicgrid = new Musicgrid();
+ var musicgrid = new Rivendell.Musicgrid();
+ musicgridView = new Rivendell.MusicgridView(musicgrid);
+
+ var musicpools = new Rivendell.GroupList(rivendell);
+ musicpoolModal = new Rivendell.MusicpoolModal(musicpools);
}
function musicgrid_cleanup() {
- musicgrid = null
+ musicpoolModal = null;
+ musicgridView = null;
rivendell = null;
}
-var Musicgrid = function() {
- this.clocks = [];
-
- this.fetch();
-};
+Rivendell.MusicgridView = function(model) {
+ this.model = model;
-Musicgrid.prototype.fetch = function() {
- this.clocks = [];
var self = this;
- rivendell.getMusicgrid(function(gridXml, status, req) {
- var dbs = $(gridXml).find("grid").children();
- dbs.each(function(index, clockXml) {
- var clock = new MusicgridClock(
- $('name', clockXml).text(),
- $('color', clockXml).text(),
- $('title', clockXml).text(),
- $(clockXml).attr('dow'),
- $(clockXml).attr('hour')
- );
-
- self.clocks.push(clock);
- });
+ this.model.fetch(function() {
self.updateTable();
});
};
-Musicgrid.prototype.updateTable = function() {
+Rivendell.MusicgridView.prototype.updateTable = function() {
var $table = $('#app-musicgrid table');
$('tr td', $table).html('').removeClass('clock').css('background-color', '').css('color', '').attr('title', null);
- $(this.clocks).each(function(index, clock) {
+ $(this.model.clocks).each(function(index, clock) {
var $td = $('tr[data-dow="' + clock.dow + '"] td[data-hour="' + clock.hour +'"]', $table);
$td.addClass('clock');
$td.html(clock.name);
@@ -80,18 +71,22 @@ Musicgrid.prototype.updateTable = function() {
// todo: move this css to stylesheet
$td.css('text-align', 'center');
- $td.on('click', function() {
- selectClock(clock.dow, clock.hour, clock.name);
+ $td.off().on('click', function() {
+ musicpoolModal.selectClock(clock.dow, clock.hour, clock.name);
});
});
- $('tr td:not(.clock)', $table).on('click', function() {
- selectClock($(this).parent().data('dow'), $(this).data('hour'), null);
+ $('tr td:not(.clock)', $table).off().on('click', function() {
+ musicpoolModal.selectClock($(this).parent().data('dow'), $(this).data('hour'), null);
});
};
-var selectClock = function(dow, hour, clockName) {
+Rivendell.MusicpoolModal = function(model) {
+ this.model = model;
+};
+
+Rivendell.MusicpoolModal.prototype.selectClock = function(dow, hour, clockName) {
$('#musicpoolModal').modal({keyboard: true});
var $modalHeader = $('#musicpoolModal .modal-header');
@@ -99,10 +94,11 @@ var selectClock = function(dow, hour, clockName) {
$('h3', $modalHeader).html('Musikpool auswählen für Tag: ' + dow + ' Stunde: ' + hour + '.');
- Musicpools.prototype.updateSelector = function() {
- $('tbody', $modalBody).html('');
+ $('tbody', $modalBody).html('');
- $(this.musicpools).each(function(index, musicpool) {
+ var self = this;
+ this.model.fetch('musicpool', function() {
+ $(self.model.groups).each(function(index, musicpool) {
var $button = null;
if (clockName === musicpool.clock) {
$button = $('<button class="btn btn-primary" disabled="disabled">Selected</button>');
@@ -124,15 +120,5 @@ var selectClock = function(dow, hour, clockName) {
$('tbody', $modalBody).append($tr);
});
- };
-
- var musicpools = new Musicpools();
-};
-
-var MusicgridClock = function(name, color, title, dow, hour) {
- this.name = name;
- this.color = color;
- this.title = title;
- this.dow = dow;
- this.hour = hour;
+ });
};
diff --git a/www/js/musicpools.js b/www/js/musicpools.js
index ec5f864..abb6679 100644
--- a/www/js/musicpools.js
+++ b/www/js/musicpools.js
@@ -22,6 +22,8 @@
'use strict';
+var Rivendell = Rivendell || {};
+
var rivendell = null;
var importer = null;
var musicpoolsView = null;
@@ -32,7 +34,7 @@ function musicpools_init() {
importer = new Rivendell.Importer();
- var musicpools = new Rivendell.GroupList(rivendell, 'musicpool');
+ var musicpools = new Rivendell.GroupList(rivendell);
musicpoolsView = new MusicpoolsView(musicpools);
}
@@ -48,7 +50,7 @@ var MusicpoolsView = function(model) {
this.currentPoolId = sessionStorage.getItem('currentPoolId');
var self = this;
- this.model.fetch(function() {
+ this.model.fetch('musicpool', function() {
self.updateSelector();
});
};
@@ -102,21 +104,23 @@ MusicpoolsView.prototype.updateSelector = function() {
};
// this and jinglegroup are basicly the same thing
-var Musicpool = function(title, clock, groupName, description, lowcart, highcart, normlevel, trimlevel) {
- this.title = title;
- this.clock = clock;
-
- this.groupName = groupName;
- this.description = description;
- this.lowcart = lowcart;
- this.highcart = highcart;
- this.normlevel = normlevel;
- this.trimlevel = trimlevel;
+var 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();
+ } else {
+ Rivendell.Group.call(this, groupName, description, lowcart, highcart, normlevel, trimlevel);
+ this.title = title;
+ this.clock = clock;
+ }
this.carts = [];
this.$el = null;
};
+Musicpool.prototype = Object.create(Rivendell.Group.prototype);
+Musicpool.prototype.constructor = Musicpool;
Musicpool.prototype.render = function() {
var self = this;
diff --git a/www/js/rivendell.js b/www/js/rivendell.js
index ffa138a..70546dc 100644
--- a/www/js/rivendell.js
+++ b/www/js/rivendell.js
@@ -348,3 +348,51 @@ Rivendell.Rivendell.prototype.deleteAudio = function(cartNumber, cutNumber, succ
};
return $.post(this.rdxportEndpoint, command, success, 'xml');
};
+
+Rivendell.GroupList = function(rivendell) {
+ this.rivendell = rivendell;
+
+ this.groups = [];
+};
+
+Rivendell.GroupList.prototype.destroy = function() {
+ $(this.groups).each(function(index, group) {
+ group.destroy();
+ });
+};
+
+Rivendell.Group = function(groupName, description, lowcart, highcart, normlevel, trimlevel) {
+ this.groupXml = 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();
+ } else {
+ this.groupName = groupName;
+ this.description = description;
+ this.lowcart = lowcart;
+ this.highcart = highcart;
+ this.normlevel = normlevel;
+ this.trimlevel = trimlevel;
+ }
+};
+
+Rivendell.Cart = function(number, title, groupName, group) {
+ this.number = number;
+ this.title = title;
+ this.groupName = groupName;
+ this.group = group;
+};
+
+Rivendell.Cut = function(cart, cartNumber, name, description) {
+ this.cart = cart;
+ this.cartNumber = cartNumber;
+ this.number = name.substr(-3);
+ this.name = name;
+ this.description = description;
+};
diff --git a/www/js/rivendell.rh.js b/www/js/rivendell.rh.js
index fdacd85..dde1fda 100644
--- a/www/js/rivendell.rh.js
+++ b/www/js/rivendell.rh.js
@@ -72,51 +72,32 @@ Rivendell.Rivendell.prototype.setMusicgrid = function(dow, hour, name, success)
return $.post(this.musicgridEndpoint, command, success, "xml");
};
-Rivendell.GroupList = function(rivendell, type) {
- this.rivendell = rivendell;
-
- this.type = type;
-
- this.groups = [];
-};
-
-Rivendell.GroupList.prototype.fetch = function(success) {
+Rivendell.GroupList.prototype.fetch = function(type, success) {
this.groups = [];
var self = this;
- this.rivendell.listDropboxes(this.type, function(groupsXml, status, req) {
+ this.rivendell.listDropboxes(type, function(groupsXml, status, req) {
var dbs = $('dropboxList', groupsXml).children();
dbs.each(function(index, groupXml) {
+ var group = null;
switch ($('type', groupXml).text()) {
- case 'show':
+ /*case 'show':
// todo
- break;
+ break;*/
case 'jingle':
- var group = 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()
- );
+ group = new JingleGroup(groupXml);
break;
case 'musicpool':
- var group = 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()
- );
+ group = new Musicpool(groupXml);
+ break;
+ default:
+ group = new Rivendell(groupXml);
break;
}
- self.groups.push(group);
+ if (group !== null) {
+ self.groups.push(group);
+ }
});
if (success) {
@@ -125,8 +106,40 @@ Rivendell.GroupList.prototype.fetch = function(success) {
});
};
-Rivendell.GroupList.prototype.destroy = function() {
- $(this.groups).each(function(index, group) {
- group.destroy();
+Rivendell.Musicgrid = function() {
+ this.clocks = [];
+};
+
+Rivendell.Musicgrid.prototype.fetch = function(success) {
+ this.clocks = [];
+
+ var self = this;
+ rivendell.getMusicgrid(function(gridXml, status, req) {
+ var dbs = $('grid', gridXml).children();
+ dbs.each(function(index, clockXml) {
+ self.clocks.push(new Rivendell.MusicgridClock(clockXml));
+ });
+ if (success) {
+ success();
+ }
});
};
+
+Rivendell.MusicgridClock = function(name, color, title, dow, hour) {
+ this.clockXml = 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');
+ } else {
+ this.name = name;
+ this.color = color;
+ this.title = title;
+ this.dow = dow;
+ this.hour = hour;
+ }
+};
diff --git a/www/js/shows.js b/www/js/shows.js
index 2ab1af1..764e0c4 100644
--- a/www/js/shows.js
+++ b/www/js/shows.js
@@ -20,15 +20,18 @@
* along with rhwebimport. If not, see <http://www.gnu.org/licenses/>.
*/
+'use strict';
+
+var Rivendell = Rivendell || {};
+
var rivendell = null;
-var shows_currentid;
+var shows_currentid = null;
var shows_list = [];
var shows_current;
var shows_group_carts = {};
var shows_log_carts = [];
var shows_clock;
-
function shows_deleteCart(cart) {
rivendell.removeCart(cart, function() {
shows_updateGroupCartInfo(cart);
@@ -92,7 +95,7 @@ function shows_importCartConfirm(cart, dz) {
cart_row.replaceWith(importing_row);
dz.off("error");
- files = dz.getAcceptedFiles();
+ var files = dz.getAcceptedFiles();
importing_row.find('.file-name').text(files[0].name);
shows_importUpdateProgress(files[0], importing_row);
dz.on("uploadprogress", function(file) { shows_importUpdateProgress(file, importing_row); });
@@ -336,7 +339,7 @@ function shows_init() {
function shows_cleanup() {
$('#show-carts tbody').find('tr').remove();
sessionStorage.removeItem("shows_currentid");
- delete shows_currentid;
+ shows_currentid = null;
shows_list = [];
shows_group_carts = {};
shows_log_carts = [];
diff --git a/www/js/utils.js b/www/js/utils.js
index 47f5cff..8a7ee9c 100644
--- a/www/js/utils.js
+++ b/www/js/utils.js
@@ -20,7 +20,11 @@
* along with rhwebimport. If not, see <http://www.gnu.org/licenses/>.
*/
-alertbox = function() {}
+'use strict';
+
+var Rivendell = Rivendell || {};
+
+var alertbox = function() {}
alertbox.warning = function (dest, heading, message) {
$('#' + dest + ' .alertbox').html('<div class="alert"><a class="close" data-dismiss="alert" href="#">&times;</a><h4 class="alert-heading">' + heading + '</h4>' + message + '</div>');
}