From 3c584d7ee53ecfb35f32a2182971dfbc30009590 Mon Sep 17 00:00:00 2001 From: Peter Grassberger Date: Thu, 24 Mar 2016 16:10:12 +0100 Subject: refactor rdxportjs (breaks stuff) diff --git a/www/js/apps.js b/www/js/apps.js index e25c7d1..478fadd 100644 --- a/www/js/apps.js +++ b/www/js/apps.js @@ -22,7 +22,7 @@ 'use strict'; -var Rivendell = Rivendell || {}; +var Rdxport = Rdxport || {}; var apps_current = null; var rdxport = null; @@ -105,13 +105,13 @@ function apps_select(app) { } function apps_init() { - importer = new Rivendell.Importer(); + importer = new Rdxport.Importer(); apps_current = locationHrefValue(); if(auth_token && auth_username) { // todo: do this at a central place - rdxport = new Rivendell.Rdxport(auth_username, auth_token, '/rd-bin/rdxport.cgi'); + rdxport = new Rdxport.Rdxport(auth_username, auth_token, '/rd-bin/rdxport.cgi'); rdxport.setListDropboxesEndpoint('/rh-bin/listdropboxes.cgi'); rdxport.setMusicgridEndpoint('/rh-bin/musicgrid.cgi'); @@ -121,7 +121,7 @@ function apps_init() { $(window).on('popstate', function(event) { if(auth_token && auth_username) { // todo: do this at a central place - rdxport = new Rivendell.Rdxport(auth_username, auth_token, '/rd-bin/rdxport.cgi'); + rdxport = new Rdxport.Rdxport(auth_username, auth_token, '/rd-bin/rdxport.cgi'); rdxport.setListDropboxesEndpoint('/rh-bin/listdropboxes.cgi'); rdxport.setMusicgridEndpoint('/rh-bin/musicgrid.cgi'); diff --git a/www/js/auth.js b/www/js/auth.js index 77d7f53..d01b70d 100644 --- a/www/js/auth.js +++ b/www/js/auth.js @@ -22,7 +22,7 @@ 'use strict'; -var Rivendell = Rivendell || {}; +var Rdxport = Rdxport || {}; var auth_username = null; var auth_fullname = null; @@ -39,7 +39,7 @@ function auth_loginSuccess(data) { sessionStorage.setItem("auth_token", auth_token); // todo: do this at a central place - rdxport = new Rivendell.Rdxport(auth_username, auth_token, '/rd-bin/rdxport.cgi'); + rdxport = new Rdxport.Rdxport(auth_username, auth_token, '/rd-bin/rdxport.cgi'); rdxport.setListDropboxesEndpoint('/rh-bin/listdropboxes.cgi'); rdxport.setMusicgridEndpoint('/rh-bin/musicgrid.cgi'); @@ -94,7 +94,7 @@ function auth_init() { $("#loginform").submit(function(event) { event.preventDefault(); - Rivendell.Rdxport.authLogin( + Rdxport.Rdxport.authLogin( '/rh-bin/authtoken.json', $("#username").val(), $("#password").val(), diff --git a/www/js/clock.js b/www/js/clock.js index 0527680..96ec9e4 100644 --- a/www/js/clock.js +++ b/www/js/clock.js @@ -22,7 +22,7 @@ 'use strict'; -var Rivendell = Rivendell || {}; +var Rdxport = Rdxport || {}; function Clock() { this.draw_callbacks = $.Callbacks('unique'); diff --git a/www/js/importer.js b/www/js/importer.js index 5f7db6f..86f7947 100644 --- a/www/js/importer.js +++ b/www/js/importer.js @@ -22,21 +22,21 @@ 'use strict'; -var Rivendell = Rivendell || {}; +var Rdxport = Rdxport || {}; -Rivendell.Importer = function() { +Rdxport.Importer = function() { this.$el = $('#uploadModal'); this.uploads = []; }; -Rivendell.Importer.prototype.resetModal = function() { +Rdxport.Importer.prototype.resetModal = function() { $('div.modal-header h4', this.$el).text("Datei auswählen..."); $('.modal-body', this.$el).empty().css("background-image", "url('/img/dz-backdrop.png')"); $('#uploadModal-confirm', this.$el).attr('disabled','disabled').off('click'); }; -Rivendell.Importer.prototype.openModal = function(group, groupView, createCart, newCartNumber, useMetadata) { +Rdxport.Importer.prototype.openModal = function(group, groupView, createCart, newCartNumber, useMetadata) { createCart = typeof createCart === 'undefined' ? false : createCart; useMetadata = typeof useMetadata === 'undefined' ? false : useMetadata; @@ -74,7 +74,7 @@ Rivendell.Importer.prototype.openModal = function(group, groupView, createCart, $('div.modal-body', self.$el).css("background-image", "url('/img/audio_file.png')"); $('#uploadModal-confirm', self.$el).off('click').on('click', function() { - var upload = new Rivendell.Upload(group, groupView, createCart, newCartNumber, useMetadata, dropzone); + var upload = new Rdxport.Upload(group, groupView, createCart, newCartNumber, useMetadata, dropzone); self.uploads.push(upload); self.$el.off('hide.bs.modal'); @@ -86,7 +86,7 @@ Rivendell.Importer.prototype.openModal = function(group, groupView, createCart, this.$el.modal({keyboard: true}); }; -Rivendell.Importer.prototype.isUploading = function() { +Rdxport.Importer.prototype.isUploading = function() { var $result = false; $.each(this.uploads, function(index, upload) { if (upload && upload.isUploading()) { @@ -96,7 +96,7 @@ Rivendell.Importer.prototype.isUploading = function() { return $result; }; -Rivendell.Importer.prototype.cancelAllUploads = function() { +Rdxport.Importer.prototype.cancelAllUploads = function() { $.each(this.uploads, function(index, upload){ if (upload) { upload.cancel(); @@ -104,7 +104,7 @@ Rivendell.Importer.prototype.cancelAllUploads = function() { }); }; -Rivendell.Importer.prototype.removeUpload = function(upload) { +Rdxport.Importer.prototype.removeUpload = function(upload) { var self = this; $.each(this.uploads, function(index, currentUpload){ if(currentUpload === upload) { @@ -113,7 +113,7 @@ Rivendell.Importer.prototype.removeUpload = function(upload) { }); }; -Rivendell.Upload = function(group, groupView, createCart, newCartNumber, useMetadata, dropzone) { +Rdxport.Upload = function(group, groupView, createCart, newCartNumber, useMetadata, dropzone) { this.group = group; this.groupView = groupView; this.createCart = createCart; @@ -127,12 +127,12 @@ Rivendell.Upload = function(group, groupView, createCart, newCartNumber, useMeta this.import(); }; -Rivendell.Upload.prototype.isUploading = function() { +Rdxport.Upload.prototype.isUploading = function() { var files = this.dropzone.getUploadingFiles(); return files.length > 0; }; -Rivendell.Upload.prototype.cancel = function() { +Rdxport.Upload.prototype.cancel = function() { this.dropzone.off(Dropzone.ERROR); this.dropzone.removeAllFiles(true); this.dropzone.disable(); @@ -154,7 +154,7 @@ Rivendell.Upload.prototype.cancel = function() { importer.removeUpload(this); }; -Rivendell.Upload.prototype.import = function() { +Rdxport.Upload.prototype.import = function() { var self = this; this.dropzone.off('uploadprogress').on('uploadprogress', function(file) { @@ -174,14 +174,14 @@ Rivendell.Upload.prototype.import = function() { }); }; -Rivendell.Upload.prototype.addCart = function(success) { +Rdxport.Upload.prototype.addCart = function(success) { var files = this.dropzone.getAcceptedFiles(); var file = files[files.length - 1]; var self = this; if (this.createCart) { rdxport.addCart(this.group.groupName, 'audio', this.newCartNumber, function(cartXML) { - self.cart = new Rivendell.Cart(cartXML, self.group); + self.cart = new Rdxport.Cart(cartXML, self.group); success(file); }).fail(function() { //self.importFileUploadError(files[0], 'Failed to add Cart.'); @@ -190,9 +190,9 @@ Rivendell.Upload.prototype.addCart = function(success) { this.cart = this.group.carts[0]; success(file); } -} +}; -Rivendell.Upload.prototype.importFileUploadSuccess = function() { +Rdxport.Upload.prototype.importFileUploadSuccess = function() { this.dropzone.off(Dropzone.ERROR); this.dropzone.removeAllFiles(true); this.dropzone.disable(); @@ -202,18 +202,18 @@ Rivendell.Upload.prototype.importFileUploadSuccess = function() { this.group.fetchCarts(); }; -Rivendell.Upload.prototype.importFileUploadError = function(file, msg, xhr) { +Rdxport.Upload.prototype.importFileUploadError = function(file, msg, xhr) { var self = this; this.groupView.uploadError(this, file, msg, xhr, function() { self.cancel(); }); }; -Rivendell.Upload.prototype.addCut = function(file) { +Rdxport.Upload.prototype.addCut = function(file) { var self = this; rdxport.addAndEditCut(this.cart.number, {DESCRIPTION: file.name}, function(cutXml) { - self.cut = new Rivendell.Cut(cutXml, self.cart); + self.cut = new Rdxport.Cut(cutXml, self.cart); self.dropzone.on('sending', function(file, xhr, formData) { var cutNumber = $('cutNumber', cutXml).text(); diff --git a/www/js/jingles.js b/www/js/jingles.js index 4748df8..72522c4 100644 --- a/www/js/jingles.js +++ b/www/js/jingles.js @@ -22,13 +22,13 @@ 'use strict'; -var Rivendell = Rivendell || {}; +var Rdxport = Rdxport || {}; var jingleGroupListView = null; function jingles_init() { - var groupList = new Rivendell.GroupList(); - jingleGroupListView = new Rivendell.JingleGroupListView(groupList); + var groupList = new Rdxport.GroupList(); + jingleGroupListView = new Rdxport.JingleGroupListView(groupList); } function jingles_cleanup() { @@ -39,7 +39,7 @@ function jingles_cleanup() { } } -Rivendell.JingleGroupListView = function(model) { +Rdxport.JingleGroupListView = function(model) { this.model = model; this.jingleGroupViews = []; @@ -49,13 +49,13 @@ Rivendell.JingleGroupListView = function(model) { var self = this; $(this.model).on('update', function() { $(self.model.groups).each(function(index, group) { - self.jingleGroupViews.push(new Rivendell.JingleGroupView(group)); + self.jingleGroupViews.push(new Rdxport.JingleGroupView(group)); }); }); this.model.fetch('jingle'); }; -Rivendell.JingleGroupListView.prototype.destroy = function() { +Rdxport.JingleGroupListView.prototype.destroy = function() { var self = this; $(this.jingleGroupViews).each(function(index, groupView) { groupView.destroy(); @@ -63,19 +63,19 @@ Rivendell.JingleGroupListView.prototype.destroy = function() { this.jingleGroupViews = []; }; -Rivendell.JingleGroup = function(groupName, description, lowcart, highcart, normlevel, trimlevel, title) { +Rdxport.JingleGroup = function(groupName, description, lowcart, highcart, normlevel, trimlevel, title) { if (arguments.length = 1) { - Rivendell.Group.call(this, groupName); + Rdxport.Group.call(this, groupName); this.title = $('jingle-title', this.xml).text(); } else { - Rivendell.Group.call(this, groupName, description, lowcart, highcart, normlevel, trimlevel); + Rdxport.Group.call(this, groupName, description, lowcart, highcart, normlevel, trimlevel); this.title = title; } }; -Rivendell.JingleGroup.prototype = Object.create(Rivendell.Group.prototype); -Rivendell.JingleGroup.prototype.constructor = Rivendell.JingleGroup; +Rdxport.JingleGroup.prototype = Object.create(Rdxport.Group.prototype); +Rdxport.JingleGroup.prototype.constructor = Rdxport.JingleGroup; -Rivendell.JingleGroupView = function(model) { +Rdxport.JingleGroupView = function(model) { this.model = model; this.mainCartView = null; @@ -90,16 +90,16 @@ Rivendell.JingleGroupView = function(model) { $('table > tbody', self.$el).html(''); self.model.mainCart = self.model.carts[0]; - self.mainCartView = new Rivendell.JingleCartView(self.model.mainCart, self, true); + self.mainCartView = new Rdxport.JingleCartView(self.model.mainCart, self, true); self.model.deactivateCart = self.model.carts[1]; - self.deactivateCartView = new Rivendell.JingleCartView(self.model.deactivateCart, self, false); + self.deactivateCartView = new Rdxport.JingleCartView(self.model.deactivateCart, self, false); }); this.model.fetchCarts(); }; -Rivendell.JingleGroupView.prototype.render = function() { +Rdxport.JingleGroupView.prototype.render = function() { var self = this; this.$el = $('#hiddenTemplates .jingleGroupTemplate').clone().removeClass('jingleGroupTemplate'); @@ -113,11 +113,11 @@ Rivendell.JingleGroupView.prototype.render = function() { }); }; -Rivendell.JingleGroupView.prototype.destroy = function() { +Rdxport.JingleGroupView.prototype.destroy = function() { $('table > tbody', this.$el).html(''); }; -Rivendell.JingleGroupView.prototype.uploadProgress = function(upload, file) { +Rdxport.JingleGroupView.prototype.uploadProgress = function(upload, file) { if (!file.cartNumber || !file.cutNumber) { return; } @@ -147,7 +147,7 @@ Rivendell.JingleGroupView.prototype.uploadProgress = function(upload, file) { } }; -Rivendell.JingleGroupView.prototype.uploadError = function(upload, file, msg, xhr, acknowledge) { +Rdxport.JingleGroupView.prototype.uploadError = function(upload, file, msg, xhr, acknowledge) { if (!file.cartNumber || !file.cutNumber) { return; } @@ -182,7 +182,7 @@ Rivendell.JingleGroupView.prototype.uploadError = function(upload, file, msg, xh $('#jingle-' + file.cartNumber + '-' + file.cutNumber).replaceWith($errorRow); }; -Rivendell.JingleCartView = function(model, groupView, active) { +Rdxport.JingleCartView = function(model, groupView, active) { this.model = model; this.groupView = groupView; this.active = active; @@ -194,7 +194,7 @@ Rivendell.JingleCartView = function(model, groupView, active) { $(this.model.cuts).each(function(index, cut) { cut.active = self.active; - var cutView = new Rivendell.JingleCutView(cut); + var cutView = new Rdxport.JingleCutView(cut); self.cutViews.push(cutView); $('table > tbody', self.groupView.$el).append(cutView.$el); @@ -202,7 +202,7 @@ Rivendell.JingleCartView = function(model, groupView, active) { } }; -Rivendell.JingleCutView = function(model) { +Rdxport.JingleCutView = function(model) { this.model = model; this.$spinner = null; @@ -211,7 +211,7 @@ Rivendell.JingleCutView = function(model) { this.render(); }; -Rivendell.JingleCutView.prototype.render = function() { +Rdxport.JingleCutView.prototype.render = function() { var status = $(''); var moveButton = $(''); var activateButton; @@ -259,7 +259,7 @@ Rivendell.JingleCutView.prototype.render = function() { ); }; -Rivendell.JingleCutView.prototype.move = function() { +Rdxport.JingleCutView.prototype.move = function() { this.$el.find('td:first').html(this.$spinner); var self = this; var destinationCart = this.model.cartNumber; @@ -288,7 +288,7 @@ Rivendell.JingleCutView.prototype.move = function() { }); }; -Rivendell.JingleCutView.prototype.toggleActive = function() { +Rdxport.JingleCutView.prototype.toggleActive = function() { this.$el.find('td:first').html(this.$spinner); var destinationCart = this.model.cartNumber; if (this.model.active) { @@ -302,7 +302,7 @@ Rivendell.JingleCutView.prototype.toggleActive = function() { }); }; -Rivendell.JingleCutView.prototype.delete = function() { +Rdxport.JingleCutView.prototype.delete = function() { this.$el.find('td:first').html(this.$spinner); var self = this; rdxport.removeCut(this.model.cartNumber, this.model.number, function() { diff --git a/www/js/musicgrid.js b/www/js/musicgrid.js index 6a47bb9..dbb2210 100644 --- a/www/js/musicgrid.js +++ b/www/js/musicgrid.js @@ -22,17 +22,17 @@ 'use strict'; -var Rivendell = Rivendell || {}; +var Rdxport = Rdxport || {}; var musicgridView = null; var musicpoolModal = null; function musicgrid_init() { - var musicgrid = new Rivendell.Musicgrid(); - musicgridView = new Rivendell.MusicgridView(musicgrid); + var musicgrid = new Rdxport.Musicgrid(); + musicgridView = new Rdxport.MusicgridView(musicgrid); - var musicpools = new Rivendell.GroupList(); - musicpoolModal = new Rivendell.MusicpoolModal(musicpools); + var musicpools = new Rdxport.GroupList(); + musicpoolModal = new Rdxport.MusicpoolModal(musicpools); } function musicgrid_cleanup() { @@ -44,7 +44,7 @@ function musicgrid_cleanup() { musicgridView = null; } -Rivendell.MusicgridView = function(model) { +Rdxport.MusicgridView = function(model) { this.model = model; this.$el = $('#app-musicgrid table'); @@ -56,7 +56,7 @@ Rivendell.MusicgridView = function(model) { this.model.fetch(); }; -Rivendell.MusicgridView.prototype.clean = function() { +Rdxport.MusicgridView.prototype.clean = function() { $('tr td', this.$el) .html('') .removeClass('clock') @@ -65,7 +65,7 @@ Rivendell.MusicgridView.prototype.clean = function() { .attr('title', null); }; -Rivendell.MusicgridView.prototype.update = function() { +Rdxport.MusicgridView.prototype.update = function() { this.clean(); $(this.model.clocks).each(function(index, clock) { @@ -95,11 +95,11 @@ Rivendell.MusicgridView.prototype.update = function() { }); }; -Rivendell.MusicpoolModal = function(model) { +Rdxport.MusicpoolModal = function(model) { this.model = model; }; -Rivendell.MusicpoolModal.prototype.selectClock = function(dow, hour, clockName) { +Rdxport.MusicpoolModal.prototype.selectClock = function(dow, hour, clockName) { $('#musicpoolModal').modal({keyboard: true}); var $modalHeader = $('#musicpoolModal .modal-header'); diff --git a/www/js/musicpools.js b/www/js/musicpools.js index 1a2c78d..4449865 100644 --- a/www/js/musicpools.js +++ b/www/js/musicpools.js @@ -22,13 +22,13 @@ 'use strict'; -var Rivendell = Rivendell || {}; +var Rdxport = Rdxport || {}; var musicpoolsView = null; function musicpools_init() { - var musicpools = new Rivendell.GroupList(); - musicpoolsView = new Rivendell.MusicpoolsView(musicpools); + var musicpools = new Rdxport.GroupList(); + musicpoolsView = new Rdxport.MusicpoolsView(musicpools); } function musicpools_cleanup() { @@ -36,7 +36,7 @@ function musicpools_cleanup() { musicpoolsView = null; } -Rivendell.MusicpoolsView = function(model) { +Rdxport.MusicpoolsView = function(model) { this.model = model; this.musicpoolViews = []; @@ -45,7 +45,7 @@ Rivendell.MusicpoolsView = function(model) { var self = this; $(this.model).on('update', function() { $(self.model.groups).each(function(index, musicpool) { - var musicpoolView = new Rivendell.MusicpoolView(musicpool); + var musicpoolView = new Rdxport.MusicpoolView(musicpool); self.musicpoolViews.push(musicpoolView); }); self.updateSelector(); @@ -53,12 +53,12 @@ Rivendell.MusicpoolsView = function(model) { this.model.fetch('musicpool'); }; -Rivendell.MusicpoolsView.prototype.setCurrentPoolId = function(currentPoolId) { +Rdxport.MusicpoolsView.prototype.setCurrentPoolId = function(currentPoolId) { this.currentPoolId = currentPoolId; sessionStorage.setItem('currentPoolId', this.currentPoolId); }; -Rivendell.MusicpoolsView.prototype.getCurrentPoolView = function() { +Rdxport.MusicpoolsView.prototype.getCurrentPoolView = function() { if (this.model.groups.length === 0) { return null; } @@ -79,7 +79,7 @@ Rivendell.MusicpoolsView.prototype.getCurrentPoolView = function() { return musicpoolViewFound; }; -Rivendell.MusicpoolsView.prototype.updateSelector = function() { +Rdxport.MusicpoolsView.prototype.updateSelector = function() { var self = this; var $musicpoolSelector = $('#musicpool-selector'); @@ -104,21 +104,21 @@ Rivendell.MusicpoolsView.prototype.updateSelector = function() { this.getCurrentPoolView().model.fetchCarts(); }; -Rivendell.Musicpool = function(groupName, description, lowcart, highcart, normlevel, trimlevel, title, clock) { +Rdxport.Musicpool = function(groupName, description, lowcart, highcart, normlevel, trimlevel, title, clock) { if (arguments.length === 1) { - Rivendell.Group.call(this, groupName); + Rdxport.Group.call(this, groupName); this.title = $('musicpool-title', this.xml).text(); this.clock = $('musicpool-clock', this.xml).text(); } else { - Rivendell.Group.call(this, groupName, description, lowcart, highcart, normlevel, trimlevel); + Rdxport.Group.call(this, groupName, description, lowcart, highcart, normlevel, trimlevel); this.title = title; this.clock = clock; } }; -Rivendell.Musicpool.prototype = Object.create(Rivendell.Group.prototype); -Rivendell.Musicpool.prototype.constructor = Rivendell.Musicpool; +Rdxport.Musicpool.prototype = Object.create(Rdxport.Group.prototype); +Rdxport.Musicpool.prototype.constructor = Rdxport.Musicpool; -Rivendell.MusicpoolView = function(model) { +Rdxport.MusicpoolView = function(model) { this.model = model; this.cartViews = []; @@ -130,7 +130,7 @@ Rivendell.MusicpoolView = function(model) { }); }; -Rivendell.MusicpoolView.prototype.render = function() { +Rdxport.MusicpoolView.prototype.render = function() { var self = this; this.$el = $('#hiddenTemplates .musicpoolTemplate').clone().removeClass('musicpoolTemplate'); @@ -141,7 +141,7 @@ Rivendell.MusicpoolView.prototype.render = function() { this.cartViews = []; $(this.model.carts).each(function(index, cart) { - var cartView = new Rivendell.MusicpoolCartView(cart); + var cartView = new Rdxport.MusicpoolCartView(cart); self.cartViews.push(cartView); $('table > tbody', self.$el).append(cartView.$el); @@ -152,7 +152,7 @@ Rivendell.MusicpoolView.prototype.render = function() { }); }; -Rivendell.MusicpoolView.prototype.uploadProgress = function(upload, file) { +Rdxport.MusicpoolView.prototype.uploadProgress = function(upload, file) { if (!file.cartNumber || !file.cutNumber) { return; } @@ -182,7 +182,7 @@ Rivendell.MusicpoolView.prototype.uploadProgress = function(upload, file) { } }; -Rivendell.MusicpoolView.prototype.uploadError = function(upload, file, msg, xhr, acknowledge) { +Rdxport.MusicpoolView.prototype.uploadError = function(upload, file, msg, xhr, acknowledge) { if (!file.cartNumber) { return; } @@ -213,7 +213,7 @@ Rivendell.MusicpoolView.prototype.uploadError = function(upload, file, msg, xhr, $('#musicpool-' + file.cartNumber).replaceWith($errorRow); }; -Rivendell.MusicpoolCartView = function(model) { +Rdxport.MusicpoolCartView = function(model) { this.model = model; this.$spinner = null; @@ -222,7 +222,7 @@ Rivendell.MusicpoolCartView = function(model) { this.render(); }; -Rivendell.MusicpoolCartView.prototype.render = function() { +Rdxport.MusicpoolCartView.prototype.render = function() { var length = '-'; var imported = '-'; var playcnt = '-'; @@ -263,7 +263,7 @@ Rivendell.MusicpoolCartView.prototype.render = function() { .append($('').addClass('text-center').append(deleteButton)); }; -Rivendell.MusicpoolCartView.prototype.delete = function() { +Rdxport.MusicpoolCartView.prototype.delete = function() { this.$el.find('td:last').html(this.$spinner); var self = this; diff --git a/www/js/rdxport.js b/www/js/rdxport.js index db8bf0a..73e4a7d 100644 --- a/www/js/rdxport.js +++ b/www/js/rdxport.js @@ -1,38 +1,64 @@ -/* - * rhwebimport - * - * Copyright (C) 2014-2016 Christian Pointner +/** + * rdxportjs a javascript library for the rivendell rdxport api. * Copyright (C) 2015-2016 Peter Grassberger * - * This file is part of rhwebimport. - * - * rhwebimport is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * rhwebimport is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with rhwebimport. If not, see . + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . */ 'use strict'; -var Rivendell = Rivendell || {}; - -Rivendell.Rdxport = function(username, token, endpoint) { +var Rdxport = Rdxport || {}; + +Rdxport.CMD_EXPORT = 1; +Rdxport.CMD_IMPORT = 2; +Rdxport.CMD_DELETEAUDIO = 3; +Rdxport.CMD_LISTGROUPS = 4; +Rdxport.CMD_LISTGROUP = 5; +Rdxport.CMD_LISTCARTS = 6; +Rdxport.CMD_LISTCART = 7; +Rdxport.CMD_LISTCUT = 8; +Rdxport.CMD_LISTCUTS = 9; +Rdxport.CMD_ADDCUT = 10; +Rdxport.CMD_REMOVECUT = 11; +Rdxport.CMD_ADDCART = 12; +Rdxport.CMD_REMOVECART = 13; +Rdxport.CMD_EDITCART = 14; +Rdxport.CMD_EDITCUT = 15; +Rdxport.CMD_EXPORT_PEAKS = 16; +Rdxport.CMD_TRIMAUDIO = 17; +Rdxport.CMD_COPYAUDIO = 18; +Rdxport.CMD_AUDIOINFO = 19; +Rdxport.CMD_LISTLOGS = 20; +Rdxport.CMD_LISTSERVICES = 21; +Rdxport.CMD_LISTLOG = 22; +Rdxport.CMD_AUDIOSTORE = 23; + +Rdxport.Rdxport = function(username, token, endpoint) { this.username = username; this.token = token; this.endpoint = endpoint; }; -Rivendell.Rdxport.prototype.listLog = function(name, success) { +Rdxport.RdxportObject = function(username, token, endpoint) { + Rdxport.Rdxport.call(this, username, token, endpoint); +}; +Rdxport.RdxportObject.prototype = Object.create(Rdxport.Rdxport.prototype); +Rdxport.RdxportObject.prototype.constructor = Rdxport.RdxportObject; + +Rdxport.Rdxport.prototype.listLog = function(name, success) { var command = { - COMMAND: 22, + COMMAND: Rdxport.CMD_LISTLOG, LOGIN_NAME: this.username, PASSWORD: this.token, NAME: name @@ -40,41 +66,38 @@ Rivendell.Rdxport.prototype.listLog = function(name, success) { return $.post(this.endpoint, command, success, 'xml'); }; -Rivendell.Rdxport.prototype.listLogs = function(success) { - var command = { - COMMAND: 20, - LOGIN_NAME: this.username, - PASSWORD: this.token - //todo: fix optionals - /*SERVICE_NAME: serviceName, - TRACKABLE: trackable*/ - }; - return $.post(this.endpoint, command, success, 'xml'); +Rdxport.Rdxport.prototype.listLogs = function(options, success) { + options = options || {}; + options.COMMAND = Rdxport.CMD_LISTLOGS; + options.LOGIN_NAME = this.username; + options.PASSWORD = this.token; + return $.post(this.endpoint, options, success, 'xml'); }; -Rivendell.Rdxport.prototype.listServices = function(success) { - var command = { - COMMAND: 21, - LOGIN_NAME: this.username, - PASSWORD: this.token - //todo: fix optionals - /*TRACKABLE: trackable*/ - }; - return $.post(this.endpoint, command, success, 'xml'); +Rdxport.Rdxport.prototype.listServices = function(options, success) { + options = options || {}; + options.COMMAND = Rdxport.CMD_LISTSERVICES; + options.LOGIN_NAME = this.username; + options.PASSWORD = this.token; + return $.post(this.endpoint, options, success, 'xml'); }; -Rivendell.Rdxport.prototype.listGroups = function(success) { +Rdxport.Rdxport.prototype.listGroups = function(success) { var command = { - COMMAND: 4, + COMMAND: Rdxport.CMD_LISTGROUPS, LOGIN_NAME: this.username, PASSWORD: this.token }; return $.post(this.endpoint, command, success, 'xml'); }; -Rivendell.Rdxport.prototype.listGroup = function(groupName, success) { +Rdxport.RdxportObject.prototype.listGroups = function(success) { + Rdxport.Rdxport.call(this, success); +}; + +Rdxport.Rdxport.prototype.listGroup = function(groupName, success) { var command = { - COMMAND: 5, + COMMAND: Rdxport.CMD_LISTGROUP, LOGIN_NAME: this.username, PASSWORD: this.token, GROUP_NAME: groupName @@ -82,53 +105,45 @@ Rivendell.Rdxport.prototype.listGroup = function(groupName, success) { return $.post(this.endpoint, command, success, 'xml'); }; -Rivendell.Rdxport.prototype.listCarts = function(groupName, includeCuts, success) { - var command = { - COMMAND: 6, - LOGIN_NAME: this.username, - PASSWORD: this.token, - GROUP_NAME: groupName, - INCLUDE_CUTS: includeCuts - }; - return $.post(this.endpoint, command, success, 'xml'); +Rdxport.Rdxport.prototype.listCarts = function(options, success) { + options = options || {}; + options.COMMAND = Rdxport.CMD_LISTCARTS; + options.LOGIN_NAME = this.username; + options.PASSWORD = this.token; + return $.post(this.endpoint, options, success, 'xml'); }; -Rivendell.Rdxport.prototype.listCart = function(cartNumber, includeCuts, success) { - var command = { - COMMAND: 7, - LOGIN_NAME: this.username, - PASSWORD: this.token, - CART_NUMBER: cartNumber, - INCLUDE_CUTS: includeCuts - }; - return $.post(this.endpoint, command, success); +Rdxport.Rdxport.prototype.listCart = function(cartNumber, options, success) { + options = options || {}; + options.COMMAND = Rdxport.CMD_LISTCART; + options.LOGIN_NAME = this.username; + options.PASSWORD = this.token; + options.CART_NUMBER = cartNumber; + return $.post(this.endpoint, options, success); }; -Rivendell.Rdxport.prototype.addCart = function(groupName, type, cartNumber, success) { - var command = { - COMMAND: 12, - LOGIN_NAME: this.username, - PASSWORD: this.token, - GROUP_NAME: groupName, - TYPE: type - }; - if (cartNumber !== null) { - command.CART_NUMBER = cartNumber; - } - return $.post(this.endpoint, command, success, 'xml'); +Rdxport.Rdxport.prototype.addCart = function(groupName, type, options, success) { + options = options || {}; + options.COMMAND = Rdxport.CMD_ADDCART; + options.LOGIN_NAME = this.username; + options.PASSWORD = this.token; + options.GROUP_NAME = groupName; + options.TYPE = type; + return $.post(this.endpoint, options, success, 'xml'); }; -Rivendell.Rdxport.prototype.editCart = function(cartNumber, options, success) { - options.COMMAND = 14; +Rdxport.Rdxport.prototype.editCart = function(cartNumber, options, success) { + options = options || {}; + options.COMMAND = Rdxport.CMD_EDITCART; options.LOGIN_NAME = this.username; options.PASSWORD = this.token; options.CART_NUMBER = cartNumber; return $.post(this.endpoint, options, success, 'xml'); }; -Rivendell.Rdxport.prototype.removeCart = function(cartNumber, success) { +Rdxport.Rdxport.prototype.removeCart = function(cartNumber, success) { var command = { - COMMAND: 13, + COMMAND: Rdxport.CMD_REMOVECART, LOGIN_NAME: this.username, PASSWORD: this.token, CART_NUMBER: cartNumber @@ -136,9 +151,9 @@ Rivendell.Rdxport.prototype.removeCart = function(cartNumber, success) { return $.post(this.endpoint, command, success, 'xml'); }; -Rivendell.Rdxport.prototype.listCuts = function(cartNumber, success) { +Rdxport.Rdxport.prototype.listCuts = function(cartNumber, success) { var command = { - COMMAND: 9, + COMMAND: Rdxport.CMD_LISTCUTS, LOGIN_NAME: this.username, PASSWORD: this.token, CART_NUMBER: cartNumber @@ -146,9 +161,9 @@ Rivendell.Rdxport.prototype.listCuts = function(cartNumber, success) { return $.post(this.endpoint, command, success, 'xml'); }; -Rivendell.Rdxport.prototype.listCut = function(cartNumber, cutNumber, success) { +Rdxport.Rdxport.prototype.listCut = function(cartNumber, cutNumber, success) { var command = { - COMMAND: 8, + COMMAND: Rdxport.CMD_LISTCUT, LOGIN_NAME: this.username, PASSWORD: this.token, CART_NUMBER: cartNumber, @@ -157,9 +172,9 @@ Rivendell.Rdxport.prototype.listCut = function(cartNumber, cutNumber, success) { return $.post(this.endpoint, command, success, 'xml'); }; -Rivendell.Rdxport.prototype.addCut = function(cartNumber, success) { +Rdxport.Rdxport.prototype.addCut = function(cartNumber, success) { var command = { - COMMAND: 10, + COMMAND: Rdxport.CMD_ADDCUT, LOGIN_NAME: this.username, PASSWORD: this.token, CART_NUMBER: cartNumber @@ -167,8 +182,9 @@ Rivendell.Rdxport.prototype.addCut = function(cartNumber, success) { return $.post(this.endpoint, command, success, 'xml'); }; -Rivendell.Rdxport.prototype.editCut = function(cartNumber, cutNumber, options, success) { - options.COMMAND = 15; +Rdxport.Rdxport.prototype.editCut = function(cartNumber, cutNumber, options, success) { + options = options || {}; + options.COMMAND = Rdxport.CMD_EDITCUT; options.LOGIN_NAME = this.username; options.PASSWORD = this.token; options.CART_NUMBER = cartNumber; @@ -176,7 +192,7 @@ Rivendell.Rdxport.prototype.editCut = function(cartNumber, cutNumber, options, s return $.post(this.endpoint, options, success, 'xml'); }; -Rivendell.Rdxport.prototype.addAndEditCut = function(cartNumber, options, success) { +Rdxport.Rdxport.prototype.addAndEditCut = function(cartNumber, options, success) { var self = this; var returnJqXHR = null; return this.addCut(cartNumber, success) @@ -186,9 +202,9 @@ Rivendell.Rdxport.prototype.addAndEditCut = function(cartNumber, options, succes }); }; -Rivendell.Rdxport.prototype.removeCut = function(cartNumber, cutNumber, success) { +Rdxport.Rdxport.prototype.removeCut = function(cartNumber, cutNumber, success) { var command = { - COMMAND: 11, + COMMAND: Rdxport.CMD_REMOVECUT, LOGIN_NAME: this.username, PASSWORD: this.token, CART_NUMBER: cartNumber, @@ -197,18 +213,8 @@ Rivendell.Rdxport.prototype.removeCut = function(cartNumber, cutNumber, success) return $.post(this.endpoint, command, success, 'xml'); }; -/** - * - * todo: copy description and other data. - * - * @param sourceCartNumber - * @param sourceCutNumber - * @param destinationCartNumber - * @param success - * @returns {*} - */ -Rivendell.Rdxport.prototype.copyCut = function(sourceCartNumber, sourceCutNumber, - destinationCartNumber, success) { +Rdxport.Rdxport.prototype.copyCut = function(sourceCartNumber, sourceCutNumber, + destinationCartNumber, success) { var self = this; var returnJqXHR = null; this.listCut(sourceCartNumber, sourceCutNumber, function(data, textStatus, jqXHR) { @@ -227,15 +233,8 @@ Rivendell.Rdxport.prototype.copyCut = function(sourceCartNumber, sourceCutNumber return returnJqXHR; }; -/** - * - * @param sourceCartNumber - * @param sourceCutNumber - * @param destinationCartNumber - * @param success - */ -Rivendell.Rdxport.prototype.moveCut = function(sourceCartNumber, sourceCutNumber, - destinationCartNumber, success) { +Rdxport.Rdxport.prototype.moveCut = function(sourceCartNumber, sourceCutNumber, + destinationCartNumber, success) { var self = this; var returnJqXHR = null; this.copyCut(sourceCartNumber, sourceCutNumber, destinationCartNumber, function(data, textStatus, jqXHR) { @@ -244,10 +243,10 @@ Rivendell.Rdxport.prototype.moveCut = function(sourceCartNumber, sourceCutNumber return returnJqXHR; }; -Rivendell.Rdxport.prototype.copyAudio = function(sourceCartNumber, sourceCutNumber, - destinationCartNumber, destinationCutNumber, success) { +Rdxport.Rdxport.prototype.copyAudio = function(sourceCartNumber, sourceCutNumber, + destinationCartNumber, destinationCutNumber, success) { var command = { - COMMAND: 18, + COMMAND: Rdxport.CMD_COPYAUDIO, LOGIN_NAME: this.username, PASSWORD: this.token, SOURCE_CART_NUMBER: sourceCartNumber, @@ -258,9 +257,9 @@ Rivendell.Rdxport.prototype.copyAudio = function(sourceCartNumber, sourceCutNumb return $.post(this.endpoint, command, success, 'xml'); }; -Rivendell.Rdxport.prototype.audioInfo = function(cartNumber, cutNumber, success) { +Rdxport.Rdxport.prototype.audioInfo = function(cartNumber, cutNumber, success) { var command = { - COMMAND: 19, + COMMAND: Rdxport.CMD_AUDIOINFO, LOGIN_NAME: this.username, PASSWORD: this.token, CART_NUMBER: cartNumber, @@ -269,19 +268,19 @@ Rivendell.Rdxport.prototype.audioInfo = function(cartNumber, cutNumber, success) return $.post(this.endpoint, command, success, 'xml'); }; -Rivendell.Rdxport.prototype.audioStore = function(success) { +Rdxport.Rdxport.prototype.audioStore = function(success) { var command = { - COMMAND: 23, + COMMAND: Rdxport.CMD_AUDIOSTORE, LOGIN_NAME: this.username, PASSWORD: this.token }; return $.post(this.endpoint, command, success, 'xml'); }; -Rivendell.Rdxport.prototype.import = function(cartNumber, cutNumber, channels, normalizationLevel, autotrimLevel, - useMetadata, filename, success) { +Rdxport.Rdxport.prototype.import = function(cartNumber, cutNumber, channels, normalizationLevel, autotrimLevel, + useMetadata, filename, success) { var command = { - COMMAND: 2, + COMMAND: Rdxport.CMD_IMPORT, LOGIN_NAME: this.username, PASSWORD: this.token, CART_NUMBER: cartNumber, @@ -295,11 +294,11 @@ Rivendell.Rdxport.prototype.import = function(cartNumber, cutNumber, channels, n return $.post(this.endpoint, command, success, 'xml'); }; -Rivendell.Rdxport.prototype.export = function(cartNumber, cutNumber, format, channels, sampleRate, bitRate, - quality, startPoint, endPoint, normalizationLevel, enableMetadata, - success) { +Rdxport.Rdxport.prototype.export = function(cartNumber, cutNumber, format, channels, sampleRate, bitRate, + quality, startPoint, endPoint, normalizationLevel, enableMetadata, + success) { var command = { - COMMAND: 1, + COMMAND: Rdxport.CMD_EXPORT, LOGIN_NAME: this.username, PASSWORD: this.token, CART_NUMBER: cartNumber, @@ -317,9 +316,9 @@ Rivendell.Rdxport.prototype.export = function(cartNumber, cutNumber, format, cha return $.post(this.endpoint, command, success, 'xml'); }; -Rivendell.Rdxport.prototype.exportPeaks = function(cartNumber, cutNumber, success) { +Rdxport.Rdxport.prototype.exportPeaks = function(cartNumber, cutNumber, success) { var command = { - COMMAND: 16, + COMMAND: Rdxport.CMD_EXPORT_PEAKS, LOGIN_NAME: this.username, PASSWORD: this.token, CART_NUMBER: cartNumber, @@ -328,9 +327,9 @@ Rivendell.Rdxport.prototype.exportPeaks = function(cartNumber, cutNumber, succes return $.post(this.endpoint, command, success, 'xml'); }; -Rivendell.Rdxport.prototype.trimAudio = function(cartNumber, cutNumber, trimLevel, success) { +Rdxport.Rdxport.prototype.trimAudio = function(cartNumber, cutNumber, trimLevel, success) { var command = { - COMMAND: 17, + COMMAND: Rdxport.CMD_TRIMAUDIO, LOGIN_NAME: this.username, PASSWORD: this.token, CART_NUMBER: cartNumber, @@ -340,9 +339,9 @@ Rivendell.Rdxport.prototype.trimAudio = function(cartNumber, cutNumber, trimLeve return $.post(this.endpoint, command, success, 'xml'); }; -Rivendell.Rdxport.prototype.deleteAudio = function(cartNumber, cutNumber, success) { +Rdxport.Rdxport.prototype.deleteAudio = function(cartNumber, cutNumber, success) { var command = { - COMMAND: 3, + COMMAND: Rdxport.CMD_DELETEAUDIO, LOGIN_NAME: this.username, PASSWORD: this.token, CART_NUMBER: cartNumber, @@ -351,13 +350,13 @@ Rivendell.Rdxport.prototype.deleteAudio = function(cartNumber, cutNumber, succes return $.post(this.endpoint, command, success, 'xml'); }; -Rivendell.GroupList = function() { +Rdxport.GroupList = function() { this.groups = []; }; -Rivendell.Group = function(groupName, description, lowcart, highcart, normlevel, trimlevel) { +Rdxport.Group = function(groupName, description, lowcart, highcart, normlevel, trimlevel) { this.xml = null; - // looks strange but child somehow can't do use $(this) otherwise. + // looks strange but child somehow can't use $(this) otherwise. this.$this = $(this); if (arguments.length === 1) { @@ -381,16 +380,16 @@ Rivendell.Group = function(groupName, description, lowcart, highcart, normlevel, this.cartsByNumber = {}; }; -Rivendell.Group.prototype.getCartByNumber = function(number) { +Rdxport.Group.prototype.getCartByNumber = function(number) { return this.cartsByNumber[number] ? this.cartsByNumber[number] : null; }; -Rivendell.Group.prototype.addCart = function(cart) { +Rdxport.Group.prototype.addCart = function(cart) { this.carts.push(cart); this.cartsByNumber[cart.number] = cart; }; -Rivendell.Group.prototype.removeCart = function(cart) { +Rdxport.Group.prototype.removeCart = function(cart) { var self = this; $.each(this.carts, function(index, currentCart){ if(currentCart === cart) { @@ -400,7 +399,7 @@ Rivendell.Group.prototype.removeCart = function(cart) { delete this.cartsByNumber[cart.number]; }; -Rivendell.Group.prototype.fetchCarts = function() { +Rdxport.Group.prototype.fetchCarts = function() { var self = this; rdxport.listCarts(this.groupName, 1, function(cartsXml, status, req) { self.carts = []; @@ -408,11 +407,11 @@ Rivendell.Group.prototype.fetchCarts = function() { var dbs = $('cartList', cartsXml).children(); dbs.each(function(index, cartXml) { - var cart = new Rivendell.Cart(cartXml, self); + var cart = new Rdxport.Cart(cartXml, self); var cuts = $('cutList', cartXml).children(); cuts.each(function(index, cut) { - cart.cuts.push(new Rivendell.Cut(cut, cart)); + cart.cuts.push(new Rdxport.Cut(cut, cart)); }); self.addCart(cart); @@ -421,37 +420,37 @@ Rivendell.Group.prototype.fetchCarts = function() { }); }; -Rivendell.Log = function(line, id, type, cartType, cartNumber, cutNumber, groupName, groupColor, title, group) { +Rdxport.Log = function(line, id, type, cartType, cartNumber, cutNumber, groupName, groupColor, title, group) { /*this.xml = null; - if (arguments.length === 2) { - this.xml = arguments[0]; - this.line = $('line', this.xml).text(); - this.id = $('id', this.xml).text(); - this.type = $('type', this.xml).text(); - this.cartType = $('cartType', this.xml).text(); - this.cartNumber = $('cartNumber', this.xml).text(); - this.cutNumber = $('cutNumber', this.xml).text(); - this.groupName = $('groupName', this.xml).text(); - this.groupColor = $('groupColor', this.xml).text(); - this.title = $('title', this.xml).text(); - this.group = arguments[1]; - } else {*/ - this.line = line; - this.id = id; - this.type = type; - this.cartType = cartType; - this.cartNumber = cartNumber; - this.cutNumber = cutNumber; - this.groupName = groupName; - this.groupColor = groupColor; - this.title = title; - this.group = group; + if (arguments.length === 2) { + this.xml = arguments[0]; + this.line = $('line', this.xml).text(); + this.id = $('id', this.xml).text(); + this.type = $('type', this.xml).text(); + this.cartType = $('cartType', this.xml).text(); + this.cartNumber = $('cartNumber', this.xml).text(); + this.cutNumber = $('cutNumber', this.xml).text(); + this.groupName = $('groupName', this.xml).text(); + this.groupColor = $('groupColor', this.xml).text(); + this.title = $('title', this.xml).text(); + this.group = arguments[1]; + } else {*/ + this.line = line; + this.id = id; + this.type = type; + this.cartType = cartType; + this.cartNumber = cartNumber; + this.cutNumber = cutNumber; + this.groupName = groupName; + this.groupColor = groupColor; + this.title = title; + this.group = group; //} }; -Rivendell.Log.newFromXml = function(xml, group) { - var log = new Rivendell.Log( +Rdxport.Log.newFromXml = function(xml, group) { + var log = new Rdxport.Log( $('line', xml).text(), $('id', xml).text(), $('type', xml).text(), @@ -467,9 +466,9 @@ Rivendell.Log.newFromXml = function(xml, group) { return log; }; -Rivendell.Cart = function(number, title, groupName, group) { +Rdxport.Cart = function(number, title, groupName, group) { this.xml = null; - + if (arguments.length === 2) { this.xml = arguments[0]; this.number = $('number', this.xml).text(); @@ -488,11 +487,11 @@ Rivendell.Cart = function(number, title, groupName, group) { this.cuts = []; }; -Rivendell.Cart.prototype.addCut = function(cut) { +Rdxport.Cart.prototype.addCut = function(cut) { this.cuts.push(cut); }; -Rivendell.Cart.prototype.removeCut = function(cut) { +Rdxport.Cart.prototype.removeCut = function(cut) { var self = this; $.each(this.cuts, function(index, currentCut){ if(currentCut === cut) { @@ -501,8 +500,8 @@ Rivendell.Cart.prototype.removeCut = function(cut) { }); }; -Rivendell.Cut = function(name, description, cart, length, originDatetime, - playCounter, lastPlayDatetime) { +Rdxport.Cut = function(name, description, cart, length, originDatetime, + playCounter, lastPlayDatetime) { this.xml = null; if (arguments.length === 2) { diff --git a/www/js/rdxport.rh.js b/www/js/rdxport.rh.js index fc3bc83..b5b58c9 100644 --- a/www/js/rdxport.rh.js +++ b/www/js/rdxport.rh.js @@ -22,9 +22,9 @@ 'use strict'; -var Rivendell = Rivendell || {}; +var Rdxport = Rdxport || {}; -Rivendell.Rdxport.authLogin = function(authEndpoint, username, password, success) { +Rdxport.Rdxport.authLogin = function(authEndpoint, username, password, success) { return $.ajax(authEndpoint, { username: username, password: password, @@ -34,15 +34,15 @@ Rivendell.Rdxport.authLogin = function(authEndpoint, username, password, success }); }; -Rivendell.Rdxport.prototype.setListDropboxesEndpoint = function(listDropboxesEndpoint) { +Rdxport.Rdxport.prototype.setListDropboxesEndpoint = function(listDropboxesEndpoint) { this.listDropboxesEndpoint = listDropboxesEndpoint; }; -Rivendell.Rdxport.prototype.setMusicgridEndpoint = function(musicgridEndpoint) { +Rdxport.Rdxport.prototype.setMusicgridEndpoint = function(musicgridEndpoint) { this.musicgridEndpoint = musicgridEndpoint; }; -Rivendell.Rdxport.prototype.listDropboxes = function(type, success) { +Rdxport.Rdxport.prototype.listDropboxes = function(type, success) { var command = { LOGIN_NAME: this.username, PASSWORD: this.token @@ -54,7 +54,7 @@ Rivendell.Rdxport.prototype.listDropboxes = function(type, success) { }; // see: https://github.com/ElvishArtisan/rivendell/pull/100 -Rivendell.Rdxport.prototype.addAndEditCut = function(cartNumber, options, success) { +Rdxport.Rdxport.prototype.addAndEditCut = function(cartNumber, options, success) { options.COMMAND = 10; options.LOGIN_NAME = this.username; options.PASSWORD = this.token; @@ -62,7 +62,7 @@ Rivendell.Rdxport.prototype.addAndEditCut = function(cartNumber, options, succes return $.post(this.endpoint, options, success, "xml"); }; -Rivendell.Rdxport.prototype.copyCut = function(sourceCartNumber, sourceCutNumber, +Rdxport.Rdxport.prototype.copyCut = function(sourceCartNumber, sourceCutNumber, destinationCartNumber, success) { var self = this; @@ -85,7 +85,7 @@ Rivendell.Rdxport.prototype.copyCut = function(sourceCartNumber, sourceCutNumber return returnJqXHR; }; -Rivendell.Rdxport.prototype.addAndEditCart = function(groupName, type, cartNumber, options, success) { +Rdxport.Rdxport.prototype.addAndEditCart = function(groupName, type, cartNumber, options, success) { options.COMMAND = 12; options.LOGIN_NAME = this.username; options.PASSWORD = this.token; @@ -97,7 +97,7 @@ Rivendell.Rdxport.prototype.addAndEditCart = function(groupName, type, cartNumbe return $.post(this.endpoint, options, success, 'xml'); }; -Rivendell.Rdxport.prototype.getMusicgrid = function(success) { +Rdxport.Rdxport.prototype.getMusicgrid = function(success) { var command = { LOGIN_NAME: this.username, PASSWORD: this.token @@ -105,7 +105,7 @@ Rivendell.Rdxport.prototype.getMusicgrid = function(success) { return $.get(this.musicgridEndpoint, command, success, "xml"); }; -Rivendell.Rdxport.prototype.setMusicgrid = function(dow, hour, name, success) { +Rdxport.Rdxport.prototype.setMusicgrid = function(dow, hour, name, success) { var command = { LOGIN_NAME: this.username, PASSWORD: this.token, @@ -116,7 +116,7 @@ Rivendell.Rdxport.prototype.setMusicgrid = function(dow, hour, name, success) { return $.post(this.musicgridEndpoint, command, success, "xml"); }; -Rivendell.GroupList.prototype.fetch = function(type) { +Rdxport.GroupList.prototype.fetch = function(type) { this.groups = []; var self = this; @@ -126,16 +126,16 @@ Rivendell.GroupList.prototype.fetch = function(type) { var group = null; switch ($('type', groupXml).text()) { case 'show': - group = new Rivendell.Show(groupXml); + group = new Rdxport.Show(groupXml); break; case 'jingle': - group = new Rivendell.JingleGroup(groupXml); + group = new Rdxport.JingleGroup(groupXml); break; case 'musicpool': - group = new Rivendell.Musicpool(groupXml); + group = new Rdxport.Musicpool(groupXml); break; default: - group = new Rivendell.Group(groupXml); + group = new Rdxport.Group(groupXml); break; } @@ -148,24 +148,24 @@ Rivendell.GroupList.prototype.fetch = function(type) { }); }; -Rivendell.Musicgrid = function() { +Rdxport.Musicgrid = function() { this.clocks = []; }; -Rivendell.Musicgrid.prototype.fetch = function() { +Rdxport.Musicgrid.prototype.fetch = function() { this.clocks = []; var self = this; rdxport.getMusicgrid(function(gridXml, status, req) { var dbs = $('grid', gridXml).children(); dbs.each(function(index, clockXml) { - self.clocks.push(new Rivendell.MusicgridClock(clockXml)); + self.clocks.push(new Rdxport.MusicgridClock(clockXml)); }); $(self).trigger('update'); }); }; -Rivendell.MusicgridClock = function(name, color, title, dow, hour) { +Rdxport.MusicgridClock = function(name, color, title, dow, hour) { this.xml = null; if (arguments.length === 1) { diff --git a/www/js/shows.js b/www/js/shows.js index 1ba86b9..0379951 100644 --- a/www/js/shows.js +++ b/www/js/shows.js @@ -22,13 +22,13 @@ 'use strict'; -var Rivendell = Rivendell || {}; +var Rdxport = Rdxport || {}; var showListView = null; function shows_init() { - var showList = new Rivendell.GroupList(); - showListView = new Rivendell.ShowListView(showList); + var showList = new Rdxport.GroupList(); + showListView = new Rdxport.ShowListView(showList); drawClock('Do, 1.1.1970', '00:00:00', 0); clock_add_callback(drawClock); @@ -39,7 +39,7 @@ function shows_cleanup() { importer.cancelAllUploads(); } -Rivendell.ShowListView = function(model) { +Rdxport.ShowListView = function(model) { this.model = model; this.showViews = []; @@ -48,7 +48,7 @@ Rivendell.ShowListView = function(model) { var self = this; $(this.model).on('update', function() { $(self.model.groups).each(function(index, show) { - var showView = new Rivendell.ShowView(show); + var showView = new Rdxport.ShowView(show); self.showViews.push(showView); }); self.updateSelector(); @@ -56,12 +56,12 @@ Rivendell.ShowListView = function(model) { this.model.fetch('show'); }; -Rivendell.ShowListView.prototype.setCurrentShowId = function(currentShowId) { +Rdxport.ShowListView.prototype.setCurrentShowId = function(currentShowId) { this.currentShowId = currentShowId; sessionStorage.setItem('currentShowId', this.currentShowId); }; -Rivendell.ShowListView.prototype.getCurrentShowView = function() { +Rdxport.ShowListView.prototype.getCurrentShowView = function() { if (this.model.groups.length === 0) { return null; } @@ -82,7 +82,7 @@ Rivendell.ShowListView.prototype.getCurrentShowView = function() { return showViewFound; }; -Rivendell.ShowListView.prototype.updateSelector = function() { +Rdxport.ShowListView.prototype.updateSelector = function() { var self = this; var $showSelector = $('#show-selector'); @@ -107,10 +107,10 @@ Rivendell.ShowListView.prototype.updateSelector = function() { this.getCurrentShowView().model.fetchCarts(); }; -Rivendell.Show = function(groupName, description, lowcart, highcart, normlevel, trimlevel, +Rdxport.Show = function(groupName, description, lowcart, highcart, normlevel, trimlevel, id, title, log, rhythm, dayofweek, starttime, length) { if (arguments.length = 1) { - Rivendell.Group.call(this, groupName); + Rdxport.Group.call(this, groupName); this.id = $('show-id', this.xml).text(); this.title = $('show-title', this.xml).text(); this.log = $('show-log', this.xml).text(); @@ -119,7 +119,7 @@ Rivendell.Show = function(groupName, description, lowcart, highcart, normlevel, this.starttime = $('show-starttime', this.xml).text(); this.length = $('show-length', this.xml).text(); } else { - Rivendell.Group.call(this, groupName, description, lowcart, highcart, normlevel, trimlevel); + Rdxport.Group.call(this, groupName, description, lowcart, highcart, normlevel, trimlevel); this.id = id; this.title = title; this.log = log; @@ -131,10 +131,10 @@ Rivendell.Show = function(groupName, description, lowcart, highcart, normlevel, this.logs = []; }; -Rivendell.Show.prototype = Object.create(Rivendell.Group.prototype); -Rivendell.Show.prototype.constructor = Rivendell.Show; +Rdxport.Show.prototype = Object.create(Rdxport.Group.prototype); +Rdxport.Show.prototype.constructor = Rdxport.Show; -Rivendell.Show.prototype.fetchCarts = function() { +Rdxport.Show.prototype.fetchCarts = function() { var self = this; var lcd = rdxport.listLog(this.log, function(logsXml, status, req) { @@ -142,7 +142,7 @@ Rivendell.Show.prototype.fetchCarts = function() { var loglines = $('logList', logsXml).children(); loglines.each(function(index, logXml) { - var log = Rivendell.Log.newFromXml(logXml, self); + var log = Rdxport.Log.newFromXml(logXml, self); if(log.cartNumber >= self.lowcart && log.cartNumber <= self.highcart) { self.logs.push(log); @@ -150,17 +150,17 @@ Rivendell.Show.prototype.fetchCarts = function() { }); }); - var gcd = rdxport.listCarts(this.groupName, 1, function(cartsXml, status, req) { + var gcd = rdxport.listCarts({GROUP_NAME: this.groupName, INCLUDE_CUTS: 1}, function(cartsXml, status, req) { self.carts = []; self.cartsByNumber = {}; var dbs = $('cartList', cartsXml).children(); dbs.each(function(index, cartXml) { - var cart = new Rivendell.Cart(cartXml, self); + var cart = new Rdxport.Cart(cartXml, self); var cuts = $('cutList', cartXml).children(); cuts.each(function(index, cut) { - cart.cuts.push(new Rivendell.Cut(cut, cart)); + cart.cuts.push(new Rdxport.Cut(cut, cart)); }); self.addCart(cart); @@ -174,7 +174,7 @@ Rivendell.Show.prototype.fetchCarts = function() { }); }; -Rivendell.ShowView = function(model) { +Rdxport.ShowView = function(model) { this.model = model; this.cartViews = []; @@ -186,7 +186,7 @@ Rivendell.ShowView = function(model) { }); }; -Rivendell.ShowView.prototype.render = function() { +Rdxport.ShowView.prototype.render = function() { $('#show-title').text(this.model.title); $('#show-dow').text(weekday[this.model.dayofweek]); $('#show-rhythm').text(this.model.rhythm); @@ -201,18 +201,18 @@ Rivendell.ShowView.prototype.render = function() { $(this.model.logs).each(function(index, log) { var cart = self.model.getCartByNumber(log.cartNumber); if (cart) { - var cartView = new Rivendell.ShowCartView(cart, self); + var cartView = new Rdxport.ShowCartView(cart, self); self.cartViews.push(cartView); cartView.render(); $('#app-shows table > tbody').append(cartView.$el); } else { - $('#app-shows table > tbody').append(Rivendell.ShowCartView.renderEmpty(self.model, self, log.cartNumber)); + $('#app-shows table > tbody').append(Rdxport.ShowCartView.renderEmpty(self.model, self, log.cartNumber)); } }); }; -Rivendell.ShowView.prototype.uploadProgress = function(upload, file) { +Rdxport.ShowView.prototype.uploadProgress = function(upload, file) { if (!file.cartNumber || !file.cutNumber) { return; } @@ -242,7 +242,7 @@ Rivendell.ShowView.prototype.uploadProgress = function(upload, file) { } }; -Rivendell.ShowView.prototype.uploadError = function(upload, file, msg, xhr, acknowledge) { +Rdxport.ShowView.prototype.uploadError = function(upload, file, msg, xhr, acknowledge) { if (!file.cartNumber) { return; } @@ -273,7 +273,7 @@ Rivendell.ShowView.prototype.uploadError = function(upload, file, msg, xhr, ackn $('#show-cart-' + file.cartNumber).replaceWith($errorRow); }; -Rivendell.ShowCartView = function(model, groupView) { +Rdxport.ShowCartView = function(model, groupView) { this.model = model; this.groupView = groupView; @@ -281,7 +281,7 @@ Rivendell.ShowCartView = function(model, groupView) { this.$el = $(''); }; -Rivendell.ShowCartView.prototype.render = function() { +Rdxport.ShowCartView.prototype.render = function() { var $deleteButton = $(''); var self = this; @@ -313,7 +313,7 @@ Rivendell.ShowCartView.prototype.render = function() { .append($('').css('text-align', 'center').append($deleteButton)); }; -Rivendell.ShowCartView.renderEmpty = function(group, groupView, cartNumber) { +Rdxport.ShowCartView.renderEmpty = function(group, groupView, cartNumber) { var $uploadButton = $(''); $uploadButton.on('click', function() { @@ -331,13 +331,13 @@ Rivendell.ShowCartView.renderEmpty = function(group, groupView, cartNumber) { .append($('').css('text-align', 'center').append($uploadButton)); }; -Rivendell.ShowCartView.prototype.delete = function() { +Rdxport.ShowCartView.prototype.delete = function() { $('td:last', this.$el).html(this.$spinner); var self = this; rdxport.removeCart(this.model.number, function() { self.model.group.removeCart(self.model); - var $empty = Rivendell.ShowCartView.renderEmpty(self.model.group, self.groupView, self.model.number); + var $empty = Rdxport.ShowCartView.renderEmpty(self.model.group, self.groupView, self.model.number); self.$el.replaceWith($empty); }); }; diff --git a/www/js/utils.js b/www/js/utils.js index fab6736..81501e9 100644 --- a/www/js/utils.js +++ b/www/js/utils.js @@ -22,27 +22,27 @@ 'use strict'; -var Rivendell = Rivendell || {}; +var Rdxport = Rdxport || {}; -var alertbox = function() {} +var alertbox = function() {}; alertbox.warning = function (dest, heading, message) { $('#' + dest + ' .alertbox').html('
×

' + heading + '

' + message + '
'); -} +}; alertbox.error = function (dest, heading, message) { $('#' + dest + ' .alertbox').html('
×

' + heading + '

' + message + '
'); -} +}; alertbox.info = function (dest, heading, message) { $('#' + dest + ' .alertbox').html('
×

' + heading + '

' + message + '
'); -} +}; alertbox.success = function (dest, heading, message) { $('#' + dest + ' .alertbox').html('
×

' + heading + '

' + message + '
'); -} +}; Number.prototype.pad = function(size) { var s = String(this); while (s.length < (size || 2)) {s = "0" + s;} return s; -} +}; var weekday = new Array(7); weekday[0] = 'Sonntag'; @@ -53,7 +53,7 @@ weekday[4] = 'Donnerstag'; weekday[5] = 'Freitag'; weekday[6] = 'Samstag'; -var weekday_short = new Array('So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa'); +var weekday_short = ['So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa']; function format_datetime(d) { if(Object.prototype.toString.call(d) !== '[object Date]') { -- cgit v0.10.2