// Copyright (C) 2013 Massachusetts Institute of Technology
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License version 2,
// as published by the Free Software Foundation.
//
// 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
'use strict';
var Reporter = function(data) {
this.cmd = data.cmd;
this.color = data.color;
this.isDiscrete = data.isDiscrete;
this.mode = data.mode;
this.param = data.param;
this.sliderMin = data.sliderMin;
this.sliderMax = data.sliderMax;
this.target = data.target;
this.visible = data.visible;
this.x = data.x;
this.y = data.y;
this.z = io.getCount();
//Set the label after hydrating the cmd and param variables
this.label = this.determineReporterLabel();
this.el = null; // jQuery Element for the outer box
this.valueEl = null; // jQ element containing the reporter value
this.slider = null; // slider jQ element
};
Reporter.prototype.determineReporterLabel = function() {
if (this.target === 'Stage' && this.cmd === "getVar:") return this.param;
if (this.target === 'Stage' && this.param === null) return this.cmd;
return this.target + ': ' + this.param;
}
Reporter.prototype.attach = function(scene) {
switch (this.mode) {
case 1: // Normal
case 3: // Slider
this.el = $('
' + this.label + '
');
this.valueEl = $('
null
');
this.el.append(this.valueEl);
if (this.mode == 3) {
// Slider-specific
// Temporarily, set the value to sliderMin until an update
this.slider = $('');
this.slider.change(this.changeSlider);
this.el.append(' ');
this.el.append(this.slider);
}
break;
case 2: // Large
this.el = $('