From ed373caa60162aee97241dbc91e579a3964812f6 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sat, 20 Jun 2015 00:43:38 +0200 Subject: improved importing visualization diff --git a/www/js/shows.js b/www/js/shows.js index b2d9d98..077cf42 100644 --- a/www/js/shows.js +++ b/www/js/shows.js @@ -56,17 +56,16 @@ function shows_importUpdateProgress(file, stats) { function shows_importCartConfirm(cart, dz) { $('#shows-upload').modal('hide'); var cart_row = $('#show-cart-' + cart) - cart_row.next().remove(); cart_row.find('.btn').attr('disabled','disabled'); - var dz_stat = shows_getDzStat(false); - dz_stat.find('button').unbind('click').click(function() { shows_importCartCancel(cart, dz); }); - cart_row.after(dz_stat); + var importing_row = shows_newImportingEntry(cart); + importing_row.find('button').unbind('click').click(function() { shows_importCartCancel(cart, dz); }); + cart_row.replaceWith(importing_row); dz.off("error"); files = dz.getAcceptedFiles(); - dz_stat.find('.file-name').text(files[0].name); - shows_importUpdateProgress(files[0], dz_stat); - dz.on("uploadprogress", function(file) { shows_importUpdateProgress(file, dz_stat); }); + 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); }); 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]); @@ -125,37 +124,6 @@ function shows_importCart(cart) { // // -function shows_getDzStat(empty) { - if(empty) { - return $('').append($('').css("border", 0) - .css("height", 0) - .css("margin", 0) - .css("padding", 0)); - } else { - var progress_bar = '
'; - var cancel_button = ''; - - return $('').append($('').addClass('file-name').text('-')) - .append($('').addClass('file-bytes').text('??.? von ??.? MB')) - .append($('').append(progress_bar)) - .append($('').append(cancel_button)); - } -} - -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 = {}; @@ -171,21 +139,45 @@ function shows_newCartEntry(elem) { ''; - return $('').append($('').text(elem)) - .append($('').text(cart.title)) - .append($('').text(msToTimeString(cart.length))) - .append($('').text(cart.imported)) - .append($('').text(cart.playcnt)) - .append($('').text(cart.lastplayed)) - .append($('').append(buttons)).attr("id", "show-cart-" + elem); + return $('').append($('').text(elem)) + .append($('').text(cart.title)) + .append($('').text(msToTimeString(cart.length))) + .append($('').text(cart.imported)) + .append($('').text(cart.playcnt)) + .append($('').text(cart.lastplayed)) + .append($('').append(buttons)).attr("id", "show-cart-" + elem); +} + +function shows_newImportingEntry(cart) { + var progress_bar = '
'; + var cancel_button = ''; + + return $('').append($('').text(cart)) + .append($('').addClass('file-name').text('-')) + .append($('').addClass('file-bytes').text('??.? von ??.? MB')) + .append($('').append(progress_bar)) + .append($('').append(cancel_button)) + .attr("id", "show-cart-" + cart); +} + +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)); } function shows_udpateCartListing() { $('#show-carts tbody').find('tr').remove(); shows_log_carts.forEach(function(elem) { - $('#show-carts > tbody:last').append(shows_newCartEntry(elem)) - .append(shows_getDzStat(true)); - }); + $('#show-carts > tbody:last').append(shows_newCartEntry(elem)); + }); } function shows_updateGroupCartList(data, status, req) { -- cgit v0.10.2