summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--www/js/jingles.js70
-rw-r--r--www/js/rivendell.js4
2 files changed, 26 insertions, 48 deletions
diff --git a/www/js/jingles.js b/www/js/jingles.js
index b95eeb1..b40c973 100644
--- a/www/js/jingles.js
+++ b/www/js/jingles.js
@@ -228,53 +228,33 @@ var JingleCut = function(cart, cartNumber, name, description, active) {
};
JingleCut.prototype.move = function() {
- console.log('JingleCut.prototype.move');
- // move to other group, if active stay in mainCart, if deactivated stay in deactivateCart
-
- // todo: remove hardcoded cartNumbers
- var destinationCart = ((parseInt(this.cartNumber) - 2000 + 2) % 4) + 2000;
- //console.log(parseInt(this.cartNumber));
- //console.log(destinationCart);
-
- 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.');
-
- // 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");
-
+ var self = this;
+ var destinationCart = this.cartNumber;
+ // todo: make this work for multiple groups
+ if (jinglesGroupList.groups.length === 2) {
+ $(jinglesGroupList.groups).each(function(index, group) {
+ if (self.active) {
+ if (self.cartNumber !== group.mainCart.number) {
+ destinationCart = group.mainCart.number;
+ }
+ } else {
+ if (self.cartNumber !== group.deactivateCart.number) {
+ destinationCart = group.deactivateCart.number;
+ }
+ }
});
+ } else {
+ return;
+ }
- }, "xml");
+ // todo: fix
+ rivendell.moveCut(this.cartNumber, this.number, destinationCart, function() {
+ $(self).trigger('add');
+ });
};
JingleCut.prototype.toggleActive = function() {
- console.log('JingleCut.prototype.toggleActive');
- // move to other cart, from mainCart to deactiveCart or the other way around
-
var destinationCart = this.cartNumber;
if (this.active) {
destinationCart++;
@@ -288,13 +268,10 @@ JingleCut.prototype.toggleActive = function() {
};
JingleCut.prototype.delete = function() {
- console.log('JingleCut.prototype.delete');
-
var self = this;
- 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() {
+ rivendell.removeCut(this.cartNumber, this.number, function() {
$(self).trigger('remove');
- }, "xml");
+ });
};
JingleCut.prototype.render = function() {
@@ -311,7 +288,6 @@ JingleCut.prototype.render = function() {
var self = this;
moveButton.on('click', function() {
- console.log('m0ve!');
self.move();
});
activateButton.on('click', function() {
diff --git a/www/js/rivendell.js b/www/js/rivendell.js
index 4de038e..18d28af 100644
--- a/www/js/rivendell.js
+++ b/www/js/rivendell.js
@@ -55,7 +55,9 @@ Rivendell.Rivendell.prototype.copyCut = function(sourceCartNumber, sourceCutNumb
var self = this;
this.addCut(destinationCartNumber, function(data, textStatus, jqXHR) {
var destinationCutNumber = $('cutAdd cut cutNumber', data).text();
- self.copyAudio(sourceCartNumber,sourceCutNumber, destinationCartNumber, destinationCutNumber, success);
+ self.copyAudio(sourceCartNumber,sourceCutNumber, destinationCartNumber, destinationCutNumber, success).fail(function() {
+ self.removeCut(destinationCartNumber, destinationCutNumber, null);
+ });
});
};