/* * 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 = Rivendell || {}; /*var shows_currentid = null; var shows_list = []; var shows_current; var shows_group_carts = {}; var shows_log_carts = [];*/ var showListView = null; function shows_init() { /*shows_currentid = sessionStorage.getItem("shows_currentid"); shows_list = []; rdxport.listDropboxes('show', shows_updateList);*/ var showList = new Rivendell.GroupList(); showListView = new Rivendell.ShowListView(showList); drawClock('Do, 1.1.1970', '00:00:00', 0); clock_add_callback(drawClock); } function shows_cleanup() { $('#show-carts tbody').find('tr').remove(); importer.cancelAllUploads(); /*sessionStorage.removeItem("shows_currentid"); shows_currentid = null; shows_list = []; shows_group_carts = {}; shows_log_carts = [];*/ } Rivendell.ShowListView = function(model) { this.model = model; this.showViews = []; this.currentShowId = sessionStorage.getItem('currentShowId'); var self = this; $(this.model).on('update', function() { $(self.model.groups).each(function(index, show) { var showView = new Rivendell.ShowView(show); self.showViews.push(showView); }); self.updateSelector(); }); this.model.fetch('show'); }; Rivendell.ShowListView.prototype.setCurrentShowId = function(currentShowId) { this.currentShowId = currentShowId; sessionStorage.setItem('currentShowId', this.currentShowId); }; Rivendell.ShowListView.prototype.getCurrentShowView = function() { if (this.model.groups.length === 0) { return null; } if (this.showViews.length === 0) { return null; } if (this.currentShowId === null) { this.setCurrentShowId(this.model.groups[0].id); } var self = this; var showViewFound = null; $(this.showViews).each(function(index, showView) { if (showView.model.id === self.currentShowId) { showViewFound = showView; return true; } }); return showViewFound; }; Rivendell.ShowListView.prototype.updateSelector = function() { var self = this; var $showSelector = $('#show-selector'); $showSelector.off(); $('option', $showSelector).remove(); $(this.model.groups).each(function(index, show) { var name = show.title + ' (' + show.rhythm + ', ' + weekday[show.dayofweek] + ', ' + show.starttime + ', ' + show.length + ' Min.)'; $showSelector.append($('