diff options
author | Peter Grassberger <petertheone@gmail.com> | 2015-09-23 14:38:34 (GMT) |
---|---|---|
committer | Peter Grassberger <petertheone@gmail.com> | 2015-09-23 14:38:34 (GMT) |
commit | 69636e8eed5da4393d6c4445835bd811faa246aa (patch) | |
tree | c235427355b3ec296775cf60de8349076fca62c2 /www | |
parent | d1b79c223f072a3d620b66fe76fa28f8f05b805d (diff) |
rivendell.js functions: add remove copy move cut, copy audio
jingle toggleActive and add .aac to acceptedFiles.
Diffstat (limited to 'www')
-rw-r--r-- | www/index.html | 4 | ||||
-rw-r--r-- | www/js/jingles.js | 44 | ||||
-rw-r--r-- | www/js/rivendell.js | 64 | ||||
-rw-r--r-- | www/js/shows.js | 2 |
4 files changed, 84 insertions, 30 deletions
diff --git a/www/index.html b/www/index.html index 41fb293..084a183 100644 --- a/www/index.html +++ b/www/index.html @@ -19,8 +19,8 @@ <script src="/javascript/twitter-bootstrap/js/bootstrap.min.js"></script> <script src="/javascript/twitter-bootstrap/js/bootstrap-alert.min.js"></script> <script src="/javascript/twitter-bootstrap/js/bootstrap-modal.min.js"></script> - <script src="/js/dropzone.js"></script> - <script src="/js/rivendell.js"></script> + <script src="/js/dropzone.js"></script> + <script src="/js/rivendell.js"></script> <script src="/js/utils.js"></script> <script src="/js/clock.js"></script> <script src="/js/auth.js"></script> 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); }); }}); |