Skip to content

Commit

Permalink
var -> const using eslint auto fix, phetsims/tasks#1012
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Sep 19, 2019
1 parent 9a61a87 commit 19bd67c
Show file tree
Hide file tree
Showing 69 changed files with 622 additions and 622 deletions.
2 changes: 1 addition & 1 deletion js/capacitance/CapacitanceScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ define( require => {
*/
function CapacitanceScreen( switchUsedProperty, tandem ) {

var options = {
const options = {
name: screenCapacitanceString,
backgroundColorProperty: new Property( CLBConstants.SCREEN_VIEW_BACKGROUND_COLOR ),
homeScreenIcon: new Image( capacitorIconImage ),
Expand Down
2 changes: 1 addition & 1 deletion js/capacitance/model/CapacitanceModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ define( require => {
*/
function CapacitanceModel( switchUsedProperty, modelViewTransform, tandem ) {

var circuitConfig = CircuitConfig.create( {
const circuitConfig = CircuitConfig.create( {
circuitConnections: [ CircuitState.BATTERY_CONNECTED, CircuitState.OPEN_CIRCUIT ]
} );

Expand Down
4 changes: 2 additions & 2 deletions js/capacitance/view/CapacitanceCircuitNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ define( require => {
function CapacitanceCircuitNode( model, tandem ) {

CLBCircuitNode.call( this, model, tandem );
var self = this;
const self = this;

Property.multilink( [ model.circuit.circuitConnectionProperty, model.currentVisibleProperty ],
function( circuitConnection, currentIndicatorsVisible ) {
Expand All @@ -45,7 +45,7 @@ define( require => {
* @param {boolean} currentIndicatorsVisible
*/
updateCurrentVisibility: function( circuitConnection, currentIndicatorsVisible ) {
var isBatteryConnected = ( circuitConnection === CircuitState.BATTERY_CONNECTED );
const isBatteryConnected = ( circuitConnection === CircuitState.BATTERY_CONNECTED );

this.batteryTopCurrentIndicatorNode.setVisible( isBatteryConnected && currentIndicatorsVisible );
this.batteryBottomCurrentIndicatorNode.setVisible( isBatteryConnected && currentIndicatorsVisible );
Expand Down
8 changes: 4 additions & 4 deletions js/capacitance/view/CapacitanceScreenView.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ define( require => {
this.capacitanceCircuitNode = new CapacitanceCircuitNode( model, tandem.createTandem( 'capacitanceCircuitNode' ) );

// meters
var voltmeterNode = new VoltmeterNode( model.voltmeter, this.modelViewTransform, model.voltmeterVisibleProperty, tandem.createTandem( 'voltmeterNode' ) );
const voltmeterNode = new VoltmeterNode( model.voltmeter, this.modelViewTransform, model.voltmeterVisibleProperty, tandem.createTandem( 'voltmeterNode' ) );

// @public {DraggableTimerNode}
var draggableTimerNode = new DraggableTimerNode(
Expand Down Expand Up @@ -79,20 +79,20 @@ define( require => {
);

// control
var viewControlPanel = new CLBViewControlPanel( model, tandem.createTandem( 'viewControlPanel' ), {
const viewControlPanel = new CLBViewControlPanel( model, tandem.createTandem( 'viewControlPanel' ), {
maxTextWidth: 200
} );
viewControlPanel.rightTop = this.layoutBounds.rightTop.plus( new Vector2( -10, 10 ) );
toolboxPanel.rightTop = viewControlPanel.rightBottom.plus( new Vector2( 0, 10 ) );

var capacitanceBarMeterPanel = new BarMeterPanel(
const capacitanceBarMeterPanel = new BarMeterPanel(
model,
tandem.createTandem( 'barMeterPanel' )
);
capacitanceBarMeterPanel.left = this.capacitanceCircuitNode.topWireNode.left - 40;
capacitanceBarMeterPanel.top = this.layoutBounds.top + 10;

var resetAllButton = new ResetAllButton( {
const resetAllButton = new ResetAllButton( {
listener: function() {
model.reset();
},
Expand Down
10 changes: 5 additions & 5 deletions js/capacitor-lab-basics-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ define( require => {
const capacitorLabBasicsTitleString = require( 'string!CAPACITOR_LAB_BASICS/capacitor-lab-basics.title' );

// constants
var tandem = Tandem.rootTandem;
const tandem = Tandem.rootTandem;

var simOptions = {
const simOptions = {
credits: {
leadDesign: 'Amy Rouinfar',
softwareDevelopment: 'Andrew Adare, Jesse Greenberg, Chris Malley, Emily Randall, Jonathan Olson',
Expand All @@ -37,13 +37,13 @@ define( require => {

// Tracks whether a circuit switch has been changed by user. Once the switch has been changed in either screen,
// the cue arrows (used to hint that the switch is available) should disappear from both screens.
var switchUsedProperty = new Property( false );
const switchUsedProperty = new Property( false );

var screens = [
const screens = [
new CapacitanceScreen( switchUsedProperty, tandem.createTandem( 'capacitanceScreen' ) ),
new CLBLightBulbScreen( switchUsedProperty, tandem.createTandem( 'lightBulbScreen' ) )
];
var sim = new Sim( capacitorLabBasicsTitleString, screens, simOptions );
const sim = new Sim( capacitorLabBasicsTitleString, screens, simOptions );
sim.start();
} );
} );
Expand Down
6 changes: 3 additions & 3 deletions js/common/CLBConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ define( require => {
const RangeWithValue = require( 'DOT/RangeWithValue' );
const Vector3 = require( 'DOT/Vector3' );

var NEGATIVE = 'NEGATIVE';
var POSITIVE = 'POSITIVE';
var CLBConstants = {
const NEGATIVE = 'NEGATIVE';
const POSITIVE = 'POSITIVE';
const CLBConstants = {

//----------------------------------------------------------------------------
// Model
Expand Down
2 changes: 1 addition & 1 deletion js/common/CLBQueryParameters.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ define( require => {
// modules
const capacitorLabBasics = require( 'CAPACITOR_LAB_BASICS/capacitorLabBasics' );

var CLBQueryParameters = QueryStringMachine.getAll( {
const CLBQueryParameters = QueryStringMachine.getAll( {

// Provided as a customization for PhET-iO.
// Removes the open-circuit switch state in the Light Bulb screen
Expand Down
16 changes: 8 additions & 8 deletions js/common/model/Battery.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,24 @@ define( require => {

// constants
// size of the associated image file, determined by visual inspection
var BODY_SIZE = new Dimension2( 0.0065, 0.01425 ); // dimensions of the rectangle that bounds the battery image
const BODY_SIZE = new Dimension2( 0.0065, 0.01425 ); // dimensions of the rectangle that bounds the battery image

/*
* Positive terminal is part of the image file.
* The terminal is a cylinder, whose dimensions were determined by visual inspection.
* The origin of the terminal is at the center of the cylinder's top.
*/
var POSITIVE_TERMINAL_ELLIPSE_SIZE = new Dimension2( 0.0025, 0.0005 );
var POSITIVE_TERMINAL_CYLINDER_HEIGHT = 0.0009;
var POSITIVE_TERMINAL_Y_OFFSET = -( BODY_SIZE.height / 2 ) - 0.00012;
const POSITIVE_TERMINAL_ELLIPSE_SIZE = new Dimension2( 0.0025, 0.0005 );
const POSITIVE_TERMINAL_CYLINDER_HEIGHT = 0.0009;
const POSITIVE_TERMINAL_Y_OFFSET = -( BODY_SIZE.height / 2 ) - 0.00012;

/*
* Negative terminal is part of the image file.
* The terminal is an ellipse, whose dimension were determined by visual inspection.
* The origin of the terminal is at the center of the ellipse.
*/
var NEGATIVE_TERMINAL_ELLIPSE_SIZE = new Dimension2( 0.0035, 0.0009 ); // Ellipse axes defining the negative terminal
var NEGATIVE_TERMINAL_Y_OFFSET = -( BODY_SIZE.height / 2 ) + 0.0006; // center of negative terminal when at the top
const NEGATIVE_TERMINAL_ELLIPSE_SIZE = new Dimension2( 0.0035, 0.0009 ); // Ellipse axes defining the negative terminal
const NEGATIVE_TERMINAL_Y_OFFSET = -( BODY_SIZE.height / 2 ) + 0.0006; // center of negative terminal when at the top

/**
* @constructor
Expand Down Expand Up @@ -69,7 +69,7 @@ define( require => {
phetioType: PropertyIO( StringIO )
} );

var self = this;
const self = this;

// @public {Dimension2}
this.positiveTerminalEllipseSize = POSITIVE_TERMINAL_ELLIPSE_SIZE;
Expand Down Expand Up @@ -116,7 +116,7 @@ define( require => {
* @returns {boolean}
*/
contacts: function( probe ) {
var shape;
let shape;
if ( this.polarityProperty.value === CLBConstants.POLARITY.POSITIVE ) {
shape = this.positiveTerminalShape;
}
Expand Down
12 changes: 6 additions & 6 deletions js/common/model/CLBModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ define( require => {

// constants
// reference coordinate frame size for world nodes
var CANVAS_RENDERING_SIZE = new Dimension2( 1024, 618 );
const CANVAS_RENDERING_SIZE = new Dimension2( 1024, 618 );

/**
* @constructor
Expand Down Expand Up @@ -149,8 +149,8 @@ define( require => {
*/
getMaxPlateCharge: function() {

var maxArea = CLBConstants.PLATE_WIDTH_RANGE.max * CLBConstants.PLATE_WIDTH_RANGE.max;
var maxVoltage = CLBConstants.BATTERY_VOLTAGE_RANGE.max;
const maxArea = CLBConstants.PLATE_WIDTH_RANGE.max * CLBConstants.PLATE_WIDTH_RANGE.max;
const maxVoltage = CLBConstants.BATTERY_VOLTAGE_RANGE.max;

return CLBConstants.EPSILON_0 * maxArea * maxVoltage / CLBConstants.PLATE_SEPARATION_RANGE.min;
},
Expand All @@ -168,8 +168,8 @@ define( require => {
*/
getMaxEffectiveEField: function() {

var maxArea = CLBConstants.PLATE_WIDTH_RANGE.max * CLBConstants.PLATE_WIDTH_RANGE.max;
var minArea = CLBConstants.PLATE_WIDTH_RANGE.min * CLBConstants.PLATE_WIDTH_RANGE.min;
const maxArea = CLBConstants.PLATE_WIDTH_RANGE.max * CLBConstants.PLATE_WIDTH_RANGE.max;
const minArea = CLBConstants.PLATE_WIDTH_RANGE.min * CLBConstants.PLATE_WIDTH_RANGE.min;

return maxArea / minArea * CLBConstants.BATTERY_VOLTAGE_RANGE.max / CLBConstants.PLATE_SEPARATION_RANGE.min;
},
Expand All @@ -185,7 +185,7 @@ define( require => {
if ( this.isPlayingProperty.value || isManual ) {

// If a manual step is called the dt should be the same a normal dt value.
var adjustedDt = isManual ? dt : dt * ( this.isSlowMotionProperty.value ? 0.125 : 1 );
const adjustedDt = isManual ? dt : dt * ( this.isSlowMotionProperty.value ? 0.125 : 1 );
this.circuit.step( adjustedDt );
this.stepEmitter.emit( adjustedDt );
if ( this.isRunningProperty.value ) {
Expand Down
8 changes: 4 additions & 4 deletions js/common/model/CLBModelViewTransform3D.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ define( require => {

// Scratch variable for performance
// @private
var scratchVector2 = new Vector2( 0, 0 );
var scratchVector3 = new Vector3( 0, 0, 0 );
const scratchVector2 = new Vector2( 0, 0 );
const scratchVector3 = new Vector3( 0, 0, 0 );

/**
* @constructor
Expand Down Expand Up @@ -100,7 +100,7 @@ define( require => {
* @returns {Vector2}
*/
modelToViewDelta: function( delta ) {
var origin = this.modelToViewPosition( scratchVector3.setXYZ( 0, 0, 0 ) );
const origin = this.modelToViewPosition( scratchVector3.setXYZ( 0, 0, 0 ) );
return this.modelToViewPosition( delta ).minus( origin );
},

Expand Down Expand Up @@ -175,7 +175,7 @@ define( require => {
* @returns {Vector3}
*/
viewToModelDelta: function( delta ) {
var origin = this.viewToModelPosition( scratchVector2.setXY( 0, 0 ) );
const origin = this.viewToModelPosition( scratchVector2.setXY( 0, 0 ) );

return this.viewToModelPosition( delta ).minus( origin );
},
Expand Down
20 changes: 10 additions & 10 deletions js/common/model/Capacitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ define( require => {
this.shapeCreator = new BoxShapeCreator( config.modelViewTransform );

// Square plates.
var plateBounds = new Bounds3( 0, 0, 0, options.plateWidth, CLBConstants.PLATE_HEIGHT, options.plateWidth );
const plateBounds = new Bounds3( 0, 0, 0, options.plateWidth, CLBConstants.PLATE_HEIGHT, options.plateWidth );

// @public {Property.<Bounds3>}
this.plateSizeProperty = new Property( plateBounds, {
Expand Down Expand Up @@ -109,7 +109,7 @@ define( require => {
this.plateChargeProperty = new DerivedProperty( [ this.capacitanceProperty, this.plateVoltageProperty, circuitConnectionProperty ],
function( capacitance, voltage, circuitConnection ) {
if ( circuitConnection ) {
var charge = capacitance * voltage;
let charge = capacitance * voltage;

// Force an underflow to zero below the threshold for stability
if ( Math.abs( charge ) < CLBConstants.MIN_PLATE_CHARGE ) {
Expand Down Expand Up @@ -148,7 +148,7 @@ define( require => {

// link the top and bottom circuit switches together so that they rotate together
// as the user drags
var self = this;
const self = this;

// JS handles negative numbers precisely so there will not be an infinite
// loop here due to mutual recursion.
Expand Down Expand Up @@ -228,16 +228,16 @@ define( require => {
assert && assert( location === CircuitLocation.CAPACITOR_TOP || location === CircuitLocation.CAPACITOR_BOTTOM,
'Invalid capacitor location: ' + location );

var shape;
var size = this.plateSizeProperty.value;
let shape;
const size = this.plateSizeProperty.value;
if ( location === CircuitLocation.CAPACITOR_TOP ) {
shape = this.shapeCreator.createBoxShape( this.location.x, this.getTopConnectionPoint().y, this.location.z, size.width, size.height, size.depth );
}
else if ( location === CircuitLocation.CAPACITOR_BOTTOM ) {
shape = this.shapeCreator.createBoxShape( this.location.x, this.location.y + this.plateSeparationProperty.value / 2, this.location.z, size.width, size.height, size.depth );
}

var contacts = probe.bounds.intersectsBounds( shape.bounds ) &&
let contacts = probe.bounds.intersectsBounds( shape.bounds ) &&
probe.shapeIntersection( shape ).getNonoverlappingArea() > 0;

if ( !contacts && location === CircuitLocation.CAPACITOR_TOP ) {
Expand All @@ -260,7 +260,7 @@ define( require => {
* @returns {number} Volts/meter
*/
getEffectiveEField: function() {
var plateCharge = this.plateChargeProperty.value;
const plateCharge = this.plateChargeProperty.value;
if ( Math.abs( plateCharge ) < CLBConstants.MIN_PLATE_CHARGE ) {
return 0;
}
Expand All @@ -285,10 +285,10 @@ define( require => {
* @param {number} dt
*/
discharge: function( R, dt ) {
var C = this.capacitanceProperty.value;
const C = this.capacitanceProperty.value;

this.transientTime += dt; // step time since switch was closed
var exp = Math.exp( -this.transientTime / ( R * C ) );
const exp = Math.exp( -this.transientTime / ( R * C ) );
this.plateVoltageProperty.value = this.voltageAtSwitchClose * exp;

this.previousCapacitance = C;
Expand All @@ -315,7 +315,7 @@ define( require => {
updateDischargeParameters: function() {

// in the discharge function, C is recalculated every time step, so we only need to adjust Vo.
var capacitanceRatio = this.capacitanceProperty.value / this.previousCapacitance;
const capacitanceRatio = this.capacitanceProperty.value / this.previousCapacitance;

// update the initial voltage Vo
this.voltageAtSwitchClose = this.plateVoltageProperty.value / capacitanceRatio;
Expand Down
12 changes: 6 additions & 6 deletions js/common/model/CircuitConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ define( require => {
const CLBModelViewTransform3D = require( 'CAPACITOR_LAB_BASICS/common/model/CLBModelViewTransform3D' );

// Constants with default assignments
var CAPACITOR_X_SPACING = 0.024; // meters
var CAPACITOR_Y_SPACING = 0; // meters
var PLATE_WIDTH = CLBConstants.PLATE_WIDTH_RANGE.defaultValue;
var PLATE_SEPARATION = CLBConstants.PLATE_SEPARATION_RANGE.defaultValue;
var WIRE_EXTENT = 0.016; // how far the wire extends above or below the capacitor (meters)
const CAPACITOR_X_SPACING = 0.024; // meters
const CAPACITOR_Y_SPACING = 0; // meters
const PLATE_WIDTH = CLBConstants.PLATE_WIDTH_RANGE.defaultValue;
const PLATE_SEPARATION = CLBConstants.PLATE_SEPARATION_RANGE.defaultValue;
const WIRE_EXTENT = 0.016; // how far the wire extends above or below the capacitor (meters)

var CircuitConfig = {
const CircuitConfig = {

/**
* Returns the default circuit config, overridden with any options.
Expand Down
2 changes: 1 addition & 1 deletion js/common/model/CircuitLocation.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ define( require => {

const capacitorLabBasics = require( 'CAPACITOR_LAB_BASICS/capacitorLabBasics' );

var CircuitLocation = {
const CircuitLocation = {
BATTERY_TOP: 'BATTERY_TOP',
BATTERY_BOTTOM: 'BATTERY_BOTTOM',
LIGHT_BULB_TOP: 'LIGHT_BULB_TOP',
Expand Down
2 changes: 1 addition & 1 deletion js/common/model/CircuitState.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ define( require => {

const capacitorLabBasics = require( 'CAPACITOR_LAB_BASICS/capacitorLabBasics' );

var CircuitState = {
const CircuitState = {
BATTERY_CONNECTED: 'BATTERY_CONNECTED',
LIGHT_BULB_CONNECTED: 'LIGHT_BULB_CONNECTED',
OPEN_CIRCUIT: 'OPEN_CIRCUIT',
Expand Down
Loading

0 comments on commit 19bd67c

Please sign in to comment.