summaryrefslogtreecommitdiff
path: root/www/js/jingles.js
diff options
context:
space:
mode:
Diffstat (limited to 'www/js/jingles.js')
-rw-r--r--www/js/jingles.js29
1 files changed, 10 insertions, 19 deletions
diff --git a/www/js/jingles.js b/www/js/jingles.js
index 16fbf8d..112772d 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();
@@ -38,6 +39,7 @@ function jingles_cleanup() {
jinglesGroupList.destroy();
jinglesGroupList = null;
}
+ rivendell = null;
}
var JingleGroupList = function() {
@@ -50,12 +52,10 @@ var JingleGroupList = function() {
};
JingleGroupList.prototype.fetch = function() {
- console.log('JingleGroupList.prototype.fetchGroups');
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,11 +86,10 @@ JingleGroupList.prototype.fetch = function() {
self.groups.push(jingleGroup);
});
- }, "xml");
+ });
};
JingleGroupList.prototype.render = function() {
- console.log('JingleGroupList.prototype.render');
$('#app-jingles .groups').html('');
$(this.groups).each(function(index, group) {
group.render();
@@ -119,17 +118,14 @@ 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');
@@ -180,7 +176,6 @@ JingleGroup.prototype.createCartFromXml = function(cartXml, active) {
};
JingleGroup.prototype.render = function() {
- console.log('JingleGroup.prototype.render');
var self = this;
this.$el = $('.jingleGroupTemplate').clone().removeClass('jingleGroupTemplate');
@@ -275,7 +270,6 @@ JingleCut.prototype.delete = function() {
};
JingleCut.prototype.render = function() {
- console.log('JingleCut.prototype.render');
var moveButton = $('<button class="btn btn-info btn-mini"><i class="icon-arrow-right icon-white"></i> Verschieben</button>');
var activateButton;
@@ -341,8 +335,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);
@@ -442,8 +435,6 @@ Importer.prototype.importFileSelectError = function(dropzone, file, msg) {
};
Importer.prototype.showUploadModal = function(cart) {
- console.log('Importer.prototype.showUploadModal');
-
var uploadModal = $('#uploadModal');
$('div.modal-header h3', uploadModal).text("Datei auswählen...");
var form = $('<form>');