diff options
Diffstat (limited to 'www')
-rw-r--r-- | www/index.html | 22 | ||||
-rw-r--r-- | www/js/jingles.js | 46 |
2 files changed, 30 insertions, 38 deletions
diff --git a/www/index.html b/www/index.html index 2113854..a7a2d6b 100644 --- a/www/index.html +++ b/www/index.html @@ -147,10 +147,11 @@ <div id="app-jingles" class="container-fluid"> <div class="alertbox"></div> - <div class="row-fluid"> + + <div class="row-fluid jingleGroupTemplate hidden"> <div class="span12"> <div class="row-fluid"> - <div class="span12" id="jingles-jingAllgem"> + <div class="span12"> <h2></h2> <table class="table table-striped"> <thead> @@ -166,23 +167,8 @@ </div> </div> </div> - <div class="row-fluid"> - <div class="span12" id="jingles-jingAnlass"> - <h2></h2> - <table class="table table-striped"> - <thead> - <tr> - <th>Cut #</th> - <th>Titel</th> - <th>Aktionen</th> - </tr> - </thead> - <tbody> - </tbody> - </table> - </div> - </div> </div> + </div> <div id="app-musicpools" class="container-fluid"> diff --git a/www/js/jingles.js b/www/js/jingles.js index 2298663..00de8d5 100644 --- a/www/js/jingles.js +++ b/www/js/jingles.js @@ -68,6 +68,8 @@ var JingleGroup = function(title, groupName, description, lowcart, highcart, nor this.mainCart = null; this.deactivateCart = null; + this.$el = null; + var self = this; $(this).on('change', function() { console.log('JingleGroup change!'); @@ -82,6 +84,15 @@ var JingleGroup = function(title, groupName, description, lowcart, highcart, nor JingleGroup.prototype.render = function() { console.log('render JingleGroup'); + // todo: copy some kind of template and render.. + if (!this.$el) { + this.$el = $('.jingleGroupTemplate').clone().removeClass('jingleGroupTemplate'); + this.$el.removeClass('hidden').appendTo('#app-jingles'); + } + + $('h2', this.$el).html(this.title); + $('table tbody tr', this.$el).remove(); + var cuts = []; if (this.mainCart && this.deactivateCart) { cuts = $.merge(this.mainCart.cuts, this.deactivateCart.cuts); @@ -93,19 +104,10 @@ JingleGroup.prototype.render = function() { return a.title < b.title; }); - if (this.groupName === 'jingAllgem') { - $('#jingles-jingAllgem h2').html(this.title); - $('#jingles-jingAllgem table tbody tr').remove(); - $.each(cuts, function(index, cut) { - $('#jingles-jingAllgem table > tbody').append(cut.render()); - }); - } else if (this.groupName === 'jingAnlass') { - $('#jingles-jingAnlass h2').html(this.title); - $('#jingles-jingAnlass table tbody tr').remove(); - $.each(cuts, function(index, cut) { - $('#jingles-jingAnlass table > tbody').append(cut.render()); - }); - } + var self = this; + $.each(cuts, function(index, cut) { + $('table > tbody', self.$el).append(cut.render()); + }); }; JingleGroup.prototype.fetchCarts = function() { @@ -194,6 +196,7 @@ JingleCut.prototype.move = function() { console.log(parseInt(this.cartNumber)); console.log(destinationCart); + var self = this; var command = { COMMAND: 9, LOGIN_NAME: auth_username, PASSWORD: auth_token, CART_NUMBER: destinationCart }; $.post("/rd-bin/rdxport.cgi", command, function(cutsXml, status, req) { var cuts = $(cutsXml).find("cutList").children(); @@ -203,17 +206,20 @@ JingleCut.prototype.move = function() { if (cuts.length < 1) { var command = { COMMAND: 10, LOGIN_NAME: auth_username, PASSWORD: auth_token, CART_NUMBER: destinationCart }; - $.post("/rd-bin/rdxport.cgi", command, null, "xml").done(function() { + $.post("/rd-bin/rdxport.cgi", command, function() { console.log('done'); - }); - } - }, "xml"); + // use command 18 copy audio from one cart to another - // use command 18 copy audio from one cart to another + // then delete old cart + self.delete(); + // auto update + //$(this).trigger('change'); + }, "xml"); + } + }, "xml"); - //$(this).trigger('change'); }; JingleCut.prototype.toggleActivate = function() { @@ -223,7 +229,7 @@ JingleCut.prototype.toggleActivate = function() { //$(this).trigger('change'); }; -JingleCut.prototype.delete = function(self) { +JingleCut.prototype.delete = function() { console.log('delete'); // remove cut, command 11 |