summaryrefslogtreecommitdiff
path: root/www/js
diff options
context:
space:
mode:
Diffstat (limited to 'www/js')
-rw-r--r--www/js/jingles.js21
-rw-r--r--www/js/rivendell.js33
-rw-r--r--www/js/rivendell.rh.js35
3 files changed, 72 insertions, 17 deletions
diff --git a/www/js/jingles.js b/www/js/jingles.js
index 16fbf8d..04d7fe6 100644
--- a/www/js/jingles.js
+++ b/www/js/jingles.js
@@ -27,7 +27,8 @@ var jinglesGroupList = null;
var importer = null;
function jingles_init() {
- rivendell = new Rivendell.Rivendell(auth_username, auth_token);
+ rivendell = new Rivendell.Rivendell(auth_username, auth_token, '/rd-bin/rdxport.cgi');
+ rivendell.setListDropboxesEndpoint('/rh-bin/listdropboxes.cgi');
importer = new Importer();
jinglesGroupList = new JingleGroupList();
jinglesGroupList.fetch();
@@ -54,8 +55,7 @@ JingleGroupList.prototype.fetch = function() {
this.groups = [];
var self = this;
- var command = { LOGIN_NAME: auth_username, PASSWORD: auth_token };
- $.post("/rh-bin/listdropboxes.cgi", command, function(groupsXml, status, req) {
+ rivendell.listDropboxes(function(groupsXml, status, req) {
var dbs = $(groupsXml).find("dropboxList").children();
dbs.each(function(index, groupXml) {
if ($('type', groupXml).text() !== 'jingle') {
@@ -86,7 +86,7 @@ JingleGroupList.prototype.fetch = function() {
self.groups.push(jingleGroup);
});
- }, "xml");
+ });
};
JingleGroupList.prototype.render = function() {
@@ -121,15 +121,13 @@ var JingleGroup = function(title, groupName, description, lowcart, highcart, nor
JingleGroup.prototype.fetchCarts = function() {
console.log('JingleGroup.prototype.fetchCarts');
var self = this;
- var command1 = { COMMAND: 7, LOGIN_NAME: auth_username, PASSWORD: auth_token, CART_NUMBER: this.lowcart, INCLUDE_CUTS: 1 };
- var command2 = { COMMAND: 7, LOGIN_NAME: auth_username, PASSWORD: auth_token, CART_NUMBER: this.highcart, INCLUDE_CUTS: 1 };
$.when(
- $.post("/rd-bin/rdxport.cgi", command1, function(cartXml) {
+ rivendell.listCart(this.lowcart, 1, function(cartXml) {
self.mainCart = self.createCartFromXml(cartXml, true);
- }, "xml"),
- $.post("/rd-bin/rdxport.cgi", command2, function(cartXml) {
+ }),
+ rivendell.listCart(this.highcart, 1, function(cartXml) {
self.deactivateCart = self.createCartFromXml(cartXml, false);
- }, "xml")
+ })
).then(function() {
$(self.mainCart).on('add', function() {
$(self).trigger('add');
@@ -341,8 +339,7 @@ var Importer = function() {
Importer.prototype.importAddCut = function(cart, dz, file) {
// todo: set additional parameters like DESCRIPTION here, when patch has been applied.
- var data = { COMMAND: 10, LOGIN_NAME: auth_username, PASSWORD: auth_token, CART_NUMBER: cart.number, DESCRIPTION: 'test' };
- $.post("/rd-bin/rdxport.cgi", data, null, "xml").done(function(cutXml) {
+ rivendell.addCut(cart.number, function(cutXml) {
var cutNumber = $(cutXml).find('cutNumber').text();
dz.on('sending', function(file, xhr, formData) {
formData.append('COMMAND', 2);
diff --git a/www/js/rivendell.js b/www/js/rivendell.js
index 1531de2..27871f1 100644
--- a/www/js/rivendell.js
+++ b/www/js/rivendell.js
@@ -24,9 +24,21 @@
var Rivendell = Rivendell || {};
-Rivendell.Rivendell = function(username, token) {
+Rivendell.Rivendell = function(username, token, rdxportEndpoint) {
this.username = username;
- this.token = token
+ this.token = token;
+ this.rdxportEndpoint = rdxportEndpoint;
+};
+
+Rivendell.Rivendell.prototype.listCart = function(cartNumber, includeCuts, success) {
+ var command = {
+ COMMAND: 7,
+ LOGIN_NAME: this.username,
+ PASSWORD: this.token,
+ CART_NUMBER: cartNumber,
+ INCLUDE_CUTS: includeCuts
+ };
+ return $.post(this.rdxportEndpoint, command, success);
};
Rivendell.Rivendell.prototype.addCut = function(cartNumber, success) {
@@ -36,7 +48,7 @@ Rivendell.Rivendell.prototype.addCut = function(cartNumber, success) {
PASSWORD: this.token,
CART_NUMBER: cartNumber
};
- return $.post("/rd-bin/rdxport.cgi", command, success, 'xml');
+ return $.post(this.rdxportEndpoint, command, success, 'xml');
};
Rivendell.Rivendell.prototype.removeCut = function(destinationCartNumber, destinationCutNumber, success) {
@@ -47,11 +59,22 @@ Rivendell.Rivendell.prototype.removeCut = function(destinationCartNumber, destin
CART_NUMBER: destinationCartNumber,
CUT_NUMBER: destinationCutNumber
};
- return $.post("/rd-bin/rdxport.cgi", command, success, 'xml');
+ return $.post(this.rdxportEndpoint, command, success, 'xml');
};
+/**
+ *
+ * todo: copy description and other data.
+ *
+ * @param sourceCartNumber
+ * @param sourceCutNumber
+ * @param destinationCartNumber
+ * @param success
+ * @returns {*}
+ */
Rivendell.Rivendell.prototype.copyCut = function(sourceCartNumber, sourceCutNumber,
destinationCartNumber, success) {
+
var self = this;
var returnJqXHR;
this.addCut(destinationCartNumber, function(data, textStatus, jqXHR) {
@@ -91,5 +114,5 @@ Rivendell.Rivendell.prototype.copyAudio = function(sourceCartNumber, sourceCutNu
DESTINATION_CART_NUMBER: destinationCartNumber,
DESTINATION_CUT_NUMBER: destinationCutNumber
};
- return $.post("/rd-bin/rdxport.cgi", command, success, 'xml');
+ return $.post(this.rdxportEndpoint, command, success, 'xml');
};
diff --git a/www/js/rivendell.rh.js b/www/js/rivendell.rh.js
new file mode 100644
index 0000000..04897b0
--- /dev/null
+++ b/www/js/rivendell.rh.js
@@ -0,0 +1,35 @@
+/*
+ * rhwebimport
+ *
+ * Copyright (C) 2014-2015 Christian Pointner <equinox@helsinki.at>
+ * Copyright (C) 2015 Peter Grassberger <petertheone@gmail.at>
+ *
+ * This file is part of rhwebimport.
+ *
+ * rhwebimport is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * rhwebimport is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with rhwebimport. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+"use strict";
+
+Rivendell.Rivendell.prototype.setListDropboxesEndpoint = function(listDropboxesEndpoint) {
+ this.listDropboxesEndpoint = listDropboxesEndpoint;
+};
+
+Rivendell.Rivendell.prototype.listDropboxes = function(success) {
+ var command = {
+ LOGIN_NAME: this.username,
+ PASSWORD: this.token
+ };
+ return $.post(this.listDropboxesEndpoint, command, success, 'xml');
+};