From bea885985e9763cb0a4dfa0e69c084ba26b65c5a Mon Sep 17 00:00:00 2001 From: Peter Grassberger Date: Sat, 5 Sep 2015 03:23:35 +0200 Subject: reprove jingle cut move diff --git a/www/js/jingles.js b/www/js/jingles.js index be739b4..01cb31c 100644 --- a/www/js/jingles.js +++ b/www/js/jingles.js @@ -224,34 +224,42 @@ JingleCut.prototype.move = function() { console.log('JingleCut.prototype.move'); // move to other group, if active stay in mainCart, if deactivated stay in deactiveCart - // check if there is an empty cut at destination // todo: remove hardcoded cartNumbers var destinationCart = ((parseInt(this.cartNumber) - 2000 + 2) % 4) + 2000; //console.log(parseInt(this.cartNumber)); //console.log(destinationCart); - var self = this; - var command = { COMMAND: 9, LOGIN_NAME: auth_username, PASSWORD: auth_token, CART_NUMBER: destinationCart }; - $.post("/rd-bin/rdxport.cgi", command, function(cutsXml, status, req) { - var cuts = $(cutsXml).find("cutList").children(); - console.log(cuts.length); - - // create one if not. - - if (cuts.length < 1) { - var command = { COMMAND: 10, LOGIN_NAME: auth_username, PASSWORD: auth_token, CART_NUMBER: destinationCart }; - $.post("/rd-bin/rdxport.cgi", command, function() { - console.log('done'); + var command = {COMMAND: 10, LOGIN_NAME: auth_username, PASSWORD: auth_token, CART_NUMBER: destinationCart}; + $.post("/rd-bin/rdxport.cgi", command, function(cutXml, status, req) { + var destinationCut = $('cutAdd cut cutNumber', cutXml).text(); + + // use command 18 copy audio from one cart to another + var command = { + COMMAND: 18, + LOGIN_NAME: auth_username, + PASSWORD: auth_token, + SOURCE_CART_NUMBER: self.cartNumber, + SOURCE_CUT_NUMBER: self.number, + DESTINATION_CART_NUMBER: destinationCart, + DESTINATION_CUT_NUMBER: destinationCut + }; + $.post("/rd-bin/rdxport.cgi", command, function() { + console.log('success.'); + + // then delete old cart + self.delete(); + + // auto update + $(self).trigger('remove'); + }, "xml").fail(function() { + console.log('fail.'); - // use command 18 copy audio from one cart to another + // delete + var command = {COMMAND: 11, LOGIN_NAME: auth_username, PASSWORD: auth_token, CART_NUMBER: destinationCart, CUT_NUMBER: destinationCut}; + $.post("/rd-bin/rdxport.cgi", command, null, "xml"); - // then delete old cart - //self.delete(); + }); - // auto update - $(self).trigger('remove'); - }, "xml"); - } }, "xml"); }; @@ -270,7 +278,7 @@ JingleCut.prototype.delete = function() { var command = { COMMAND: 11, LOGIN_NAME: auth_username, PASSWORD: auth_token, CART_NUMBER: this.cartNumber, CUT_NUMBER: this.number}; $.post("/rd-bin/rdxport.cgi", command, function() { $(self).trigger('remove'); - }); + }, "xml"); }; JingleCut.prototype.render = function() { -- cgit v0.10.2