summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rw-r--r--js/shows.js104
1 files changed, 64 insertions, 40 deletions
diff --git a/js/shows.js b/js/shows.js
index c705405..a0022b6 100644
--- a/js/shows.js
+++ b/js/shows.js
@@ -7,7 +7,20 @@ var shows_log_carts = [];
function shows_deleteCart(cart) {
data = { COMMAND: 13, LOGIN_NAME: auth_username, PASSWORD: auth_token, CART_NUMBER: cart };
- $.post("/rd-bin/rdxport.cgi", data, null, "xml").done(shows_showSelected);
+ $.post("/rd-bin/rdxport.cgi", data, null, "xml").done(function() { shows_updateGroupCartInfo(cart); });
+}
+
+function shows_importAddCut(cart, dz, file) {
+ data = { COMMAND: 10, LOGIN_NAME: auth_username, PASSWORD: auth_token, CART_NUMBER: cart };
+ $.post("/rd-bin/rdxport.cgi", data, null, "xml").done(function() { dz.processQueue(); })
+ .fail(function(xhr, status, err) { shows_importFileUploadError(cart, dz, file, err, xhr); });
+}
+
+function shows_importAddCart(cart, dz, file) {
+ data = { COMMAND: 12, LOGIN_NAME: auth_username, PASSWORD: auth_token,
+ GROUP_NAME: shows_current.group.name, TYPE: 'audio', CART_NUMBER: cart };
+ $.post("/rd-bin/rdxport.cgi", data, null, "xml").done(function() { shows_importAddCut(cart, dz, file); })
+ .fail(function(xhr, status, err) { shows_importFileUploadError(cart, dz, file, err, xhr); });
}
function shows_importCartCancel(cart, dz) {
@@ -21,17 +34,16 @@ function shows_importCartCancel(cart, dz) {
function shows_importFileUploadError(cart, dz, file, msg, xhr) {
alert("import file upload error: " + msg);
+ dz.disable();
+ shows_updateGroupCartInfo(cart);
}
function shows_importFileUploadSuccess(cart, dz, file) {
- alert("import file upload success for cart " + cart);
-}
-
-function shows_importFileUploadComplete(cart, dz, file) {
- alert("import file upload success/error for cart " + cart);
+ dz.disable();
+ shows_updateGroupCartInfo(cart);
}
-function shows_updateProgress(file, stats)
+function shows_importUpdateProgress(file, stats)
{
var bytes_str = Number((file.upload.bytesSent/1024)/1024).toFixed(1) + " von " +
Number((file.upload.total/1024)/1024).toFixed(1) + " MB";
@@ -49,15 +61,13 @@ function shows_importCartConfirm(cart, dz) {
cart_row.after(dz_stat);
dz.off("error");
- dz.on("error", function(file, msg, xhr) { shows_importFileUploadError(cart, this, file, msg, xhr); });
files = dz.getAcceptedFiles();
-
dz_stat.find('.file-name').text(files[0].name);
- shows_updateProgress(files[0], dz_stat);
- dz.on("uploadprogress", function(file) { shows_updateProgress(file, dz_stat); });
- dz.on("success", function(file) { shows_updateProgress(cart, dz, file); });
- dz.on("complete", function(file) { shows_updateProgress(cart, dz, file); });
- dz.processQueue();
+ shows_importUpdateProgress(files[0], dz_stat);
+ dz.on("uploadprogress", function(file) { shows_importUpdateProgress(file, dz_stat); });
+ dz.on("success", function(file) { shows_importFileUploadSuccess(cart, dz, file); });
+ dz.on("error", function(file, msg, xhr) { shows_importFileUploadError(cart, this, file, msg, xhr); });
+ shows_importAddCart(cart, dz, files[0]);
}
function shows_createImportForm(cart) {
@@ -132,37 +142,52 @@ function shows_getDzStat(empty)
}
}
+function shows_updateGroupCartInfo(cart) {
+ data = { COMMAND: 7, LOGIN_NAME: auth_username, PASSWORD: auth_token, CART_NUMBER: cart, INCLUDE_CUTS: 1 };
+ var defer = $.post("/rd-bin/rdxport.cgi", data, shows_updateGroupCartList, "xml")
+ .fail(function() { delete shows_group_carts[cart]; shows_redrawCartEntry(cart); });
+
+ $.when(defer).done(function() { shows_redrawCartEntry(cart); });
+}
+
+function shows_redrawCartEntry(cart) {
+ $('#show-cart-' + cart).replaceWith(shows_newCartEntry(cart));
+ $('#show-cart-' + cart).next().replaceWith(shows_getDzStat(true));
+}
+
+function shows_newCartEntry(elem) {
+ var cart_exists = shows_group_carts[elem] ? 1 : 0;
+ var cart = {};
+ cart.title = cart_exists ? shows_group_carts[elem].title : '-';
+ cart.length = cart_exists ? shows_group_carts[elem].length : '-';
+ cart.imported = cart_exists ? format_datetime(shows_group_carts[elem].imported) : '-';
+ cart.playcnt = cart_exists ? shows_group_carts[elem].playcnt : '-';
+ cart.lastplayed = cart_exists ? format_datetime(shows_group_carts[elem].lastplayed) : '-';
+
+ var buttons = cart_exists ?
+ '<button class="btn btn-danger btn-mini" onclick="shows_deleteCart(' + elem + ');">' +
+ '<i class="icon-trash icon-white"></i> Löschen</button>' :
+ '<button class="btn btn-success btn-mini" onclick="shows_importCart(' + elem + ');">' +
+ '<i class="icon-upload icon-white"></i> Importieren</button>';
+
+ return $('<tr>').append($('<td rowspan=2>').text(elem))
+ .append($('<td>').text(cart.title))
+ .append($('<td>').text(cart.length))
+ .append($('<td>').text(cart.imported))
+ .append($('<td>').text(cart.playcnt))
+ .append($('<td>').text(cart.lastplayed))
+ .append($('<td>').append(buttons)).attr("id", "show-cart-" + elem);
+}
+
function shows_udpateCartListing() {
$('#show-carts tbody').find('tr').remove();
shows_log_carts.forEach(function(elem) {
- var cart_exists = shows_group_carts[elem] ? 1 : 0;
- var cart = {};
- cart.title = cart_exists ? shows_group_carts[elem].title : '-';
- cart.length = cart_exists ? shows_group_carts[elem].length : '-';
- cart.imported = cart_exists ? format_datetime(shows_group_carts[elem].imported) : '-';
- cart.playcnt = cart_exists ? shows_group_carts[elem].playcnt : '-';
- cart.lastplayed = cart_exists ? format_datetime(shows_group_carts[elem].lastplayed) : '-';
-
- var buttons = cart_exists ?
- '<button class="btn btn-danger btn-mini" onclick="shows_deleteCart(' + elem + ');">' +
- '<i class="icon-trash icon-white"></i> Löschen</button>' :
- '<button class="btn btn-success btn-mini" onclick="shows_importCart(' + elem + ');">' +
- '<i class="icon-upload icon-white"></i> Importieren</button>';
-
- $('#show-carts > tbody:last').append(
- $('<tr>').append($('<td rowspan=2>').text(elem))
- .append($('<td>').text(cart.title))
- .append($('<td>').text(cart.length))
- .append($('<td>').text(cart.imported))
- .append($('<td>').text(cart.playcnt))
- .append($('<td>').text(cart.lastplayed))
- .append($('<td>').append(buttons)).attr("id", "show-cart-" + elem)
- ).append(shows_getDzStat(true));
- });
+ $('#show-carts > tbody:last').append(shows_newCartEntry(elem))
+ .append(shows_getDzStat(true));
+ });
}
function shows_updateGroupCartList(data, status, req) {
- shows_group_carts = {};
var cartlist = $(data).find("cartList");
var carts = cartlist.children();
carts.each(function() {
@@ -183,7 +208,6 @@ function shows_updateGroupCartList(data, status, req) {
}
function shows_updateLogCartList(data, status, req) {
- shows_log_carts = [];
var loglist = $(data).find("logList");
var loglines = loglist.children();
loglines.each(function() {