summaryrefslogtreecommitdiff
path: root/www/js
diff options
context:
space:
mode:
Diffstat (limited to 'www/js')
-rw-r--r--www/js/rivendell.js36
-rw-r--r--www/js/rivendell.rh.js19
2 files changed, 35 insertions, 20 deletions
diff --git a/www/js/rivendell.js b/www/js/rivendell.js
index 9c25e1c..93c37f6 100644
--- a/www/js/rivendell.js
+++ b/www/js/rivendell.js
@@ -174,13 +174,23 @@ Rivendell.Rivendell.prototype.editCut = function(cartNumber, cutNumber, options,
return $.post(this.rdxportEndpoint, options, success, "xml");
};
-Rivendell.Rivendell.prototype.removeCut = function(destinationCartNumber, destinationCutNumber, success) {
+Rivendell.Rivendell.prototype.addAndEditCut = function(cartNumber, options, success) {
+ var self = this;
+ var returnJqXHR = null;
+ return this.addCut(cartNumber, success)
+ .success(function(data, textStatus, jqXHR) {
+ var cutNumber = $('cutAdd cut cutNumber', data).text();
+ returnJqXHR = self.editCut(cartNumber, cutNumber, options, null);
+ });
+};
+
+Rivendell.Rivendell.prototype.removeCut = function(cartNumber, cutNumber, success) {
var command = {
COMMAND: 11,
LOGIN_NAME: this.username,
PASSWORD: this.token,
- CART_NUMBER: destinationCartNumber,
- CUT_NUMBER: destinationCutNumber
+ CART_NUMBER: cartNumber,
+ CUT_NUMBER: cutNumber
};
return $.post(this.rdxportEndpoint, command, success, 'xml');
};
@@ -197,13 +207,19 @@ Rivendell.Rivendell.prototype.removeCut = function(destinationCartNumber, destin
*/
Rivendell.Rivendell.prototype.copyCut = function(sourceCartNumber, sourceCutNumber,
destinationCartNumber, success) {
-
var self = this;
- var returnJqXHR;
- this.addCut(destinationCartNumber, function(data, textStatus, jqXHR) {
- var destinationCutNumber = $('cutAdd cut cutNumber', data).text();
- returnJqXHR = self.copyAudio(sourceCartNumber,sourceCutNumber, destinationCartNumber, destinationCutNumber, success).fail(function() {
- self.removeCut(destinationCartNumber, destinationCutNumber, null);
+ var returnJqXHR = null;
+ this.listCut(sourceCartNumber, sourceCutNumber, function(data, textStatus, jqXHR) {
+ var options = {
+ DESCRIPTION: $('cutList cut description', data).text()
+ // todo: add more options
+ };
+ self.addAndEditCut(destinationCartNumber, options, function(data, textStatus, jqXHR) {
+ var destinationCutNumber = $('cutAdd cut cutNumber', data).text();
+ returnJqXHR = self.copyAudio(sourceCartNumber,sourceCutNumber, destinationCartNumber, destinationCutNumber, success)
+ .fail(function() {
+ self.removeCut(destinationCartNumber, destinationCutNumber, null);
+ });
});
});
return returnJqXHR;
@@ -219,7 +235,7 @@ Rivendell.Rivendell.prototype.copyCut = function(sourceCartNumber, sourceCutNumb
Rivendell.Rivendell.prototype.moveCut = function(sourceCartNumber, sourceCutNumber,
destinationCartNumber, success) {
var self = this;
- var returnJqXHR;
+ var returnJqXHR = null;
this.copyCut(sourceCartNumber, sourceCutNumber, destinationCartNumber, function(data, textStatus, jqXHR) {
returnJqXHR = self.removeCut(sourceCartNumber, sourceCutNumber, success);
});
diff --git a/www/js/rivendell.rh.js b/www/js/rivendell.rh.js
index 8f030d2..136440c 100644
--- a/www/js/rivendell.rh.js
+++ b/www/js/rivendell.rh.js
@@ -34,14 +34,13 @@ Rivendell.Rivendell.prototype.listDropboxes = function(success) {
return $.post(this.listDropboxesEndpoint, command, success, 'xml');
};
-Rivendell.Rivendell.prototype.addCut = function(cartNumber, description, success) {
- var command = {
- COMMAND: 10,
- LOGIN_NAME: this.username,
- PASSWORD: this.token,
- CART_NUMBER: cartNumber,
- DESCRIPTION: description
- // todo: add more optionals
- };
- return $.post(this.rdxportEndpoint, command, success, 'xml');
+// see: https://github.com/ElvishArtisan/rivendell/pull/73
+Rivendell.Rivendell.prototype.addAndEditCut = function(cartNumber, options, success) {
+ options.COMMAND = 10;
+ options.LOGIN_NAME = this.username;
+ options.PASSWORD = this.token;
+ options.CART_NUMBER = cartNumber;
+ return $.post(this.rdxportEndpoint, options, success, "xml");
};
+
+// todo: addAndEditCart