summaryrefslogtreecommitdiff
path: root/www/js
diff options
context:
space:
mode:
authorPeter Grassberger <petertheone@gmail.com>2015-09-04 16:28:19 (GMT)
committerPeter Grassberger <petertheone@gmail.com>2015-09-04 16:28:19 (GMT)
commit77376357c285265546107e66b4c6949a8fe6f09e (patch)
tree5a9e72674deced9b0c14d7f484fbc5603f62a3aa /www/js
parent7dfedffd34b8096bcf3c0b5bc96b4cca8095f862 (diff)
render jingleGroups from template
Diffstat (limited to 'www/js')
-rw-r--r--www/js/jingles.js46
1 files changed, 26 insertions, 20 deletions
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