diff options
Diffstat (limited to 'www')
-rw-r--r-- | www/js/jingles.js | 50 |
1 files changed, 29 insertions, 21 deletions
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() { |