diff options
Diffstat (limited to 'www/js')
-rw-r--r-- | www/js/jingles.js | 1 | ||||
-rw-r--r-- | www/js/rivendell.js | 43 | ||||
-rw-r--r-- | www/js/shows.js | 45 |
3 files changed, 71 insertions, 18 deletions
diff --git a/www/js/jingles.js b/www/js/jingles.js index 04d7fe6..e8975ae 100644 --- a/www/js/jingles.js +++ b/www/js/jingles.js @@ -39,6 +39,7 @@ function jingles_cleanup() { jinglesGroupList.destroy(); jinglesGroupList = null; } + rivendell = null; } var JingleGroupList = function() { diff --git a/www/js/rivendell.js b/www/js/rivendell.js index 27871f1..d303620 100644 --- a/www/js/rivendell.js +++ b/www/js/rivendell.js @@ -30,6 +30,16 @@ Rivendell.Rivendell = function(username, token, rdxportEndpoint) { this.rdxportEndpoint = rdxportEndpoint; }; +Rivendell.Rivendell.prototype.listLog = function(name, success) { + var command = { + COMMAND: 22, + LOGIN_NAME: this.username, + PASSWORD: this.token, + NAME: shows_current.log + }; + return $.post(this.rdxportEndpoint, command, success, "xml"); +}; + Rivendell.Rivendell.prototype.listCart = function(cartNumber, includeCuts, success) { var command = { COMMAND: 7, @@ -41,6 +51,39 @@ Rivendell.Rivendell.prototype.listCart = function(cartNumber, includeCuts, succe return $.post(this.rdxportEndpoint, command, success); }; +Rivendell.Rivendell.prototype.listCarts = function(groupName, includeCuts, success) { + var command = { + COMMAND: 6, + LOGIN_NAME: this.username, + PASSWORD: this.token, + GROUP_NAME: groupName, + INCLUDE_CUTS: includeCuts + }; + return $.post(this.rdxportEndpoint, command, success, "xml"); +}; + +Rivendell.Rivendell.prototype.addCart = function(groupName, type, cartNumber, success) { + var command = { + COMMAND: 12, + LOGIN_NAME: this.username, + PASSWORD: this.token, + GROUP_NAME: groupName, + TYPE: type, + CART_NUMBER: cartNumber + }; + return $.post(this.rdxportEndpoint, command, success, "xml"); +}; + +Rivendell.Rivendell.prototype.removeCart = function(cartNumber, success) { + var command = { + COMMAND: 13, + LOGIN_NAME: this.username, + PASSWORD: this.token, + CART_NUMBER: cartNumber + }; + return $.post(this.rdxportEndpoint, command, success, "xml"); +}; + Rivendell.Rivendell.prototype.addCut = function(cartNumber, success) { var command = { COMMAND: 10, diff --git a/www/js/shows.js b/www/js/shows.js index 33beb60..1dde924 100644 --- a/www/js/shows.js +++ b/www/js/shows.js @@ -20,6 +20,7 @@ * along with rhwebimport. If not, see <http://www.gnu.org/licenses/>. */ +var rivendell = null; var shows_currentid; var shows_list = []; var shows_current; @@ -29,21 +30,25 @@ var shows_clock; function shows_deleteCart(cart) { - data = { COMMAND: 13, LOGIN_NAME: auth_username, PASSWORD: auth_token, CART_NUMBER: cart }; - $.post("/rd-bin/rdxport.cgi", data, null, "xml").done(function() { shows_updateGroupCartInfo(cart); }); + rivendell.removeCart(cart, function() { + shows_updateGroupCartInfo(cart); + }); } function shows_importAddCut(cart, dz, file) { - data = { COMMAND: 10, LOGIN_NAME: auth_username, PASSWORD: auth_token, CART_NUMBER: cart }; - $.post("/rd-bin/rdxport.cgi", data, null, "xml").done(function() { dz.processQueue(); }) - .fail(function(xhr, status, err) { shows_importFileUploadError(cart, dz, file, err, xhr); }); + rivendell.addCut(cart, function() { + dz.processQueue(); + }).fail(function(xhr, status, err) { + shows_importFileUploadError(cart, dz, file, err, xhr); + }); } function shows_importAddCart(cart, dz, file) { - data = { COMMAND: 12, LOGIN_NAME: auth_username, PASSWORD: auth_token, - GROUP_NAME: shows_current.group.name, TYPE: 'audio', CART_NUMBER: cart }; - $.post("/rd-bin/rdxport.cgi", data, null, "xml").done(function() { shows_importAddCut(cart, dz, file); }) - .fail(function(xhr, status, err) { shows_importFileUploadError(cart, dz, file, err, xhr); }); + rivendell.addCart(shows_current.group.name, 'audio', cart, function() { + shows_importAddCut(cart, dz, file); + }).fail(function(xhr, status, err) { + shows_importFileUploadError(cart, dz, file, err, xhr); + }); } function shows_importCartCancel(cart, dz) { @@ -206,10 +211,13 @@ function shows_newImportErrorEntry(cart, msg) { } function shows_updateGroupCartInfo(cart) { - data = { COMMAND: 7, LOGIN_NAME: auth_username, PASSWORD: auth_token, CART_NUMBER: cart, INCLUDE_CUTS: 1 }; - $.post("/rd-bin/rdxport.cgi", data, shows_updateGroupCartList, "xml") - .fail(function() { delete shows_group_carts[cart]; shows_redrawCartEntry(cart); }) - .done(function() { shows_redrawCartEntry(cart); }); + rivendell.listCart(cart, 1, function(data) { + shows_updateGroupCartList(data); + shows_redrawCartEntry(cart); + }).fail(function() { + delete shows_group_carts[cart]; + shows_redrawCartEntry(cart); + }); } function shows_redrawCartEntry(cart) { @@ -223,7 +231,7 @@ function shows_updateCartListing() { }); } -function shows_updateGroupCartList(data, status, req) { +function shows_updateGroupCartList(data) { var cartlist = $(data).find("cartList"); var carts = cartlist.children(); carts.each(function() { @@ -268,12 +276,10 @@ function shows_showSelected() { $('#show-length').text(shows_current.length + ' Min.'); shows_log_carts = []; - data = { COMMAND: 22, LOGIN_NAME: auth_username, PASSWORD: auth_token, NAME: shows_current.log }; - lcd = $.post("/rd-bin/rdxport.cgi", data, shows_updateLogCartList, "xml"); + var lcd = rivendell.listLog(shows_current.log, shows_updateLogCartList); shows_group_carts = {}; - data = { COMMAND: 6, LOGIN_NAME: auth_username, PASSWORD: auth_token, GROUP_NAME: shows_current.group.name, INCLUDE_CUTS: 1 }; - gcd = $.post("/rd-bin/rdxport.cgi", data, shows_updateGroupCartList, "xml"); + var gcd = rivendell.listCarts(shows_current.group.name, 1, shows_updateGroupCartList); $.when(lcd, gcd).done( function(lcres, gcres) { @@ -322,6 +328,8 @@ function shows_updateList(data, status, req) { } function shows_init() { + rivendell = new Rivendell.Rivendell(auth_username, auth_token, '/rd-bin/rdxport.cgi'); + rivendell.setListDropboxesEndpoint('/rh-bin/listdropboxes.cgi'); shows_currentid = sessionStorage.getItem("shows_currentid"); shows_list = []; data = { LOGIN_NAME: auth_username, PASSWORD: auth_token }; @@ -337,4 +345,5 @@ function shows_cleanup() { shows_list = []; shows_group_carts = {}; shows_log_carts = []; + rivendell = null; } |