/* * rhwebimport * * Copyright (C) 2014-2016 Christian Pointner * 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 . */ 'use strict'; var rivendell = null; var musicpools = null; function musicpools_init() { rivendell = new Rivendell.Rivendell(auth_username, auth_token, '/rd-bin/rdxport.cgi'); rivendell.setListDropboxesEndpoint('/rh-bin/listdropboxes.cgi'); musicpools = new Musicpools(); } function musicpools_cleanup() { rivendell = null; } // this and jinglegroups are basicly the same var Musicpools = function() { // todo: get current Pool Id from session like shows? this.currentPoolId = sessionStorage.getItem("currentPoolId"); this.currentPoolId = this.currentPoolId === null ? 0 : this.currentPoolId; this.musicpools = []; this.fetch(); }; Musicpools.prototype.fetch = function() { var self = this; rivendell.listDropboxes('musicpool', function(groupsXml, status, req) { self.musicpools = []; var dbs = $(groupsXml).find("dropboxList").children(); dbs.each(function(index, groupXml) { var musicpool = new Musicpool( $('musicpool-title', groupXml).text(), $('musicpool-clock', groupXml).text(), $('group', groupXml).text(), $('group-description', groupXml).text(), $('group-low-cart', groupXml).text(), $('group-high-cart', groupXml).text(), $('normalization-level', groupXml).text(), $('autotrim-level', groupXml).text() ); self.musicpools.push(musicpool); }); self.updateSelector(); }); }; Musicpools.prototype.updateSelector = function() { $('#musicpool-selector').find('option').remove(); // todo: add from list $(this.musicpools).each(function(index, musicpool) { var name = musicpool.title + ' (' + musicpool.clock + ')'; $('#musicpool-selector').append($('