summaryrefslogtreecommitdiff
path: root/www/js
diff options
context:
space:
mode:
Diffstat (limited to 'www/js')
-rw-r--r--www/js/jingles.js44
-rw-r--r--www/js/rivendell.js64
-rw-r--r--www/js/shows.js2
3 files changed, 82 insertions, 28 deletions
diff --git a/www/js/jingles.js b/www/js/jingles.js
index 599870d..b95eeb1 100644
--- a/www/js/jingles.js
+++ b/www/js/jingles.js
@@ -22,10 +22,12 @@
"use strict";
+var rivendell = null;
var jinglesGroupList = null;
var importer = null;
function jingles_init() {
+ rivendell = new Rivendell.Rivendell(auth_username, auth_token);
importer = new Importer();
jinglesGroupList = new JingleGroupList();
jinglesGroupList.fetch();
@@ -191,27 +193,6 @@ JingleGroup.prototype.render = function() {
importer.showUploadModal(self.mainCart);
});
- // todo: fix
- /*var cuts = [];
- if (this.mainCart && this.deactivateCart) {
- cuts = $.merge(this.mainCart.cuts, this.deactivateCart.cuts);
- } else if (this.mainCart) {
- cuts = this.mainCart.cuts;
- } else if (this.deactivateCart) {
- cuts = this.deactivateCart.cuts;
- }
- console.log(cuts);
- cuts = cuts.sort(function(a, b) {
- if (a.title && b.title) {
- return a.title.toLowerCase() < b.title.toLowerCase();
- }
- return a.title < b.title;
- });
-
- var self = this;
- $.each(cuts, function(index, cut) {
- $('table > tbody', self.$el).append(cut.render());
- });*/
if (this.mainCart) {
$.each(this.mainCart.cuts, function(index, cut) {
$('table > tbody', self.$el).append(cut.render());
@@ -248,7 +229,7 @@ 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 deactiveCart
+ // 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;
@@ -290,11 +271,20 @@ JingleCut.prototype.move = function() {
};
-JingleCut.prototype.toggleActivate = function() {
- console.log('JingleCut.prototype.toggleActivate');
+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++;
+ } else {
+ destinationCart--;
+ }
+ var self = this;
+ rivendell.moveCut(this.cartNumber, this.number, destinationCart, function() {
+ $(self).trigger('add');
+ });
};
JingleCut.prototype.delete = function() {
@@ -325,7 +315,7 @@ JingleCut.prototype.render = function() {
self.move();
});
activateButton.on('click', function() {
- self.toggleActivate();
+ self.toggleActive();
});
deleteButton.on('click', function() {
self.delete();
@@ -491,7 +481,7 @@ Importer.prototype.showUploadModal = function(cart) {
uploadMultiple: false, // todo: maybe enable this?
clickable: true,
createImageThumbnails: false,
- acceptedFiles: '.flac,.wav,.ogg,.mp3,.m4a',
+ acceptedFiles: '.flac,.wav,.ogg,.mp3,.m4a,.aac',
autoProcessQueue: false,
init: function() {
this.on("addedfile", function(file) {
diff --git a/www/js/rivendell.js b/www/js/rivendell.js
index eb3d99f..4de038e 100644
--- a/www/js/rivendell.js
+++ b/www/js/rivendell.js
@@ -23,3 +23,67 @@
"use strict";
var Rivendell = Rivendell || {};
+
+Rivendell.Rivendell = function(username, token) {
+ this.username = username;
+ this.token = token
+};
+
+Rivendell.Rivendell.prototype.addCut = function(cartNumber, success) {
+ var command = {
+ COMMAND: 10,
+ LOGIN_NAME: this.username,
+ PASSWORD: this.token,
+ CART_NUMBER: cartNumber
+ };
+ return $.post("/rd-bin/rdxport.cgi", command, success, 'xml');
+};
+
+Rivendell.Rivendell.prototype.removeCut = function(destinationCartNumber, destinationCutNumber, success) {
+ var command = {
+ COMMAND: 11,
+ LOGIN_NAME: this.username,
+ PASSWORD: this.token,
+ CART_NUMBER: destinationCartNumber,
+ CUT_NUMBER: destinationCutNumber
+ };
+ return $.post("/rd-bin/rdxport.cgi", command, success, 'xml');
+};
+
+Rivendell.Rivendell.prototype.copyCut = function(sourceCartNumber, sourceCutNumber,
+ destinationCartNumber, success) {
+ var self = this;
+ this.addCut(destinationCartNumber, function(data, textStatus, jqXHR) {
+ var destinationCutNumber = $('cutAdd cut cutNumber', data).text();
+ self.copyAudio(sourceCartNumber,sourceCutNumber, destinationCartNumber, destinationCutNumber, success);
+ });
+};
+
+/**
+ *
+ * @param sourceCartNumber
+ * @param sourceCutNumber
+ * @param destinationCartNumber
+ * @param success
+ */
+Rivendell.Rivendell.prototype.moveCut = function(sourceCartNumber, sourceCutNumber,
+ destinationCartNumber, success) {
+ var self = this;
+ this.copyCut(sourceCartNumber, sourceCutNumber, destinationCartNumber, function(data, textStatus, jqXHR) {
+ self.removeCut(sourceCartNumber, sourceCutNumber, success);
+ });
+};
+
+Rivendell.Rivendell.prototype.copyAudio = function(sourceCartNumber, sourceCutNumber,
+ destinationCartNumber, destinationCutNumber, success) {
+ var command = {
+ COMMAND: 18,
+ LOGIN_NAME: this.username,
+ PASSWORD: this.token,
+ SOURCE_CART_NUMBER: sourceCartNumber,
+ SOURCE_CUT_NUMBER: sourceCutNumber,
+ DESTINATION_CART_NUMBER: destinationCartNumber,
+ DESTINATION_CUT_NUMBER: destinationCutNumber
+ };
+ return $.post("/rd-bin/rdxport.cgi", command, success, 'xml');
+};
diff --git a/www/js/shows.js b/www/js/shows.js
index d14d99e..151eb36 100644
--- a/www/js/shows.js
+++ b/www/js/shows.js
@@ -130,7 +130,7 @@ function shows_importCart(cart) {
$('#uploadModal-confirm').attr('disabled','disabled').unbind('click');
var dz = form.dropzone({ url: "/rd-bin/rdxport.cgi", parallelUploads: 1, maxFilesize: 2048, paramName: 'FILENAME',
uploadMultiple: false, clickable: true, createImageThumbnails: false,
- acceptedFiles: ".flac,.wav,.ogg,.mp3,.m4a", autoProcessQueue: false, init: function() {
+ acceptedFiles: ".flac,.wav,.ogg,.mp3,.m4a,.aac", autoProcessQueue: false, init: function() {
this.on("addedfile", function(file) { shows_importFileAdded(this, file, cart); });
this.on("error", function(file, msg) { shows_importFileSelectError(this, file, msg); });
}});