<commit_before>define(function (require) {

	'use strict';

	var $        = require('jquery');
	var _        = require('underscore');
	var Backbone = require('backbone');

	var html  = require('text!templates/oscillator.html');

	var OscillatorView = Backbone.View.extend({

		template: _.template(html),

		tagName: 'div',
		className: 'oscillator-view',

		events: {
			'click .btn-oscillator-pulse' : 'pulseClicked',
			'change .oscillator-on-off'   : 'changeState',
		},

		initialize: function(options) {
			if (options.heatmapView)
				this.heatmapView = options.heatmapView;
			else
				throw 'OscillatorView requires a HeatmapView instance.';

			if (options.oscillator)
				this.oscillator = options.oscillator;
			else
				throw 'OscillatorView requires an Oscillator instance.';

			this.waveSimulation = this.heatmapView.waveSimulation;

			this.listenTo(this.heatmapView, 'resized', this.resize);
			this.listenTo(this.waveSimulation, 'oscillators-changed', function(){
				this.updateOnNextFrame = true;
			});
			this.listenTo(this.waveSimulation, 'change:oscillatorCount', this.determinePosition);
		},

		resize: function(){
			this.updateOnNextFrame = true;

			
		},

		render: function() {
			this.$el.html(this.template({ unique: this.cid }));
			this.$graphic = this.$('.oscillator-graphic');

			this.resize();
			this.update(0, 0);
		},

		update: function(time, delta) {
			if (!this.updateOnNextFrame)
				return;

			this.updateOnNextFrame = false;

			if (!this.hidden) {
				this.$graphic.css('top', this.heatmapView.height - this.oscillator.y * this.heatmapView.ySpacing);
			}
		},

		toLatticeXScale: function(x) {
			return x / this.heatmapView.xSpacing;
		},

		toLatticeYScale: function(y) {
			return y / this.heatmapView.ySpacing * -1;
		},

		pulseClicked: function(event) {
			event.preventDefault();

			var estimatedTime = this.oscillator.firePulse();

			$(event.target)
				.css({
					'animation-duration': estimatedTime + 'ms',
					'-webkit-animation-duration': estimatedTime + 'ms'
				})
				.addClass('clicked')
				.prop('disabled', true);

			var $on = this.$('#oscillator-on-' + this.cid);
			setTimeout(function(){
				if ($on.is(':checked')) {
					$(event.target)
						.removeClass('clicked');
				}
				else {
					$(event.target)
						.removeClass('clicked')
						.prop('disabled', false);	
				}
			}, estimatedTime);
		},

		changeState: function(event) {
			var enabled = parseInt($(event.target).val());

			this.$('.btn-oscillator-pulse')
				.prop('disabled', enabled)
				.removeClass('clicked');

			this.oscillator.enabled = enabled;
		},

		hide: function() {
			this.hidden = true;
			this.$el.hide();
		},

		show: function() {
			this.hidden = false;
			this.$el.show();
		},

		determinePosition: function() {
			if (this.waveSimulation.get('oscillatorCount') > 1) {
				var pos = _.indexOf(this.waveSimulation.oscillators, this.oscillator);

				if (pos === 0)
					this.$el.addClass('top-oscillator');
				else
					this.$el.addClass('bottom-oscillator');
			}
			else {
				this.$el
					.removeClass('top-oscillator')
					.removeClass('bottom-oscillator');
			}
		}

	});

	return OscillatorView;
});<commit_msg>The controls for the oscillator views were flipped. Now they go to the right ones.<commit_after>define(function (require) {

	'use strict';

	var $        = require('jquery');
	var _        = require('underscore');
	var Backbone = require('backbone');

	var html  = require('text!templates/oscillator.html');

	var OscillatorView = Backbone.View.extend({

		template: _.template(html),

		tagName: 'div',
		className: 'oscillator-view',

		events: {
			'click .btn-oscillator-pulse' : 'pulseClicked',
			'change .oscillator-on-off'   : 'changeState',
		},

		initialize: function(options) {
			if (options.heatmapView)
				this.heatmapView = options.heatmapView;
			else
				throw 'OscillatorView requires a HeatmapView instance.';

			if (options.oscillator)
				this.oscillator = options.oscillator;
			else
				throw 'OscillatorView requires an Oscillator instance.';

			this.waveSimulation = this.heatmapView.waveSimulation;

			this.listenTo(this.heatmapView, 'resized', this.resize);
			this.listenTo(this.waveSimulation, 'oscillators-changed', function(){
				this.updateOnNextFrame = true;
			});
			this.listenTo(this.waveSimulation, 'change:oscillatorCount', this.determinePosition);
		},

		resize: function(){
			this.updateOnNextFrame = true;

			
		},

		render: function() {
			this.$el.html(this.template({ unique: this.cid }));
			this.$graphic = this.$('.oscillator-graphic');

			this.resize();
			this.update(0, 0);
		},

		update: function(time, delta) {
			if (!this.updateOnNextFrame)
				return;

			this.updateOnNextFrame = false;

			if (!this.hidden) {
				this.$graphic.css('top', this.heatmapView.height - this.oscillator.y * this.heatmapView.ySpacing);
			}
		},

		toLatticeXScale: function(x) {
			return x / this.heatmapView.xSpacing;
		},

		toLatticeYScale: function(y) {
			return y / this.heatmapView.ySpacing * -1;
		},

		pulseClicked: function(event) {
			event.preventDefault();

			var estimatedTime = this.oscillator.firePulse();

			$(event.target)
				.css({
					'animation-duration': estimatedTime + 'ms',
					'-webkit-animation-duration': estimatedTime + 'ms'
				})
				.addClass('clicked')
				.prop('disabled', true);

			var $on = this.$('#oscillator-on-' + this.cid);
			setTimeout(function(){
				if ($on.is(':checked')) {
					$(event.target)
						.removeClass('clicked');
				}
				else {
					$(event.target)
						.removeClass('clicked')
						.prop('disabled', false);	
				}
			}, estimatedTime);
		},

		changeState: function(event) {
			var enabled = parseInt($(event.target).val());

			this.$('.btn-oscillator-pulse')
				.prop('disabled', enabled)
				.removeClass('clicked');

			this.oscillator.enabled = enabled;
		},

		hide: function() {
			this.hidden = true;
			this.$el.hide();
		},

		show: function() {
			this.hidden = false;
			this.$el.show();
		},

		determinePosition: function() {
			if (this.waveSimulation.get('oscillatorCount') > 1) {
				var pos = _.indexOf(this.waveSimulation.oscillators, this.oscillator);

				if (pos === 0)
					this.$el.addClass('bottom-oscillator');
				else
					this.$el.addClass('top-oscillator');
			}
			else {
				this.$el
					.removeClass('top-oscillator')
					.removeClass('bottom-oscillator');
			}
		}

	});

	return OscillatorView;
});
{'fraction_non_alphanumeric': 0.16090528600217022, 'fraction_numerical': 0.0015501472639900791, 'mean_word_length': 3.281353682813537, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3216284', 'n_tokens_mistral': 2678, 'n_tokens_neox': 2143, 'n_words': 374}