From 14a11014f673443fdc547e4f8ebf4a0e23398241 Mon Sep 17 00:00:00 2001 From: zepumph Date: Thu, 19 Sep 2019 14:24:48 -0800 Subject: [PATCH] var -> const using eslint auto fix, https://github.com/phetsims/tasks/issues/1012 --- js/common/GEEConstants.js | 8 +- js/common/GEEQueryParameters.js | 2 +- js/common/model/AttachmentSite.js | 4 +- js/common/model/BasePair.js | 2 +- js/common/model/BioShapeUtils.js | 88 +++++------ js/common/model/DnaMolecule.js | 142 +++++++++--------- js/common/model/DnaStrandPoint.js | 2 +- js/common/model/FlatSegment.js | 22 +-- js/common/model/Gene.js | 38 ++--- js/common/model/GeneA.js | 10 +- js/common/model/MessengerRna.js | 50 +++--- js/common/model/MessengerRnaDestroyer.js | 12 +- js/common/model/MessengerRnaFragment.js | 2 +- js/common/model/MobileBiomolecule.js | 6 +- js/common/model/Protein.js | 2 +- js/common/model/Ribosome.js | 38 ++--- js/common/model/RnaPolymerase.js | 18 +-- js/common/model/ShapeChangingModelElement.js | 12 +- js/common/model/ShapeSegment.js | 2 +- js/common/model/ShapeUtils.js | 22 +-- js/common/model/SquareSegment.js | 8 +- js/common/model/TranscriptionFactor.js | 12 +- js/common/model/WindingBiomolecule.js | 122 +++++++-------- .../AttachedAndConformingState.js | 10 +- .../AttachedAndDeconformingState.js | 20 +-- .../AttachedAndTranscribingState.js | 24 +-- .../AttachedToDnaNotTranscribingState.js | 18 +-- .../BeingRecycledState.js | 6 +- .../DetachingFromPolymeraseState.js | 2 +- .../GenericAttachedState.js | 4 +- .../GenericMovingTowardsAttachmentState.js | 4 +- .../GenericUnattachedAndAvailableState.js | 2 +- .../GenericUnattachedButUnavailableState.js | 4 +- .../MRnaDestroyerAttachedState.js | 12 +- .../MessengerRnaAttachmentStateMachine.js | 2 +- ...sengerRnaFragmentAttachmentStateMachine.js | 12 +- .../ProteinAttachmentStateMachine.js | 4 +- .../RibosomeAttachedState.js | 18 +-- .../RnaPolymeraseAttachmentStateMachine.js | 6 +- .../TranscriptionFactorAttachedState.js | 16 +- ...achedAndAvailableForMRnaAttachmentState.js | 2 +- .../UnattachedAndFadingState.js | 6 +- .../DestroyerTrackingRnaMotionStrategy.js | 2 +- .../DriftThenTeleportMotionStrategy.js | 22 +-- .../MeanderToDestinationMotionStrategy.js | 4 +- .../model/motion-strategies/MotionBounds.js | 6 +- .../model/motion-strategies/MotionStrategy.js | 22 +-- ...MoveDirectlyToDestinationMotionStrategy.js | 18 +-- .../RandomWalkMotionStrategy.js | 24 +-- .../RibosomeTranslatingRnaMotionStrategy.js | 2 +- .../WanderInGeneralDirectionMotionStrategy.js | 16 +- js/common/util/GradientUtil.js | 6 +- js/common/view/BiomoleculeDragHandler.js | 4 +- js/common/view/ControllerNode.js | 8 +- js/common/view/DnaMoleculeCanvasNode.js | 42 +++--- js/common/view/DnaMoleculeNode.js | 4 +- js/common/view/FadeLabel.js | 10 +- js/common/view/FadeTimer.js | 2 +- js/common/view/GeneNode.js | 38 ++--- js/common/view/MessengerRnaNode.js | 14 +- js/common/view/MobileBiomoleculeNode.js | 6 +- js/common/view/PlacementHintNode.js | 14 +- js/gene-expression-essentials-main.js | 4 +- .../ManualGeneExpressionScreen.js | 2 +- js/manual-gene-expression/model/GeneB.js | 10 +- js/manual-gene-expression/model/GeneC.js | 12 +- .../model/ManualGeneExpressionModel.js | 26 ++-- js/manual-gene-expression/model/ProteinA.js | 8 +- js/manual-gene-expression/model/ProteinB.js | 12 +- js/manual-gene-expression/model/ProteinC.js | 14 +- .../view/BiomoleculeCreatorNode.js | 10 +- .../view/BiomoleculeToolboxNode.js | 58 +++---- .../view/FlashController.js | 4 +- .../view/FlashingShapeNode.js | 4 +- .../view/ManualGeneExpressionScreenView.js | 48 +++--- .../view/MessengerRnaDestroyerCreatorNode.js | 6 +- .../view/ProteinCaptureNode.js | 26 ++-- .../view/ProteinCollectionArea.js | 16 +- .../view/ProteinCollectionNode.js | 30 ++-- .../view/RibosomeCreatorNode.js | 6 +- .../view/RnaPolymeraseCreatorNode.js | 6 +- .../view/TranscriptionFactorCreatorNode.js | 6 +- .../MessengerRnaProductionScreen.js | 2 +- .../model/MessengerRnaProductionModel.js | 62 ++++---- js/mrna-production/view/AffinityController.js | 18 +-- .../view/ConcentrationController.js | 4 +- .../view/MessengerRnaProductionScreenView.js | 40 ++--- .../view/PolymeraseAffinityControlPanel.js | 32 ++-- .../view/TranscriptionFactorControlPanel.js | 22 +-- js/multiple-cells/MultipleCellsScreen.js | 2 +- js/multiple-cells/model/Cell.js | 10 +- .../model/CellProteinSynthesisSimulator.js | 46 +++--- js/multiple-cells/model/MultipleCellsModel.js | 34 ++--- .../view/ColorChangingCellNode.js | 12 +- js/multiple-cells/view/ControlPanelNode.js | 12 +- .../view/FluorescentCellsPictureDialog.js | 12 +- .../view/MultipleCellsScreenView.js | 44 +++--- .../view/ProteinLevelChartNode.js | 24 +-- 98 files changed, 872 insertions(+), 872 deletions(-) diff --git a/js/common/GEEConstants.js b/js/common/GEEConstants.js index 1009e466..f21ab7dc 100644 --- a/js/common/GEEConstants.js +++ b/js/common/GEEConstants.js @@ -17,11 +17,11 @@ define( require => { const Vector2 = require( 'DOT/Vector2' ); // constants - var LENGTH_PER_TWIST = 340;// In picometers - var BASE_PAIRS_PER_TWIST = 10;// In picometers. - var INTER_POINT_DISTANCE = 75;// In picometers + const LENGTH_PER_TWIST = 340;// In picometers + const BASE_PAIRS_PER_TWIST = 10;// In picometers. + const INTER_POINT_DISTANCE = 75;// In picometers - var GEEConstants = { + const GEEConstants = { // max DT value, used by all screens now, but this doesn't need to be the case MAX_DT: ( 1 / 60 ) * 10, diff --git a/js/common/GEEQueryParameters.js b/js/common/GEEQueryParameters.js index 4a8635b3..78b51fb5 100644 --- a/js/common/GEEQueryParameters.js +++ b/js/common/GEEQueryParameters.js @@ -11,7 +11,7 @@ define( require => { // modules const geneExpressionEssentials = require( 'GENE_EXPRESSION_ESSENTIALS/geneExpressionEssentials' ); - var GEEQueryParameters = QueryStringMachine.getAll( { + const GEEQueryParameters = QueryStringMachine.getAll( { // show bounding rectangle for mRNA, useful for debugging showMRnaBoundingRect: { type: 'flag' } diff --git a/js/common/model/AttachmentSite.js b/js/common/model/AttachmentSite.js index 5dab0f49..2f0269b6 100644 --- a/js/common/model/AttachmentSite.js +++ b/js/common/model/AttachmentSite.js @@ -20,7 +20,7 @@ define( require => { const Range = require( 'DOT/Range' ); // constants - var ATTACHED_THRESHOLD = 10; // Threshold used to decide whether or not a biomolecule is attached, in picometers. + const ATTACHED_THRESHOLD = 10; // Threshold used to decide whether or not a biomolecule is attached, in picometers. /** * @param {Object} owner - the molecule upon which this attachment site exists @@ -79,7 +79,7 @@ define( require => { if ( !( obj instanceof AttachmentSite ) ) { return false; } - var otherAttachmentSite = obj; + const otherAttachmentSite = obj; return (this.affinityProperty.get() === otherAttachmentSite.affinityProperty.get() ) && this.positionProperty.get().equals( otherAttachmentSite.positionProperty.get() ); diff --git a/js/common/model/BasePair.js b/js/common/model/BasePair.js index 068ba33f..81baedf5 100644 --- a/js/common/model/BasePair.js +++ b/js/common/model/BasePair.js @@ -22,7 +22,7 @@ define( require => { const inherit = require( 'PHET_CORE/inherit' ); // constants - var BASE_PAIR_WIDTH = 13; // In picometers. Not sure if this is close to real life, chosen to look decent in view. + const BASE_PAIR_WIDTH = 13; // In picometers. Not sure if this is close to real life, chosen to look decent in view. /** * @param {number} centerLocationX diff --git a/js/common/model/BioShapeUtils.js b/js/common/model/BioShapeUtils.js index 1411dd76..584bc10e 100644 --- a/js/common/model/BioShapeUtils.js +++ b/js/common/model/BioShapeUtils.js @@ -20,7 +20,7 @@ define( require => { const ShapeUtils = require( 'GENE_EXPRESSION_ESSENTIALS/common/model/ShapeUtils' ); const Vector2 = require( 'DOT/Vector2' ); - var BioShapeUtils = { + const BioShapeUtils = { /** * Create a distorted shape from a list of points. This is useful when trying to animate some sort of deviation * from a basic shape. @@ -34,21 +34,21 @@ define( require => { * @public */ createdDistortedRoundedShapeFromPoints: function( points, distortionFactor, randomNumberSeed ) { - var rand = new Random( { + const rand = new Random( { seed: randomNumberSeed } ); // Alter the positions of the points that define the shape in order to define a distorted version of the shape. - var alteredPoints = []; + const alteredPoints = []; - for ( var i = 0; i < points.length; i++ ) { - var pointAsVector = points[ i ].copy(); + for ( let i = 0; i < points.length; i++ ) { + const pointAsVector = points[ i ].copy(); pointAsVector.multiplyScalar( 1 + ( rand.nextDouble() - 0.5 ) * distortionFactor ); alteredPoints.push( pointAsVector ); } // Create the basis for the new shape. - var distortedShape = ShapeUtils.createRoundedShapeFromPoints( alteredPoints ); + const distortedShape = ShapeUtils.createRoundedShapeFromPoints( alteredPoints ); return distortedShape; }, @@ -65,19 +65,19 @@ define( require => { */ createRandomShapeFromPoints: function( points, seed ) { - var shape = new Shape(); - var rand = new Random( { + const shape = new Shape(); + const rand = new Random( { seed: seed } ); - var cp1 = Vector2.dirtyFromPool(); - var cp2 = Vector2.dirtyFromPool(); + let cp1 = Vector2.dirtyFromPool(); + let cp2 = Vector2.dirtyFromPool(); shape.moveToPoint( points[ 0 ] ); - for ( var i = 0; i < points.length; i++ ) { - var segmentStartPoint = points[ i ]; - var segmentEndPoint = points[ ( i + 1 ) % points.length ]; - var previousPoint = points[ i - 1 >= 0 ? i - 1 : points.length - 1 ]; - var nextPoint = points[ ( i + 2 ) % points.length ]; + for ( let i = 0; i < points.length; i++ ) { + const segmentStartPoint = points[ i ]; + const segmentEndPoint = points[ ( i + 1 ) % points.length ]; + const previousPoint = points[ i - 1 >= 0 ? i - 1 : points.length - 1 ]; + const nextPoint = points[ ( i + 2 ) % points.length ]; cp1 = ShapeUtils.extrapolateControlPoint( previousPoint, segmentStartPoint, segmentEndPoint, cp1 ); cp2 = ShapeUtils.extrapolateControlPoint( nextPoint, segmentEndPoint, segmentStartPoint,cp2 ); if ( rand.nextBoolean() ) { @@ -102,23 +102,23 @@ define( require => { * @public */ createRandomShape: function( size, seed ) { - var pointList = []; - var rand = new Random( { + const pointList = []; + const rand = new Random( { seed: seed } ); // Create a series of points that will enclose a space. - for ( var angle = 0; angle < 1.9 * Math.PI; angle += Math.PI / 10 + rand.nextDouble() * Math.PI / 10 ) { + for ( let angle = 0; angle < 1.9 * Math.PI; angle += Math.PI / 10 + rand.nextDouble() * Math.PI / 10 ) { pointList.push( Vector2.createPolar( 0.5 + rand.nextDouble(), angle ) ); } - var unscaledShape = this.createRandomShapeFromPoints( pointList, seed ); - var unscaledShapeBounds = unscaledShape.bounds; + const unscaledShape = this.createRandomShapeFromPoints( pointList, seed ); + const unscaledShapeBounds = unscaledShape.bounds; // Scale the shape to the specified size. - var horizontalScale = size.width / unscaledShapeBounds.width; - var verticalScale = size.height / unscaledShapeBounds.height; + const horizontalScale = size.width / unscaledShapeBounds.width; + const verticalScale = size.height / unscaledShapeBounds.height; - var scaledMatrix = Matrix3.scaling( horizontalScale, verticalScale ); + const scaledMatrix = Matrix3.scaling( horizontalScale, verticalScale ); return unscaledShape.transformed( scaledMatrix ); }, @@ -133,10 +133,10 @@ define( require => { assert && assert( points.length > 0 ); // Control points, used throughout the code below for curving the line. - var cp1 = Vector2.dirtyFromPool(); - var cp2 = Vector2.dirtyFromPool(); + let cp1 = Vector2.dirtyFromPool(); + let cp2 = Vector2.dirtyFromPool(); - var path = new Shape(); + const path = new Shape(); path.moveTo( points[ 0 ].x, points[ 0 ].y ); if ( points.length === 1 || points.length === 2 ) { @@ -150,11 +150,11 @@ define( require => { path.quadraticCurveTo( cp1.x, cp1.y, points[ 1 ].x, points[ 1 ].y ); // create the middle segments - for ( var i = 1; i < points.length - 2; i++ ) { - var segmentStartPoint = points[ i ]; - var segmentEndPoint = points[ i + 1 ]; - var previousPoint = points[ i - 1 ]; - var nextPoint = points[ ( i + 2 ) ]; + for ( let i = 1; i < points.length - 2; i++ ) { + const segmentStartPoint = points[ i ]; + const segmentEndPoint = points[ i + 1 ]; + const previousPoint = points[ i - 1 ]; + const nextPoint = points[ ( i + 2 ) ]; cp1 = ShapeUtils.extrapolateControlPoint( previousPoint, segmentStartPoint, segmentEndPoint, cp1 ); cp2 = ShapeUtils.extrapolateControlPoint( nextPoint, segmentEndPoint, segmentStartPoint, cp2 ); path.cubicCurveTo( cp1.x, cp1.y, cp2.x, cp2.y, segmentEndPoint.x, segmentEndPoint.y ); @@ -189,31 +189,31 @@ define( require => { assert && assert( width > height ); // Param checking. Can't create the needed shape if this isn't true. // Tweakable parameters that affect number of points used to define the shape. - var numPointsPerLineSegment = 8; - var numPointsPerCurvedSegment = 8; + const numPointsPerLineSegment = 8; + const numPointsPerCurvedSegment = 8; // Adjustable parameter that affects the degree to which the shape is altered to make it look somewhat irregular. // Zero means no change from the perfect geometric shape, 1 means a lot of variation. - var alterationFactor = 0.025; + const alterationFactor = 0.025; // The list of points that will define the shape. - var pointList = []; + const pointList = []; // Random number generator used for deviation from the perfect geometric shape. - var rand = new Random( { + const rand = new Random( { seed: 45 // empirically determined to make shape look distorted } ); // Variables needed for the calculations. - var curveRadius = height / 2; - var lineLength = width - height; - var rightCurveCenterX = width / 2 - height / 2; - var leftCurveCenterX = -width / 2 + height / 2; - var centerY = 0; - var angle = 0; - var radius = 0; - var nextPoint = null; + const curveRadius = height / 2; + const lineLength = width - height; + const rightCurveCenterX = width / 2 - height / 2; + const leftCurveCenterX = -width / 2 + height / 2; + const centerY = 0; + let angle = 0; + let radius = 0; + let nextPoint = null; // Create a shape that is like E. Coli. Start at the left side of the line that defines the top edge and move // around the shape in a clockwise direction. diff --git a/js/common/model/DnaMolecule.js b/js/common/model/DnaMolecule.js index a66e6fa2..616b5c16 100644 --- a/js/common/model/DnaMolecule.js +++ b/js/common/model/DnaMolecule.js @@ -31,12 +31,12 @@ define( require => { // constants // distance within which transcription factors may attach - var TRANSCRIPTION_FACTOR_ATTACHMENT_DISTANCE = 400; + const TRANSCRIPTION_FACTOR_ATTACHMENT_DISTANCE = 400; // distance within which RNA polymerase may attach - var RNA_POLYMERASE_ATTACHMENT_DISTANCE = 400; + const RNA_POLYMERASE_ATTACHMENT_DISTANCE = 400; - var attachmentSiteLocation = new Vector2( 0, 0 ); + const attachmentSiteLocation = new Vector2( 0, 0 ); /** * @param {GeneExpressionModel} model - the gene expression model within which this DNA strand exists @@ -89,11 +89,11 @@ define( require => { // Add the initial set of shape-defining points for each of the two strands. Points are spaced the same as the // base pairs. - for ( var i = 0; i < numBasePairs; i++ ) { - var xPos = leftEdgeXOffset + i * GEEConstants.DISTANCE_BETWEEN_BASE_PAIRS; - var strand1YPos = this.getDnaStrandYPosition( xPos, 0 ); - var strand2YPos = this.getDnaStrandYPosition( xPos, GEEConstants.INTER_STRAND_OFFSET ); - var height = Math.abs( strand1YPos - strand2YPos ); + for ( let i = 0; i < numBasePairs; i++ ) { + const xPos = leftEdgeXOffset + i * GEEConstants.DISTANCE_BETWEEN_BASE_PAIRS; + const strand1YPos = this.getDnaStrandYPosition( xPos, 0 ); + const strand2YPos = this.getDnaStrandYPosition( xPos, GEEConstants.INTER_STRAND_OFFSET ); + const height = Math.abs( strand1YPos - strand2YPos ); this.maxBasePairHeight = height > this.maxBasePairHeight ? height : this.maxBasePairHeight; // Add in the base pairs between the backbone strands. This calculates the distance between the two strands and @@ -147,13 +147,13 @@ define( require => { * @private */ initializeStrandSegments: function() { - var strand1SegmentPoints = []; - var strand2SegmentPoints = []; - var segmentStartX = this.strandPoints[ 0 ].xPos; - var strand1InFront = true; - for ( var i = 0; i < this.strandPoints.length; i++ ) { - var dnaStrandPoint = this.strandPoints[ i ]; - var xPos = dnaStrandPoint.xPos; + let strand1SegmentPoints = []; + let strand2SegmentPoints = []; + let segmentStartX = this.strandPoints[ 0 ].xPos; + let strand1InFront = true; + for ( let i = 0; i < this.strandPoints.length; i++ ) { + const dnaStrandPoint = this.strandPoints[ i ]; + const xPos = dnaStrandPoint.xPos; strand1SegmentPoints.push( new Vector2( xPos, dnaStrandPoint.strand1YPos ) ); strand2SegmentPoints.push( new Vector2( xPos, dnaStrandPoint.strand2YPos ) ); if ( xPos - segmentStartX >= ( GEEConstants.LENGTH_PER_TWIST / 2 ) ) { @@ -161,7 +161,7 @@ define( require => { // Time to add these segments and start a new ones. this.strand1Segments.push( strand1SegmentPoints ); this.strand2Segments.push( strand2SegmentPoints ); - var firstPointOfNextSegment = strand1SegmentPoints[ strand1SegmentPoints.length - 1 ]; + let firstPointOfNextSegment = strand1SegmentPoints[ strand1SegmentPoints.length - 1 ]; strand1SegmentPoints = []; // clear; strand1SegmentPoints.push( firstPointOfNextSegment ); // This point must be on this segment too in order to prevent gaps. firstPointOfNextSegment = strand2SegmentPoints[ strand2SegmentPoints.length - 1 ]; @@ -197,7 +197,7 @@ define( require => { * @private */ updateStrandSegments: function() { - var self = this; + const self = this; this.redraw = false; // Set the shadow points to the nominal, non-deformed positions. @@ -212,9 +212,9 @@ define( require => { this.separations.forEach( function( separation ) { // Make the window wider than it is high. This was chosen to look decent, tweak if needed. - var windowWidth = separation.getAmount() * 1.5; + const windowWidth = separation.getAmount() * 1.5; - var separationWindowXIndexRange = new Range( + const separationWindowXIndexRange = new Range( Math.floor( ( separation.getXPosition() - ( windowWidth / 2 ) - self.leftEdgeXOffset ) / GEEConstants.DISTANCE_BETWEEN_BASE_PAIRS ), @@ -222,13 +222,13 @@ define( require => { ( separation.getXPosition() + ( windowWidth / 2 ) - self.leftEdgeXOffset ) / GEEConstants.DISTANCE_BETWEEN_BASE_PAIRS ) ); - for ( var i = separationWindowXIndexRange.min; i < separationWindowXIndexRange.max; i++ ) { - var windowCenterX = ( separationWindowXIndexRange.min + separationWindowXIndexRange.max ) / 2; + for ( let i = separationWindowXIndexRange.min; i < separationWindowXIndexRange.max; i++ ) { + const windowCenterX = ( separationWindowXIndexRange.min + separationWindowXIndexRange.max ) / 2; if ( i >= 0 && i < self.strandPointsShadow.length ) { // Perform a windowing algorithm that weights the separation at 1 in the center, 0 at the edges, and linear // graduations in between. - var separationWeight = 1 - Math.abs( 2 * ( i - windowCenterX ) / separationWindowXIndexRange.getLength() ); + const separationWeight = 1 - Math.abs( 2 * ( i - windowCenterX ) / separationWindowXIndexRange.getLength() ); self.strandPointsShadow[ i ].strand1YPos = ( 1 - separationWeight ) * self.strandPointsShadow[ i ].strand1YPos + separationWeight * separation.getAmount() / 2; self.strandPointsShadow[ i ].strand2YPos = ( 1 - separationWeight ) * self.strandPointsShadow[ i ].strand2YPos - @@ -244,22 +244,22 @@ define( require => { } ); // See if any of the points have moved and, if so, update the corresponding shape segment. - var numSegments = this.strand1Segments.length; - for ( var i = 0; i < numSegments; i++ ) { - var segmentChanged = false; - var strand1Segment = this.strand1Segments[ i ]; + const numSegments = this.strand1Segments.length; + for ( let i = 0; i < numSegments; i++ ) { + let segmentChanged = false; + const strand1Segment = this.strand1Segments[ i ]; // Determine the bounds of the current segment. Assumes that the bounds for the strand1 and strand2 segments are // the same, which should be a safe assumption. //var bounds = strand1Segment.getShape().bounds; - var minX = strand1Segment[ 0 ].x; - var maxX = strand1Segment[ strand1Segment.length - 1 ].x; - var pointIndexRange = new Range( Math.floor( ( minX - this.leftEdgeXOffset ) / GEEConstants.DISTANCE_BETWEEN_BASE_PAIRS ), + const minX = strand1Segment[ 0 ].x; + const maxX = strand1Segment[ strand1Segment.length - 1 ].x; + const pointIndexRange = new Range( Math.floor( ( minX - this.leftEdgeXOffset ) / GEEConstants.DISTANCE_BETWEEN_BASE_PAIRS ), Math.floor( ( maxX - this.leftEdgeXOffset ) / GEEConstants.DISTANCE_BETWEEN_BASE_PAIRS ) ); // Check to see if any of the points within the identified range have changed and, if so, update the // corresponding segment shape in the strands. If the points for either strand has changed, both are updated. - for ( var j = pointIndexRange.min; j < pointIndexRange.max; j++ ) { + for ( let j = pointIndexRange.min; j < pointIndexRange.max; j++ ) { if ( !this.strandPoints[ j ].equals( this.strandPointsShadow[ j ] ) ) { // The point has changed. Update it, mark the change. @@ -276,9 +276,9 @@ define( require => { if ( segmentChanged ) { this.redraw = true; // Update the shape of this segment. - var strand1ShapePoints = []; - var strand2ShapePoints = []; - for ( var k = pointIndexRange.min; k < pointIndexRange.max; k++ ) { + const strand1ShapePoints = []; + const strand2ShapePoints = []; + for ( let k = pointIndexRange.min; k < pointIndexRange.max; k++ ) { //for performance reasons using object literals instead of Vector instances strand1ShapePoints.push( { x: this.strandPoints[ k ].xPos, y: this.strandPoints[ k ].strand1YPos } ); @@ -355,7 +355,7 @@ define( require => { * @public */ removeSeparation: function( separation ) { - var index = this.separations.indexOf( separation ); + const index = this.separations.indexOf( separation ); if ( index !== -1 ) { this.separations.splice( index, 1 ); } @@ -432,8 +432,8 @@ define( require => { * @public */ getTopEdgeYPosition: function() { - var dnaStrand = this.strand1Segments[ 0 ]; - var index = Math.floor( dnaStrand.length / 2 ); + const dnaStrand = this.strand1Segments[ 0 ]; + const index = Math.floor( dnaStrand.length / 2 ); return dnaStrand[ index ].y; }, @@ -444,8 +444,8 @@ define( require => { */ getBottomEdgeYPosition: function() { // assert statement here - var dnaStrand = this.strand1Segments[ 1 ]; - var index = Math.floor( dnaStrand.length / 2 ); + const dnaStrand = this.strand1Segments[ 1 ]; + const index = Math.floor( dnaStrand.length / 2 ); return dnaStrand[ index ].y; }, @@ -459,7 +459,7 @@ define( require => { * @public */ considerProposalFromTranscriptionFactor: function( transcriptionFactor ) { - var self = this; + const self = this; return this.considerProposalFromBiomolecule( transcriptionFactor, TRANSCRIPTION_FACTOR_ATTACHMENT_DISTANCE, @@ -485,7 +485,7 @@ define( require => { * @public */ considerProposalFromRnaPolymerase: function( rnaPolymerase ) { - var self = this; + const self = this; return this.considerProposalFromBiomolecule( rnaPolymerase, RNA_POLYMERASE_ATTACHMENT_DISTANCE, function( basePairIndex ) { return self.getRnaPolymeraseAttachmentSiteForBasePairIndex( basePairIndex ); @@ -512,8 +512,8 @@ define( require => { considerProposalFromBiomolecule: function( biomolecule, maxAttachDistance, getAttachSiteForBasePair, isOkayToAttach, getAttachmentSite ) { - var potentialAttachmentSites = []; - for ( var i = 0; i < this.basePairs.length; i++ ) { + let potentialAttachmentSites = []; + for ( let i = 0; i < this.basePairs.length; i++ ) { // See if the base pair is within the max attachment distance. attachmentSiteLocation.setXY( this.basePairs[ i ].getCenterLocationX(), GEEConstants.DNA_MOLECULE_Y_POS ); @@ -521,7 +521,7 @@ define( require => { if ( attachmentSiteLocation.distance( biomolecule.getPosition() ) <= maxAttachDistance ) { // In range. Add it to the list if it is available. - var potentialAttachmentSite = getAttachSiteForBasePair( i ); + const potentialAttachmentSite = getAttachSiteForBasePair( i ); if ( potentialAttachmentSite.attachedOrAttachingMoleculeProperty.get() === null ) { potentialAttachmentSites.push( potentialAttachmentSite ); } @@ -533,7 +533,7 @@ define( require => { if ( potentialAttachmentSites.length === 0 && this.pursueAttachments ) { this.genes.forEach( function( gene ) { if ( isOkayToAttach( gene ) ) { - var matchingSite = getAttachmentSite( gene ); + const matchingSite = getAttachmentSite( gene ); // Found a matching site on a gene. if ( matchingSite.attachedOrAttachingMoleculeProperty.get() === null ) { @@ -542,8 +542,8 @@ define( require => { potentialAttachmentSites.push( matchingSite ); } else if ( !matchingSite.isMoleculeAttached() ) { - var thisDistance = biomolecule.getPosition().distance( matchingSite.positionProperty.get() ); - var thatDistance = matchingSite.attachedOrAttachingMoleculeProperty.get().getPosition().distance( + const thisDistance = biomolecule.getPosition().distance( matchingSite.positionProperty.get() ); + const thatDistance = matchingSite.attachedOrAttachingMoleculeProperty.get().getPosition().distance( matchingSite.positionProperty.get() ); if ( thisDistance < thatDistance ) { @@ -567,8 +567,8 @@ define( require => { return null; } - var exponent = 1; - var attachLocation = biomolecule.getPosition(); + const exponent = 1; + const attachLocation = biomolecule.getPosition(); // Sort the collection so that the best site is at the top of the list. potentialAttachmentSites.sort( function( attachmentSite1, attachmentSite2 ) { @@ -577,9 +577,9 @@ define( require => { // The exponent effectively sets the relative weighting of one versus another. An exponent value of zero means // only the affinity matters, a value of 100 means it is pretty much entirely distance. A value of 2 is how // gravity works, so it appears kind of natural. Tweak as needed. - var as1Factor = attachmentSite1.getAffinity() / + const as1Factor = attachmentSite1.getAffinity() / Math.pow( attachLocation.distance( attachmentSite1.positionProperty.get() ), exponent ); - var as2Factor = attachmentSite2.getAffinity() / + const as2Factor = attachmentSite2.getAffinity() / Math.pow( attachLocation.distance( attachmentSite2.positionProperty.get() ), exponent ); if ( as2Factor > as1Factor ) { @@ -606,12 +606,12 @@ define( require => { * @private */ eliminateInvalidAttachmentSites: function( biomolecule, potentialAttachmentSites ) { - var self = this; + const self = this; return _.filter( potentialAttachmentSites, function( attachmentSite ) { // determine the bounds for the provided biomolecule when translated to the attachment site - var translationVector = attachmentSite.positionProperty.get().minus( biomolecule.getPosition() ); - var translatedShapeBounds = biomolecule.bounds.shifted( translationVector.x, translationVector.y ); + let translationVector = attachmentSite.positionProperty.get().minus( biomolecule.getPosition() ); + const translatedShapeBounds = biomolecule.bounds.shifted( translationVector.x, translationVector.y ); // if the biomolecule would be out of the model bounds, the site should be excluded if ( !biomolecule.motionBoundsProperty.get().inBounds( translatedShapeBounds ) ) { @@ -619,7 +619,7 @@ define( require => { } // make a list of the bounds where all attached or incoming biomolecules are or will be (once attached) - var attachedOrIncomingBiomoleculeBounds = []; + const attachedOrIncomingBiomoleculeBounds = []; self.model.mobileBiomoleculeList.forEach( function( mobileBiomolecule ) { // skip the biomolecule being tested for overlap @@ -627,7 +627,7 @@ define( require => { return; } - var attachmentSite = mobileBiomolecule.attachmentStateMachine.attachmentSite; + const attachmentSite = mobileBiomolecule.attachmentStateMachine.attachmentSite; if ( attachmentSite && attachmentSite.owner === self ) { if ( mobileBiomolecule.attachedToDnaProperty.get() ) { @@ -647,9 +647,9 @@ define( require => { } } ); - var overlapsOtherMolecules = false; - for ( var i = 0; i < attachedOrIncomingBiomoleculeBounds.length; i++ ) { - var mobileBiomoleculeBounds = attachedOrIncomingBiomoleculeBounds[ i ]; + let overlapsOtherMolecules = false; + for ( let i = 0; i < attachedOrIncomingBiomoleculeBounds.length; i++ ) { + const mobileBiomoleculeBounds = attachedOrIncomingBiomoleculeBounds[ i ]; if ( mobileBiomoleculeBounds.intersectsBounds( translatedShapeBounds ) ) { overlapsOtherMolecules = true; break; @@ -667,7 +667,7 @@ define( require => { */ getTranscriptionFactorAttachmentSiteForBasePairIndex: function( i, tfConfig ) { // See if this base pair is inside a gene. - var gene = this.getGeneContainingBasePair( i ); + const gene = this.getGeneContainingBasePair( i ); if ( gene !== null ) { // Base pair is in a gene, so get it from the gene. @@ -686,7 +686,7 @@ define( require => { */ getRnaPolymeraseAttachmentSiteForBasePairIndex: function( i ) { // See if this base pair is inside a gene. - var gene = this.getGeneContainingBasePair( i ); + const gene = this.getGeneContainingBasePair( i ); if ( gene !== null ) { // Base pair is in a gene. See if site is available. return gene.getPolymeraseAttachmentSiteByIndex( i ); @@ -708,9 +708,9 @@ define( require => { * @public */ getAdjacentAttachmentSitesTranscriptionFactor: function( transcriptionFactor, attachmentSite ) { - var basePairIndex = this.getBasePairIndexFromXOffset( attachmentSite.positionProperty.get().x ); - var attachmentSites = []; - var potentialSite; + const basePairIndex = this.getBasePairIndexFromXOffset( attachmentSite.positionProperty.get().x ); + const attachmentSites = []; + let potentialSite; if ( basePairIndex !== 0 ) { potentialSite = this.getTranscriptionFactorAttachmentSiteForBasePairIndex( basePairIndex - 1, transcriptionFactor.getConfig() ); @@ -739,9 +739,9 @@ define( require => { * @public */ getAdjacentAttachmentSitesRnaPolymerase: function( rnaPolymerase, attachmentSite ) { - var basePairIndex = this.getBasePairIndexFromXOffset( attachmentSite.positionProperty.get().x ); - var attachmentSites = []; - var potentialSite; + const basePairIndex = this.getBasePairIndexFromXOffset( attachmentSite.positionProperty.get().x ); + const attachmentSites = []; + let potentialSite; if ( basePairIndex !== 0 ) { potentialSite = this.getRnaPolymeraseAttachmentSiteForBasePairIndex( basePairIndex - 1 ); if ( potentialSite.attachedOrAttachingMoleculeProperty.get() === null ) { @@ -765,9 +765,9 @@ define( require => { * @private */ getGeneContainingBasePair: function( basePairIndex ) { - var geneContainingBasePair = null; - for ( var i = 0; i < this.genes.length; i++ ) { - var gene = this.genes[ i ]; + let geneContainingBasePair = null; + for ( let i = 0; i < this.genes.length; i++ ) { + const gene = this.genes[ i ]; if ( gene.containsBasePair( basePairIndex ) ) { geneContainingBasePair = gene; break; @@ -810,8 +810,8 @@ define( require => { 'requested location is not on DNA molecule: ' + location ); - var geneAtLocation = null; - var basePairIndex = this.getBasePairIndexFromXOffset( location.x ); + let geneAtLocation = null; + const basePairIndex = this.getBasePairIndexFromXOffset( location.x ); this.genes.forEach( function( gene ) { if ( gene.containsBasePair( basePairIndex ) ) { diff --git a/js/common/model/DnaStrandPoint.js b/js/common/model/DnaStrandPoint.js index cd81ccc4..1f97f4d5 100644 --- a/js/common/model/DnaStrandPoint.js +++ b/js/common/model/DnaStrandPoint.js @@ -23,7 +23,7 @@ define( require => { */ function DnaStrandPoint( xPos, strand1YPos, strand2YPos ) { if ( !_.isFinite( strand1YPos ) ) { // use isFinite otherwise the condition fails at zero (Ashraf) - var strandPoint = xPos; + const strandPoint = xPos; this.xPos = strandPoint.xPos; // @public this.strand1YPos = strandPoint.strand1YPos; // @public this.strand2YPos = strandPoint.strand2YPos; // @public diff --git a/js/common/model/FlatSegment.js b/js/common/model/FlatSegment.js index c2588ac0..a6208132 100644 --- a/js/common/model/FlatSegment.js +++ b/js/common/model/FlatSegment.js @@ -53,12 +53,12 @@ define( require => { // This shouldn't be called if there is no remaining capacity. assert && assert( this.getContainedLength() <= this.capacity ); - var growthAmount = length; + let growthAmount = length; if ( this.getContainedLength() + length > this.capacity ) { // This segment can't hold the specified length. Add a new square segment to the end of the segment list and put // the excess in there. - var newSquareSegment = new SquareSegment( this.owner, this.getLowerRightCornerPosition() ); + const newSquareSegment = new SquareSegment( this.owner, this.getLowerRightCornerPosition() ); growthAmount = this.capacity - this.getContainedLength(); // Clamp growth at remaining capacity. newSquareSegment.add( length - growthAmount, windingBiomolecule, shapeSegmentList ); windingBiomolecule.insertAfterShapeSegment( this, newSquareSegment ); @@ -85,7 +85,7 @@ define( require => { // If the length has gotten to zero, remove this segment from the list. if ( this.getContainedLength() < ShapeSegment.FLOATING_POINT_COMP_FACTOR ) { - var index = shapeSegmentList.indexOf( this ); + const index = shapeSegmentList.indexOf( this ); shapeSegmentList.splice( index, 1 ); } this.updateAttachmentSitePosition(); @@ -99,13 +99,13 @@ define( require => { * @public */ advance: function( length, windingBiomolecule, shapeSegmentList ) { - var outputSegment = windingBiomolecule.getPreviousShapeSegment( this ); - var inputSegment = windingBiomolecule.getNextShapeSegment( this ); + let outputSegment = windingBiomolecule.getPreviousShapeSegment( this ); + const inputSegment = windingBiomolecule.getNextShapeSegment( this ); if ( inputSegment === null ) { // There is no input segment, meaning that the end of the mRNA strand is contained in THIS segment, so this // segment needs to shrink. - var lengthToAdvance = Math.min( length, this.getContainedLength() ); + const lengthToAdvance = Math.min( length, this.getContainedLength() ); this.remove( lengthToAdvance, shapeSegmentList ); outputSegment.add( lengthToAdvance, windingBiomolecule, shapeSegmentList ); } @@ -120,7 +120,7 @@ define( require => { else { // This segment is full or close enough to being full that it can't accommodate all of the specified length. // Some or all of that length must go in the output segment. - var remainingCapacity = this.getRemainingCapacity(); + const remainingCapacity = this.getRemainingCapacity(); if ( remainingCapacity > ShapeSegment.FLOATING_POINT_COMP_FACTOR ) { // Not quite full yet - fill it up. @@ -131,7 +131,7 @@ define( require => { assert && assert( outputSegment === null ); - var newLeaderSegment = new FlatSegment( this.owner, this.getUpperLeftCornerPosition() ); + const newLeaderSegment = new FlatSegment( this.owner, this.getUpperLeftCornerPosition() ); newLeaderSegment.setCapacity( GEEConstants.LEADER_LENGTH ); windingBiomolecule.insertBeforeShapeSegment( this, newLeaderSegment ); outputSegment = newLeaderSegment; @@ -161,12 +161,12 @@ define( require => { * @public */ advanceAndRemove: function( length, windingBiomolecule, shapeSegmentList ) { - var inputSegment = windingBiomolecule.getNextShapeSegment( this ); + const inputSegment = windingBiomolecule.getNextShapeSegment( this ); if ( inputSegment === null ) { // There is no input segment, meaning that the end of the mRNA strand is contained in THIS segment, so this // segment needs to shrink. - var lengthToRemove = Math.min( length, this.getContainedLength() ); + const lengthToRemove = Math.min( length, this.getContainedLength() ); this.remove( lengthToRemove, shapeSegmentList ); } else if ( inputSegment.getContainedLength() > length ) { @@ -188,7 +188,7 @@ define( require => { * @private */ maxOutLength: function() { - var growthAmount = this.getRemainingCapacity(); + const growthAmount = this.getRemainingCapacity(); this.bounds.setMinMax( this.bounds.x - growthAmount, this.bounds.minY, this.bounds.x - growthAmount + this.capacity, this.bounds.minY ); diff --git a/js/common/model/Gene.js b/js/common/model/Gene.js index 585d2d6d..3dcc4590 100644 --- a/js/common/model/Gene.js +++ b/js/common/model/Gene.js @@ -207,7 +207,7 @@ define( require => { */ addTranscriptionFactorLocation: function( basePairOffset, tfConfig ) { this.transcriptionFactorMap[ basePairOffset ] = new TranscriptionFactor( null, tfConfig ); - var position = new Vector2( + const position = new Vector2( this.dnaMolecule.getBasePairXOffsetByIndex( basePairOffset + this.regulatoryRegion.min ), GEEConstants.DNA_MOLECULE_Y_POS ); @@ -233,7 +233,7 @@ define( require => { } // Count the number of positive transcription factors needed to enable transcription. - var numPositiveTranscriptionFactorsNeeded = 0; + let numPositiveTranscriptionFactorsNeeded = 0; _.values( this.transcriptionFactorMap ).forEach( function( transcriptionFactor ) { if ( transcriptionFactor.getConfig().isPositive ) { numPositiveTranscriptionFactorsNeeded += 1; @@ -241,10 +241,10 @@ define( require => { } ); // Count the number of positive transcription factors attached. - var numPositiveTranscriptionFactorsAttached = 0; + let numPositiveTranscriptionFactorsAttached = 0; this.transcriptionFactorAttachmentSites.forEach( function( transcriptionFactorAttachmentSite ) { if ( transcriptionFactorAttachmentSite.attachedOrAttachingMoleculeProperty.get() !== null ) { - var tf = transcriptionFactorAttachmentSite.attachedOrAttachingMoleculeProperty.get(); + const tf = transcriptionFactorAttachmentSite.attachedOrAttachingMoleculeProperty.get(); // there is a very slight difference in the y direction and to mitigate that we use an empirically determined // tolerance factor @@ -265,8 +265,8 @@ define( require => { * @private */ transcriptionFactorsBlockTranscription: function() { - for ( var i = 0; i < this.transcriptionFactorAttachmentSites.length; i++ ) { - var transcriptionFactorAttachmentSite = this.transcriptionFactorAttachmentSites[ i ]; + for ( let i = 0; i < this.transcriptionFactorAttachmentSites.length; i++ ) { + const transcriptionFactorAttachmentSite = this.transcriptionFactorAttachmentSites[ i ]; if ( transcriptionFactorAttachmentSite.attachedOrAttachingMoleculeProperty.get() !== null ) { if ( !(transcriptionFactorAttachmentSite.attachedOrAttachingMoleculeProperty.get() ).isPositive() ) { return true; @@ -291,13 +291,13 @@ define( require => { */ getTranscriptionFactorAttachmentSite: function( basePairIndex, tfConfig ) { // Assume a default affinity site until proven otherwise. - var attachmentSite = this.dnaMolecule.createDefaultAffinityAttachmentSite( + let attachmentSite = this.dnaMolecule.createDefaultAffinityAttachmentSite( this.dnaMolecule.getBasePairXOffsetByIndex( basePairIndex ) ); // Determine whether there are any transcription factor attachment sites on this gene that match the specified // configuration. - for ( var i = 0; i < this.transcriptionFactorAttachmentSites.length; i++ ) { - var transcriptionFactorAttachmentSite = this.transcriptionFactorAttachmentSites[ i ]; + for ( let i = 0; i < this.transcriptionFactorAttachmentSites.length; i++ ) { + const transcriptionFactorAttachmentSite = this.transcriptionFactorAttachmentSites[ i ]; if ( transcriptionFactorAttachmentSite.configurationMatches( tfConfig ) ) { // Found matching site. Is it available and in the right place? if ( transcriptionFactorAttachmentSite.attachedOrAttachingMoleculeProperty.get() === null && @@ -325,8 +325,8 @@ define( require => { * @public */ getMatchingSite: function( transcriptionFactorConfig ) { - for ( var i = 0; i < this.transcriptionFactorAttachmentSites.length; i++ ) { - var transcriptionFactorAttachmentSite = this.transcriptionFactorAttachmentSites[ i ]; + for ( let i = 0; i < this.transcriptionFactorAttachmentSites.length; i++ ) { + const transcriptionFactorAttachmentSite = this.transcriptionFactorAttachmentSites[ i ]; if ( transcriptionFactorAttachmentSite.configurationMatches( transcriptionFactorConfig ) ) { return transcriptionFactorAttachmentSite; } @@ -343,9 +343,9 @@ define( require => { * @public */ getTranscriptionFactorAffinityProperty: function( tfConfig ) { - var affinityProperty = null; - for ( var i = 0; i < this.transcriptionFactorAttachmentSites.length; i++ ) { - var transcriptionFactorAttachmentSite = this.transcriptionFactorAttachmentSites[ i ]; + let affinityProperty = null; + for ( let i = 0; i < this.transcriptionFactorAttachmentSites.length; i++ ) { + const transcriptionFactorAttachmentSite = this.transcriptionFactorAttachmentSites[ i ]; if ( transcriptionFactorAttachmentSite.configurationMatches( tfConfig ) ) { affinityProperty = transcriptionFactorAttachmentSite.affinityProperty; // Built-in assumption here: Only one site for given TF config. @@ -379,7 +379,7 @@ define( require => { * @public */ activateHints: function( biomolecule ) { - var self = this; + const self = this; if ( this.rnaPolymerasePlacementHint.isMatchingBiomolecule( biomolecule ) ) { if ( !this.transcriptionFactorsBlockTranscription() ) { @@ -430,7 +430,7 @@ define( require => { * @public */ getPlacementHints: function() { - var placementHints = [ this.rnaPolymerasePlacementHint ]; + const placementHints = [ this.rnaPolymerasePlacementHint ]; this.transcriptionFactorPlacementHints.forEach( function( transcriptionFactorPlacementHint ) { placementHints.push( transcriptionFactorPlacementHint ); } ); @@ -463,10 +463,10 @@ define( require => { * @public */ getTranscriptionFactorConfigs: function() { - var configList = []; - for ( var key in this.transcriptionFactorMap ) { + const configList = []; + for ( const key in this.transcriptionFactorMap ) { if ( this.transcriptionFactorMap.hasOwnProperty( key ) ) { - var transcriptionFactor = this.transcriptionFactorMap[ key ]; + const transcriptionFactor = this.transcriptionFactorMap[ key ]; configList.push( transcriptionFactor.getConfig() ); } } diff --git a/js/common/model/GeneA.js b/js/common/model/GeneA.js index 8b510ab2..7502c319 100644 --- a/js/common/model/GeneA.js +++ b/js/common/model/GeneA.js @@ -20,11 +20,11 @@ define( require => { const TranscriptionFactor = require( 'GENE_EXPRESSION_ESSENTIALS/common/model/TranscriptionFactor' ); // constants - var REGULATORY_REGION_COLOR = new Color( 216, 191, 216 ); - var TRANSCRIBED_REGION_COLOR = new Color( 255, 165, 79, 150 ); - var NUM_BASE_PAIRS_IN_REGULATORY_REGION = 16; - var NUM_BASE_PAIRS_IN_TRANSCRIBED_REGION = 100; - var MRNA_WINDING_ALGORITHM_NUMBER = 4; + const REGULATORY_REGION_COLOR = new Color( 216, 191, 216 ); + const TRANSCRIBED_REGION_COLOR = new Color( 255, 165, 79, 150 ); + const NUM_BASE_PAIRS_IN_REGULATORY_REGION = 16; + const NUM_BASE_PAIRS_IN_TRANSCRIBED_REGION = 100; + const MRNA_WINDING_ALGORITHM_NUMBER = 4; /** * Constructor. diff --git a/js/common/model/MessengerRna.js b/js/common/model/MessengerRna.js index 0ec27b10..b8cf0ac8 100644 --- a/js/common/model/MessengerRna.js +++ b/js/common/model/MessengerRna.js @@ -27,10 +27,10 @@ define( require => { const WindingBiomolecule = require( 'GENE_EXPRESSION_ESSENTIALS/common/model/WindingBiomolecule' ); // constants - var RIBOSOME_CONNECTION_DISTANCE = 400; // picometers - distance within which this will connect to a ribosome - var MRNA_DESTROYER_CONNECT_DISTANCE = 400; // picometers - Distance within which this will connect to a mRNA destroyer - var INITIAL_MRNA_SHAPE = Shape.circle( 0, 0, 0.1 ); // tiny circle until the strand starts to grow - var MIN_LENGTH_TO_ATTACH = 75; // picometers - min length before attachments are allowed + const RIBOSOME_CONNECTION_DISTANCE = 400; // picometers - distance within which this will connect to a ribosome + const MRNA_DESTROYER_CONNECT_DISTANCE = 400; // picometers - Distance within which this will connect to a mRNA destroyer + const INITIAL_MRNA_SHAPE = Shape.circle( 0, 0, 0.1 ); // tiny circle until the strand starts to grow + const MIN_LENGTH_TO_ATTACH = 75; // picometers - min length before attachments are allowed /** * Constructor. This creates the mRNA as a single point, with the intention of growing it. @@ -43,7 +43,7 @@ define( require => { */ function MessengerRna( model, proteinPrototype, position, options ) { - var self = this; + const self = this; // @private {Object} - object that maps from ribosomes to the shape segment to which they are attached this.mapRibosomeToShapeSegment = {}; @@ -74,19 +74,19 @@ define( require => { this.setPosition( position ); // Add the first segment to the shape segment list. This segment will contain the "leader" for the mRNA. - var segment = new FlatSegment( this, Vector2.ZERO ); + const segment = new FlatSegment( this, Vector2.ZERO ); segment.setCapacity( GEEConstants.LEADER_LENGTH ); this.shapeSegments.push( segment ); // Add the placement hints for the locations where the user can attach a ribosome or an mRNA destroyer. - var ribosome = new Ribosome( model ); + const ribosome = new Ribosome( model ); this.ribosomePlacementHint = new PlacementHint( ribosome ); //@public(read-only) this.mRnaDestroyerPlacementHint = new PlacementHint( new MessengerRnaDestroyer( model ) ); //@public(read-only) function updateHintPositions( shape ) { // All hints always sit at the beginning of the RNA strand and are positioned relative to its center. - var strandStartPosition = new Vector2( shape.bounds.minX, shape.bounds.maxY ); + const strandStartPosition = new Vector2( shape.bounds.minX, shape.bounds.maxY ); self.ribosomePlacementHint.setPosition( strandStartPosition.minus( ribosome.offsetToTranslationChannelEntrance ) ); self.mRnaDestroyerPlacementHint.setPosition( strandStartPosition ); } @@ -94,7 +94,7 @@ define( require => { this.shapeProperty.link( updateHintPositions ); // update the attachment site position when the mRNA moves or changes shape - var attachmentSitePositionUpdater = this.updateAttachmentSitePosition.bind( this ); + const attachmentSitePositionUpdater = this.updateAttachmentSitePosition.bind( this ); this.positionProperty.link( attachmentSitePositionUpdater ); this.shapeProperty.link( attachmentSitePositionUpdater ); @@ -141,7 +141,7 @@ define( require => { */ advanceTranslation: function( ribosome, length ) { - var segmentToAdvance = this.mapRibosomeToShapeSegment[ ribosome.id ]; + const segmentToAdvance = this.mapRibosomeToShapeSegment[ ribosome.id ]; // Error checking. assert && assert( segmentToAdvance !== null ); // Should never happen, since it means that the ribosome isn't attached. @@ -215,7 +215,7 @@ define( require => { this.segmentBeingDestroyed.advanceAndRemove( reductionAmount, this, this.shapeSegments ); // Remove the length from the shape defining points. - for ( var amountRemoved = 0; amountRemoved < reductionAmount; ) { + for ( let amountRemoved = 0; amountRemoved < reductionAmount; ) { if ( this.lastShapeDefiningPoint.getTargetDistanceToPreviousPoint() <= reductionAmount - amountRemoved ) { // Remove the last point from the list. @@ -238,7 +238,7 @@ define( require => { */ updateAttachmentSitePosition: function() { if ( this.shapeSegments.length > 0 ) { - var leadingShapeSegment = this.shapeSegments[ 0 ]; + const leadingShapeSegment = this.shapeSegments[ 0 ]; this.attachmentSite.positionProperty.set( new Vector2( this.positionProperty.get().x + leadingShapeSegment.bounds.minX, this.positionProperty.get().y + leadingShapeSegment.bounds.minY @@ -271,10 +271,10 @@ define( require => { this.mapRibosomeToShapeSegment[ ribosome.id ], 'attempt made to get attachment location for unattached ribosome' ); - var generateInitialPosition3D; - var mRnaPosition = this.positionProperty.get(); - var segment = this.mapRibosomeToShapeSegment[ ribosome.id ]; - var segmentCornerPosition; + let generateInitialPosition3D; + const mRnaPosition = this.positionProperty.get(); + const segment = this.mapRibosomeToShapeSegment[ ribosome.id ]; + let segmentCornerPosition; if ( this.getPreviousShapeSegment( segment ) === null ) { // There is no previous segment, which means that the segment to which this ribosome is attached is the leader @@ -326,7 +326,7 @@ define( require => { */ handleGrabbedByUser: function() { - var attachedOrAttachingMolecule = this.attachmentSite.attachedOrAttachingMoleculeProperty.get(); + const attachedOrAttachingMolecule = this.attachmentSite.attachedOrAttachingMoleculeProperty.get(); if ( attachedOrAttachingMolecule instanceof Ribosome ) { @@ -385,7 +385,7 @@ define( require => { // Set the capacity of the first segment to the size of the channel through which it will be pulled plus the // leader length. - var firstShapeSegment = this.shapeSegments[ 0 ]; + const firstShapeSegment = this.shapeSegments[ 0 ]; assert && assert( firstShapeSegment.isFlat() ); firstShapeSegment.setCapacity( ribosome.getTranslationChannelLength() + GEEConstants.LEADER_LENGTH ); }, @@ -424,7 +424,7 @@ define( require => { * @public */ getProportionOfRnaTranslated: function( ribosome ) { - var translatedLength = this.getLengthOfRnaTranslated( ribosome ); + const translatedLength = this.getLengthOfRnaTranslated( ribosome ); return Math.max( translatedLength / this.getLength(), 0 ); }, @@ -436,14 +436,14 @@ define( require => { */ getLengthOfRnaTranslated: function( ribosome ) { assert && assert( this.mapRibosomeToShapeSegment[ ribosome.id ] ); // Makes no sense if ribosome isn't attached. - var translatedLength = 0; - var segmentInRibosomeChannel = this.mapRibosomeToShapeSegment[ ribosome.id ]; + let translatedLength = 0; + const segmentInRibosomeChannel = this.mapRibosomeToShapeSegment[ ribosome.id ]; assert && assert( segmentInRibosomeChannel.isFlat() ); // Make sure things are as we expect. // Add the length for each segment that precedes this ribosome. - for ( var i = 0; i < this.shapeSegments.length; i++ ) { - var shapeSegment = this.shapeSegments[ i ]; + for ( let i = 0; i < this.shapeSegments.length; i++ ) { + const shapeSegment = this.shapeSegments[ i ]; if ( shapeSegment === segmentInRibosomeChannel ) { break; } @@ -480,7 +480,7 @@ define( require => { */ considerProposalFromRibosome: function( ribosome ) { assert && assert( !this.mapRibosomeToShapeSegment[ ribosome.id ] ); // Shouldn't get redundant proposals from a ribosome. - var returnValue = null; + let returnValue = null; if ( this.attachmentAllowed() ) { @@ -510,7 +510,7 @@ define( require => { considerProposalFromMessengerRnaDestroyer: function( messengerRnaDestroyer ) { assert && assert( this.messengerRnaDestroyer !== messengerRnaDestroyer ); // Shouldn't get redundant proposals from same destroyer. - var returnValue = null; + let returnValue = null; if ( this.attachmentAllowed() ) { diff --git a/js/common/model/MessengerRnaDestroyer.js b/js/common/model/MessengerRnaDestroyer.js index 6d9f8be3..0704466f 100644 --- a/js/common/model/MessengerRnaDestroyer.js +++ b/js/common/model/MessengerRnaDestroyer.js @@ -20,14 +20,14 @@ define( require => { const Vector2 = require( 'DOT/Vector2' ); // constants - var WIDTH = 250; // In nanometers. + const WIDTH = 250; // In nanometers. /** * helper function * @returns {Shape} */ function createShape() { - var mouthShape = new Shape().moveTo( 0, 0 ). + const mouthShape = new Shape().moveTo( 0, 0 ). arc( 0, 0, WIDTH / 2, Math.PI / 6, 2 * Math.PI - Math.PI / 6 ). close(); return mouthShape; @@ -79,10 +79,10 @@ define( require => { * @public */ proposeAttachments: function() { - var attachmentSite = null; - var messengerRnaList = this.model.getMessengerRnaList(); - for ( var i = 0; i < messengerRnaList.length; i++ ) { - var messengerRna = messengerRnaList.get( i ); + let attachmentSite = null; + const messengerRnaList = this.model.getMessengerRnaList(); + for ( let i = 0; i < messengerRnaList.length; i++ ) { + const messengerRna = messengerRnaList.get( i ); attachmentSite = messengerRna.considerProposalFromMessengerRnaDestroyer( this ); if ( attachmentSite !== null ) { // Proposal accepted. diff --git a/js/common/model/MessengerRnaFragment.js b/js/common/model/MessengerRnaFragment.js index 96624fdc..daf8b285 100644 --- a/js/common/model/MessengerRnaFragment.js +++ b/js/common/model/MessengerRnaFragment.js @@ -20,7 +20,7 @@ define( require => { const WindingBiomolecule = require( 'GENE_EXPRESSION_ESSENTIALS/common/model/WindingBiomolecule' ); // constants - var MRNA_WINDING_ALGORITHMS = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]; + const MRNA_WINDING_ALGORITHMS = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]; /** * This creates the mRNA fragment as a single point, with the intention of growing it. diff --git a/js/common/model/MobileBiomolecule.js b/js/common/model/MobileBiomolecule.js index 6d4f16a5..5026739e 100644 --- a/js/common/model/MobileBiomolecule.js +++ b/js/common/model/MobileBiomolecule.js @@ -31,7 +31,7 @@ define( require => { * @constructor */ function MobileBiomolecule( model, initialShape, baseColor ) { - var self = this; + const self = this; // @private {MotionStrategy} - Motion strategy that governs how this biomolecule moves. This changes as the molecule // interacts with other portions of the model. @@ -154,7 +154,7 @@ define( require => { this.setPosition3D( this.motionStrategy.getNextPosition3D( this.getPosition3D(), this.bounds, dt ) ); } else { - var currentPosition = this.getPosition(); + const currentPosition = this.getPosition(); this.setPosition( this.motionStrategy.getNextPosition( currentPosition, this.bounds, dt ) ); // currentPosition.freeToPool(); } @@ -172,7 +172,7 @@ define( require => { * @private */ getPosition3D: function() { - var position = this.positionProperty.get(); + const position = this.positionProperty.get(); return new Vector3( position.x, position.y, this.zPositionProperty.get() ); }, diff --git a/js/common/model/Protein.js b/js/common/model/Protein.js index f4efcdf6..76e2ea55 100644 --- a/js/common/model/Protein.js +++ b/js/common/model/Protein.js @@ -19,7 +19,7 @@ define( require => { const ProteinAttachmentStateMachine = require( 'GENE_EXPRESSION_ESSENTIALS/common/model/attachment-state-machines/ProteinAttachmentStateMachine' ); // constants - var MAX_GROWTH_FACTOR = 1; // Max value for the growth factor, indicates that it is fully grown. + const MAX_GROWTH_FACTOR = 1; // Max value for the growth factor, indicates that it is fully grown. /** * diff --git a/js/common/model/Ribosome.js b/js/common/model/Ribosome.js index ab872b4a..88c3eb55 100644 --- a/js/common/model/Ribosome.js +++ b/js/common/model/Ribosome.js @@ -21,22 +21,22 @@ define( require => { const Vector2 = require( 'DOT/Vector2' ); // constants - var WIDTH = 430; // In nanometers. - var OVERALL_HEIGHT = 450; // In nanometers. - var TOP_SUBUNIT_HEIGHT_PROPORTION = 0.6; - var TOP_SUBUNIT_HEIGHT = OVERALL_HEIGHT * TOP_SUBUNIT_HEIGHT_PROPORTION; - var BOTTOM_SUBUNIT_HEIGHT = OVERALL_HEIGHT * ( 1 - TOP_SUBUNIT_HEIGHT_PROPORTION ); + const WIDTH = 430; // In nanometers. + const OVERALL_HEIGHT = 450; // In nanometers. + const TOP_SUBUNIT_HEIGHT_PROPORTION = 0.6; + const TOP_SUBUNIT_HEIGHT = OVERALL_HEIGHT * TOP_SUBUNIT_HEIGHT_PROPORTION; + const BOTTOM_SUBUNIT_HEIGHT = OVERALL_HEIGHT * ( 1 - TOP_SUBUNIT_HEIGHT_PROPORTION ); // Offset from the center position to the entrance of the translation channel. May require some tweaking if the shape // changes. - var OFFSET_TO_TRANSLATION_CHANNEL_ENTRANCE = new Vector2( WIDTH * 0.45, -OVERALL_HEIGHT * 0.23 ); + const OFFSET_TO_TRANSLATION_CHANNEL_ENTRANCE = new Vector2( WIDTH * 0.45, -OVERALL_HEIGHT * 0.23 ); // Offset from the center position to the point from which the protein emerges. May require some tweaking if the overall // shape changes. - var OFFSET_TO_PROTEIN_OUTPUT_CHANNEL = new Vector2( WIDTH * 0.4, OVERALL_HEIGHT * 0.55 ); + const OFFSET_TO_PROTEIN_OUTPUT_CHANNEL = new Vector2( WIDTH * 0.4, OVERALL_HEIGHT * 0.55 ); // a counter used to create a unique ID for each instance - var instanceCounter = 0; + let instanceCounter = 0; /** * @param {GeneExpressionModel} model @@ -78,10 +78,10 @@ define( require => { * @public */ proposeAttachments: function() { - var attachmentSite = null; - var messengerRnaList = this.model.getMessengerRnaList(); - for ( var i = 0; i < messengerRnaList.length; i++ ) { - var messengerRna = messengerRnaList.get( i ); + let attachmentSite = null; + const messengerRnaList = this.model.getMessengerRnaList(); + for ( let i = 0; i < messengerRnaList.length; i++ ) { + const messengerRna = messengerRnaList.get( i ); attachmentSite = messengerRna.considerProposalFromRibosome( this ); if ( attachmentSite !== null ) { // Proposal accepted. @@ -119,7 +119,7 @@ define( require => { // Draw the top portion, which in this sim is the larger subunit. The shape is essentially a lumpy ellipse, and // is based on some drawings seen on the web. - var topSubunitPointList = [ + const topSubunitPointList = [ // Define the shape with a series of points. Starts at top left. new Vector2( -WIDTH * 0.3, TOP_SUBUNIT_HEIGHT * 0.9 ), new Vector2( WIDTH * 0.3, TOP_SUBUNIT_HEIGHT ), @@ -130,12 +130,12 @@ define( require => { new Vector2( -WIDTH * 0.5, 0 ) ]; - var translation = Matrix3.translation( 0, OVERALL_HEIGHT / 4 ); - var topSubunitShape = ShapeUtils.createRoundedShapeFromPoints( topSubunitPointList ).transformed( translation ); + const translation = Matrix3.translation( 0, OVERALL_HEIGHT / 4 ); + const topSubunitShape = ShapeUtils.createRoundedShapeFromPoints( topSubunitPointList ).transformed( translation ); // Draw the bottom portion, which in this sim is the smaller subunit. - var startPointY = topSubunitShape.bounds.minY; - var bottomSubunitPointList = [ + const startPointY = topSubunitShape.bounds.minY; + const bottomSubunitPointList = [ // Define the shape with a series of points. new Vector2( -WIDTH * 0.45, startPointY ), new Vector2( 0, startPointY ), @@ -145,8 +145,8 @@ define( require => { new Vector2( -WIDTH * 0.45, startPointY - BOTTOM_SUBUNIT_HEIGHT ) ]; - var bottomSubunitTranslation = Matrix3.translation( 0, -OVERALL_HEIGHT / 4 ); - var ribosomeShape = ShapeUtils.createRoundedShapeFromPoints( bottomSubunitPointList, topSubunitShape ).transformed( bottomSubunitTranslation ); + const bottomSubunitTranslation = Matrix3.translation( 0, -OVERALL_HEIGHT / 4 ); + const ribosomeShape = ShapeUtils.createRoundedShapeFromPoints( bottomSubunitPointList, topSubunitShape ).transformed( bottomSubunitTranslation ); return ribosomeShape; }, diff --git a/js/common/model/RnaPolymerase.js b/js/common/model/RnaPolymerase.js index 2afb44b7..02fa4831 100644 --- a/js/common/model/RnaPolymerase.js +++ b/js/common/model/RnaPolymerase.js @@ -22,16 +22,16 @@ define( require => { const Vector2 = require( 'DOT/Vector2' ); // Overall size of the polymerase molecule. - var WIDTH = 340; // picometers - var HEIGHT = 480; // picometers + const WIDTH = 340; // picometers + const HEIGHT = 480; // picometers // Offset from the center of the molecule to the location where mRNA should emerge when transcription is occurring. // This is determined empirically, and may need to change if the shape is changed. - var MESSENGER_RNA_GENERATION_OFFSET = new Vector2( -WIDTH * 0.4, HEIGHT * 0.4 ); + const MESSENGER_RNA_GENERATION_OFFSET = new Vector2( -WIDTH * 0.4, HEIGHT * 0.4 ); // Set of points that outline the basic, non-distorted shape of this molecule. The shape is meant to look like // illustrations in "The Machinery of Life" by David Goodsell. - var SHAPE_POINTS = [ new Vector2( 0, HEIGHT / 2 ), // Middle top. + const SHAPE_POINTS = [ new Vector2( 0, HEIGHT / 2 ), // Middle top. new Vector2( WIDTH / 2, HEIGHT * 0.25 ), new Vector2( WIDTH * 0.35, -HEIGHT * 0.25 ), new Vector2( 0, -HEIGHT / 2 ), // Middle bottom. @@ -40,12 +40,12 @@ define( require => { ]; // Colors used by this molecule. - var NOMINAL_COLOR = new Color( 0, 153, 210 ); - var CONFORMED_COLOR = Color.CYAN; + const NOMINAL_COLOR = new Color( 0, 153, 210 ); + const CONFORMED_COLOR = Color.CYAN; // Direction vectors when polymerase detaches from DNA - var UP_VECTOR = new Vector2( 0, 1 ); - var DOWN_VECTOR = new Vector2( 0, -1 ); + const UP_VECTOR = new Vector2( 0, 1 ); + const DOWN_VECTOR = new Vector2( 0, -1 ); /** * @@ -86,7 +86,7 @@ define( require => { changeConformation: function( changeFactor ) { // seed value chosen empirically through trial and error - var newUntranslatedShape = BioShapeUtils.createdDistortedRoundedShapeFromPoints( SHAPE_POINTS, changeFactor, 45 ); + const newUntranslatedShape = BioShapeUtils.createdDistortedRoundedShapeFromPoints( SHAPE_POINTS, changeFactor, 45 ); this.shapeProperty.set( newUntranslatedShape ); this.colorProperty.set( Color.interpolateRGBA( NOMINAL_COLOR, CONFORMED_COLOR, changeFactor ) ); }, diff --git a/js/common/model/ShapeChangingModelElement.js b/js/common/model/ShapeChangingModelElement.js index 04548183..ff690166 100644 --- a/js/common/model/ShapeChangingModelElement.js +++ b/js/common/model/ShapeChangingModelElement.js @@ -25,7 +25,7 @@ define( require => { */ function ShapeChangingModelElement( initialShape ) { - var self = this; + const self = this; // @public {Property.} - can be read or listened to by anyone, should only be written by descendant types this.shapeProperty = new Property( initialShape ); @@ -40,10 +40,10 @@ define( require => { this.bounds = new Bounds2( 0, 0, 1, 1 ); // initial value is arbitrary, will be updated immediately // update the bounds whenever the shape or the position changes - var boundsUpdateMultilink = Property.multilink( + const boundsUpdateMultilink = Property.multilink( [ this.shapeProperty, this.positionProperty ], function( shape, position ) { - var shapeBounds = shape.bounds; + const shapeBounds = shape.bounds; self.bounds.setMinMax( position.x + shapeBounds.minX, position.y + shapeBounds.minY, @@ -92,8 +92,8 @@ define( require => { translate: function( x, y ) { // in order to reduce allocations of vectors, pull them from our local pool - var currentPosition = this.positionProperty.get(); - var newPosition = this.getFreeReusablePositionVector(); + const currentPosition = this.positionProperty.get(); + const newPosition = this.getFreeReusablePositionVector(); newPosition.setXY( currentPosition.x + x, currentPosition.y + y ); this.positionProperty.set( newPosition ); }, @@ -115,7 +115,7 @@ define( require => { setPositionXY: function( x, y ) { // in order to reduce allocations of vectors, use vectors from the local vector pool - var newPosition = this.getFreeReusablePositionVector(); + const newPosition = this.getFreeReusablePositionVector(); newPosition.setXY( x, y ); this.positionProperty.set( newPosition ); }, diff --git a/js/common/model/ShapeSegment.js b/js/common/model/ShapeSegment.js index 157579cb..35a259c9 100644 --- a/js/common/model/ShapeSegment.js +++ b/js/common/model/ShapeSegment.js @@ -23,7 +23,7 @@ define( require => { const Vector2 = require( 'DOT/Vector2' ); // constants - var FLOATING_POINT_COMP_FACTOR = 1E-7; // Factor to use to avoid issues with floating point resolution. + const FLOATING_POINT_COMP_FACTOR = 1E-7; // Factor to use to avoid issues with floating point resolution. /** * @param {Object} owner - the model object that this shape segment is a portion of diff --git a/js/common/model/ShapeUtils.js b/js/common/model/ShapeUtils.js index df4a0a27..90282c52 100644 --- a/js/common/model/ShapeUtils.js +++ b/js/common/model/ShapeUtils.js @@ -15,7 +15,7 @@ define( require => { const Shape = require( 'KITE/Shape' ); const Vector2 = require( 'DOT/Vector2' ); - var ShapeUtils = { + const ShapeUtils = { /** * Creates a rounded shape from a set of points. The points must be in an order that, if connected by straight lines, @@ -27,15 +27,15 @@ define( require => { * @public */ createRoundedShapeFromPoints: function( points, existingShape ) { - var shape = existingShape || new Shape(); + const shape = existingShape || new Shape(); shape.moveToPoint( points[ 0 ] ); - var cp1 = Vector2.dirtyFromPool(); - var cp2 = Vector2.dirtyFromPool(); - for ( var i = 0; i < points.length; i++ ) { - var segmentStartPoint = points[ i ]; - var segmentEndPoint = points[ ( i + 1 ) % points.length ]; - var previousPoint = points[ i - 1 >= 0 ? i - 1 : points.length - 1 ]; - var nextPoint = points[ ( i + 2 ) % points.length ]; + let cp1 = Vector2.dirtyFromPool(); + let cp2 = Vector2.dirtyFromPool(); + for ( let i = 0; i < points.length; i++ ) { + const segmentStartPoint = points[ i ]; + const segmentEndPoint = points[ ( i + 1 ) % points.length ]; + const previousPoint = points[ i - 1 >= 0 ? i - 1 : points.length - 1 ]; + const nextPoint = points[ ( i + 2 ) % points.length ]; cp1 = this.extrapolateControlPoint( previousPoint, segmentStartPoint, segmentEndPoint, cp1 ); cp2 = this.extrapolateControlPoint( nextPoint, segmentEndPoint, segmentStartPoint, cp2 ); shape.cubicCurveTo( cp1.x, cp1.y, cp2.x, cp2.y, segmentEndPoint.x, segmentEndPoint.y ); @@ -57,8 +57,8 @@ define( require => { * @public */ extrapolateControlPoint: function( x, y, z, cp ) { - var xz_x = 0.25 * ( z.x - x.x ); - var xz_y = 0.25 * ( z.y - x.y ); + const xz_x = 0.25 * ( z.x - x.x ); + const xz_y = 0.25 * ( z.y - x.y ); return( cp.setXY( y.x + xz_x, y.y + xz_y ) ); } }; diff --git a/js/common/model/SquareSegment.js b/js/common/model/SquareSegment.js index 197a9a53..cbcd22c4 100644 --- a/js/common/model/SquareSegment.js +++ b/js/common/model/SquareSegment.js @@ -55,7 +55,7 @@ define( require => { this.containedLength += length; // Grow the bounds up and to the left to accommodate the additional length. - var sideGrowthAmount = this.calculateSideLength() - this.bounds.getWidth(); + const sideGrowthAmount = this.calculateSideLength() - this.bounds.getWidth(); assert && assert( length >= 0 && sideGrowthAmount >= 0 ); // this.bounds.set( Bounds2.rect( this.bounds.x - sideGrowthAmount, this.bounds.y, @@ -73,7 +73,7 @@ define( require => { this.containedLength -= length; // Shrink by moving the lower right corner up and to the left. - var sideShrinkageAmount = this.bounds.getWidth() - this.calculateSideLength(); + const sideShrinkageAmount = this.bounds.getWidth() - this.calculateSideLength(); this.bounds.set( Bounds2.rect( this.bounds.x, this.bounds.y + sideShrinkageAmount, @@ -82,7 +82,7 @@ define( require => { // If the length has gotten to zero, remove this segment from the list. if ( this.getContainedLength() <= ShapeSegment.FLOATING_POINT_COMP_FACTOR ) { - var index = shapeSegmentList.indexOf( this ); + const index = shapeSegmentList.indexOf( this ); shapeSegmentList.splice( index, 1 ); } this.updateAttachmentSitePosition(); @@ -121,7 +121,7 @@ define( require => { * @private */ calculateSideLength: function() { - var desiredDiagonalLength = Math.pow( this.containedLength, 0.7 ); // Power value was empirically determined. + const desiredDiagonalLength = Math.pow( this.containedLength, 0.7 ); // Power value was empirically determined. return Math.sqrt( 2 * desiredDiagonalLength * desiredDiagonalLength ); } } ); diff --git a/js/common/model/TranscriptionFactor.js b/js/common/model/TranscriptionFactor.js index 37c88361..9bc6be3b 100644 --- a/js/common/model/TranscriptionFactor.js +++ b/js/common/model/TranscriptionFactor.js @@ -25,9 +25,9 @@ define( require => { const Vector2 = require( 'DOT/Vector2' ); // constants - var WIDTH = 325; // In nanometers. - var HEIGHT = 240; // In nanometers. - var SIZE = new Dimension2( WIDTH, HEIGHT ); + const WIDTH = 325; // In nanometers. + const HEIGHT = 240; // In nanometers. + const SIZE = new Dimension2( WIDTH, HEIGHT ); /** * @param {GeneExpressionModel} model @@ -81,10 +81,10 @@ define( require => { // directly into the detaching state so that this drifts away from the DNA. This makes it clear the you can't have // two transcription factors in the same place on the DNA. - var moleculesShapes = this.model.getOverlappingBiomolecules( this.bounds ); + const moleculesShapes = this.model.getOverlappingBiomolecules( this.bounds ); - for ( var i = 0; i < moleculesShapes.length; i++ ) { - var biomolecule = moleculesShapes[ i ]; + for ( let i = 0; i < moleculesShapes.length; i++ ) { + const biomolecule = moleculesShapes[ i ]; if ( biomolecule !== this && biomolecule.attachedToDnaProperty.get() ) { this.attachmentStateMachine.forceImmediateUnattachedButUnavailable(); break; diff --git a/js/common/model/WindingBiomolecule.js b/js/common/model/WindingBiomolecule.js index 982babd6..7dea3cce 100644 --- a/js/common/model/WindingBiomolecule.js +++ b/js/common/model/WindingBiomolecule.js @@ -25,13 +25,13 @@ define( require => { // constants // Color used by this molecule. Since mRNA is depicted as a line and not as a closed shape, a transparent color is // used for the fill. This enables reuse of generic biomolecule classes. - var NOMINAL_COLOR = new Color( 0, 0, 0, 0 ); + const NOMINAL_COLOR = new Color( 0, 0, 0, 0 ); // Parameters that control how the winding biomolecule winds. NOTE: The different variations of winding parameters // were added in an effort to come to some consensus about how the mRNA should look for the various genes. In the // end, a single set was chosen, but I (jbphet) have left the other parameter sets here in case this question ever // comes up again so that we don't have to "rediscover" parameters that look reasonably good. - var WINDING_PARAMS = [ + const WINDING_PARAMS = [ { // straight line - generally only used for debug @@ -226,8 +226,8 @@ define( require => { * @private */ getFirstEnclosedPoint: function( lengthRange ) { - var currentPoint = this.firstShapeDefiningPoint; - var currentLength = 0; + let currentPoint = this.firstShapeDefiningPoint; + let currentLength = 0; while ( currentPoint !== null ) { if ( currentLength >= lengthRange.min && currentLength < lengthRange.max ) { @@ -247,8 +247,8 @@ define( require => { * @private */ getLastEnclosedPoint: function( lengthRange ) { - var currentPoint = this.firstShapeDefiningPoint; - var currentLength = 0; + let currentPoint = this.firstShapeDefiningPoint; + let currentLength = 0; while ( currentPoint !== null ) { if ( currentLength >= lengthRange.min && currentLength < lengthRange.max ) { break; @@ -284,7 +284,7 @@ define( require => { this.addPointToEnd( this.lastShapeDefiningPoint.getPosition(), length ); } else if ( this.lastShapeDefiningPoint.getTargetDistanceToPreviousPoint() < GEEConstants.INTER_POINT_DISTANCE ) { - var prevDistance = this.lastShapeDefiningPoint.getTargetDistanceToPreviousPoint(); + const prevDistance = this.lastShapeDefiningPoint.getTargetDistanceToPreviousPoint(); if ( prevDistance + length <= GEEConstants.INTER_POINT_DISTANCE ) { // No need to add a new point - just set the distance of the current last point to be further away from the @@ -304,9 +304,9 @@ define( require => { else { // add new point or points to the end - var remainingLengthToAdd = length; + let remainingLengthToAdd = length; while ( remainingLengthToAdd > 0 ) { - var targetDistanceToPreviousPoint = Math.min( GEEConstants.INTER_POINT_DISTANCE, remainingLengthToAdd ); + const targetDistanceToPreviousPoint = Math.min( GEEConstants.INTER_POINT_DISTANCE, remainingLengthToAdd ); this.addPointToEnd( this.lastShapeDefiningPoint.getPosition(), targetDistanceToPreviousPoint ); remainingLengthToAdd -= targetDistanceToPreviousPoint; } @@ -330,11 +330,11 @@ define( require => { * @protected */ windPointsThroughSegments: function() { - var handledLength = 0; + let handledLength = 0; // Loop through the shape segments positioning the shape-defining points within them. - for ( var i = 0; i < this.shapeSegments.length; i++ ) { - var shapeSegment = this.shapeSegments[ i ]; + for ( let i = 0; i < this.shapeSegments.length; i++ ) { + const shapeSegment = this.shapeSegments[ i ]; var lengthRange; // determine how much of the mRNA is within this shape segment and set the amount of length to work with accordingly @@ -356,8 +356,8 @@ define( require => { ); } - var firstEnclosedPoint = this.getFirstEnclosedPoint( lengthRange ); - var lastEnclosedPoint = this.getLastEnclosedPoint( lengthRange ); + const firstEnclosedPoint = this.getFirstEnclosedPoint( lengthRange ); + const lastEnclosedPoint = this.getLastEnclosedPoint( lengthRange ); if ( firstEnclosedPoint === null ) { // The segment contains no points. @@ -387,7 +387,7 @@ define( require => { * @private */ getTotalLengthInShapeSegments: function() { - var totalShapeSegmentLength = 0; + let totalShapeSegmentLength = 0; this.shapeSegments.forEach( function( shapeSeg ) { totalShapeSegmentLength += shapeSeg.getContainedLength(); @@ -406,8 +406,8 @@ define( require => { * @private */ positionPointsInLine: function( firstPoint, lastPoint, origin ) { - var currentPoint = firstPoint; - var xOffset = 0; + let currentPoint = firstPoint; + let xOffset = 0; while ( currentPoint !== lastPoint && currentPoint !== null ) { currentPoint.setPositionXY( origin.x + xOffset, origin.y ); currentPoint = currentPoint.getNextPoint(); @@ -443,40 +443,40 @@ define( require => { return; } - var diagonalSpan = Math.sqrt( bounds.width * bounds.width + bounds.height * bounds.height ); + const diagonalSpan = Math.sqrt( bounds.width * bounds.width + bounds.height * bounds.height ); // for easier manipulation, make a list of all of the points in order from first to last - var points = []; - var currentPoint = firstPoint; + const points = []; + let currentPoint = firstPoint; points.push( currentPoint ); while ( currentPoint !== lastPoint ) { currentPoint = currentPoint.getNextPoint(); points.push( currentPoint ); } - var nextLinearPosition = new Vector2( bounds.minX, bounds.maxY ); - var interPointXDistance = bounds.width / ( points.length - 1 ); - var interPointYDistance = -bounds.height / ( points.length - 1 ); - var totalDistanceTraversed = 0; - var totalDistancePerStep = Math.sqrt( interPointXDistance * interPointXDistance + + const nextLinearPosition = new Vector2( bounds.minX, bounds.maxY ); + const interPointXDistance = bounds.width / ( points.length - 1 ); + const interPointYDistance = -bounds.height / ( points.length - 1 ); + let totalDistanceTraversed = 0; + const totalDistancePerStep = Math.sqrt( interPointXDistance * interPointXDistance + interPointYDistance * interPointYDistance ); // convenience vars for winding params - var yWave1Frequency = this.windingParams.yWave1Frequency; - var yWave1PhaseOffset = this.windingParams.yWave1PhaseOffset; - var yWave1Multiplier = this.windingParams.yWave1Multiplier; - var yWave2Frequency = this.windingParams.yWave2Frequency; - var yWave2PhaseOffset = this.windingParams.yWave2PhaseOffset; - var yWave2Multiplier = this.windingParams.yWave2Multiplier; - var xWaveFrequency = this.windingParams.xWaveFrequency; - var xWavePhaseOffset = this.windingParams.xWavePhaseOffset; - var xWaveMultiplier = this.windingParams.xWaveMultiplier; + const yWave1Frequency = this.windingParams.yWave1Frequency; + const yWave1PhaseOffset = this.windingParams.yWave1PhaseOffset; + const yWave1Multiplier = this.windingParams.yWave1Multiplier; + const yWave2Frequency = this.windingParams.yWave2Frequency; + const yWave2PhaseOffset = this.windingParams.yWave2PhaseOffset; + const yWave2Multiplier = this.windingParams.yWave2Multiplier; + const xWaveFrequency = this.windingParams.xWaveFrequency; + const xWavePhaseOffset = this.windingParams.xWavePhaseOffset; + const xWaveMultiplier = this.windingParams.xWaveMultiplier; // pre-allocate and reuse the offset vector for optimal performance - var offsetFromLinearSequence = new Vector2( 0, 0 ); + const offsetFromLinearSequence = new Vector2( 0, 0 ); // implement the winding algorithm - for ( var i = 0; i < points.length; i++ ) { + for ( let i = 0; i < points.length; i++ ) { // window function to modulate less at corners of square than in middle so that everything fits in the segment var offsetScale; @@ -510,11 +510,11 @@ define( require => { * @private */ realignSegmentsFromEnd: function() { - var copyOfShapeSegments = this.shapeSegments.slice(); + let copyOfShapeSegments = this.shapeSegments.slice(); copyOfShapeSegments = copyOfShapeSegments.reverse(); - for ( var i = 0; i < copyOfShapeSegments.length - 1; i++ ) { + for ( let i = 0; i < copyOfShapeSegments.length - 1; i++ ) { // Assumes that the shape segments attach to one another in such a way that they chain from the upper left to // the lower right. @@ -538,7 +538,7 @@ define( require => { * @private */ addPointToEnd: function( position, targetDistanceToPreviousPoint ) { - var newPoint = new ShapeDefiningPoint( position, targetDistanceToPreviousPoint ); + const newPoint = new ShapeDefiningPoint( position, targetDistanceToPreviousPoint ); this.lastShapeDefiningPoint.setNextPoint( newPoint ); newPoint.setPreviousPoint( this.lastShapeDefiningPoint ); this.lastShapeDefiningPoint = newPoint; @@ -550,8 +550,8 @@ define( require => { * @private */ getPointList: function() { - var pointList = []; - var thisPoint = this.firstShapeDefiningPoint; + const pointList = []; + let thisPoint = this.firstShapeDefiningPoint; while ( thisPoint !== null ) { pointList.push( thisPoint.getPosition() ); thisPoint = thisPoint.getNextPoint(); @@ -566,8 +566,8 @@ define( require => { * @protected */ getLength: function() { - var length = 0; - var thisPoint = this.firstShapeDefiningPoint.getNextPoint(); + let length = 0; + let thisPoint = this.firstShapeDefiningPoint.getNextPoint(); while ( thisPoint !== null ) { length += thisPoint.getTargetDistanceToPreviousPoint(); thisPoint = thisPoint.getNextPoint(); @@ -581,9 +581,9 @@ define( require => { * @public */ setLowerRightPositionXY: function( x, y ) { - var totalWidth = 0; - var totalHeight = 0; - for ( var i = 0; i < this.shapeSegments.length; i++ ) { + let totalWidth = 0; + let totalHeight = 0; + for ( let i = 0; i < this.shapeSegments.length; i++ ) { totalWidth += this.shapeSegments[ i ].bounds.width; totalHeight += this.shapeSegments[ i ].bounds.height; } @@ -603,17 +603,17 @@ define( require => { * the segments change shape and can move such that the position is not longer at the center of the shape. */ recenter: function() { - var shapeBounds = this.shapeProperty.get().bounds; - var adjustmentX = shapeBounds.centerX; - var adjustmentY = shapeBounds.centerY; + const shapeBounds = this.shapeProperty.get().bounds; + const adjustmentX = shapeBounds.centerX; + const adjustmentY = shapeBounds.centerY; // only readjust if needed if ( adjustmentX !== 0 || adjustmentY !== 0 ) { // adjust the shape segments - for ( var i = 0; i < this.shapeSegments.length; i++ ) { - var shapeSegment = this.shapeSegments[ i ]; - var upperLeftCornerPosition = shapeSegment.getUpperLeftCornerPosition(); + for ( let i = 0; i < this.shapeSegments.length; i++ ) { + const shapeSegment = this.shapeSegments[ i ]; + const upperLeftCornerPosition = shapeSegment.getUpperLeftCornerPosition(); shapeSegment.setUpperLeftCornerPositionXY( upperLeftCornerPosition.x - adjustmentX, upperLeftCornerPosition.y - adjustmentY @@ -621,7 +621,7 @@ define( require => { } // adjust the position - var position = this.getPosition(); + const position = this.getPosition(); this.setPositionXY( position.x + adjustmentX, position.y + adjustmentY ); } }, @@ -640,10 +640,10 @@ define( require => { ); // Align segments that follow this one. - var currentSegment = segmentToAlignFrom; - var nextSegment = this.getNextShapeSegment( currentSegment ); + let currentSegment = segmentToAlignFrom; + let nextSegment = this.getNextShapeSegment( currentSegment ); while ( nextSegment !== null ) { - var nextSegmentLowerRightCornerPos = currentSegment.getLowerRightCornerPosition(); + const nextSegmentLowerRightCornerPos = currentSegment.getLowerRightCornerPosition(); nextSegment.setUpperLeftCornerPositionXY( nextSegmentLowerRightCornerPos.x, nextSegmentLowerRightCornerPos.y ); currentSegment = nextSegment; nextSegment = this.getNextShapeSegment( currentSegment ); @@ -651,7 +651,7 @@ define( require => { // Align segments that precede this one. currentSegment = segmentToAlignFrom; - var previousSegment = this.getPreviousShapeSegment( currentSegment ); + let previousSegment = this.getPreviousShapeSegment( currentSegment ); while ( previousSegment !== null ) { previousSegment.setLowerRightCornerPosition( currentSegment.getUpperLeftCornerPosition() ); currentSegment = previousSegment; @@ -666,7 +666,7 @@ define( require => { * @public */ getNextShapeSegment: function( shapeSegment ) { - var index = this.shapeSegments.indexOf( shapeSegment ); + const index = this.shapeSegments.indexOf( shapeSegment ); assert && assert( index !== -1, 'Given item not in list' ); @@ -686,7 +686,7 @@ define( require => { * @public */ getPreviousShapeSegment: function( shapeSegment ) { - var index = this.shapeSegments.indexOf( shapeSegment ); + const index = this.shapeSegments.indexOf( shapeSegment ); assert && assert( index !== -1, 'Given item not in list' ); @@ -706,7 +706,7 @@ define( require => { * @public */ insertAfterShapeSegment: function( existingShapeSegment, shapeSegmentToInsert ) { - var index = this.shapeSegments.indexOf( existingShapeSegment ); + const index = this.shapeSegments.indexOf( existingShapeSegment ); assert && assert( index !== -1, 'Given item not in list' ); this.shapeSegments.splice( index + 1, 0, shapeSegmentToInsert ); }, @@ -718,7 +718,7 @@ define( require => { * @public */ insertBeforeShapeSegment: function( existingShapeSegment, shapeSegmentToInsert ) { - var index = this.shapeSegments.indexOf( existingShapeSegment ); + const index = this.shapeSegments.indexOf( existingShapeSegment ); assert && assert( index !== -1, 'Given item not in list' ); this.shapeSegments.splice( index, 0, shapeSegmentToInsert ); } diff --git a/js/common/model/attachment-state-machines/AttachedAndConformingState.js b/js/common/model/attachment-state-machines/AttachedAndConformingState.js index 3e9a91c4..1507beb4 100644 --- a/js/common/model/attachment-state-machines/AttachedAndConformingState.js +++ b/js/common/model/attachment-state-machines/AttachedAndConformingState.js @@ -43,9 +43,9 @@ define( require => { */ step: function( asm, dt ) { - var biomolecule = this.rnaPolymeraseAttachmentStateMachine.biomolecule; - var dnaStrandSeparation = this.rnaPolymeraseAttachmentStateMachine.dnaStrandSeparation; - var attachedAndTranscribingState = this.rnaPolymeraseAttachmentStateMachine.attachedAndTranscribingState; + const biomolecule = this.rnaPolymeraseAttachmentStateMachine.biomolecule; + const dnaStrandSeparation = this.rnaPolymeraseAttachmentStateMachine.dnaStrandSeparation; + const attachedAndTranscribingState = this.rnaPolymeraseAttachmentStateMachine.attachedAndTranscribingState; // Verify that state is consistent. assert && assert( asm.attachmentSite !== null ); @@ -68,8 +68,8 @@ define( require => { * @public */ entered: function( asm ) { - var rnaPolymerase = this.rnaPolymeraseAttachmentStateMachine.rnaPolymerase; - var dnaStrandSeparation = this.rnaPolymeraseAttachmentStateMachine.dnaStrandSeparation; + const rnaPolymerase = this.rnaPolymeraseAttachmentStateMachine.rnaPolymerase; + const dnaStrandSeparation = this.rnaPolymeraseAttachmentStateMachine.dnaStrandSeparation; // Prevent user interaction. asm.biomolecule.movableByUserProperty.set( false ); diff --git a/js/common/model/attachment-state-machines/AttachedAndDeconformingState.js b/js/common/model/attachment-state-machines/AttachedAndDeconformingState.js index a74e3470..6ed7c0ac 100644 --- a/js/common/model/attachment-state-machines/AttachedAndDeconformingState.js +++ b/js/common/model/attachment-state-machines/AttachedAndDeconformingState.js @@ -22,7 +22,7 @@ define( require => { // the deconformation rate needs to be a little faster than the conformational change rate so that the polymerase is // less likely to collide at the end of the gene, see https://github.com/phetsims/gene-expression-essentials/issues/102. - var DECONFORMATION_RATE = GEEConstants.CONFORMATIONAL_CHANGE_RATE * 1.25; + const DECONFORMATION_RATE = GEEConstants.CONFORMATIONAL_CHANGE_RATE * 1.25; /** * @param {RnaPolymeraseAttachmentStateMachine} rnaPolymeraseAttachmentStateMachine @@ -49,13 +49,13 @@ define( require => { * @public */ step: function( asm, dt ) { - var biomolecule = this.rnaPolymeraseAttachmentStateMachine.biomolecule; + const biomolecule = this.rnaPolymeraseAttachmentStateMachine.biomolecule; // Verify that state is consistent. assert && assert( asm.attachmentSite !== null ); assert && assert( asm.attachmentSite.attachedOrAttachingMoleculeProperty.get() === biomolecule ); - var dnaStrandSeparation = this.rnaPolymeraseAttachmentStateMachine.dnaStrandSeparation; + const dnaStrandSeparation = this.rnaPolymeraseAttachmentStateMachine.dnaStrandSeparation; this.conformationalChangeAmount = Math.max( this.conformationalChangeAmount - DECONFORMATION_RATE * dt, @@ -74,13 +74,13 @@ define( require => { */ detachFromDna: function(){ - var asm = this.rnaPolymeraseAttachmentStateMachine; - var dnaStrandSeparation = asm.dnaStrandSeparation; - var rnaPolymerase = asm.rnaPolymerase; - var attachmentSite = asm.attachmentSite; - var recycleMode = asm.recycleMode; - var recycleReturnZones = asm.recycleReturnZones; - var attachedAndWanderingState = asm.attachedAndWanderingState; + const asm = this.rnaPolymeraseAttachmentStateMachine; + const dnaStrandSeparation = asm.dnaStrandSeparation; + const rnaPolymerase = asm.rnaPolymerase; + let attachmentSite = asm.attachmentSite; + const recycleMode = asm.recycleMode; + const recycleReturnZones = asm.recycleReturnZones; + const attachedAndWanderingState = asm.attachedAndWanderingState; // Remove the DNA separator, which makes the DNA close back up. rnaPolymerase.getModel().getDnaMolecule().removeSeparation( dnaStrandSeparation ); diff --git a/js/common/model/attachment-state-machines/AttachedAndTranscribingState.js b/js/common/model/attachment-state-machines/AttachedAndTranscribingState.js index 1deb5ee4..3fedd094 100644 --- a/js/common/model/attachment-state-machines/AttachedAndTranscribingState.js +++ b/js/common/model/attachment-state-machines/AttachedAndTranscribingState.js @@ -22,10 +22,10 @@ define( require => { const Vector2 = require( 'DOT/Vector2' ); // constants - var MRNA_GROWTH_FACTOR = 0.63; // empirically determined adjustment factor to make mRNA appear to be about the right length + const MRNA_GROWTH_FACTOR = 0.63; // empirically determined adjustment factor to make mRNA appear to be about the right length // used for comparing the position of Biomolecule and endOfGene's position. - var BIO_MOLECULE_POSITION_COMPARISON_EPSILON = 0.000001; + const BIO_MOLECULE_POSITION_COMPARISON_EPSILON = 0.000001; /** * @param {RnaPolymeraseAttachmentStateMachine} rnaPolymeraseAttachmentStateMachine @@ -53,11 +53,11 @@ define( require => { * @public */ step: function( asm, dt ) { - var rnaPolymerase = this.rnaPolymeraseAttachmentStateMachine.rnaPolymerase; - var dnaStrandSeparation = this.rnaPolymeraseAttachmentStateMachine.dnaStrandSeparation; - var biomolecule = this.rnaPolymeraseAttachmentStateMachine.biomolecule; - var attachedState = this.rnaPolymeraseAttachmentStateMachine.attachedState; - var attachedAndDeconformingState = this.rnaPolymeraseAttachmentStateMachine.attachedAndDeconformingState; + const rnaPolymerase = this.rnaPolymeraseAttachmentStateMachine.rnaPolymerase; + const dnaStrandSeparation = this.rnaPolymeraseAttachmentStateMachine.dnaStrandSeparation; + const biomolecule = this.rnaPolymeraseAttachmentStateMachine.biomolecule; + let attachedState = this.rnaPolymeraseAttachmentStateMachine.attachedState; + const attachedAndDeconformingState = this.rnaPolymeraseAttachmentStateMachine.attachedAndDeconformingState; // Verify that state is consistent assert && assert( asm.attachmentSite !== null ); @@ -74,7 +74,7 @@ define( require => { dnaStrandSeparation.setXPosition( rnaPolymerase.getPosition().x ); // Check for molecules that are in the way. - var molecules = asm.biomolecule.getModel().getOverlappingBiomolecules( asm.biomolecule.bounds ); + const molecules = asm.biomolecule.getModel().getOverlappingBiomolecules( asm.biomolecule.bounds ); molecules.forEach( function( molecule ) { if ( molecule.getPosition().x > asm.biomolecule.getPosition().x && molecule.attachedToDnaProperty.get() ) { @@ -101,15 +101,15 @@ define( require => { * @public */ entered: function( asm ) { - var biomolecule = this.rnaPolymeraseAttachmentStateMachine.biomolecule; - var transcribingAttachmentSite = this.rnaPolymeraseAttachmentStateMachine.transcribingAttachmentSite; - var attachmentSite = this.rnaPolymeraseAttachmentStateMachine.attachmentSite; + const biomolecule = this.rnaPolymeraseAttachmentStateMachine.biomolecule; + const transcribingAttachmentSite = this.rnaPolymeraseAttachmentStateMachine.transcribingAttachmentSite; + const attachmentSite = this.rnaPolymeraseAttachmentStateMachine.attachmentSite; // Prevent user interaction. asm.biomolecule.movableByUserProperty.set( false ); // Determine the gene that is being transcribed. - var geneToTranscribe = biomolecule.getModel().getDnaMolecule().getGeneAtLocation( biomolecule.getPosition() ); + const geneToTranscribe = biomolecule.getModel().getDnaMolecule().getGeneAtLocation( biomolecule.getPosition() ); assert && assert( geneToTranscribe !== null ); // Set up the motion strategy to move to the end of the transcribed region of the gene. diff --git a/js/common/model/attachment-state-machines/AttachedToDnaNotTranscribingState.js b/js/common/model/attachment-state-machines/AttachedToDnaNotTranscribingState.js index d41c8582..5d6652ca 100644 --- a/js/common/model/attachment-state-machines/AttachedToDnaNotTranscribingState.js +++ b/js/common/model/attachment-state-machines/AttachedToDnaNotTranscribingState.js @@ -21,7 +21,7 @@ define( require => { const WanderInGeneralDirectionMotionStrategy = require( 'GENE_EXPRESSION_ESSENTIALS/common/model/motion-strategies/WanderInGeneralDirectionMotionStrategy' ); // constant - var REEVALUATE_TRANSCRIPTION_DECISION_TIME = 1; // seconds + const REEVALUATE_TRANSCRIPTION_DECISION_TIME = 1; // seconds /** * @param {RnaPolymeraseAttachmentStateMachine} rnaPolymeraseAttachmentStateMachine @@ -73,11 +73,11 @@ define( require => { assert && assert( asm.attachmentSite.attachedOrAttachingMoleculeProperty.get() === asm.biomolecule ); // set up some convenient variables - var attachedState = this.rnaPolymeraseAttachmentStateMachine.attachedState; - var attachedAndConformingState = this.rnaPolymeraseAttachmentStateMachine.attachedAndConformingState; - var biomolecule = this.rnaPolymeraseAttachmentStateMachine.biomolecule; - var detachFromDnaThreshold = this.rnaPolymeraseAttachmentStateMachine.detachFromDnaThreshold; - var attachmentSite = this.rnaPolymeraseAttachmentStateMachine.attachmentSite; + let attachedState = this.rnaPolymeraseAttachmentStateMachine.attachedState; + const attachedAndConformingState = this.rnaPolymeraseAttachmentStateMachine.attachedAndConformingState; + const biomolecule = this.rnaPolymeraseAttachmentStateMachine.biomolecule; + const detachFromDnaThreshold = this.rnaPolymeraseAttachmentStateMachine.detachFromDnaThreshold; + let attachmentSite = this.rnaPolymeraseAttachmentStateMachine.attachmentSite; // Decide whether to transcribe the DNA. The decision is based on the affinity of the site and the time of // attachment. @@ -101,7 +101,7 @@ define( require => { else { // Move to an adjacent base pair. Start by making a list of candidate base pairs. - var attachmentSites = biomolecule.getModel().getDnaMolecule().getAdjacentAttachmentSitesRnaPolymerase( + let attachmentSites = biomolecule.getModel().getDnaMolecule().getAdjacentAttachmentSitesRnaPolymerase( biomolecule, asm.attachmentSite ); @@ -172,8 +172,8 @@ define( require => { * @public */ entered: function( asm ) { - var attachmentSite = this.rnaPolymeraseAttachmentStateMachine.attachmentSite; - var randValue = phet.joist.random.nextDouble(); + const attachmentSite = this.rnaPolymeraseAttachmentStateMachine.attachmentSite; + const randValue = phet.joist.random.nextDouble(); // Decide right away whether or not to transcribe. this.transcribe = attachmentSite.getAffinity() > GEEConstants.DEFAULT_AFFINITY && diff --git a/js/common/model/attachment-state-machines/BeingRecycledState.js b/js/common/model/attachment-state-machines/BeingRecycledState.js index c692e403..37273dbd 100644 --- a/js/common/model/attachment-state-machines/BeingRecycledState.js +++ b/js/common/model/attachment-state-machines/BeingRecycledState.js @@ -49,8 +49,8 @@ define( require => { // Verify that state is consistent. assert && assert( asm.attachmentSite === null ); - var biomolecule = this.rnaPolymeraseAttachmentStateMachine.biomolecule; - var unattachedAndAvailableState = this.rnaPolymeraseAttachmentStateMachine.unattachedAndAvailableState; + const biomolecule = this.rnaPolymeraseAttachmentStateMachine.biomolecule; + const unattachedAndAvailableState = this.rnaPolymeraseAttachmentStateMachine.unattachedAndAvailableState; if ( this.rnaPolymeraseAttachmentStateMachine.pointContainedInBoundsList( asm.biomolecule.getPosition(), this.recycleReturnZones @@ -68,7 +68,7 @@ define( require => { * @public */ entered: function( asm ) { - var biomolecule = this.rnaPolymeraseAttachmentStateMachine.biomolecule; + const biomolecule = this.rnaPolymeraseAttachmentStateMachine.biomolecule; // Prevent user interaction. asm.biomolecule.movableByUserProperty.set( false ); diff --git a/js/common/model/attachment-state-machines/DetachingFromPolymeraseState.js b/js/common/model/attachment-state-machines/DetachingFromPolymeraseState.js index 2cf1c204..1e6d28c3 100644 --- a/js/common/model/attachment-state-machines/DetachingFromPolymeraseState.js +++ b/js/common/model/attachment-state-machines/DetachingFromPolymeraseState.js @@ -21,7 +21,7 @@ define( require => { const WanderInGeneralDirectionMotionStrategy = require( 'GENE_EXPRESSION_ESSENTIALS/common/model/motion-strategies/WanderInGeneralDirectionMotionStrategy' ); // constants - var DETACHING_TIME = 3; // seconds + const DETACHING_TIME = 3; // seconds function DetachingFromPolymeraseState( msgRnaAttachmentStateMachine ) { AttachmentState.call( this ); diff --git a/js/common/model/attachment-state-machines/GenericAttachedState.js b/js/common/model/attachment-state-machines/GenericAttachedState.js index d2373bf8..fbc84c43 100644 --- a/js/common/model/attachment-state-machines/GenericAttachedState.js +++ b/js/common/model/attachment-state-machines/GenericAttachedState.js @@ -20,7 +20,7 @@ define( require => { const WanderInGeneralDirectionMotionStrategy = require( 'GENE_EXPRESSION_ESSENTIALS/common/model/motion-strategies/WanderInGeneralDirectionMotionStrategy' ); // constants - var DEFAULT_ATTACH_TIME = 3; // In seconds. + const DEFAULT_ATTACH_TIME = 3; // In seconds. /** * @@ -42,7 +42,7 @@ define( require => { * @public */ step: function( enclosingStateMachine, dt ) { - var gsm = enclosingStateMachine; + const gsm = enclosingStateMachine; // Verify that state is consistent. assert && assert( gsm.attachmentSite !== null ); diff --git a/js/common/model/attachment-state-machines/GenericMovingTowardsAttachmentState.js b/js/common/model/attachment-state-machines/GenericMovingTowardsAttachmentState.js index 29924a5a..1948dfaf 100644 --- a/js/common/model/attachment-state-machines/GenericMovingTowardsAttachmentState.js +++ b/js/common/model/attachment-state-machines/GenericMovingTowardsAttachmentState.js @@ -32,14 +32,14 @@ define( require => { */ step: function( enclosingStateMachine, dt ) { - var gsm = enclosingStateMachine; + const gsm = enclosingStateMachine; // verify that state is consistent assert && assert( gsm.attachmentSite !== null ); assert && assert( gsm.attachmentSite.attachedOrAttachingMoleculeProperty.get() === this.genericAttachmentStateMachine.biomolecule ); // calculate the position where this biomolecule must be in order to attach to the attachment site - var destination = new Vector2( + const destination = new Vector2( gsm.attachmentSite.positionProperty.get().x - gsm.destinationOffset.x, gsm.attachmentSite.positionProperty.get().y - gsm.destinationOffset.y ); diff --git a/js/common/model/attachment-state-machines/GenericUnattachedAndAvailableState.js b/js/common/model/attachment-state-machines/GenericUnattachedAndAvailableState.js index 6038c1b0..fe3a13c5 100644 --- a/js/common/model/attachment-state-machines/GenericUnattachedAndAvailableState.js +++ b/js/common/model/attachment-state-machines/GenericUnattachedAndAvailableState.js @@ -31,7 +31,7 @@ define( require => { * @public */ step: function( enclosingStateMachine, dt ) { - var gsm = enclosingStateMachine; + const gsm = enclosingStateMachine; // Verify that state is consistent assert && assert( gsm.attachmentSite === null ); diff --git a/js/common/model/attachment-state-machines/GenericUnattachedButUnavailableState.js b/js/common/model/attachment-state-machines/GenericUnattachedButUnavailableState.js index 6de7fe4f..f5f5a8bc 100644 --- a/js/common/model/attachment-state-machines/GenericUnattachedButUnavailableState.js +++ b/js/common/model/attachment-state-machines/GenericUnattachedButUnavailableState.js @@ -15,7 +15,7 @@ define( require => { const inherit = require( 'PHET_CORE/inherit' ); // constants - var DEFAULT_DETACH_TIME = 3; // In seconds. + const DEFAULT_DETACH_TIME = 3; // In seconds. /** * @constructor @@ -36,7 +36,7 @@ define( require => { * @public */ step: function( enclosingStateMachine, dt ) { - var gsm = enclosingStateMachine; + const gsm = enclosingStateMachine; // Verify that state is consistent assert && assert( gsm.attachmentSite === null ); diff --git a/js/common/model/attachment-state-machines/MRnaDestroyerAttachedState.js b/js/common/model/attachment-state-machines/MRnaDestroyerAttachedState.js index 01c2c219..5431afb3 100644 --- a/js/common/model/attachment-state-machines/MRnaDestroyerAttachedState.js +++ b/js/common/model/attachment-state-machines/MRnaDestroyerAttachedState.js @@ -21,10 +21,10 @@ define( require => { // constants // Scalar velocity for transcription. - var RNA_DESTRUCTION_RATE = 750; // Picometers per second. + const RNA_DESTRUCTION_RATE = 750; // Picometers per second. // Range of lengths for mRNA fragments. - var MRNA_FRAGMENT_LENGTH_RANGE = new Range( 100, 400 ); // In picometers. + const MRNA_FRAGMENT_LENGTH_RANGE = new Range( 100, 400 ); // In picometers. /** * @param {MRnaDestroyerAttachmentStateMachine} MRnaDestroyerAttachmentStateMachine @@ -51,7 +51,7 @@ define( require => { * @public */ step: function( asm, dt ) { - var biomolecule = this.MRnaDestroyerAttachmentStateMachine.biomolecule; + const biomolecule = this.MRnaDestroyerAttachmentStateMachine.biomolecule; // Verify that state is consistent. assert && assert( asm.attachmentSite !== null ); @@ -75,9 +75,9 @@ define( require => { // Advance the destruction of the mRNA. Destruction must proceed more slowly when the mRNA is being synthesized // to avoid a situation where it gets destroyed more rapidly than it is created. - var destructionRate = biomolecule.getMessengerRnaBeingDestroyed().beingSynthesizedProperty.get() ? + const destructionRate = biomolecule.getMessengerRnaBeingDestroyed().beingSynthesizedProperty.get() ? RNA_DESTRUCTION_RATE / 2 : RNA_DESTRUCTION_RATE; - var destructionComplete = this.MRnaDestroyerAttachmentStateMachine.mRnaDestroyer.advanceMessengerRnaDestruction( + const destructionComplete = this.MRnaDestroyerAttachmentStateMachine.mRnaDestroyer.advanceMessengerRnaDestruction( destructionRate * dt ); if ( destructionComplete ) { @@ -106,7 +106,7 @@ define( require => { * @public */ entered: function( asm ) { - var mRnaDestroyer = this.MRnaDestroyerAttachmentStateMachine.mRnaDestroyer; + const mRnaDestroyer = this.MRnaDestroyerAttachmentStateMachine.mRnaDestroyer; mRnaDestroyer.initiateMessengerRnaDestruction(); mRnaDestroyer.setMotionStrategy( new DestroyerTrackingRnaMotionStrategy( mRnaDestroyer ) ); diff --git a/js/common/model/attachment-state-machines/MessengerRnaAttachmentStateMachine.js b/js/common/model/attachment-state-machines/MessengerRnaAttachmentStateMachine.js index 983c1b11..5001f136 100644 --- a/js/common/model/attachment-state-machines/MessengerRnaAttachmentStateMachine.js +++ b/js/common/model/attachment-state-machines/MessengerRnaAttachmentStateMachine.js @@ -61,7 +61,7 @@ define( require => { */ forceImmediateUnattachedAndAvailable: function() { if ( this.attachmentSite !== null ) { - var attachedOrAttachingMolecule = this.attachmentSite.attachedOrAttachingMoleculeProperty.get(); + const attachedOrAttachingMolecule = this.attachmentSite.attachedOrAttachingMoleculeProperty.get(); // this is the case for when the incoming molecule is a ribosome attachedOrAttachingMolecule.cancelTranslation && attachedOrAttachingMolecule.cancelTranslation(); diff --git a/js/common/model/attachment-state-machines/MessengerRnaFragmentAttachmentStateMachine.js b/js/common/model/attachment-state-machines/MessengerRnaFragmentAttachmentStateMachine.js index 19f44a04..b3e347a3 100644 --- a/js/common/model/attachment-state-machines/MessengerRnaFragmentAttachmentStateMachine.js +++ b/js/common/model/attachment-state-machines/MessengerRnaFragmentAttachmentStateMachine.js @@ -20,12 +20,12 @@ define( require => { const StillnessMotionStrategy = require( 'GENE_EXPRESSION_ESSENTIALS/common/model/motion-strategies/StillnessMotionStrategy' ); // constants - var FADE_OUT_TIME = 3; // In seconds. + const FADE_OUT_TIME = 3; // In seconds. //------------------------------------------ // States for this attachment state machine //------------------------------------------ - var AttachedToDestroyerState = inherit( + const AttachedToDestroyerState = inherit( AttachmentState, @@ -41,13 +41,13 @@ define( require => { * @param {AttachmentStateMachine} asm */ entered: function( asm ) { - var biomolecule = this.messengerRnaFragmentAttachmentStateMachine.biomolecule; + const biomolecule = this.messengerRnaFragmentAttachmentStateMachine.biomolecule; biomolecule.setMotionStrategy( new StillnessMotionStrategy() ); } } ); - var UnattachedAndFadingState = inherit( + const UnattachedAndFadingState = inherit( AttachmentState, @@ -63,7 +63,7 @@ define( require => { * @param {AttachmentStateMachine} asm */ entered: function( asm ) { - var biomolecule = this.messengerRnaFragmentAttachmentStateMachine.biomolecule; + const biomolecule = this.messengerRnaFragmentAttachmentStateMachine.biomolecule; assert && assert( biomolecule.existenceStrengthProperty.get() === 1 ); biomolecule.setMotionStrategy( new RandomWalkMotionStrategy( biomolecule.motionBoundsProperty ) ); }, @@ -74,7 +74,7 @@ define( require => { * @param {number} dt */ step: function( asm, dt ) { - var biomolecule = this.messengerRnaFragmentAttachmentStateMachine.biomolecule; + const biomolecule = this.messengerRnaFragmentAttachmentStateMachine.biomolecule; biomolecule.existenceStrengthProperty.set( Math.max( biomolecule.existenceStrengthProperty.get() - dt / FADE_OUT_TIME, 0 ) ); } } ); diff --git a/js/common/model/attachment-state-machines/ProteinAttachmentStateMachine.js b/js/common/model/attachment-state-machines/ProteinAttachmentStateMachine.js index ce9ac670..50153bd7 100644 --- a/js/common/model/attachment-state-machines/ProteinAttachmentStateMachine.js +++ b/js/common/model/attachment-state-machines/ProteinAttachmentStateMachine.js @@ -21,7 +21,7 @@ define( require => { //------------------------------------------ //States for this attachment state machine //------------------------------------------ - var ProteinAttachedToRibosomeState = inherit( AttachmentState, + const ProteinAttachedToRibosomeState = inherit( AttachmentState, /** * @param {ProteinAttachmentStateMachine} proteinAttachmentStateMachine @@ -35,7 +35,7 @@ define( require => { * @param {AttachmentStateMachine} asm */ entered: function( asm ) { - var biomolecule = this.proteinAttachmentStateMachine.biomolecule; + const biomolecule = this.proteinAttachmentStateMachine.biomolecule; biomolecule.setMotionStrategy( new StillnessMotionStrategy() ); // Prevent user interaction while the protein is growing. diff --git a/js/common/model/attachment-state-machines/RibosomeAttachedState.js b/js/common/model/attachment-state-machines/RibosomeAttachedState.js index 776403fe..fe6eebe9 100644 --- a/js/common/model/attachment-state-machines/RibosomeAttachedState.js +++ b/js/common/model/attachment-state-machines/RibosomeAttachedState.js @@ -19,8 +19,8 @@ define( require => { const Vector2 = require( 'DOT/Vector2' ); // constants - var RNA_TRANSLATION_RATE = 750; // picometers per second - var CLEAR_RNA_ATTACHMENT_LENGTH = 700; // length which, once translated, a new biomolecule can attach to mRNA + const RNA_TRANSLATION_RATE = 750; // picometers per second + const CLEAR_RNA_ATTACHMENT_LENGTH = 700; // length which, once translated, a new biomolecule can attach to mRNA /** * @@ -45,9 +45,9 @@ define( require => { */ step: function( asm, dt ) { - var proteinBeingSynthesized = this.ribosomeAttachmentStateMachine.proteinBeingSynthesized; - var ribosome = this.ribosomeAttachmentStateMachine.ribosome; - var mRna = ribosome.getMessengerRnaBeingTranslated(); + let proteinBeingSynthesized = this.ribosomeAttachmentStateMachine.proteinBeingSynthesized; + const ribosome = this.ribosomeAttachmentStateMachine.ribosome; + const mRna = ribosome.getMessengerRnaBeingTranslated(); // grow the protein proteinBeingSynthesized.setFullSizeProportion( @@ -73,8 +73,8 @@ define( require => { // Advance the translation of the mRNA. This must proceed more slowly if the mRNA is in the process of being // synthesized, otherwise the ribosome with run out of mRNA to work with. The amount of reduction was chosen to // look good and to cause minimal "jumpiness" when translation and trnascription occur simultaneously. - var translationRate = mRna.beingSynthesizedProperty.get() ? RNA_TRANSLATION_RATE * 0.4 : RNA_TRANSLATION_RATE; - var translationComplete = ribosome.advanceMessengerRnaTranslation( translationRate * dt ); + const translationRate = mRna.beingSynthesizedProperty.get() ? RNA_TRANSLATION_RATE * 0.4 : RNA_TRANSLATION_RATE; + const translationComplete = ribosome.advanceMessengerRnaTranslation( translationRate * dt ); if ( translationComplete ) { // release the mRNA @@ -95,10 +95,10 @@ define( require => { * @public */ entered: function( asm ) { - var ribosome = this.ribosomeAttachmentStateMachine.ribosome; + const ribosome = this.ribosomeAttachmentStateMachine.ribosome; ribosome.initiateTranslation(); ribosome.setMotionStrategy( new RibosomeTranslatingRnaMotionStrategy( ribosome ) ); - var proteinBeingSynthesized = ribosome.getMessengerRnaBeingTranslated().getProteinPrototype().createInstance(); + const proteinBeingSynthesized = ribosome.getMessengerRnaBeingTranslated().getProteinPrototype().createInstance(); this.ribosomeAttachmentStateMachine.proteinBeingSynthesized = proteinBeingSynthesized; proteinBeingSynthesized.setAttachmentPointPosition( ribosome.getProteinAttachmentPoint() ); ribosome.getModel().addMobileBiomolecule( proteinBeingSynthesized ); diff --git a/js/common/model/attachment-state-machines/RnaPolymeraseAttachmentStateMachine.js b/js/common/model/attachment-state-machines/RnaPolymeraseAttachmentStateMachine.js index 0933a2f4..a12d963a 100644 --- a/js/common/model/attachment-state-machines/RnaPolymeraseAttachmentStateMachine.js +++ b/js/common/model/attachment-state-machines/RnaPolymeraseAttachmentStateMachine.js @@ -25,7 +25,7 @@ define( require => { const Vector2 = require( 'DOT/Vector2' ); // constants - var HALF_LIFE_FOR_HALF_AFFINITY = 1.5; // In seconds. Half-life of attachment to a site with affinity of 0.5. + const HALF_LIFE_FOR_HALF_AFFINITY = 1.5; // In seconds. Half-life of attachment to a site with affinity of 0.5. /** * @param {RnaPolymerase} rnaPolymerase @@ -132,8 +132,8 @@ define( require => { * @public */ pointContainedInBoundsList: function( p, boundsList ) { - for ( var i = 0; i < boundsList.length; i++ ) { - var bounds = boundsList[ i ]; + for ( let i = 0; i < boundsList.length; i++ ) { + const bounds = boundsList[ i ]; if ( bounds.containsPoint( p ) ) { return true; } diff --git a/js/common/model/attachment-state-machines/TranscriptionFactorAttachedState.js b/js/common/model/attachment-state-machines/TranscriptionFactorAttachedState.js index 7df145c4..664ca3ab 100644 --- a/js/common/model/attachment-state-machines/TranscriptionFactorAttachedState.js +++ b/js/common/model/attachment-state-machines/TranscriptionFactorAttachedState.js @@ -20,7 +20,7 @@ define( require => { const WanderInGeneralDirectionMotionStrategy = require( 'GENE_EXPRESSION_ESSENTIALS/common/model/motion-strategies/WanderInGeneralDirectionMotionStrategy' ); // constants - var HALF_LIFE_FOR_HALF_AFFINITY = 1.5; // In seconds. + const HALF_LIFE_FOR_HALF_AFFINITY = 1.5; // In seconds. /** * @param {TranscriptionFactorAttachmentStateMachine} transcriptionFactorAttachmentStateMachine @@ -50,7 +50,7 @@ define( require => { // Map affinity to a half life. Units are in seconds. This formula can be tweaked as needed in order to make the // half life longer or shorter. However, zero affinity should always map to zero half life, and an affinity of one // should always map to an infinite half life. - var halfLife = HALF_LIFE_FOR_HALF_AFFINITY * ( affinity / ( 1 - affinity ) ); + const halfLife = HALF_LIFE_FOR_HALF_AFFINITY * ( affinity / ( 1 - affinity ) ); // Use standard half-life formula to decide on probability of detachment. return 1 - Math.exp( -0.693 * dt / halfLife ); @@ -61,7 +61,7 @@ define( require => { * @private */ detachFromDnaMolecule: function( asm ) { - var biomolecule = this.transcriptionFactorAttachmentStateMachine.biomolecule; + const biomolecule = this.transcriptionFactorAttachmentStateMachine.biomolecule; asm.attachmentSite.attachedOrAttachingMoleculeProperty.set( null ); asm.attachmentSite = null; asm.setState( this.transcriptionFactorAttachmentStateMachine.unattachedButUnavailableState ); @@ -78,10 +78,10 @@ define( require => { * @public */ step: function( asm, dt ) { - var attachmentSite = this.transcriptionFactorAttachmentStateMachine.attachmentSite; - var detachFromDnaThreshold = this.transcriptionFactorAttachmentStateMachine.detachFromDnaThreshold; - var biomolecule = this.transcriptionFactorAttachmentStateMachine.biomolecule; - var movingTowardsAttachmentState = this.transcriptionFactorAttachmentStateMachine.movingTowardsAttachmentState; + let attachmentSite = this.transcriptionFactorAttachmentStateMachine.attachmentSite; + const detachFromDnaThreshold = this.transcriptionFactorAttachmentStateMachine.detachFromDnaThreshold; + const biomolecule = this.transcriptionFactorAttachmentStateMachine.biomolecule; + const movingTowardsAttachmentState = this.transcriptionFactorAttachmentStateMachine.movingTowardsAttachmentState; // Decide whether or not to detach from the current attachment site. if ( phet.joist.random.nextDouble() > ( 1 - this.calculateProbabilityOfDetachment( attachmentSite.getAffinity(), dt ) ) ) { @@ -96,7 +96,7 @@ define( require => { else { // Move to an adjacent base pair. Start by making a list of candidate base pairs. - var attachmentSites = biomolecule.getModel().getDnaMolecule().getAdjacentAttachmentSitesTranscriptionFactor( biomolecule, asm.attachmentSite ); + let attachmentSites = biomolecule.getModel().getDnaMolecule().getAdjacentAttachmentSitesTranscriptionFactor( biomolecule, asm.attachmentSite ); // Eliminate sites that, if moved to, would put the biomolecule out of bounds. //var clonedAttachmentSites = [].concat( attachmentSites ); diff --git a/js/common/model/attachment-state-machines/UnattachedAndAvailableForMRnaAttachmentState.js b/js/common/model/attachment-state-machines/UnattachedAndAvailableForMRnaAttachmentState.js index 1582f56f..e03d919a 100644 --- a/js/common/model/attachment-state-machines/UnattachedAndAvailableForMRnaAttachmentState.js +++ b/js/common/model/attachment-state-machines/UnattachedAndAvailableForMRnaAttachmentState.js @@ -46,7 +46,7 @@ define( require => { * @public */ step: function( enclosingStateMachine, dt ) { - var gsm = enclosingStateMachine; + const gsm = enclosingStateMachine; // verify that state is consistent assert && assert( gsm.attachmentSite === null ); diff --git a/js/common/model/attachment-state-machines/UnattachedAndFadingState.js b/js/common/model/attachment-state-machines/UnattachedAndFadingState.js index 585877ef..78d80193 100644 --- a/js/common/model/attachment-state-machines/UnattachedAndFadingState.js +++ b/js/common/model/attachment-state-machines/UnattachedAndFadingState.js @@ -17,8 +17,8 @@ define( require => { const WanderInGeneralDirectionMotionStrategy = require( 'GENE_EXPRESSION_ESSENTIALS/common/model/motion-strategies/WanderInGeneralDirectionMotionStrategy' ); // constants - var PRE_FADE_TIME = 5; - var FADE_OUT_TIME = 2; + const PRE_FADE_TIME = 5; + const FADE_OUT_TIME = 2; /** * @param {MessengerRnaAttachmentStateMachine} messengerRnaAttachmentStateMachine @@ -44,7 +44,7 @@ define( require => { this.preFadeCountdown -= dt; } else { - var biomolecule = this.messengerRnaAttachmentStateMachine.biomolecule; + const biomolecule = this.messengerRnaAttachmentStateMachine.biomolecule; biomolecule.existenceStrengthProperty.set( Math.max( biomolecule.existenceStrengthProperty.get() - dt / FADE_OUT_TIME, 0 ) ); } }, diff --git a/js/common/model/motion-strategies/DestroyerTrackingRnaMotionStrategy.js b/js/common/model/motion-strategies/DestroyerTrackingRnaMotionStrategy.js index fb1080fd..f2cd0ecd 100644 --- a/js/common/model/motion-strategies/DestroyerTrackingRnaMotionStrategy.js +++ b/js/common/model/motion-strategies/DestroyerTrackingRnaMotionStrategy.js @@ -39,7 +39,7 @@ define( require => { * @public */ getNextPosition: function( currentPosition, bounds, dt ) { - var generateInitialPosition3D = this.messengerRna.getDestroyerGenerateInitialPosition3D(); + const generateInitialPosition3D = this.messengerRna.getDestroyerGenerateInitialPosition3D(); return new Vector2( generateInitialPosition3D.x, generateInitialPosition3D.y ); } } ); diff --git a/js/common/model/motion-strategies/DriftThenTeleportMotionStrategy.js b/js/common/model/motion-strategies/DriftThenTeleportMotionStrategy.js index 00f59c5a..2223cbde 100644 --- a/js/common/model/motion-strategies/DriftThenTeleportMotionStrategy.js +++ b/js/common/model/motion-strategies/DriftThenTeleportMotionStrategy.js @@ -22,9 +22,9 @@ define( require => { const Vector3 = require( 'DOT/Vector3' ); // constants - var PRE_FADE_DRIFT_TIME = 1.5; // In seconds. - var FADE_AND_DRIFT_TIME = 1; // In seconds. - var PRE_TELEPORT_VELOCITY = 250; // In picometers per second. + const PRE_FADE_DRIFT_TIME = 1.5; // In seconds. + const FADE_AND_DRIFT_TIME = 1; // In seconds. + const PRE_TELEPORT_VELOCITY = 250; // In picometers per second. /** * @param {Vector2} wanderDirection @@ -33,7 +33,7 @@ define( require => { * @constructor */ function DriftThenTeleportMotionStrategy( wanderDirection, destinationZones, motionBoundsProperty ) { - var self = this; + const self = this; MotionStrategy.call( this ); function handleMotionBoundsChanged( motionBounds ) { @@ -74,11 +74,11 @@ define( require => { generateRandomPositionInBounds: function( destinationZones, bounds ) { // randomly choose one of the destination zones - var destinationBounds = phet.joist.random.sample( destinationZones ); + const destinationBounds = phet.joist.random.sample( destinationZones ); // generate a random valid location within the chosen zone - var reducedBoundsWidth = destinationBounds.getWidth() - bounds.getWidth(); - var reducedBoundsHeight = destinationBounds.getHeight() - bounds.getHeight(); + const reducedBoundsWidth = destinationBounds.getWidth() - bounds.getWidth(); + const reducedBoundsHeight = destinationBounds.getHeight() - bounds.getHeight(); assert && assert( reducedBoundsWidth > 0 && reducedBoundsHeight > 0, 'earning: bounds cannot contain shape' @@ -98,7 +98,7 @@ define( require => { * @public */ getNextPosition: function( currentPosition, bounds, dt ) { - var position3D = this.getNextPosition3D( new Vector3( currentPosition.x, currentPosition.x, 0 ), bounds, dt ); + const position3D = this.getNextPosition3D( new Vector3( currentPosition.x, currentPosition.x, 0 ), bounds, dt ); return new Vector2( position3D.x, position3D.y ); }, @@ -116,19 +116,19 @@ define( require => { if ( currentPosition.z <= -1 ) { // Time to teleport. - var destination2D = this.generateRandomPositionInBounds( this.destinationZones, bounds ); + const destination2D = this.generateRandomPositionInBounds( this.destinationZones, bounds ); return new Vector3( destination2D.x, destination2D.y, -1 ); } // Determine movement for drift. - var xyMovement; + let xyMovement; if ( this.motionBounds.testIfInMotionBoundsWithDelta( bounds, this.velocityXY, dt ) ) { xyMovement = this.velocityXY.timesScalar( dt ); } else { xyMovement = new Vector2( 0, 0 ); } - var zMovement = 0; + let zMovement = 0; if ( this.preFadeCountdown > 0 ) { // In pre-fade state, so no movement in Z direction. diff --git a/js/common/model/motion-strategies/MeanderToDestinationMotionStrategy.js b/js/common/model/motion-strategies/MeanderToDestinationMotionStrategy.js index 2eae1c07..c7533cb2 100644 --- a/js/common/model/motion-strategies/MeanderToDestinationMotionStrategy.js +++ b/js/common/model/motion-strategies/MeanderToDestinationMotionStrategy.js @@ -56,7 +56,7 @@ define( require => { * @public */ getNextPosition: function( currentPosition, bounds, dt ) { - var nextPosition3D = this.getNextPosition3D( new Vector3( currentPosition.x, currentPosition.y, 0 ), bounds, dt ); + const nextPosition3D = this.getNextPosition3D( new Vector3( currentPosition.x, currentPosition.y, 0 ), bounds, dt ); return new Vector2( nextPosition3D.x, nextPosition3D.y ); }, @@ -79,7 +79,7 @@ define( require => { else { // Use a combination of the random and linear motion. - var intermediateLocation = this.randomWalkMotionStrategy.getNextPosition3D( currentPosition, bounds, dt * 0.6 ); + const intermediateLocation = this.randomWalkMotionStrategy.getNextPosition3D( currentPosition, bounds, dt * 0.6 ); return this.directToDestinationMotionStrategy.getNextPosition3D( intermediateLocation, bounds, dt * 0.4 ); } } diff --git a/js/common/model/motion-strategies/MotionBounds.js b/js/common/model/motion-strategies/MotionBounds.js index 5a6114b8..34fa6ded 100644 --- a/js/common/model/motion-strategies/MotionBounds.js +++ b/js/common/model/motion-strategies/MotionBounds.js @@ -60,7 +60,7 @@ define( require => { * @private */ inOffLimitMotionSpace: function( bounds ) { - var flag = false; + let flag = false; this.offLimitMotionSpaces.forEach( function( offLimitMotionSpace ) { if ( bounds.intersectsBounds( offLimitMotionSpace ) ) { flag = true; @@ -112,8 +112,8 @@ define( require => { * @public */ testIfInMotionBounds: function( bounds, proposedPosition ) { - var shapeCenter = bounds.getCenter(); - var translationVector = proposedPosition.minus( shapeCenter ); + const shapeCenter = bounds.getCenter(); + const translationVector = proposedPosition.minus( shapeCenter ); return this.inBounds( bounds.shifted( translationVector.x, translationVector.y ) ); } } ); diff --git a/js/common/model/motion-strategies/MotionStrategy.js b/js/common/model/motion-strategies/MotionStrategy.js index 3350931b..38abc22f 100644 --- a/js/common/model/motion-strategies/MotionStrategy.js +++ b/js/common/model/motion-strategies/MotionStrategy.js @@ -65,7 +65,7 @@ define( require => { getNextPosition3D: function( currentPosition, bounds, dt ) { // Default version does not move in Z direction, override for true 3D motion. - var nextPosition2D = this.getNextPosition( new Vector2( currentPosition.x, currentPosition.y ), bounds, dt ); + const nextPosition2D = this.getNextPosition( new Vector2( currentPosition.x, currentPosition.y ), bounds, dt ); return new Vector3( nextPosition2D.x, nextPosition2D.y, 0 ); }, @@ -86,19 +86,19 @@ define( require => { assert && assert( !this.motionBounds.inBounds( bounds.shifted( originalMotionVector.x * dt, originalMotionVector.y * dt ) ) ); // Try reversing X direction. - var reversedXMotionVector = new Vector2( -originalMotionVector.x, originalMotionVector.y ); + const reversedXMotionVector = new Vector2( -originalMotionVector.x, originalMotionVector.y ); if ( this.motionBounds.inBounds( bounds.shifted( reversedXMotionVector.x * dt, reversedXMotionVector.y * dt ) ) ) { return reversedXMotionVector; } // Try reversing Y direction. - var reversedYMotionVector = new Vector2( originalMotionVector.x, -originalMotionVector.y ); + const reversedYMotionVector = new Vector2( originalMotionVector.x, -originalMotionVector.y ); if ( this.motionBounds.inBounds( bounds.shifted( reversedYMotionVector.x * dt, reversedYMotionVector * dt ) ) ) { return reversedYMotionVector; } // Try reversing both X and Y directions. - var reversedXYMotionVector = new Vector2( -originalMotionVector.x, -originalMotionVector.y ); + const reversedXYMotionVector = new Vector2( -originalMotionVector.x, -originalMotionVector.y ); if ( this.motionBounds.inBounds( bounds.shifted( reversedXYMotionVector.x * dt, reversedXYMotionVector.x * dt ) ) ) { return reversedXYMotionVector; } @@ -107,8 +107,8 @@ define( require => { // bounds. This might be because the molecule was dropped somewhere out of bounds, or maybe just that it is stuck // to the DNA or something. So, just return a vector back to the center of the motion bounds. That should be a // safe bet. - var centerOfMotionBounds = this.motionBounds.getBounds().getCenter(); - var vectorToMotionBoundsCenter = new Vector2( centerOfMotionBounds.x - bounds.getCenterX(), + const centerOfMotionBounds = this.motionBounds.getBounds().getCenter(); + const vectorToMotionBoundsCenter = new Vector2( centerOfMotionBounds.x - bounds.getCenterX(), centerOfMotionBounds.y - bounds.getCenterY() ); vectorToMotionBoundsCenter.multiplyScalar( maxVelocity / vectorToMotionBoundsCenter.magnitude ); return vectorToMotionBoundsCenter; @@ -122,7 +122,7 @@ define( require => { * @private */ calculateDistanceBetweenRanges: function( r1, r2 ) { - var distance; + let distance; if ( r1.intersects( r2 ) ) { // Ranges overlap, so there is no distance between them. @@ -148,12 +148,12 @@ define( require => { * @protected */ getMinZ: function( bounds, positionXY ) { - var shapeYRange = new Range( positionXY.y - bounds.height / 2, + const shapeYRange = new Range( positionXY.y - bounds.height / 2, positionXY.y + bounds.height / 2 ); - var dnaYRange = new Range( GEEConstants.DNA_MOLECULE_Y_POS - GEEConstants.DNA_MOLECULE_DIAMETER / 2, + const dnaYRange = new Range( GEEConstants.DNA_MOLECULE_Y_POS - GEEConstants.DNA_MOLECULE_DIAMETER / 2, GEEConstants.DNA_MOLECULE_Y_POS + GEEConstants.DNA_MOLECULE_DIAMETER / 2 ); - var minZ = -1; - var distanceToEdgeOfDna = this.calculateDistanceBetweenRanges( shapeYRange, dnaYRange ); + let minZ = -1; + const distanceToEdgeOfDna = this.calculateDistanceBetweenRanges( shapeYRange, dnaYRange ); if ( distanceToEdgeOfDna < shapeYRange.getLength() / 2 ) { // Limit the z-dimension so that the biomolecule is at the front when over the DNA and make a gradient as it diff --git a/js/common/model/motion-strategies/MoveDirectlyToDestinationMotionStrategy.js b/js/common/model/motion-strategies/MoveDirectlyToDestinationMotionStrategy.js index c6a55a6a..c9e435c2 100644 --- a/js/common/model/motion-strategies/MoveDirectlyToDestinationMotionStrategy.js +++ b/js/common/model/motion-strategies/MoveDirectlyToDestinationMotionStrategy.js @@ -18,7 +18,7 @@ define( require => { const Vector3 = require( 'DOT/Vector3' ); // constants - var MAX_Z_VELOCITY = 10; // Max Z velocity in normalized units. + const MAX_Z_VELOCITY = 10; // Max Z velocity in normalized units. /** * @param {Property} destinationProperty @@ -28,7 +28,7 @@ define( require => { * @constructor */ function MoveDirectlyToDestinationMotionStrategy( destinationProperty, motionBoundsProperty, destinationOffset, velocity ) { - var self = this; + const self = this; MotionStrategy.call( self ); function handleMotionBoundsChanged( motionBounds ) { @@ -77,7 +77,7 @@ define( require => { * @public */ getNextPosition: function( currentPosition, bounds, dt ) { - var nextPosition3D = this.getNextPosition3D( new Vector3( currentPosition.x, currentPosition.y, 0 ), bounds, dt ); + const nextPosition3D = this.getNextPosition3D( new Vector3( currentPosition.x, currentPosition.y, 0 ), bounds, dt ); return new Vector2( nextPosition3D.x, nextPosition3D.y ); }, @@ -107,16 +107,16 @@ define( require => { getNextPosition3D: function( currentPosition3D, bounds, dt ) { // destination is assumed to always have a Z value of 0, i.e. at the "surface" - var currentDestination3D = new Vector3( + const currentDestination3D = new Vector3( this.destinationProperty.get().x - this.offsetFromDestination.x, this.destinationProperty.get().y - this.offsetFromDestination.y, 0 ); - var currentDestination2D = new Vector2( + const currentDestination2D = new Vector2( this.destinationProperty.get().x - this.offsetFromDestination.x, this.destinationProperty.get().y - this.offsetFromDestination.y ); - var currentPosition2D = new Vector2( currentPosition3D.x, currentPosition3D.y ); + const currentPosition2D = new Vector2( currentPosition3D.x, currentPosition3D.y ); this.updateVelocityVector2D( currentPosition2D, new Vector2( currentDestination3D.x, currentDestination3D.y ), @@ -125,8 +125,8 @@ define( require => { // make the Z velocity such that the front (i.e. z = 0) will be reached at the same time as the destination in XY // space - var distanceToDestination2D = currentPosition2D.distance( this.destinationProperty.get() ); - var zVelocity; + const distanceToDestination2D = currentPosition2D.distance( this.destinationProperty.get() ); + let zVelocity; if ( distanceToDestination2D > 0 ) { zVelocity = Math.min( Math.abs( currentPosition3D.z ) / ( currentPosition2D.distance( this.destinationProperty.get() ) / this.scalarVelocity2D ), @@ -138,7 +138,7 @@ define( require => { } // make sure that the current motion won't move the model element past the destination - var distanceToDestination = currentPosition2D.distance( currentDestination2D ); + const distanceToDestination = currentPosition2D.distance( currentDestination2D ); if ( this.velocityVector2D.magnitude * dt > distanceToDestination ) { return currentDestination3D; } diff --git a/js/common/model/motion-strategies/RandomWalkMotionStrategy.js b/js/common/model/motion-strategies/RandomWalkMotionStrategy.js index ea64fb60..1246baa5 100644 --- a/js/common/model/motion-strategies/RandomWalkMotionStrategy.js +++ b/js/common/model/motion-strategies/RandomWalkMotionStrategy.js @@ -20,22 +20,22 @@ define( require => { const Vector3 = require( 'DOT/Vector3' ); // constants - var MIN_XY_VELOCITY = 200; // In picometers/s - var MAX_XY_VELOCITY = 400; // In picometers/s - var MIN_Z_VELOCITY = 0.3; // In normalized units per sec - var MAX_Z_VELOCITY = 0.6; // In normalized units per sec - var MIN_TIME_IN_ONE_DIRECTION = 0.25; // In seconds. - var MAX_TIME_IN_ONE_DIRECTION = 0.8; // In seconds. + const MIN_XY_VELOCITY = 200; // In picometers/s + const MAX_XY_VELOCITY = 400; // In picometers/s + const MIN_Z_VELOCITY = 0.3; // In normalized units per sec + const MAX_Z_VELOCITY = 0.6; // In normalized units per sec + const MIN_TIME_IN_ONE_DIRECTION = 0.25; // In seconds. + const MAX_TIME_IN_ONE_DIRECTION = 0.8; // In seconds. // Vector used for intermediate calculations - Added to avoid excessive creation of Vector3 instances - Ashraf - var nextPosition3DScratchVector = new Vector3( 0, 0, 0 ); + const nextPosition3DScratchVector = new Vector3( 0, 0, 0 ); /** * @param {Property} motionBoundsProperty * @constructor */ function RandomWalkMotionStrategy( motionBoundsProperty ) { - var self = this; + const self = this; MotionStrategy.call( self ); this.directionChangeCountdown = 0; // @private this.currentMotionVector2D = new Vector2( 0, 0 ); // @private @@ -76,7 +76,7 @@ define( require => { nextPosition3DScratchVector.x = currentPosition.x; nextPosition3DScratchVector.y = currentPosition.y; nextPosition3DScratchVector.z = 0; - var position3D = this.getNextPosition3D( nextPosition3DScratchVector, bounds, dt ); + const position3D = this.getNextPosition3D( nextPosition3DScratchVector, bounds, dt ); return new Vector2( position3D.x, position3D.y ); }, @@ -102,8 +102,8 @@ define( require => { if ( this.directionChangeCountdown <= 0 ) { // Time to change direction. - var newXYVelocity = MIN_XY_VELOCITY + phet.joist.random.nextDouble() * ( MAX_XY_VELOCITY - MIN_XY_VELOCITY ); - var newXYAngle = Math.PI * 2 * phet.joist.random.nextDouble(); + const newXYVelocity = MIN_XY_VELOCITY + phet.joist.random.nextDouble() * ( MAX_XY_VELOCITY - MIN_XY_VELOCITY ); + const newXYAngle = Math.PI * 2 * phet.joist.random.nextDouble(); this.currentMotionVector2D = Vector2.createPolar( newXYVelocity, newXYAngle ); this.currentZVelocity = MIN_Z_VELOCITY + phet.joist.random.nextDouble() * ( MAX_Z_VELOCITY - MIN_Z_VELOCITY ); this.currentZVelocity = phet.joist.random.nextBoolean() ? -this.currentZVelocity : this.currentZVelocity; @@ -124,7 +124,7 @@ define( require => { // To prevent odd-looking situations, the Z direction is limited so that biomolecules don't appear transparent // when on top of the DNA molecule. - var minZ = this.getMinZ( bounds, currentPosition ); + const minZ = this.getMinZ( bounds, currentPosition ); // Calculate the next position based on current motion. return new Vector3( diff --git a/js/common/model/motion-strategies/RibosomeTranslatingRnaMotionStrategy.js b/js/common/model/motion-strategies/RibosomeTranslatingRnaMotionStrategy.js index c457bbcc..dfcf954f 100644 --- a/js/common/model/motion-strategies/RibosomeTranslatingRnaMotionStrategy.js +++ b/js/common/model/motion-strategies/RibosomeTranslatingRnaMotionStrategy.js @@ -39,7 +39,7 @@ define( require => { * @public */ getNextPosition: function( currentPosition, bounds, dt ) { - var ribosomeAttachmentPoint = this.messengerRna.getRibosomeGenerateInitialPosition3D( this.ribosome ); + const ribosomeAttachmentPoint = this.messengerRna.getRibosomeGenerateInitialPosition3D( this.ribosome ); return ribosomeAttachmentPoint.minus( this.ribosome.offsetToTranslationChannelEntrance ); } } ); diff --git a/js/common/model/motion-strategies/WanderInGeneralDirectionMotionStrategy.js b/js/common/model/motion-strategies/WanderInGeneralDirectionMotionStrategy.js index 48ad78ec..5f919adb 100644 --- a/js/common/model/motion-strategies/WanderInGeneralDirectionMotionStrategy.js +++ b/js/common/model/motion-strategies/WanderInGeneralDirectionMotionStrategy.js @@ -18,10 +18,10 @@ define( require => { const Vector3 = require( 'DOT/Vector3' ); // constants - var MIN_VELOCITY = 100; // In picometers/s - var MAX_VELOCITY = 500; // In picometers/s - var MIN_TIME_IN_ONE_DIRECTION = 0.25; // In seconds. - var MAX_TIME_IN_ONE_DIRECTION = 1.25; // In seconds. + const MIN_VELOCITY = 100; // In picometers/s + const MAX_VELOCITY = 500; // In picometers/s + const MIN_TIME_IN_ONE_DIRECTION = 0.25; // In seconds. + const MAX_TIME_IN_ONE_DIRECTION = 1.25; // In seconds. /** * @param {Vector2} generalDirection @@ -29,7 +29,7 @@ define( require => { * @constructor */ function WanderInGeneralDirectionMotionStrategy( generalDirection, motionBoundsProperty ) { - var self = this; + const self = this; MotionStrategy.call( self ); this.directionChangeCountdown = 0; // @private this.currentMotionVector = new Vector2( 0, 0 ); // @private @@ -81,8 +81,8 @@ define( require => { if ( this.directionChangeCountdown <= 0 ) { // Time to change the direction. - var newVelocity = MIN_VELOCITY + phet.joist.random.nextDouble() * ( MAX_VELOCITY - MIN_VELOCITY ); - var varianceAngle = ( phet.joist.random.nextDouble() - 0.5 ) * Math.PI / 3; + const newVelocity = MIN_VELOCITY + phet.joist.random.nextDouble() * ( MAX_VELOCITY - MIN_VELOCITY ); + const varianceAngle = ( phet.joist.random.nextDouble() - 0.5 ) * Math.PI / 3; this.currentMotionVector = this.generalDirection.withMagnitude( newVelocity ).rotated( varianceAngle ); // Reset the countdown timer. @@ -113,7 +113,7 @@ define( require => { getNextPosition3D: function( currentPosition, bounds, dt ) { // The 3D version of this motion strategy doesn't move in the z direction. This may change some day. - var nextPosition2D = this.getNextPosition( new Vector2( currentPosition.x, currentPosition.y ), bounds, dt ); + const nextPosition2D = this.getNextPosition( new Vector2( currentPosition.x, currentPosition.y ), bounds, dt ); return new Vector3( nextPosition2D.x, nextPosition2D.y, currentPosition.z ); } } ); diff --git a/js/common/util/GradientUtil.js b/js/common/util/GradientUtil.js index 5f2167c1..dea062bb 100644 --- a/js/common/util/GradientUtil.js +++ b/js/common/util/GradientUtil.js @@ -15,7 +15,7 @@ define( require => { const geneExpressionEssentials = require( 'GENE_EXPRESSION_ESSENTIALS/geneExpressionEssentials' ); const LinearGradient = require( 'SCENERY/util/LinearGradient' ); - var GradientUtil = { + const GradientUtil = { /** * Create a gradient paint in order to give a molecule a little depth. This is public so that it can be used by other * nodes that need to depict biomolecules. @@ -24,9 +24,9 @@ define( require => { * @param {Color} baseColor */ createGradientPaint: function( shape, baseColor ) { - var paint; + let paint; if ( !GEEConstants.FLORESCENT_FILL_COLOR.equals( baseColor ) ) { - var shapeBounds = shape.bounds; + const shapeBounds = shape.bounds; paint = new LinearGradient( shapeBounds.getMinX(), shapeBounds.getCenterY(), shapeBounds.getMaxX(), diff --git a/js/common/view/BiomoleculeDragHandler.js b/js/common/view/BiomoleculeDragHandler.js index 32f61c32..ed01933a 100644 --- a/js/common/view/BiomoleculeDragHandler.js +++ b/js/common/view/BiomoleculeDragHandler.js @@ -22,7 +22,7 @@ define( require => { * @constructor */ function BiomoleculeDragHandler( biomolecule, modelViewTransform ) { - var self = this; + const self = this; SimpleDragHandler.call( self, { allowTouchSnag: true, @@ -32,7 +32,7 @@ define( require => { }, translate: function( translationParams ) { - var modelDelta = modelViewTransform.viewToModelDelta( translationParams.delta ); + const modelDelta = modelViewTransform.viewToModelDelta( translationParams.delta ); biomolecule.translate( modelDelta.x, modelDelta.y ); }, diff --git a/js/common/view/ControllerNode.js b/js/common/view/ControllerNode.js index 98409b05..c0fef752 100644 --- a/js/common/view/ControllerNode.js +++ b/js/common/view/ControllerNode.js @@ -38,8 +38,8 @@ define( require => { trackSize: new Dimension2( 100, 5 ) }, options ); - var range; - var passThroughController; + let range; + let passThroughController; if ( options.logScale ) { range = new Range( Math.log( minValue ) / Math.LN10, Math.log( maxValue ) / Math.LN10 ); passThroughController = new Property( Math.log( controller.get() ) / Math.LN10, { reentrant: true } ); @@ -70,13 +70,13 @@ define( require => { } } ); - var tickLabelOptions = { + const tickLabelOptions = { font: new PhetFont( 12 ), pickable: false, maxWidth: 50 }; - var slider = new HSlider( passThroughController, range, { + const slider = new HSlider( passThroughController, range, { trackSize: options.trackSize, thumbSize: new Dimension2( 15, 30 ), majorTickLength: 15, diff --git a/js/common/view/DnaMoleculeCanvasNode.js b/js/common/view/DnaMoleculeCanvasNode.js index 278d9eba..9d163f03 100644 --- a/js/common/view/DnaMoleculeCanvasNode.js +++ b/js/common/view/DnaMoleculeCanvasNode.js @@ -18,9 +18,9 @@ define( require => { const Vector2 = require( 'DOT/Vector2' ); // constants - var STRAND_1_COLOR = new Color( 31, 163, 223 ); - var STRAND_2_COLOR = new Color( 214, 87, 107 ); - var BASE_PAIR_COLOR = Color.DARK_GRAY.computeCSS(); + const STRAND_1_COLOR = new Color( 31, 163, 223 ); + const STRAND_2_COLOR = new Color( 214, 87, 107 ); + const BASE_PAIR_COLOR = Color.DARK_GRAY.computeCSS(); /** * @param {DnaMolecule} model @@ -39,8 +39,8 @@ define( require => { this.cp2ResuableVector = new Vector2( 0, 0 ); // @private - four arrays for the DNA backbone representation - var longerArrayLength = Util.roundSymmetric( this.model.strand1Segments.length / 2 ); - var shorterArrayLength = Math.floor( this.model.strand1Segments.length / 2 ); + const longerArrayLength = Util.roundSymmetric( this.model.strand1Segments.length / 2 ); + const shorterArrayLength = Math.floor( this.model.strand1Segments.length / 2 ); this.strand1ArrayBehind = new Array( shorterArrayLength ); this.strand2ArrayBehind = new Array( longerArrayLength ); this.strand1ArrayFront = new Array( longerArrayLength ); @@ -63,7 +63,7 @@ define( require => { */ drawBasePair: function( context, basePair ) { - var endOffset = basePair.width / 2; + const endOffset = basePair.width / 2; if ( basePair.topYLocation - basePair.bottomYLocation <= this.model.maxBasePairHeight ) { @@ -74,7 +74,7 @@ define( require => { else { // the strands are separated, draw two separate base pairs, one at the top and one at the bottom - var dividedBasePairHeight = this.model.maxBasePairHeight / 2; + const dividedBasePairHeight = this.model.maxBasePairHeight / 2; context.moveTo( basePair.x, basePair.topYLocation + endOffset ); context.lineTo( basePair.x, basePair.topYLocation - dividedBasePairHeight ); context.moveTo( basePair.x, basePair.bottomYLocation - endOffset ); @@ -95,13 +95,13 @@ define( require => { context.beginPath(); // allocate reusable vectors for optimal performance - var cp1 = this.cp1ResuableVector; - var cp2 = this.cp2ResuableVector; + let cp1 = this.cp1ResuableVector; + let cp2 = this.cp2ResuableVector; // loop, drawing each strand segment - for ( var i = 0; i < strandSegmentArray.length; i++ ) { - var strandSegment = strandSegmentArray[ i ]; - var strandSegmentLength = strandSegment.length; + for ( let i = 0; i < strandSegmentArray.length; i++ ) { + const strandSegment = strandSegmentArray[ i ]; + const strandSegmentLength = strandSegment.length; context.moveTo( strandSegment[ 0 ].x, strandSegment[ 0 ].y ); if ( strandSegmentLength === 1 || strandSegmentLength === 2 ) { @@ -118,11 +118,11 @@ define( require => { context.quadraticCurveTo( cp1.x, cp1.y, strandSegment[ 1 ].x, strandSegment[ 1 ].y ); // create the middle segments - for ( var j = 1; j < strandSegmentLength - 2; j++ ) { - var segmentStartPoint = strandSegment[ j ]; - var segmentEndPoint = strandSegment[ j + 1 ]; - var previousPoint = strandSegment[ j - 1 ]; - var nextPoint = strandSegment[ ( j + 2 ) ]; + for ( let j = 1; j < strandSegmentLength - 2; j++ ) { + const segmentStartPoint = strandSegment[ j ]; + const segmentEndPoint = strandSegment[ j + 1 ]; + const previousPoint = strandSegment[ j - 1 ]; + const nextPoint = strandSegment[ ( j + 2 ) ]; cp1 = ShapeUtils.extrapolateControlPoint( previousPoint, segmentStartPoint, segmentEndPoint, cp1 ); cp2 = ShapeUtils.extrapolateControlPoint( nextPoint, segmentEndPoint, segmentStartPoint, cp2 ); context.bezierCurveTo( cp1.x, cp1.y, cp2.x, cp2.y, segmentEndPoint.x, segmentEndPoint.y ); @@ -156,10 +156,10 @@ define( require => { // map the segments of the DNA in the model to the arrays used in rendering for ( var i = 0; i < this.model.strand1Segments.length; i++ ) { - var strand1Segment = this.model.strand1Segments[ i ]; - var strand2Segment = this.model.strand2Segments[ i ]; + const strand1Segment = this.model.strand1Segments[ i ]; + const strand2Segment = this.model.strand2Segments[ i ]; - var index = Math.floor( i / 2 ); + const index = Math.floor( i / 2 ); if ( i % 2 === 0 ) { this.strand2ArrayBehind[ index ] = strand2Segment; this.strand1ArrayFront[ index ] = strand1Segment; @@ -180,7 +180,7 @@ define( require => { context.beginPath(); context.strokeStyle = BASE_PAIR_COLOR; for ( i = 0; i < this.model.basePairs.length; i++ ) { - var basePair = this.model.basePairs[ i ]; + const basePair = this.model.basePairs[ i ]; this.drawBasePair( context, basePair ); } context.stroke(); diff --git a/js/common/view/DnaMoleculeNode.js b/js/common/view/DnaMoleculeNode.js index 40e91947..fe8002ea 100644 --- a/js/common/view/DnaMoleculeNode.js +++ b/js/common/view/DnaMoleculeNode.js @@ -34,7 +34,7 @@ define( require => { Node.call( this ); // Add the layers onto which the various nodes that represent parts of the dna, the hints, etc. are placed. - var geneBackgroundLayer = new Node(); + const geneBackgroundLayer = new Node(); this.addChild( geneBackgroundLayer ); // Layers for supporting the 3D look by allowing the "twist" to be depicted. @@ -51,7 +51,7 @@ define( require => { this.addChild( this.dnaBackboneLayer ); // Put the gene backgrounds and labels behind everything. - for ( var i = 0; i < dnaMolecule.getGenes().length; i++ ) { + for ( let i = 0; i < dnaMolecule.getGenes().length; i++ ) { geneBackgroundLayer.addChild( new GeneNode( modelViewTransform, dnaMolecule.getGenes()[ i ], diff --git a/js/common/view/FadeLabel.js b/js/common/view/FadeLabel.js index 17dc7a4a..c64df364 100644 --- a/js/common/view/FadeLabel.js +++ b/js/common/view/FadeLabel.js @@ -19,8 +19,8 @@ define( require => { const Text = require( 'SCENERY/nodes/Text' ); // constants - var FONT = new PhetFont( 14 ); - var TIMER_DELAY = 100; // In milliseconds. + const FONT = new PhetFont( 14 ); + const TIMER_DELAY = 100; // In milliseconds. /** * @@ -30,12 +30,12 @@ define( require => { * @constructor */ function FadeLabel( text, initiallyVisible, existenceStrengthProperty ) { - var self = this; + const self = this; Node.call( self, { pickable: false } ); this.fadeDelta = 0; // @private - var opacity = 0; + let opacity = 0; - var label = new Text( text, { font: FONT, maxWidth: 80 } ); + const label = new Text( text, { font: FONT, maxWidth: 80 } ); this.addChild( label ); if ( !initiallyVisible ) { diff --git a/js/common/view/FadeTimer.js b/js/common/view/FadeTimer.js index bdc18a17..87807b6e 100644 --- a/js/common/view/FadeTimer.js +++ b/js/common/view/FadeTimer.js @@ -38,7 +38,7 @@ define( require => { * @public */ start: function() { - var self = this; + const self = this; if ( !this.isRunningProperty.get() ) { self._intervalId = timer.setInterval( function() { self.listener(); diff --git a/js/common/view/GeneNode.js b/js/common/view/GeneNode.js index ce36a31f..9ca56e55 100644 --- a/js/common/view/GeneNode.js +++ b/js/common/view/GeneNode.js @@ -28,10 +28,10 @@ define( require => { const transcribedRegionString = require( 'string!GENE_EXPRESSION_ESSENTIALS/transcribedRegion' ); // constants - var REGION_LABEL_FONT = new PhetFont( { size: 12, weight: 'bold' } ); - var GENE_LABEL_FONT = new PhetFont( { size: 18, weight: 'bold' } ); - var BRACKET_DEPTH = 30; - var RECT_ROUNDING = 15; + const REGION_LABEL_FONT = new PhetFont( { size: 12, weight: 'bold' } ); + const GENE_LABEL_FONT = new PhetFont( { size: 18, weight: 'bold' } ); + const BRACKET_DEPTH = 30; + const RECT_ROUNDING = 15; /** * @param {ModelViewTransform2} modelViewTransform @@ -44,22 +44,22 @@ define( require => { function GeneNode( modelViewTransform, gene, dnaMolecule, label, showBracketLabel ) { Node.call( this ); - var highlightHeight = -modelViewTransform.modelToViewDeltaY( GEEConstants.DNA_MOLECULE_DIAMETER * 1.5 ); - var highlightStartY = modelViewTransform.modelToViewY( dnaMolecule.getLeftEdgePosition().y ) - highlightHeight / 2; + const highlightHeight = -modelViewTransform.modelToViewDeltaY( GEEConstants.DNA_MOLECULE_DIAMETER * 1.5 ); + const highlightStartY = modelViewTransform.modelToViewY( dnaMolecule.getLeftEdgePosition().y ) - highlightHeight / 2; // Add the highlight for the regulatory region. - var regRegionHighlightStartX = modelViewTransform.modelToViewX( + const regRegionHighlightStartX = modelViewTransform.modelToViewX( dnaMolecule.getBasePairXOffsetByIndex( gene.getRegulatoryRegion().min ) ); - var regRegionWidth = modelViewTransform.modelToViewX( + const regRegionWidth = modelViewTransform.modelToViewX( dnaMolecule.getBasePairXOffsetByIndex( gene.getRegulatoryRegion().max ) ) - regRegionHighlightStartX; - var regRegionShape = Shape.roundRect( regRegionHighlightStartX, highlightStartY, regRegionWidth, highlightHeight, + const regRegionShape = Shape.roundRect( regRegionHighlightStartX, highlightStartY, regRegionWidth, highlightHeight, RECT_ROUNDING, RECT_ROUNDING ); - var regulatoryRegionNode = new Path( regRegionShape, { fill: gene.getRegulatoryRegionColor() } ); + const regulatoryRegionNode = new Path( regRegionShape, { fill: gene.getRegulatoryRegionColor() } ); this.addChild( regulatoryRegionNode ); - var regulatoryRegionCaption = new RichText( regulatoryRegionString, { + const regulatoryRegionCaption = new RichText( regulatoryRegionString, { font: REGION_LABEL_FONT, maxWidth: 100, align: 'center', @@ -69,19 +69,19 @@ define( require => { this.addChild( regulatoryRegionCaption ); // Add the highlight for the transcribed region. - var transcribedRegionHighlightStartX = modelViewTransform.modelToViewX( + const transcribedRegionHighlightStartX = modelViewTransform.modelToViewX( dnaMolecule.getBasePairXOffsetByIndex( gene.getTranscribedRegion().min ) ); - var transcribedRegionWidth = modelViewTransform.modelToViewX( + const transcribedRegionWidth = modelViewTransform.modelToViewX( dnaMolecule.getBasePairXOffsetByIndex( gene.getTranscribedRegion().max ) ) - transcribedRegionHighlightStartX; - var transcribedRegionShape = Shape.roundRect( transcribedRegionHighlightStartX, highlightStartY, + const transcribedRegionShape = Shape.roundRect( transcribedRegionHighlightStartX, highlightStartY, transcribedRegionWidth, highlightHeight, RECT_ROUNDING, RECT_ROUNDING ); - var transcribedRegionNode = new Path( transcribedRegionShape, { fill: gene.getTranscribedRegionColor() } ); + const transcribedRegionNode = new Path( transcribedRegionShape, { fill: gene.getTranscribedRegionColor() } ); this.addChild( transcribedRegionNode ); - var transcribedRegionCaption = new RichText( transcribedRegionString, { + const transcribedRegionCaption = new RichText( transcribedRegionString, { font: REGION_LABEL_FONT, maxWidth: 100, align: 'center', @@ -92,7 +92,7 @@ define( require => { // Add the bracket. This is a portion (the non-textual part) of the label for the gene. if ( showBracketLabel ) { - var bracketPath = new Shape(); + const bracketPath = new Shape(); bracketPath.moveTo( regulatoryRegionNode.bounds.getMinX(), regulatoryRegionCaption.bounds.getMaxY() ); bracketPath.lineToRelative( BRACKET_DEPTH, BRACKET_DEPTH ); bracketPath.lineTo( @@ -103,12 +103,12 @@ define( require => { this.addChild( new Path( bracketPath, { lineWidth: 2, stroke: Color.BLACK } ) ); // And the textual label for the gene. - var labelText = new Text( label, { + const labelText = new Text( label, { font: GENE_LABEL_FONT, maxWidth: 150 } ); this.addChild( labelText ); - var bracketBounds = bracketPath.bounds; + const bracketBounds = bracketPath.bounds; labelText.x = bracketBounds.getCenterX() - labelText.bounds.width / 2; labelText.y = bracketBounds.getMaxY() + 20; } diff --git a/js/common/view/MessengerRnaNode.js b/js/common/view/MessengerRnaNode.js index 7a066d19..191fb86a 100644 --- a/js/common/view/MessengerRnaNode.js +++ b/js/common/view/MessengerRnaNode.js @@ -34,18 +34,18 @@ define( require => { function MessengerRnaNode( modelViewTransform, messengerRna ) { MobileBiomoleculeNode.call( this, modelViewTransform, messengerRna, { lineWidth: 2 } ); - var self = this; + const self = this; // Add placement hints that show where ribosomes and mRNA destroyers can be attached. Placement hint node, like // other mobile biomolecule nodes, are designed to position themselves, but we don't want that to happen here since // they are child nodes, so a compensated model-view transform is needed. - var scaleOnlyTransform = ModelViewTransform2.createSinglePointScaleInvertedYMapping( + const scaleOnlyTransform = ModelViewTransform2.createSinglePointScaleInvertedYMapping( Vector2.ZERO, Vector2.ZERO, modelViewTransform.getMatrix().getScaleVector().x ); - var ribosomePlacementHintNode = new PlacementHintNode( scaleOnlyTransform, messengerRna.ribosomePlacementHint ); - var mRnaDestroyerPlacementHintNode = new PlacementHintNode( + const ribosomePlacementHintNode = new PlacementHintNode( scaleOnlyTransform, messengerRna.ribosomePlacementHint ); + const mRnaDestroyerPlacementHintNode = new PlacementHintNode( scaleOnlyTransform, messengerRna.mRnaDestroyerPlacementHint ); @@ -53,7 +53,7 @@ define( require => { this.addChild( mRnaDestroyerPlacementHintNode ); // Add the label. This fades in during synthesis, then fades out. - var label = new FadeLabel( quotedMRnaString, false, messengerRna.existenceStrengthProperty ); + const label = new FadeLabel( quotedMRnaString, false, messengerRna.existenceStrengthProperty ); this.addChild( label ); // handler function for changes to the "being synthesized" state @@ -79,9 +79,9 @@ define( require => { // handler for shape changes function handleShapeChanged( shape ) { - var shapeBounds = shape.bounds; + const shapeBounds = shape.bounds; if ( shapeBounds.isFinite() ) { - var scaledShapeBounds = self.scaleOnlyModelViewTransform.modelToViewShape( shapeBounds ); + const scaledShapeBounds = self.scaleOnlyModelViewTransform.modelToViewShape( shapeBounds ); rect && rect.setRectBounds( scaledShapeBounds ); // position the label diff --git a/js/common/view/MobileBiomoleculeNode.js b/js/common/view/MobileBiomoleculeNode.js index 98ed8858..a18911ec 100644 --- a/js/common/view/MobileBiomoleculeNode.js +++ b/js/common/view/MobileBiomoleculeNode.js @@ -31,7 +31,7 @@ define( require => { * @constructor */ function MobileBiomoleculeNode( modelViewTransform, mobileBiomolecule, options ) { - var self = this; + const self = this; Node.call( self, { cursor: 'pointer' } ); options = _.extend( { lineWidth: 1 @@ -58,7 +58,7 @@ define( require => { // update the shape self.shapeNode.shape = null; - var transformedShape = self.scaleOnlyModelViewTransform.modelToViewShape( shape ); + const transformedShape = self.scaleOnlyModelViewTransform.modelToViewShape( shape ); self.shapeNode.setShape( transformedShape ); self.mouseArea = transformedShape.bounds.dilated( 2 ); self.touchArea = transformedShape.bounds.dilated( 5 ); @@ -116,7 +116,7 @@ define( require => { mobileBiomolecule.attachedToDnaProperty.link( handleAttachedToDnaChanged ); // drag handling - var dragHandler = new BiomoleculeDragHandler( mobileBiomolecule, modelViewTransform ); + const dragHandler = new BiomoleculeDragHandler( mobileBiomolecule, modelViewTransform ); this.addInputListener( dragHandler ); function handleMovableByUserChanged( movableByUser ) { diff --git a/js/common/view/PlacementHintNode.js b/js/common/view/PlacementHintNode.js index 1bb26c4d..ffd8292b 100644 --- a/js/common/view/PlacementHintNode.js +++ b/js/common/view/PlacementHintNode.js @@ -22,8 +22,8 @@ define( require => { const Vector2 = require( 'DOT/Vector2' ); // constants - var HINT_STROKE_COLOR = new Color( 0, 0, 0, 100 ); // Somewhat transparent stroke. - var HINT_STROKE = { lineJoin: 'bevel', lineDash: [ 5, 5 ], stroke: HINT_STROKE_COLOR }; + const HINT_STROKE_COLOR = new Color( 0, 0, 0, 100 ); // Somewhat transparent stroke. + const HINT_STROKE = { lineJoin: 'bevel', lineDash: [ 5, 5 ], stroke: HINT_STROKE_COLOR }; /** * @@ -33,11 +33,11 @@ define( require => { */ function PlacementHintNode( modelViewTransform, placementHint ) { - var self = this; + const self = this; Node.call( this ); // Create a transparent color based on the base color of the molecule. - var transparentColor = new Color( + const transparentColor = new Color( placementHint.getBaseColor().getRed(), placementHint.getBaseColor().getGreen(), placementHint.getBaseColor().getBlue(), @@ -45,20 +45,20 @@ define( require => { ); // create a transform that will be used to scale but not translate the placement hint's shape - var scaleOnlyTransform = ModelViewTransform2.createSinglePointScaleInvertedYMapping( + const scaleOnlyTransform = ModelViewTransform2.createSinglePointScaleInvertedYMapping( Vector2.ZERO, Vector2.ZERO, modelViewTransform.getMatrix().getScaleVector().x ); - var pathStyleOptions = _.extend( HINT_STROKE, { + const pathStyleOptions = _.extend( HINT_STROKE, { lineWidth: 2, lineDash: [ 5, 5 ], fill: transparentColor, boundsMethod: 'unstroked' } ); - var path = new Path( new Shape(), pathStyleOptions ); + const path = new Path( new Shape(), pathStyleOptions ); this.addChild( path ); function handlePositionChanged( position ) { diff --git a/js/gene-expression-essentials-main.js b/js/gene-expression-essentials-main.js index ebf54cb9..95ec123d 100644 --- a/js/gene-expression-essentials-main.js +++ b/js/gene-expression-essentials-main.js @@ -18,7 +18,7 @@ define( require => { // strings const geneExpressionEssentialsTitleString = require( 'string!GENE_EXPRESSION_ESSENTIALS/gene-expression-essentials.title' ); - var simOptions = { + const simOptions = { credits: { leadDesign: 'Steele Dalton, John Blanco', softwareDevelopment: 'John Blanco, Aadish Gupta, Sharfudeen Ashraf, George Emanuel', @@ -29,7 +29,7 @@ define( require => { // we are go for launch SimLauncher.launch( function() { - var sim = new Sim( geneExpressionEssentialsTitleString, + const sim = new Sim( geneExpressionEssentialsTitleString, [ new ManualGeneExpressionScreen(), new MessengerRnaProductionScreen(), diff --git a/js/manual-gene-expression/ManualGeneExpressionScreen.js b/js/manual-gene-expression/ManualGeneExpressionScreen.js index d22bf9c4..b0ce80af 100644 --- a/js/manual-gene-expression/ManualGeneExpressionScreen.js +++ b/js/manual-gene-expression/ManualGeneExpressionScreen.js @@ -31,7 +31,7 @@ define( require => { */ function ManualGeneExpressionScreen() { - var options = { + const options = { name: screenExpressionString, backgroundColorProperty: new Property( '#ABCBDB' ), homeScreenIcon: new Image( manualGeneExpressionIcon ), diff --git a/js/manual-gene-expression/model/GeneB.js b/js/manual-gene-expression/model/GeneB.js index 46af27ff..12820e2d 100644 --- a/js/manual-gene-expression/model/GeneB.js +++ b/js/manual-gene-expression/model/GeneB.js @@ -20,11 +20,11 @@ define( require => { const TranscriptionFactor = require( 'GENE_EXPRESSION_ESSENTIALS/common/model/TranscriptionFactor' ); // constants - var REGULATORY_REGION_COLOR = new Color( 216, 191, 216 ); - var TRANSCRIBED_REGION_COLOR = new Color( 240, 246, 143, 150 ); - var NUM_BASE_PAIRS_IN_REGULATORY_REGION = 28; - var NUM_BASE_PAIRS_IN_TRANSCRIBED_REGION = 150; - var MRNA_WINDING_ALGORITHM_NUMBER = 4; + const REGULATORY_REGION_COLOR = new Color( 216, 191, 216 ); + const TRANSCRIBED_REGION_COLOR = new Color( 240, 246, 143, 150 ); + const NUM_BASE_PAIRS_IN_REGULATORY_REGION = 28; + const NUM_BASE_PAIRS_IN_TRANSCRIBED_REGION = 150; + const MRNA_WINDING_ALGORITHM_NUMBER = 4; /** * @param {DnaMolecule} dnaMolecule - The DNA molecule within which this gene exists diff --git a/js/manual-gene-expression/model/GeneC.js b/js/manual-gene-expression/model/GeneC.js index 87e5fd74..db1f98ed 100644 --- a/js/manual-gene-expression/model/GeneC.js +++ b/js/manual-gene-expression/model/GeneC.js @@ -20,12 +20,12 @@ define( require => { const TranscriptionFactor = require( 'GENE_EXPRESSION_ESSENTIALS/common/model/TranscriptionFactor' ); // constants - var REGULATORY_REGION_COLOR = new Color( 216, 191, 216 ); - var TRANSCRIBED_REGION_COLOR = new Color( 205, 255, 112, 150 ); - var NUM_BASE_PAIRS_IN_REGULATORY_REGION = 28; - var NUM_BASE_PAIRS_IN_TRANSCRIBED_REGION = 200; - var NUM_BASE_PAIRS = NUM_BASE_PAIRS_IN_REGULATORY_REGION + NUM_BASE_PAIRS_IN_TRANSCRIBED_REGION; - var MRNA_WINDING_ALGORITHM_NUMBER = 4; + const REGULATORY_REGION_COLOR = new Color( 216, 191, 216 ); + const TRANSCRIBED_REGION_COLOR = new Color( 205, 255, 112, 150 ); + const NUM_BASE_PAIRS_IN_REGULATORY_REGION = 28; + const NUM_BASE_PAIRS_IN_TRANSCRIBED_REGION = 200; + const NUM_BASE_PAIRS = NUM_BASE_PAIRS_IN_REGULATORY_REGION + NUM_BASE_PAIRS_IN_TRANSCRIBED_REGION; + const MRNA_WINDING_ALGORITHM_NUMBER = 4; /** * @param {DnaMolecule} dnaMolecule - The DNA molecule within which this gene exists diff --git a/js/manual-gene-expression/model/ManualGeneExpressionModel.js b/js/manual-gene-expression/model/ManualGeneExpressionModel.js index 5e282b5d..d4730899 100644 --- a/js/manual-gene-expression/model/ManualGeneExpressionModel.js +++ b/js/manual-gene-expression/model/ManualGeneExpressionModel.js @@ -37,11 +37,11 @@ define( require => { // constants // Stage size for the mobile biomolecules, which is basically the area in which the molecules can move. These are // empirically determined such that the molecules don't move off of the screen when looking at a given gene. - var BIOMOLECULE_STAGE_WIDTH = 10000; // In picometers. - var BIOMOLECULE_STAGE_HEIGHT = 6000; // In picometers. + const BIOMOLECULE_STAGE_WIDTH = 10000; // In picometers. + const BIOMOLECULE_STAGE_HEIGHT = 6000; // In picometers. // size of the DNA strand - var NUM_BASE_PAIRS_ON_DNA_STRAND = 2000; + const NUM_BASE_PAIRS_ON_DNA_STRAND = 2000; /** * @constructor @@ -163,8 +163,8 @@ define( require => { * @private */ switchToGeneRelative: function( i ) { - var genes = this.dnaMolecule.getGenes(); - var index = Util.clamp( 0, genes.indexOf( this.activeGeneProperty.get() ) + i, genes.length - 1 ); + const genes = this.dnaMolecule.getGenes(); + const index = Util.clamp( 0, genes.indexOf( this.activeGeneProperty.get() ) + i, genes.length - 1 ); this.activeGeneProperty.set( genes[ index ] ); }, @@ -182,7 +182,7 @@ define( require => { * @public */ addMobileBiomolecule: function( mobileBiomolecule ) { - var self = this; + const self = this; self.mobileBiomoleculeList.add( mobileBiomolecule ); mobileBiomolecule.setMotionBounds( self.getBoundsForActiveGene() ); @@ -234,7 +234,7 @@ define( require => { */ getOverlappingBiomolecules: function( testShapeBounds ) { - var overlappingBiomolecules = []; + const overlappingBiomolecules = []; this.mobileBiomoleculeList.forEach( function( mobileBiomolecule ) { if ( mobileBiomolecule.bounds.intersectsBounds( testShapeBounds ) ) { @@ -272,7 +272,7 @@ define( require => { * @public */ getProteinCount: function( proteinClassType ) { - var count = 0; + let count = 0; this.mobileBiomoleculeList.forEach( function( mobileBiomolecule ) { if ( mobileBiomolecule instanceof proteinClassType ) { count++; @@ -337,9 +337,9 @@ define( require => { * @public */ addOffLimitsMotionSpace: function( newOffLimitsSpace ) { - for ( var i = 0; i < this.offLimitsMotionSpaces.length; i++ ) { + for ( let i = 0; i < this.offLimitsMotionSpaces.length; i++ ) { - var offLimitsMotionSpace = this.offLimitsMotionSpaces[ i ]; + const offLimitsMotionSpace = this.offLimitsMotionSpaces[ i ]; if ( offLimitsMotionSpace.equals( newOffLimitsSpace ) ) { // An equivalent space already exists, so don't bother adding this one. return; @@ -357,15 +357,15 @@ define( require => { getBoundsForActiveGene: function() { // The bottom bounds are intended to be roughly at the bottom of the viewport. The value was empirically determined. - var bottomYPos = GEEConstants.DNA_MOLECULE_Y_POS - 2100; + const bottomYPos = GEEConstants.DNA_MOLECULE_Y_POS - 2100; // Get the nominal bounds for this gene. - var bounds = new Bounds2( this.activeGeneProperty.get().getCenterX() - BIOMOLECULE_STAGE_WIDTH / 2, + const bounds = new Bounds2( this.activeGeneProperty.get().getCenterX() - BIOMOLECULE_STAGE_WIDTH / 2, bottomYPos, this.activeGeneProperty.get().getCenterX() - BIOMOLECULE_STAGE_WIDTH / 2 + BIOMOLECULE_STAGE_WIDTH, bottomYPos + BIOMOLECULE_STAGE_HEIGHT ); - var motionBounds = new MotionBounds( bounds ); + const motionBounds = new MotionBounds( bounds ); // Subtract off any off limits areas. this.offLimitsMotionSpaces.forEach( function( offLimitMotionSpace ) { if ( bounds.intersectsBounds( offLimitMotionSpace ) ) { diff --git a/js/manual-gene-expression/model/ProteinA.js b/js/manual-gene-expression/model/ProteinA.js index 3220fc03..bee3170d 100644 --- a/js/manual-gene-expression/model/ProteinA.js +++ b/js/manual-gene-expression/model/ProteinA.js @@ -21,8 +21,8 @@ define( require => { const Vector2 = require( 'DOT/Vector2' ); // constants - var BASE_COLOR = new Color( 255, 99, 71 ); - var FULL_GROWN_WIDTH = 450; + const BASE_COLOR = new Color( 255, 99, 71 ); + const FULL_GROWN_WIDTH = 450; /** * @param {GeneExpressionModel} model @@ -94,8 +94,8 @@ define( require => { * @private */ createShape: function( growthFactor ) { - var currentWidth = Util.clamp( growthFactor, 0.01, 1 ) * FULL_GROWN_WIDTH; - var shape = new Shape(); + const currentWidth = Util.clamp( growthFactor, 0.01, 1 ) * FULL_GROWN_WIDTH; + const shape = new Shape(); shape.moveTo( -currentWidth / 2, 0 ); shape.lineTo( 0, -currentWidth / 2 ); shape.lineTo( currentWidth / 2, 0 ); diff --git a/js/manual-gene-expression/model/ProteinB.js b/js/manual-gene-expression/model/ProteinB.js index 5f182a55..30e4b4e0 100644 --- a/js/manual-gene-expression/model/ProteinB.js +++ b/js/manual-gene-expression/model/ProteinB.js @@ -21,8 +21,8 @@ define( require => { const Vector2 = require( 'DOT/Vector2' ); // constants - var BASE_COLOR = new Color( 255, 99, 71 ); - var FULL_GROWN_WIDTH = 450; + const BASE_COLOR = new Color( 255, 99, 71 ); + const FULL_GROWN_WIDTH = 450; /** * @param {GeneExpressionModel} model @@ -93,11 +93,11 @@ define( require => { * @private */ createShape: function( growthFactor ) { - var currentWidth = Util.clamp( growthFactor, 0.01, 1 ) * FULL_GROWN_WIDTH; - var path = new Shape(); - var vector = new Vector2( -currentWidth / 2, 0 ); + const currentWidth = Util.clamp( growthFactor, 0.01, 1 ) * FULL_GROWN_WIDTH; + const path = new Shape(); + const vector = new Vector2( -currentWidth / 2, 0 ); path.moveTo( vector.x, vector.y ); - for ( var i = 0; i < 6; i++ ) { + for ( let i = 0; i < 6; i++ ) { vector.rotate( Math.PI / 3 ); path.lineTo( vector.x, vector.y ); } diff --git a/js/manual-gene-expression/model/ProteinC.js b/js/manual-gene-expression/model/ProteinC.js index f4bc51a3..1be10fa8 100644 --- a/js/manual-gene-expression/model/ProteinC.js +++ b/js/manual-gene-expression/model/ProteinC.js @@ -21,8 +21,8 @@ define( require => { const Vector2 = require( 'DOT/Vector2' ); // constants - var BASE_COLOR = new Color( 57, 255, 20 ); - var FULL_GROWN_WIDTH = 320; + const BASE_COLOR = new Color( 57, 255, 20 ); + const FULL_GROWN_WIDTH = 320; /** * @param {GeneExpressionModel} model @@ -92,11 +92,11 @@ define( require => { * @private */ createShape: function( growthFactor ) { - var currentWidth = Util.clamp( growthFactor, 0.01, 1 ) * FULL_GROWN_WIDTH; - var currentHeight = currentWidth * 1.4; - var path = new Shape(); - var topAndBottomCurveMultiplier = 0.55; - var sideCurvesMultiplier = 0.40; + const currentWidth = Util.clamp( growthFactor, 0.01, 1 ) * FULL_GROWN_WIDTH; + const currentHeight = currentWidth * 1.4; + const path = new Shape(); + const topAndBottomCurveMultiplier = 0.55; + const sideCurvesMultiplier = 0.40; // Start in the upper left and proceed clockwise in adding segments. path.moveTo( -currentWidth * 0.45, currentHeight * 0.45 ); path.cubicCurveTo( -currentWidth * 0.33, currentHeight * topAndBottomCurveMultiplier, currentWidth * 0.3, currentHeight * topAndBottomCurveMultiplier, currentWidth * 0.45, currentHeight * 0.45 ); diff --git a/js/manual-gene-expression/view/BiomoleculeCreatorNode.js b/js/manual-gene-expression/view/BiomoleculeCreatorNode.js index cff206a8..74bc9938 100644 --- a/js/manual-gene-expression/view/BiomoleculeCreatorNode.js +++ b/js/manual-gene-expression/view/BiomoleculeCreatorNode.js @@ -32,7 +32,7 @@ define( require => { * @constructor */ function BiomoleculeCreatorNode( appearanceNode, canvas, modelViewTransform, moleculeCreator, moleculeDestroyer, enclosingToolboxNode ) { - var self = this; + const self = this; Node.call( self, { cursor: 'pointer' } ); this.canvas = canvas; // @private this.modelViewTransform = modelViewTransform; // @private @@ -57,14 +57,14 @@ define( require => { self.appearanceNode.opacity = 0.3; // Convert the canvas position to the corresponding location in the model. - var modelPos = self.getModelPosition( event.pointer.point ); + const modelPos = self.getModelPosition( event.pointer.point ); // Create the corresponding biomolecule and add it to the model. self.biomolecule = moleculeCreator( modelPos ); self.biomolecule.userControlledProperty.set( true ); // Add an observer to watch for this model element to be returned. - var finalBiomolecule = self.biomolecule; + const finalBiomolecule = self.biomolecule; var userControlledPropertyObserver = function( userControlled ) { if ( !userControlled ) { // The user has released this biomolecule. If it was dropped above the return bounds (which are generally @@ -119,8 +119,8 @@ define( require => { * @private */ getModelPosition: function( point ) { - var canvasPosition = this.canvas.globalToLocalPoint( point ); - var adjustedCanvasPos = canvasPosition.minus( this.canvas.viewPortOffset ); + const canvasPosition = this.canvas.globalToLocalPoint( point ); + const adjustedCanvasPos = canvasPosition.minus( this.canvas.viewPortOffset ); return this.modelViewTransform.viewToModelPosition( adjustedCanvasPos ); } } ); diff --git a/js/manual-gene-expression/view/BiomoleculeToolboxNode.js b/js/manual-gene-expression/view/BiomoleculeToolboxNode.js index 68b25d22..19eb561b 100644 --- a/js/manual-gene-expression/view/BiomoleculeToolboxNode.js +++ b/js/manual-gene-expression/view/BiomoleculeToolboxNode.js @@ -30,7 +30,7 @@ define( require => { const VBox = require( 'SCENERY/nodes/VBox' ); // constants - var TITLE_FONT = new PhetFont( { size: 20, weight: 'bold' } ); + const TITLE_FONT = new PhetFont( { size: 20, weight: 'bold' } ); // strings const biomoleculeToolboxString = require( 'string!GENE_EXPRESSION_ESSENTIALS/biomoleculeToolbox' ); @@ -60,30 +60,30 @@ define( require => { */ function BiomoleculeToolboxNode( model, canvas, modelViewTransform, gene ) { - var self = this; + const self = this; this.model = model; //@private this.canvas = canvas; //@private this.modelViewTransform = modelViewTransform; //@private this.biomoleculeCreatorNodeList = []; // Add the title. - var toolboxTitleNode = new Text( biomoleculeToolboxString, { + const toolboxTitleNode = new Text( biomoleculeToolboxString, { font: TITLE_FONT, maxWidth: 200 } ); - var positiveTranscriptionFactorLabel = new RowLabel( positiveTranscriptionFactorHtmlString ); - var positiveTranscriptionFactorLabelWidth = positiveTranscriptionFactorLabel.width; - var rnaPolymeraseLabel = new RowLabel( rnaPolymeraseString ); - var rnaPolymeraseLabelWidth = rnaPolymeraseLabel.width; - var ribosomeLabel = new RowLabel( ribosomeString ); - var ribosomeLabelWidth = ribosomeLabel.width; - var mrnaDestroyerLabel = new RowLabel( mrnaDestroyerString ); - var mrnaDestroyerLabelWidth = mrnaDestroyerLabel.width; - var negativeTranscriptionFactorLabel = new RowLabel( negativeTranscriptionFactorHtmlString ); - var negativeTranscriptionFactorLabelWidth = negativeTranscriptionFactorLabel.width; - - var maxWidth = _.max( [ + const positiveTranscriptionFactorLabel = new RowLabel( positiveTranscriptionFactorHtmlString ); + const positiveTranscriptionFactorLabelWidth = positiveTranscriptionFactorLabel.width; + const rnaPolymeraseLabel = new RowLabel( rnaPolymeraseString ); + const rnaPolymeraseLabelWidth = rnaPolymeraseLabel.width; + const ribosomeLabel = new RowLabel( ribosomeString ); + const ribosomeLabelWidth = ribosomeLabel.width; + const mrnaDestroyerLabel = new RowLabel( mrnaDestroyerString ); + const mrnaDestroyerLabelWidth = mrnaDestroyerLabel.width; + const negativeTranscriptionFactorLabel = new RowLabel( negativeTranscriptionFactorHtmlString ); + const negativeTranscriptionFactorLabelWidth = negativeTranscriptionFactorLabel.width; + + const maxWidth = _.max( [ positiveTranscriptionFactorLabelWidth, rnaPolymeraseLabelWidth, ribosomeLabelWidth, @@ -92,13 +92,13 @@ define( require => { ] ); // Transcription factor(s). - var transcriptionFactors = gene.getTranscriptionFactorConfigs(); - var positiveTranscriptBoxNodes = []; - var negativeTranscriptBoxNodes = []; + const transcriptionFactors = gene.getTranscriptionFactorConfigs(); + const positiveTranscriptBoxNodes = []; + const negativeTranscriptBoxNodes = []; transcriptionFactors.forEach( function( tfConfig ) { - var creatorNode = self.addCreatorNode( new TranscriptionFactorCreatorNode( self, tfConfig ) ); + const creatorNode = self.addCreatorNode( new TranscriptionFactorCreatorNode( self, tfConfig ) ); if ( tfConfig.isPositive ) { - var positiveTranscriptionBox = new HBox( { + const positiveTranscriptionBox = new HBox( { children: [ positiveTranscriptionFactorLabel, new Spacer( maxWidth - positiveTranscriptionFactorLabelWidth, 0 ), @@ -109,7 +109,7 @@ define( require => { positiveTranscriptBoxNodes.push( positiveTranscriptionBox ); } else { - var negativeTranscriptionBox = new HBox( { + const negativeTranscriptionBox = new HBox( { children: [ negativeTranscriptionFactorLabel, new Spacer( maxWidth - negativeTranscriptionFactorLabelWidth, 0 ), @@ -122,7 +122,7 @@ define( require => { } ); // Polymerase. - var polymeraseBox = new HBox( { + const polymeraseBox = new HBox( { children: [ rnaPolymeraseLabel, new Spacer( maxWidth - rnaPolymeraseLabelWidth, 0 ), @@ -133,7 +133,7 @@ define( require => { } ); // Ribosomes. - var ribosomeBox = new HBox( { + const ribosomeBox = new HBox( { children: [ ribosomeLabel, new Spacer( maxWidth - ribosomeLabelWidth, 0 ), @@ -144,7 +144,7 @@ define( require => { } ); // mRNA destroyer. - var mRnaDestroyerBox = new HBox( { + const mRnaDestroyerBox = new HBox( { children: [ mrnaDestroyerLabel, new Spacer( maxWidth - mrnaDestroyerLabelWidth, 0 ), @@ -154,16 +154,16 @@ define( require => { spacing: 10 } ); - var childrenNodesArray = []; + let childrenNodesArray = []; childrenNodesArray = childrenNodesArray.concat( positiveTranscriptBoxNodes ); childrenNodesArray.push( polymeraseBox ); childrenNodesArray.push( ribosomeBox ); childrenNodesArray.push( mRnaDestroyerBox ); childrenNodesArray = childrenNodesArray.concat( negativeTranscriptBoxNodes ); // Create the content of this control panel. - var contentNode = new Node(); + const contentNode = new Node(); contentNode.addChild( toolboxTitleNode ); - var childrenNode = new VBox( { + const childrenNode = new VBox( { children: childrenNodesArray, spacing: 10, align: 'left' @@ -191,8 +191,8 @@ define( require => { * @public reset the toolbox */ reset: function() { - var bioMoleculeCreatorNodeLength = this.biomoleculeCreatorNodeList.length; - for ( var i = 0; i < bioMoleculeCreatorNodeLength; i++ ) { + const bioMoleculeCreatorNodeLength = this.biomoleculeCreatorNodeList.length; + for ( let i = 0; i < bioMoleculeCreatorNodeLength; i++ ) { this.biomoleculeCreatorNodeList[ i ].reset(); } }, diff --git a/js/manual-gene-expression/view/FlashController.js b/js/manual-gene-expression/view/FlashController.js index d7349595..5855d92f 100644 --- a/js/manual-gene-expression/view/FlashController.js +++ b/js/manual-gene-expression/view/FlashController.js @@ -23,7 +23,7 @@ define( require => { * @constructor */ function FlashController( flashingNode, normalColor, flashColor, options ) { - var self = this; + const self = this; // variables used to implement the flashing behavior this.transitionCountdown = 0; // @private @@ -35,7 +35,7 @@ define( require => { this.numFlashes = options.numFlashes; // @private this.timerHandle = null; // @private - var time = 0; + let time = 0; // @private this.timerListener = function() { diff --git a/js/manual-gene-expression/view/FlashingShapeNode.js b/js/manual-gene-expression/view/FlashingShapeNode.js index e03f59b2..6c0c8807 100644 --- a/js/manual-gene-expression/view/FlashingShapeNode.js +++ b/js/manual-gene-expression/view/FlashingShapeNode.js @@ -19,7 +19,7 @@ define( require => { const Path = require( 'SCENERY/nodes/Path' ); // constants - var INVISIBLE_COLOR = new Color( 0, 0, 0, 0 ); + const INVISIBLE_COLOR = new Color( 0, 0, 0, 0 ); /** * @param {Shape} shape @@ -38,7 +38,7 @@ define( require => { Node.call( this ); - var flashingNode = new Path( shape, { + const flashingNode = new Path( shape, { fill: options.visibleAtStart ? flashColor : INVISIBLE_COLOR } ); this.addChild( flashingNode ); diff --git a/js/manual-gene-expression/view/ManualGeneExpressionScreenView.js b/js/manual-gene-expression/view/ManualGeneExpressionScreenView.js index 9d985cf8..ccf96fad 100644 --- a/js/manual-gene-expression/view/ManualGeneExpressionScreenView.js +++ b/js/manual-gene-expression/view/ManualGeneExpressionScreenView.js @@ -32,8 +32,8 @@ define( require => { const Vector2 = require( 'DOT/Vector2' ); // constants - var GENE_TO_GENE_ANIMATION_TIME = 1; // in seconds - var INSET = 15; // inset for several of the controls, in view coordinates + const GENE_TO_GENE_ANIMATION_TIME = 1; // in seconds + const INSET = 15; // inset for several of the controls, in view coordinates // strings const nextGeneString = require( 'string!GENE_EXPRESSION_ESSENTIALS/nextGene' ); @@ -46,10 +46,10 @@ define( require => { function ManualGeneExpressionScreenView( model ) { ScreenView.call( this, { preventFit: true } ); - var self = this; + const self = this; this.viewPortOffset = new Vector2( 0, 0 ); - var biomoleculeToolboxNodeList = []; // array containing the toolbox nodes used to create biomolecules + const biomoleculeToolboxNodeList = []; // array containing the toolbox nodes used to create biomolecules // Set up the model-canvas transform. The multiplier factors for the 2nd point can be adjusted to shift the center // right or left, and the scale factor can be adjusted to zoom in or out (smaller numbers zoom out, larger ones zoom @@ -62,7 +62,7 @@ define( require => { // Set up the node where all controls that need to be below the biomolecules should be placed. This node and its // children will stay in one place and not scroll. - var backControlsLayer = new Node(); + const backControlsLayer = new Node(); this.addChild( backControlsLayer ); // Set up the root node for all model objects. Nodes placed under this one will scroll when the user moves along the @@ -71,20 +71,20 @@ define( require => { this.addChild( this.modelRootNode ); // Add some layers for enforcing some z-order relationships needed in order to keep things looking good. - var dnaLayer = new Node(); + const dnaLayer = new Node(); this.modelRootNode.addChild( dnaLayer ); - var biomoleculeToolboxLayer = new Node(); + const biomoleculeToolboxLayer = new Node(); this.modelRootNode.addChild( biomoleculeToolboxLayer ); - var messengerRnaLayer = new Node(); + const messengerRnaLayer = new Node(); this.modelRootNode.addChild( messengerRnaLayer ); - var topBiomoleculeLayer = new Node(); + const topBiomoleculeLayer = new Node(); this.modelRootNode.addChild( topBiomoleculeLayer ); - var placementHintLayer = new Node(); + const placementHintLayer = new Node(); this.modelRootNode.addChild( placementHintLayer ); // Set up the node where all controls that need to be above the biomolecules should be placed. This node and its // children will stay in one place and not scroll. - var frontControlsLayer = new Node(); + const frontControlsLayer = new Node(); this.addChild( frontControlsLayer ); // Add the representation of the DNA strand. @@ -100,7 +100,7 @@ define( require => { } ); // Add the protein collection box. - var proteinCollectionNode = new ProteinCollectionNode( model, this.modelViewTransform ); + const proteinCollectionNode = new ProteinCollectionNode( model, this.modelViewTransform ); proteinCollectionNode.x = this.layoutBounds.width - proteinCollectionNode.bounds.width - INSET; proteinCollectionNode.y = INSET; backControlsLayer.addChild( proteinCollectionNode ); @@ -113,7 +113,7 @@ define( require => { // Watch for and handle comings and goings of biomolecules in the model. Most, but not all, of the biomolecules // are handled by this. Some others are handled as special cases. model.mobileBiomoleculeList.addItemAddedListener( function( addedBiomolecule ) { - var biomoleculeNode = new MobileBiomoleculeNode( self.modelViewTransform, addedBiomolecule ); + const biomoleculeNode = new MobileBiomoleculeNode( self.modelViewTransform, addedBiomolecule ); topBiomoleculeLayer.addChild( biomoleculeNode ); function removeItemListener( removedBiomolecule ) { @@ -130,7 +130,7 @@ define( require => { // Watch for and handle comings and goings of messenger RNA. model.messengerRnaList.addItemAddedListener( function( addedMessengerRna ) { - var messengerRnaNode = new MessengerRnaNode( self.modelViewTransform, addedMessengerRna ); + const messengerRnaNode = new MessengerRnaNode( self.modelViewTransform, addedMessengerRna ); messengerRnaLayer.addChild( messengerRnaNode ); function removeItemListener( removedMessengerRna ) { @@ -146,7 +146,7 @@ define( require => { // Add the toolboxes from which the various biomolecules can be moved into the active area of the sim. model.getDnaMolecule().getGenes().forEach( function( gene ) { - var biomoleculeToolboxNode = new BiomoleculeToolboxNode( model, self, self.modelViewTransform, gene ); + const biomoleculeToolboxNode = new BiomoleculeToolboxNode( model, self, self.modelViewTransform, gene ); biomoleculeToolboxNode.x = self.modelViewTransform.modelToViewX( gene.getCenterX() ) - self.layoutBounds.getWidth() / 2 + INSET; biomoleculeToolboxNode.y = INSET; biomoleculeToolboxNodeList.push( biomoleculeToolboxNode ); @@ -162,7 +162,7 @@ define( require => { } // add button for moving to next gene - var nextGeneButtonContent = new HBox( { + const nextGeneButtonContent = new HBox( { children: [ new Text( nextGeneString, { font: new PhetFont( { size: 18 } ), @@ -176,7 +176,7 @@ define( require => { ], spacing: 5 } ); - var nextGeneButton = new RectangularPushButton( { + const nextGeneButton = new RectangularPushButton( { content: nextGeneButtonContent, listener: function() { model.nextGene(); @@ -190,7 +190,7 @@ define( require => { nextGeneButton.y = this.modelViewTransform.modelToViewY( model.getDnaMolecule().getLeftEdgePosition().y ) + 90; // add buttons for moving to previous gene - var previousGeneButtonContent = new HBox( { + const previousGeneButtonContent = new HBox( { children: [ new ArrowNode( 0, 0, -20, 0, { headHeight: 8, @@ -204,7 +204,7 @@ define( require => { ], spacing: 5 } ); - var previousGeneButton = new RectangularPushButton( { + const previousGeneButton = new RectangularPushButton( { content: previousGeneButtonContent, listener: function() { model.previousGene(); @@ -235,7 +235,7 @@ define( require => { self.viewPortOffset.setXY( -self.modelViewTransform.modelToViewX( gene.getCenterX() ) + self.layoutBounds.width / 2, 0 ); // create and run the animation that will move the view to the selected gene - var modelRootNodeAnimator = new Animation( { + const modelRootNodeAnimator = new Animation( { duration: GENE_TO_GENE_ANIMATION_TIME, easing: Easing.CUBIC_IN_OUT, setValue: function( newXPos ) { @@ -247,9 +247,9 @@ define( require => { modelRootNodeAnimator.finishEmitter.addListener( function() { self.modelRootNode.visible = true; self.modelRootNode.pickable = null; - var boundsInControlNode = proteinCollectionNode.getBounds().copy(); - var boundsAfterTransform = boundsInControlNode.transform( self.modelRootNode.getTransform().getInverse() ); - var boundsInModel = self.modelViewTransform.viewToModelBounds( boundsAfterTransform ); + const boundsInControlNode = proteinCollectionNode.getBounds().copy(); + const boundsAfterTransform = boundsInControlNode.transform( self.modelRootNode.getTransform().getInverse() ); + const boundsInModel = self.modelViewTransform.viewToModelBounds( boundsAfterTransform ); model.setProteinCaptureArea( boundsInModel ); model.addOffLimitsMotionSpace( boundsInModel ); setBiomoleculeToolboxPickability( true ); @@ -261,7 +261,7 @@ define( require => { frontControlsLayer.addChild( previousGeneButton ); // Create and add the Reset All Button in the bottom right, which resets the model - var resetAllButton = new ResetAllButton( { + const resetAllButton = new ResetAllButton( { listener: function() { model.reset(); biomoleculeToolboxNodeList.forEach( function( biomoleculeToolboxNode ) { diff --git a/js/manual-gene-expression/view/MessengerRnaDestroyerCreatorNode.js b/js/manual-gene-expression/view/MessengerRnaDestroyerCreatorNode.js index ca7ed104..5db9783d 100644 --- a/js/manual-gene-expression/view/MessengerRnaDestroyerCreatorNode.js +++ b/js/manual-gene-expression/view/MessengerRnaDestroyerCreatorNode.js @@ -23,8 +23,8 @@ define( require => { // constants // Scaling factor for this node when used as a creator node. May be significantly different from the size of the // corresponding element in the model. - var SCALING_FACTOR = 0.07; - var SCALING_MVT = ModelViewTransform2.createSinglePointScaleInvertedYMapping( + const SCALING_FACTOR = 0.07; + const SCALING_MVT = ModelViewTransform2.createSinglePointScaleInvertedYMapping( new Vector2( 0, 0 ), new Vector2( 0, 0 ), SCALING_FACTOR @@ -40,7 +40,7 @@ define( require => { biomoleculeBoxNode.canvas, biomoleculeBoxNode.modelViewTransform, function( pos ) { - var mRnaDestroyer = new MessengerRnaDestroyer( biomoleculeBoxNode.model, pos ); + const mRnaDestroyer = new MessengerRnaDestroyer( biomoleculeBoxNode.model, pos ); biomoleculeBoxNode.model.addMobileBiomolecule( mRnaDestroyer ); return mRnaDestroyer; diff --git a/js/manual-gene-expression/view/ProteinCaptureNode.js b/js/manual-gene-expression/view/ProteinCaptureNode.js index 979701ef..2e5de078 100644 --- a/js/manual-gene-expression/view/ProteinCaptureNode.js +++ b/js/manual-gene-expression/view/ProteinCaptureNode.js @@ -27,14 +27,14 @@ define( require => { const Text = require( 'SCENERY/nodes/Text' ); // constants - var FLASH_COLOR = new Color( 173, 255, 47 ); - var SCALE_FOR_FLASH_NODE = 1.5; + const FLASH_COLOR = new Color( 173, 255, 47 ); + const SCALE_FOR_FLASH_NODE = 1.5; // Tweak warning: This is used to make sure that the counters on the various protein nodes end up horizontally // aligned. This will need to be adjust if the protein shapes change a lot. - var VERTICAL_DISTANCE_TO_COUNT_NODE = 40; + const VERTICAL_DISTANCE_TO_COUNT_NODE = 40; - var proteinStringConstructorMap = { + const proteinStringConstructorMap = { 'ProteinA': ProteinA, 'ProteinB': ProteinB, 'ProteinC': ProteinC @@ -51,9 +51,9 @@ define( require => { Node.call( this ); // Get the shape of the protein. - var protein = new proteinStringConstructorMap[ proteinClassName ](); - var proteinShape = protein.getFullyGrownShape().transformed( transform ); - var fullBaseColor = protein.colorProperty.get(); + const protein = new proteinStringConstructorMap[ proteinClassName ](); + const proteinShape = protein.getFullyGrownShape().transformed( transform ); + const fullBaseColor = protein.colorProperty.get(); // Add the background node. This is invisible, and exists only to make the node a specific size. this.addChild( new Path( Shape.rectangle( -size.width / 2, -size.height / 2, size.width, size.height ), { @@ -62,18 +62,18 @@ define( require => { // Add the node that will flash when a protein is created, stay lit until the protein is captured, and turn off once // it is captured. - var flashingCaptureNodeShape = proteinShape.transformed( Matrix3.scaling( SCALE_FOR_FLASH_NODE, SCALE_FOR_FLASH_NODE ) ); - var flashingCaptureNode = new FlashingShapeNode( flashingCaptureNodeShape, FLASH_COLOR ); + const flashingCaptureNodeShape = proteinShape.transformed( Matrix3.scaling( SCALE_FOR_FLASH_NODE, SCALE_FOR_FLASH_NODE ) ); + const flashingCaptureNode = new FlashingShapeNode( flashingCaptureNodeShape, FLASH_COLOR ); this.addChild( flashingCaptureNode ); // Add the node that will represent the spot where the protein can be captured, which is a black shape (signifying // emptiness) until a protein is captured, then it changes to look filled in. - var captureAreaNode = new Path( proteinShape, { stroke: 'black' } ); + const captureAreaNode = new Path( proteinShape, { stroke: 'black' } ); this.addChild( captureAreaNode ); - var gradientPaint = GradientUtil.createGradientPaint( proteinShape, fullBaseColor ); + const gradientPaint = GradientUtil.createGradientPaint( proteinShape, fullBaseColor ); // Add the node that represents a count of the collected type. - var countNode = new Text( '', { font: new PhetFont( { size: 18, weight: 'bold' } ) } ); + const countNode = new Text( '', { font: new PhetFont( { size: 18, weight: 'bold' } ) } ); this.addChild( countNode ); model.getCollectedCounterForProteinType( proteinClassName ).link( function( proteinCaptureCount ) { countNode.text = proteinCaptureCount; @@ -94,7 +94,7 @@ define( require => { } ); // Get the capture count property for this protein. - var captureCountProperty = model.getCollectedCounterForProteinType( proteinClassName ); + const captureCountProperty = model.getCollectedCounterForProteinType( proteinClassName ); // Observe the capture indicator and set the state of the nodes appropriately. captureCountProperty.link( function( captureCount ) { diff --git a/js/manual-gene-expression/view/ProteinCollectionArea.js b/js/manual-gene-expression/view/ProteinCollectionArea.js index b7c298e3..e47b6f48 100644 --- a/js/manual-gene-expression/view/ProteinCollectionArea.js +++ b/js/manual-gene-expression/view/ProteinCollectionArea.js @@ -32,22 +32,22 @@ define( require => { Node.call( this ); // Get a transform that performs only the scaling portion of the modelViewTransform. - var scaleVector = modelViewTransform.getMatrix().getScaleVector(); - var scale = modelViewTransform.getMatrix().scaleVector.x; + const scaleVector = modelViewTransform.getMatrix().getScaleVector(); + const scale = modelViewTransform.getMatrix().scaleVector.x; // The getScaleVector method of Matrix3 always returns positive value for the scales, even though // the modelViewTransform uses inverted scaling for Y, so changing the assertion statement to check for absolute values // see issue #7 assert && assert( scale === Math.abs( scaleVector.y ) ); // This only handles symmetric transform case. - var transform = Matrix3.scaling( scale, -scale ); + const transform = Matrix3.scaling( scale, -scale ); // Figure out the max dimensions of the various protein types so that the capture nodes can be properly laid out. - var captureNodeBackgroundSize = new Dimension2( 0, 0 ); + const captureNodeBackgroundSize = new Dimension2( 0, 0 ); - var proteinTypes = [ ProteinA, ProteinB, ProteinC ]; - for ( var i = 0; i < proteinTypes.length; i++ ) { - var protein = new proteinTypes[ i ](); - var proteinShapeBounds = protein.getFullyGrownShape() + const proteinTypes = [ ProteinA, ProteinB, ProteinC ]; + for ( let i = 0; i < proteinTypes.length; i++ ) { + const protein = new proteinTypes[ i ](); + const proteinShapeBounds = protein.getFullyGrownShape() .transformed( transform ) .getStrokedBounds( new kite.LineStyles( { lineWidth: 1 } ) ); captureNodeBackgroundSize.width = ( Math.max( diff --git a/js/manual-gene-expression/view/ProteinCollectionNode.js b/js/manual-gene-expression/view/ProteinCollectionNode.js index 57c09ed6..5fd01bca 100644 --- a/js/manual-gene-expression/view/ProteinCollectionNode.js +++ b/js/manual-gene-expression/view/ProteinCollectionNode.js @@ -25,13 +25,13 @@ define( require => { const VBox = require( 'SCENERY/nodes/VBox' ); // constants - var NUM_PROTEIN_TYPES = 3; // Total number of protein types that can be collected. + const NUM_PROTEIN_TYPES = 3; // Total number of protein types that can be collected. // attributes of various aspects of the box - var TITLE_FONT = new PhetFont( { size: 18, weight: 'bold' } ); - var READOUT_FONT = new PhetFont( { size: 18, weight: 'bold' } ); - var BACKGROUND_COLOR = new Color( 255, 250, 205 ); - var INTEGER_BOX_BACKGROUND_COLOR = new Color( 240, 240, 240 ); + const TITLE_FONT = new PhetFont( { size: 18, weight: 'bold' } ); + const READOUT_FONT = new PhetFont( { size: 18, weight: 'bold' } ); + const BACKGROUND_COLOR = new Color( 255, 250, 205 ); + const INTEGER_BOX_BACKGROUND_COLOR = new Color( 240, 240, 240 ); // strings const collectionCompleteString = require( 'string!GENE_EXPRESSION_ESSENTIALS/collectionComplete' ); @@ -48,7 +48,7 @@ define( require => { Node.call( this ); // Create the title and scale it if needed. - var title = new RichText( yourProteinCollectionString, { + const title = new RichText( yourProteinCollectionString, { fill: Color.BLACK, font: TITLE_FONT, maxWidth: 120, @@ -56,7 +56,7 @@ define( require => { } ); // create the collection area - var collectionArea = new ProteinCollectionArea( model, modelViewTransform ); + const collectionArea = new ProteinCollectionArea( model, modelViewTransform ); // create the panel this.addChild( new Panel( @@ -75,18 +75,18 @@ define( require => { * @param {ManualGeneExpressionModel}model */ function createCollectionCountIndicator( model ) { - var contentNode = new Node(); + const contentNode = new Node(); - var collectionCompleteNode = new Text( collectionCompleteString, { + const collectionCompleteNode = new Text( collectionCompleteString, { font: new PhetFont( 20 ), maxWidth: 200 } ); contentNode.addChild( collectionCompleteNode ); - var countReadoutText = new Text( 0, { + const countReadoutText = new Text( 0, { font: READOUT_FONT } ); - var countReadoutPanel = new Panel( countReadoutText, { + const countReadoutPanel = new Panel( countReadoutText, { minWidth: countReadoutText.width, resize: false, cornerRadius: GEEConstants.CORNER_RADIUS, @@ -94,7 +94,7 @@ define( require => { align: 'center', fill: INTEGER_BOX_BACKGROUND_COLOR } ); - var countIndicatorNode = new HBox( { + const countIndicatorNode = new HBox( { children: [ new Text( proteinCountCaptionPart1String, { font: READOUT_FONT, maxWidth: 100 @@ -103,11 +103,11 @@ define( require => { spacing: 4 } ); - var children = [ countIndicatorNode, new Text( proteinCountCaptionPart2String, { + const children = [ countIndicatorNode, new Text( proteinCountCaptionPart2String, { font: READOUT_FONT, maxWidth: 200 } ) ]; - var collectedQuantityIndicator = new VBox( { + const collectedQuantityIndicator = new VBox( { children: children, spacing: 10 } ); @@ -115,7 +115,7 @@ define( require => { collectedQuantityIndicator.center = collectionCompleteNode.center; function countChangeUpdater() { - var numProteinTypesCollected = 0; + let numProteinTypesCollected = 0; if ( model.proteinACollectedProperty.get() > 0 ) { numProteinTypesCollected++; } diff --git a/js/manual-gene-expression/view/RibosomeCreatorNode.js b/js/manual-gene-expression/view/RibosomeCreatorNode.js index 48c374e7..ba3c3f2a 100644 --- a/js/manual-gene-expression/view/RibosomeCreatorNode.js +++ b/js/manual-gene-expression/view/RibosomeCreatorNode.js @@ -22,8 +22,8 @@ define( require => { // Scaling factor for this node when used as a creator node. May be significantly different from the size of the // corresponding element in the model. - var SCALING_FACTOR = 0.07; - var SCALING_MVT = ModelViewTransform2.createSinglePointScaleInvertedYMapping( + const SCALING_FACTOR = 0.07; + const SCALING_MVT = ModelViewTransform2.createSinglePointScaleInvertedYMapping( new Vector2( 0, 0 ), new Vector2( 0, 0 ), SCALING_FACTOR @@ -43,7 +43,7 @@ define( require => { biomoleculeBoxNode.canvas, biomoleculeBoxNode.modelViewTransform, function( pos ) { - var srs = new Ribosome( biomoleculeBoxNode.model, pos ); + const srs = new Ribosome( biomoleculeBoxNode.model, pos ); biomoleculeBoxNode.model.addMobileBiomolecule( srs ); return srs; }, diff --git a/js/manual-gene-expression/view/RnaPolymeraseCreatorNode.js b/js/manual-gene-expression/view/RnaPolymeraseCreatorNode.js index 47fc2716..63fb1395 100644 --- a/js/manual-gene-expression/view/RnaPolymeraseCreatorNode.js +++ b/js/manual-gene-expression/view/RnaPolymeraseCreatorNode.js @@ -23,8 +23,8 @@ define( require => { // Scaling factor for this node when used as a creator node. May be significantly different from the size of the // corresponding element in the model. - var SCALING_FACTOR = 0.07; - var SCALING_MVT = ModelViewTransform2.createSinglePointScaleInvertedYMapping( + const SCALING_FACTOR = 0.07; + const SCALING_MVT = ModelViewTransform2.createSinglePointScaleInvertedYMapping( new Vector2( 0, 0 ), new Vector2( 0, 0 ), SCALING_FACTOR @@ -42,7 +42,7 @@ define( require => { biomoleculeBoxNode.modelViewTransform, function( pos ) { // Molecule creator function. - var rnaPolymerase = new RnaPolymerase( biomoleculeBoxNode.model, pos ); + const rnaPolymerase = new RnaPolymerase( biomoleculeBoxNode.model, pos ); biomoleculeBoxNode.model.addMobileBiomolecule( rnaPolymerase ); return rnaPolymerase; }, diff --git a/js/manual-gene-expression/view/TranscriptionFactorCreatorNode.js b/js/manual-gene-expression/view/TranscriptionFactorCreatorNode.js index deb4a231..7af62fb4 100644 --- a/js/manual-gene-expression/view/TranscriptionFactorCreatorNode.js +++ b/js/manual-gene-expression/view/TranscriptionFactorCreatorNode.js @@ -23,8 +23,8 @@ define( require => { // constants // Scaling factor for this node when used as a creator node. May be significantly different from the size of the // corresponding element in the model. - var SCALING_FACTOR = 0.07; - var SCALING_MVT = ModelViewTransform2.createSinglePointScaleInvertedYMapping( + const SCALING_FACTOR = 0.07; + const SCALING_MVT = ModelViewTransform2.createSinglePointScaleInvertedYMapping( new Vector2( 0, 0 ), new Vector2( 0, 0 ), SCALING_FACTOR @@ -41,7 +41,7 @@ define( require => { biomoleculeBoxNode.canvas, biomoleculeBoxNode.modelViewTransform, function( pos ) { - var transcriptionFactor = new TranscriptionFactor( biomoleculeBoxNode.model, tfConfig, pos ); + const transcriptionFactor = new TranscriptionFactor( biomoleculeBoxNode.model, tfConfig, pos ); biomoleculeBoxNode.model.addMobileBiomolecule( transcriptionFactor ); return transcriptionFactor; }, diff --git a/js/mrna-production/MessengerRnaProductionScreen.js b/js/mrna-production/MessengerRnaProductionScreen.js index 52c51335..ebf820fe 100644 --- a/js/mrna-production/MessengerRnaProductionScreen.js +++ b/js/mrna-production/MessengerRnaProductionScreen.js @@ -30,7 +30,7 @@ define( require => { */ function MessengerRnaProductionScreen() { - var options = { + const options = { name: screenMRnaString, backgroundColorProperty: new Property( '#ABCBDB' ), homeScreenIcon: new Image( mRnaProductionIcon ), diff --git a/js/mrna-production/model/MessengerRnaProductionModel.js b/js/mrna-production/model/MessengerRnaProductionModel.js index e8e7e0c0..6ec4f733 100644 --- a/js/mrna-production/model/MessengerRnaProductionModel.js +++ b/js/mrna-production/model/MessengerRnaProductionModel.js @@ -29,26 +29,26 @@ define( require => { // constants // period for shuffling biomolecules, helps with random behavior - var SHUFFLE_TIME = 1; // seconds + const SHUFFLE_TIME = 1; // seconds // Length, in terms of base pairs, of the DNA molecule. - var NUM_BASE_PAIRS_ON_DNA_STRAND = 500; + const NUM_BASE_PAIRS_ON_DNA_STRAND = 500; // Configurations for the transcriptions factors used within this model. - var POSITIVE_TRANSCRIPTION_FACTOR_CONFIG = TranscriptionFactor.TRANSCRIPTION_FACTOR_CONFIG_GENE_1_POS; - var NEGATIVE_TRANSCRIPTION_FACTOR_CONFIG = TranscriptionFactor.TRANSCRIPTION_FACTOR_CONFIG_GENE_1_NEG; + const POSITIVE_TRANSCRIPTION_FACTOR_CONFIG = TranscriptionFactor.TRANSCRIPTION_FACTOR_CONFIG_GENE_1_POS; + const NEGATIVE_TRANSCRIPTION_FACTOR_CONFIG = TranscriptionFactor.TRANSCRIPTION_FACTOR_CONFIG_GENE_1_NEG; // Maximum number of transcription factor molecules. The pertains to both positive and negative transcription factors. - var MAX_TRANSCRIPTION_FACTOR_COUNT = 8; + const MAX_TRANSCRIPTION_FACTOR_COUNT = 8; // Number of RNA polymerase molecules present. - var RNA_POLYMERASE_COUNT = 7; + const RNA_POLYMERASE_COUNT = 7; /** * @constructor */ function MessengerRnaProductionModel() { - var self = this; + const self = this; this.clockRunningProperty = new Property( true ); //@public // DNA strand, which is where the genes reside, where the polymerase does its transcription, and where a lot of the @@ -103,14 +103,14 @@ define( require => { // The bounds within which polymerase may be moved when recycled. Set up the area where RNA polymerase goes when it // is recycled. This is near the beginning of the transcribed region in order to make transcription more likely to // occur. - var polymeraseSize = new RnaPolymerase().bounds; - var firstGene = this.dnaMolecule.getGenes()[ 0 ]; - var recycleZoneCenterX = this.dnaMolecule.getBasePairXOffsetByIndex( firstGene.getTranscribedRegion().min ) + + const polymeraseSize = new RnaPolymerase().bounds; + const firstGene = this.dnaMolecule.getGenes()[ 0 ]; + const recycleZoneCenterX = this.dnaMolecule.getBasePairXOffsetByIndex( firstGene.getTranscribedRegion().min ) + ( phet.joist.random.nextDouble() - 0.5 ) * 2000; - var recycleZoneHeight = polymeraseSize.getHeight() * 1.2; - var recycleZoneWidth = polymeraseSize.getWidth() * 4; - var minX = recycleZoneCenterX - polymeraseSize.getWidth() * 2; - var minY = GEEConstants.DNA_MOLECULE_Y_POS + polymeraseSize.getHeight(); + const recycleZoneHeight = polymeraseSize.getHeight() * 1.2; + const recycleZoneWidth = polymeraseSize.getWidth() * 4; + const minX = recycleZoneCenterX - polymeraseSize.getWidth() * 2; + let minY = GEEConstants.DNA_MOLECULE_Y_POS + polymeraseSize.getHeight(); // @private this.aboveDnaPolymeraseReturnBounds = new Bounds2( @@ -238,12 +238,12 @@ define( require => { setUpMotionBounds: function() { // Bounds, have been empirically determined to keep biomolecules in . - var minY = -1854; - var maxY = 1236; - var minX = -2458; - var maxX = 2663; + const minY = -1854; + const maxY = 1236; + const minX = -2458; + const maxX = 2663; - var bounds = new Bounds2( minX, minY, maxX, maxY ); + const bounds = new Bounds2( minX, minY, maxX, maxY ); this.moleculeMotionBounds = new MotionBounds( bounds ); }, @@ -271,7 +271,7 @@ define( require => { * @public */ getOverlappingBiomolecules: function( testShapeBounds ) { - var overlappingBiomolecules = []; + const overlappingBiomolecules = []; this.mobileBiomoleculeList.forEach( function( mobileBiomolecule ) { if ( mobileBiomolecule.bounds.intersectsBounds( testShapeBounds ) ) { overlappingBiomolecules.push( mobileBiomolecule ); @@ -333,8 +333,8 @@ define( require => { // Add the polymerase molecules. These don't come and go, the concentration of these remains constant in this // model. - for ( var i = 0; i < RNA_POLYMERASE_COUNT; i++ ) { - var rnaPolymerase = new RnaPolymerase( this, new Vector2( 0, 0 ) ); + for ( let i = 0; i < RNA_POLYMERASE_COUNT; i++ ) { + const rnaPolymerase = new RnaPolymerase( this, new Vector2( 0, 0 ) ); rnaPolymerase.setPosition3D( this.generateInitialPosition3D( rnaPolymerase ) ); rnaPolymerase.set3DMotionEnabled( true ); rnaPolymerase.setRecycleMode( true ); @@ -351,13 +351,13 @@ define( require => { * @private */ generateInitialPosition3D: function( biomolecule ) { - var xMin = this.moleculeMotionBounds.getBounds().minX + biomolecule.bounds.getWidth() / 2; - var yMin = this.moleculeMotionBounds.getBounds().minY + biomolecule.bounds.getHeight() / 2; - var xMax = this.moleculeMotionBounds.getBounds().maxX - biomolecule.bounds.getWidth() / 2; - var yMax = this.moleculeMotionBounds.getBounds().maxY - biomolecule.bounds.getHeight() / 2; - var xPos = xMin + phet.joist.random.nextDouble() * ( xMax - xMin ); - var yPos = yMin + phet.joist.random.nextDouble() * ( yMax - yMin ); - var zPos = -phet.joist.random.nextDouble(); // Valid z values are from -1 to 0. + const xMin = this.moleculeMotionBounds.getBounds().minX + biomolecule.bounds.getWidth() / 2; + const yMin = this.moleculeMotionBounds.getBounds().minY + biomolecule.bounds.getHeight() / 2; + const xMax = this.moleculeMotionBounds.getBounds().maxX - biomolecule.bounds.getWidth() / 2; + const yMax = this.moleculeMotionBounds.getBounds().maxY - biomolecule.bounds.getHeight() / 2; + const xPos = xMin + phet.joist.random.nextDouble() * ( xMax - xMin ); + const yPos = yMin + phet.joist.random.nextDouble() * ( yMax - yMin ); + const zPos = -phet.joist.random.nextDouble(); // Valid z values are from -1 to 0. return new Vector3( xPos, yPos, zPos ); }, @@ -370,7 +370,7 @@ define( require => { setTranscriptionFactorCount: function( tcConfig, targetCount, transcriptionFactorList ) { if ( transcriptionFactorList.length < targetCount ) { while ( transcriptionFactorList.length < targetCount ) { - var transcriptionFactor = new TranscriptionFactor( this, tcConfig, new Vector2( 0, 0 ) ); + const transcriptionFactor = new TranscriptionFactor( this, tcConfig, new Vector2( 0, 0 ) ); transcriptionFactor.setPosition3D( this.generateInitialPosition3D( transcriptionFactor ) ); transcriptionFactor.set3DMotionEnabled( true ); this.addMobileBiomolecule( transcriptionFactor ); @@ -379,7 +379,7 @@ define( require => { } else if ( transcriptionFactorList.length > targetCount ) { while ( transcriptionFactorList.length > targetCount ) { - var mobileBiomolecule = transcriptionFactorList.pop(); + const mobileBiomolecule = transcriptionFactorList.pop(); mobileBiomolecule.forceDetach(); this.removeMobileBiomolecule( mobileBiomolecule ); } diff --git a/js/mrna-production/view/AffinityController.js b/js/mrna-production/view/AffinityController.js index a9fdad65..567ae185 100644 --- a/js/mrna-production/view/AffinityController.js +++ b/js/mrna-production/view/AffinityController.js @@ -25,8 +25,8 @@ define( require => { const Vector2 = require( 'DOT/Vector2' ); // constants - var ARROW_LENGTH = 30; - var ARROW_HEAD_HEIGHT = 10; + const ARROW_LENGTH = 30; + const ARROW_HEAD_HEIGHT = 10; // strings const affinityString = require( 'string!GENE_EXPRESSION_ESSENTIALS/affinity' ); @@ -41,26 +41,26 @@ define( require => { */ function AffinityController( leftNode, rightNode, affinityProperty ) { Node.call( this ); - var captionNode = new Text( affinityString, { + const captionNode = new Text( affinityString, { font: new PhetFont( { size: 14, weight: 'bold' } ), maxWidth: 180 } ); - var arrowTail = new Vector2( 0, 0 ); - var arrowTip = new Vector2( ARROW_LENGTH, 0 ); - var arrowOptions = { + const arrowTail = new Vector2( 0, 0 ); + const arrowTip = new Vector2( ARROW_LENGTH, 0 ); + const arrowOptions = { doubleHead: true, headHeight: ARROW_HEAD_HEIGHT / 2, headWidth: ARROW_HEAD_HEIGHT, tailWidth: ARROW_HEAD_HEIGHT / 3 }; - var arrowNode = new ArrowNode( arrowTail.x, arrowTail.y, arrowTip.x, arrowTip.y, arrowOptions ); - var affinityKey = new HBox( { + const arrowNode = new ArrowNode( arrowTail.x, arrowTail.y, arrowTip.x, arrowTip.y, arrowOptions ); + const affinityKey = new HBox( { children: [ leftNode, arrowNode, rightNode ], spacing: 10 } ); affinityKey.setPickable( false ); - var horizontalSlider = new ControllerNode( + const horizontalSlider = new ControllerNode( affinityProperty, 0, 1, diff --git a/js/mrna-production/view/ConcentrationController.js b/js/mrna-production/view/ConcentrationController.js index ff1a037b..6feeb242 100644 --- a/js/mrna-production/view/ConcentrationController.js +++ b/js/mrna-production/view/ConcentrationController.js @@ -41,12 +41,12 @@ define( require => { function ConcentrationController( transcriptionFactorConfig, tfLevelProperty, min, max ) { Node.call( this ); - var captionNode = new Text( concentrationString, { + const captionNode = new Text( concentrationString, { font: new PhetFont( { size: 14, weight: 'bold' } ), maxWidth: 180 } ); - var molecule = new MobileBiomoleculeNode( GEEConstants.TRANSCRIPTION_FACTOR_MVT, + const molecule = new MobileBiomoleculeNode( GEEConstants.TRANSCRIPTION_FACTOR_MVT, new TranscriptionFactor( new StubGeneExpressionModel(), transcriptionFactorConfig ) ); molecule.setPickable( false ); diff --git a/js/mrna-production/view/MessengerRnaProductionScreenView.js b/js/mrna-production/view/MessengerRnaProductionScreenView.js index 26fc6c3c..68abb4f5 100644 --- a/js/mrna-production/view/MessengerRnaProductionScreenView.js +++ b/js/mrna-production/view/MessengerRnaProductionScreenView.js @@ -32,7 +32,7 @@ define( require => { const Vector2 = require( 'DOT/Vector2' ); // constants - var INSET = 10; // Inset for several of the controls. + const INSET = 10; // Inset for several of the controls. // strings const negativeTranscriptionFactorString = require( 'string!GENE_EXPRESSION_ESSENTIALS/negativeTranscriptionFactor' ); @@ -45,10 +45,10 @@ define( require => { // due to odd behavior of flickering on this screen, we run it with preventFit ScreenView.call( this, { preventFit: true } ); - var self = this; + const self = this; this.model = model; this.negativeTranscriptionFactorEnabled = new Property( false ); - var viewPortPosition = new Vector2( this.layoutBounds.width * 0.48, this.layoutBounds.height * 0.4 ); + const viewPortPosition = new Vector2( this.layoutBounds.width * 0.48, this.layoutBounds.height * 0.4 ); // Set up the model-canvas transform. this.modelViewTransform = ModelViewTransform2.createSinglePointScaleInvertedYMapping( @@ -63,21 +63,21 @@ define( require => { this.addChild( this.modelRootNode ); // Add some layers for enforcing some z-order relationships needed in order to keep things looking good. - var dnaLayer = new Node(); + const dnaLayer = new Node(); this.modelRootNode.addChild( dnaLayer ); dnaLayer.setPickable( false ); - var messengerRnaLayer = new Node(); + const messengerRnaLayer = new Node(); messengerRnaLayer.setPickable( false ); this.modelRootNode.addChild( messengerRnaLayer ); - var transcribingPolymeraseLayer = new Node(); + const transcribingPolymeraseLayer = new Node(); transcribingPolymeraseLayer.setPickable( false ); this.modelRootNode.addChild( transcribingPolymeraseLayer ); - var topBiomoleculeLayer = new Node(); + const topBiomoleculeLayer = new Node(); topBiomoleculeLayer.setPickable( false ); this.modelRootNode.addChild( topBiomoleculeLayer ); - var placementHintLayer = new Node(); + const placementHintLayer = new Node(); this.modelRootNode.addChild( placementHintLayer ); - var controlsNode = new Node(); + const controlsNode = new Node(); this.addChild( controlsNode ); // Add the representation of the DNA strand. @@ -85,24 +85,24 @@ define( require => { dnaLayer.addChild( this.dnaMoleculeNode ); // Get a reference to the gene being controlled. - var gene = model.getDnaMolecule().getGenes()[ 0 ]; + const gene = model.getDnaMolecule().getGenes()[ 0 ]; // Add the nodes that allow the user to control the concentrations and affinities. - var positiveTranscriptionFactorControlPanel = new TranscriptionFactorControlPanel( + const positiveTranscriptionFactorControlPanel = new TranscriptionFactorControlPanel( model, MessengerRnaProductionModel.POSITIVE_TRANSCRIPTION_FACTOR_CONFIG, gene.getTranscriptionFactorAffinityProperty( MessengerRnaProductionModel.POSITIVE_TRANSCRIPTION_FACTOR_CONFIG ) ); controlsNode.addChild( positiveTranscriptionFactorControlPanel ); - var polymeraseAffinityControlPanel = new PolymeraseAffinityControlPanel( + const polymeraseAffinityControlPanel = new PolymeraseAffinityControlPanel( MessengerRnaProductionModel.POSITIVE_TRANSCRIPTION_FACTOR_CONFIG, positiveTranscriptionFactorControlPanel.bounds.height, gene.getPolymeraseAffinityProperty() ); controlsNode.addChild( polymeraseAffinityControlPanel ); - var negativeTranscriptionFactorControlPanel = new TranscriptionFactorControlPanel( + const negativeTranscriptionFactorControlPanel = new TranscriptionFactorControlPanel( model, MessengerRnaProductionModel.NEGATIVE_TRANSCRIPTION_FACTOR_CONFIG, gene.getTranscriptionFactorAffinityProperty( MessengerRnaProductionModel.NEGATIVE_TRANSCRIPTION_FACTOR_CONFIG ) @@ -110,7 +110,7 @@ define( require => { controlsNode.addChild( negativeTranscriptionFactorControlPanel ); // Add the checkbox for showing/hiding the control panel for the negative transcription factor. - var negativeFactorEnabledCheckbox = new Checkbox( + const negativeFactorEnabledCheckbox = new Checkbox( new Text( negativeTranscriptionFactorString, { font: new PhetFont( 18 ), maxWidth: 275 } ), this.negativeTranscriptionFactorEnabled, { boxWidth: 20 } @@ -127,14 +127,14 @@ define( require => { } ); // Add the play/pause button. - var playPauseButton = new PlayPauseButton( model.clockRunningProperty, { + const playPauseButton = new PlayPauseButton( model.clockRunningProperty, { radius: 23, touchAreaDilation: 5 } ); this.addChild( playPauseButton ); // Add the step button. - var stepButton = new StepForwardButton( { + const stepButton = new StepForwardButton( { isPlayingProperty: model.clockRunningProperty, listener: function() { model.stepInTime( 0.016 ); }, radius: 15, @@ -143,7 +143,7 @@ define( require => { this.addChild( stepButton ); // Add the Reset All button. - var resetAllButton = new ResetAllButton( { + const resetAllButton = new ResetAllButton( { listener: function() { self.model.reset(); self.negativeTranscriptionFactorEnabled.reset(); @@ -174,7 +174,7 @@ define( require => { // define a function for adding views of biomolecules function addBiomoleculeView( addedBiomolecule ) { - var biomoleculeNode = new MobileBiomoleculeNode( self.modelViewTransform, addedBiomolecule ); + const biomoleculeNode = new MobileBiomoleculeNode( self.modelViewTransform, addedBiomolecule ); // On this screen, users can't directly interact with individual biomolecules. biomoleculeNode.setPickable( false ); @@ -182,7 +182,7 @@ define( require => { // Add a listener that moves the child on to a lower layer when it connects to the DNA so that we see the desired // overlap behavior. - var positionBiomolecule = function( attachedToDna ) { + const positionBiomolecule = function( attachedToDna ) { if ( attachedToDna ) { if ( topBiomoleculeLayer.hasChild( biomoleculeNode ) ) { topBiomoleculeLayer.removeChild( biomoleculeNode ); @@ -226,7 +226,7 @@ define( require => { // Watch for and handle comings and goings of messenger RNA. model.messengerRnaList.addItemAddedListener( function( addedMessengerRna ) { - var messengerRnaNode = new MessengerRnaNode( self.modelViewTransform, addedMessengerRna ); + const messengerRnaNode = new MessengerRnaNode( self.modelViewTransform, addedMessengerRna ); messengerRnaLayer.addChild( messengerRnaNode ); model.messengerRnaList.addItemRemovedListener( function removalListener( removedMessengerRna ) { diff --git a/js/mrna-production/view/PolymeraseAffinityControlPanel.js b/js/mrna-production/view/PolymeraseAffinityControlPanel.js index c8bfabae..02865e82 100644 --- a/js/mrna-production/view/PolymeraseAffinityControlPanel.js +++ b/js/mrna-production/view/PolymeraseAffinityControlPanel.js @@ -32,15 +32,15 @@ define( require => { const Vector2 = require( 'DOT/Vector2' ); // constants - var TITLE_FONT = new PhetFont( { size: 16, weight: 'bold' } ); - var POLYMERASE_SCALE = 0.08; - var POLYMERASE_MVT = ModelViewTransform2.createSinglePointScaleInvertedYMapping( + const TITLE_FONT = new PhetFont( { size: 16, weight: 'bold' } ); + const POLYMERASE_SCALE = 0.08; + const POLYMERASE_MVT = ModelViewTransform2.createSinglePointScaleInvertedYMapping( new Vector2( 0, 0 ), new Vector2( 0, 0 ), POLYMERASE_SCALE ); - var DNA_AND_TF_SCALE = 0.08; - var DNA_AND_TF_MVT = ModelViewTransform2.createSinglePointScaleInvertedYMapping( + const DNA_AND_TF_SCALE = 0.08; + const DNA_AND_TF_MVT = ModelViewTransform2.createSinglePointScaleInvertedYMapping( new Vector2( 0, 0 ), new Vector2( 0, 0 ), DNA_AND_TF_SCALE @@ -56,14 +56,14 @@ define( require => { * @constructor */ function PolymeraseAffinityControlPanel( tfConfig, minHeight, polymeraseAffinityProperty ) { - var titleNode = new Text( rnaPolymeraseString, { + const titleNode = new Text( rnaPolymeraseString, { font: TITLE_FONT, maxWidth: 180 } ); // Create the affinity control node. - var polymeraseNode = new MobileBiomoleculeNode( POLYMERASE_MVT, new RnaPolymerase() ); - var dnaFragmentNode = new DnaMoleculeNode( + const polymeraseNode = new MobileBiomoleculeNode( POLYMERASE_MVT, new RnaPolymerase() ); + const dnaFragmentNode = new DnaMoleculeNode( new DnaMolecule( null, GEEConstants.BASE_PAIRS_PER_TWIST * 2 + 1, @@ -74,7 +74,7 @@ define( require => { 2, false ).toDataURLNodeSynchronous(); // make this into an image in the control panel so another canvas isn't created - var transcriptionFactorNode = new MobileBiomoleculeNode( DNA_AND_TF_MVT, new TranscriptionFactor( null, tfConfig ) ); + const transcriptionFactorNode = new MobileBiomoleculeNode( DNA_AND_TF_MVT, new TranscriptionFactor( null, tfConfig ) ); // Set position to be on top of the dna, values empirically determined. transcriptionFactorNode.x = 25; @@ -82,7 +82,7 @@ define( require => { dnaFragmentNode.addChild( transcriptionFactorNode ); - var panelOptions = { + const panelOptions = { cornerRadius: GEEConstants.CORNER_RADIUS, fill: new Color( 250, 250, 250 ), lineWidth: 2, @@ -95,21 +95,21 @@ define( require => { // In order to size the control panel correctly, make one first, see how far off it is, and then make one of the // correct size. - var dummyContents = new VBox( { + const dummyContents = new VBox( { children: [ titleNode, new AffinityController( polymeraseNode, dnaFragmentNode, new Property( 0 ) ) ], spacing: 20 } ); - var dummyControlPanel = new Panel( dummyContents, panelOptions ); - var growthAmount = minHeight - dummyControlPanel.height - 40; + const dummyControlPanel = new Panel( dummyContents, panelOptions ); + const growthAmount = minHeight - dummyControlPanel.height - 40; // Create the spacers used to make the panel meet the min size. - var topSpacer = new Spacer( 0, growthAmount * 0.25 ); - var bottomSpacer = new Spacer( 0, growthAmount * 0.75 ); + const topSpacer = new Spacer( 0, growthAmount * 0.25 ); + const bottomSpacer = new Spacer( 0, growthAmount * 0.75 ); - var contents = new VBox( { + const contents = new VBox( { children: [ titleNode, topSpacer, diff --git a/js/mrna-production/view/TranscriptionFactorControlPanel.js b/js/mrna-production/view/TranscriptionFactorControlPanel.js index 7c621e0b..03e281ef 100644 --- a/js/mrna-production/view/TranscriptionFactorControlPanel.js +++ b/js/mrna-production/view/TranscriptionFactorControlPanel.js @@ -30,9 +30,9 @@ define( require => { const Vector2 = require( 'DOT/Vector2' ); // constants - var DNA_SCALE = 0.1; - var DNA_MVT = ModelViewTransform2.createSinglePointScaleInvertedYMapping( new Vector2( 0, 0 ), new Vector2( 0, 0 ), DNA_SCALE ); - var TITLE_FONT = new PhetFont( { size: 16, weight: 'bold' } ); + const DNA_SCALE = 0.1; + const DNA_MVT = ModelViewTransform2.createSinglePointScaleInvertedYMapping( new Vector2( 0, 0 ), new Vector2( 0, 0 ), DNA_SCALE ); + const TITLE_FONT = new PhetFont( { size: 16, weight: 'bold' } ); // strings const negativeTranscriptionFactorHtmlString = require( 'string!GENE_EXPRESSION_ESSENTIALS/negativeTranscriptionFactorHtml' ); @@ -45,8 +45,8 @@ define( require => { * @constructor */ function TranscriptionFactorControlPanel( model, transcriptionFactorConfig, affinityProperty ) { - var titleText; - var tfLevelProperty; + let titleText; + let tfLevelProperty; if ( transcriptionFactorConfig.isPositive ) { transcriptionFactorConfig = MessengerRnaProductionModel.POSITIVE_TRANSCRIPTION_FACTOR_CONFIG; titleText = positiveTranscriptionFactorHtmlString; @@ -58,32 +58,32 @@ define( require => { tfLevelProperty = model.negativeTranscriptionFactorCountProperty; } - var titleNode = new RichText( titleText, { + const titleNode = new RichText( titleText, { font: TITLE_FONT, maxWidth: 180, align: 'center' } ); - var transcriptionFactorNode = new MobileBiomoleculeNode( + const transcriptionFactorNode = new MobileBiomoleculeNode( GEEConstants.TRANSCRIPTION_FACTOR_MVT, new TranscriptionFactor( null, transcriptionFactorConfig ) ); - var dnaFragmentNode = new DnaMoleculeNode( + const dnaFragmentNode = new DnaMoleculeNode( new DnaMolecule( null, GEEConstants.BASE_PAIRS_PER_TWIST + 1, 0.0, true ), DNA_MVT, 2, false ).toDataURLNodeSynchronous(); // turn into an image so as not to create a canvas layer - var concentrationController = new ConcentrationController( + const concentrationController = new ConcentrationController( transcriptionFactorConfig, tfLevelProperty, 0, MessengerRnaProductionModel.MAX_TRANSCRIPTION_FACTOR_COUNT ); - var affinityController = new AffinityController( transcriptionFactorNode, dnaFragmentNode, affinityProperty ); + const affinityController = new AffinityController( transcriptionFactorNode, dnaFragmentNode, affinityProperty ); - var contentNode = new VBox( { + const contentNode = new VBox( { children: [ titleNode, concentrationController, affinityController ], spacing: 10 } ); diff --git a/js/multiple-cells/MultipleCellsScreen.js b/js/multiple-cells/MultipleCellsScreen.js index 9bf9bd6e..46476e31 100644 --- a/js/multiple-cells/MultipleCellsScreen.js +++ b/js/multiple-cells/MultipleCellsScreen.js @@ -30,7 +30,7 @@ define( require => { */ function MultipleCellsScreen() { - var options = { + const options = { name: screenMultipleCellsString, backgroundColorProperty: new Property( 'black' ), homeScreenIcon: new Image( multipleCellsIcon ), diff --git a/js/multiple-cells/model/Cell.js b/js/multiple-cells/model/Cell.js index fbe9c393..60613b7f 100644 --- a/js/multiple-cells/model/Cell.js +++ b/js/multiple-cells/model/Cell.js @@ -21,17 +21,17 @@ define( require => { const ShapeChangingModelElement = require( 'GENE_EXPRESSION_ESSENTIALS/common/model/ShapeChangingModelElement' ); // Default size for a cell. - var DEFAULT_CELL_SIZE = new Dimension2( 2E-6, 0.75E-6 ); // In meters. + const DEFAULT_CELL_SIZE = new Dimension2( 2E-6, 0.75E-6 ); // In meters. // Protein level at which the cell color starts to change. This is meant to make the cell act as though the protein // being produced is florescent. - var PROTEIN_LEVEL_WHERE_COLOR_CHANGE_STARTS = 50; + const PROTEIN_LEVEL_WHERE_COLOR_CHANGE_STARTS = 50; // Protein level at which the color change (towards the florescent color) is complete. - var PROTEIN_LEVEL_WHERE_COLOR_CHANGE_COMPLETES = 150; + const PROTEIN_LEVEL_WHERE_COLOR_CHANGE_COMPLETES = 150; // Default E-Coli like shape for performance improvement and we make copy of it and rotate for different instances - var E_COLI_LLIKE_SHAPE = BioShapeUtils.createEColiLikeShape( DEFAULT_CELL_SIZE.width, DEFAULT_CELL_SIZE.height ); + const E_COLI_LLIKE_SHAPE = BioShapeUtils.createEColiLikeShape( DEFAULT_CELL_SIZE.width, DEFAULT_CELL_SIZE.height ); /** * @param {number} rotationAngle rotation for the cell in model space @@ -70,7 +70,7 @@ define( require => { * @returns {Shape} */ createShape: function( rotationAngle ) { - var eColiShape = E_COLI_LLIKE_SHAPE.copy(); + const eColiShape = E_COLI_LLIKE_SHAPE.copy(); // rotate and return return eColiShape.transformed( Matrix3.rotation2( rotationAngle ) ); }, diff --git a/js/multiple-cells/model/CellProteinSynthesisSimulator.js b/js/multiple-cells/model/CellProteinSynthesisSimulator.js index a186bd26..4675d71c 100644 --- a/js/multiple-cells/model/CellProteinSynthesisSimulator.js +++ b/js/multiple-cells/model/CellProteinSynthesisSimulator.js @@ -17,16 +17,16 @@ define( require => { const inherit = require( 'PHET_CORE/inherit' ); const Range = require( 'DOT/Range' ); - var DEFAULT_TRANSCRIPTION_FACTOR_COUNT = 2000; - var TRANSCRIPTION_FACTOR_COUNT_RANGE = new Range( DEFAULT_TRANSCRIPTION_FACTOR_COUNT / 10, DEFAULT_TRANSCRIPTION_FACTOR_COUNT * 10 ); - var DEFAULT_TF_ASSOCIATION_PROBABILITY = 2.5E-6; - var TF_ASSOCIATION_PROBABILITY_RANGE = new Range( DEFAULT_TF_ASSOCIATION_PROBABILITY / 10, DEFAULT_TF_ASSOCIATION_PROBABILITY * 10 ); - var DEFAULT_POLYMERASE_ASSOCIATION_PROBABILITY = 9.5E-7; - var POLYMERASE_ASSOCIATION_PROBABILITY_RANGE = new Range( 0.0, 2 * DEFAULT_POLYMERASE_ASSOCIATION_PROBABILITY ); - var DEFAULT_PROTEIN_DEGRADATION_RATE = 0.0004; - var PROTEIN_DEGRADATION_RANGE = new Range( DEFAULT_PROTEIN_DEGRADATION_RATE * 0.7, DEFAULT_PROTEIN_DEGRADATION_RATE * 1.3 ); - var DEFAULT_MRNA_DEGRADATION_RATE = 0.01; - var MRNA_DEGRADATION_RATE_RANGE = new Range( DEFAULT_MRNA_DEGRADATION_RATE / 1000, DEFAULT_MRNA_DEGRADATION_RATE * 1000 ); + const DEFAULT_TRANSCRIPTION_FACTOR_COUNT = 2000; + const TRANSCRIPTION_FACTOR_COUNT_RANGE = new Range( DEFAULT_TRANSCRIPTION_FACTOR_COUNT / 10, DEFAULT_TRANSCRIPTION_FACTOR_COUNT * 10 ); + const DEFAULT_TF_ASSOCIATION_PROBABILITY = 2.5E-6; + const TF_ASSOCIATION_PROBABILITY_RANGE = new Range( DEFAULT_TF_ASSOCIATION_PROBABILITY / 10, DEFAULT_TF_ASSOCIATION_PROBABILITY * 10 ); + const DEFAULT_POLYMERASE_ASSOCIATION_PROBABILITY = 9.5E-7; + const POLYMERASE_ASSOCIATION_PROBABILITY_RANGE = new Range( 0.0, 2 * DEFAULT_POLYMERASE_ASSOCIATION_PROBABILITY ); + const DEFAULT_PROTEIN_DEGRADATION_RATE = 0.0004; + const PROTEIN_DEGRADATION_RANGE = new Range( DEFAULT_PROTEIN_DEGRADATION_RATE * 0.7, DEFAULT_PROTEIN_DEGRADATION_RATE * 1.3 ); + const DEFAULT_MRNA_DEGRADATION_RATE = 0.01; + const MRNA_DEGRADATION_RATE_RANGE = new Range( DEFAULT_MRNA_DEGRADATION_RATE / 1000, DEFAULT_MRNA_DEGRADATION_RATE * 1000 ); /** * @param {number} ribosomeCount @@ -137,8 +137,8 @@ define( require => { * @public */ step: function( dt ) { - var accumulatedTime = 0.0; - var timeIncrement = -1.0; + let accumulatedTime = 0.0; + let timeIncrement = -1.0; while ( accumulatedTime < dt && timeIncrement !== 0.0 ) { timeIncrement = this.simulateOneReaction( dt - accumulatedTime ); accumulatedTime += timeIncrement; @@ -153,18 +153,18 @@ define( require => { * @private */ simulateOneReaction: function( maxTime ) { - var a = this.calculateA(); - var a0 = this.sum( a ); + const a = this.calculateA(); + const a0 = this.sum( a ); - var r1 = phet.joist.random.nextDouble(); - var r2 = phet.joist.random.nextDouble(); - var tau = ( 1 / a0 ) * Math.log( 1 / r1 ); + const r1 = phet.joist.random.nextDouble(); + const r2 = phet.joist.random.nextDouble(); + const tau = ( 1 / a0 ) * Math.log( 1 / r1 ); if ( tau > maxTime ) { return 0.0; } - var mu = 0; - var sumSoFar = a[ 0 ]; + let mu = 0; + let sumSoFar = a[ 0 ]; while ( sumSoFar < r2 * a0 ) { mu++; sumSoFar += a[ mu ]; @@ -180,8 +180,8 @@ define( require => { * @private */ sum: function( array ) { - var total = 0; - for ( var i = 0; i < array.length; i++ ) { + let total = 0; + for ( let i = 0; i < array.length; i++ ) { total += array[ i ]; } return total; @@ -192,7 +192,7 @@ define( require => { * @private */ calculateA: function() { - var h = [ + const h = [ this.objectCounts[ 0 ] * this.objectCounts[ 1 ], this.objectCounts[ 3 ], this.objectCounts[ 2 ] * this.objectCounts[ 3 ], @@ -205,7 +205,7 @@ define( require => { this.objectCounts[ 5 ] ]; - for ( var i = 0; i < h.length; i++ ) { + for ( let i = 0; i < h.length; i++ ) { h[ i ] *= this.reactionProbabilities[ i ]; } return h; diff --git a/js/multiple-cells/model/MultipleCellsModel.js b/js/multiple-cells/model/MultipleCellsModel.js index 9e6782e0..311b1496 100644 --- a/js/multiple-cells/model/MultipleCellsModel.js +++ b/js/multiple-cells/model/MultipleCellsModel.js @@ -20,11 +20,11 @@ define( require => { const Random = require( 'DOT/Random' ); // constants - var MAX_CELLS = 90; + const MAX_CELLS = 90; - var boundingShapeWidth = Cell.DefaultCellSize.width * 20; - var boundingShapeHeight = boundingShapeWidth * 0.35; - var bounds = new Bounds2( + const boundingShapeWidth = Cell.DefaultCellSize.width * 20; + const boundingShapeHeight = boundingShapeWidth * 0.35; + const bounds = new Bounds2( -boundingShapeWidth / 2, -boundingShapeHeight / 2, -boundingShapeWidth / 2 + boundingShapeWidth, @@ -32,14 +32,14 @@ define( require => { ); // Seeds for the random number generators. Values chosen empirically. - var POSITION_RANDOMIZER_SEED = 226; - var SIZE_AND_ORIENTATION_RANDOMIZER_SEED = 25214903912; + const POSITION_RANDOMIZER_SEED = 226; + const SIZE_AND_ORIENTATION_RANDOMIZER_SEED = 25214903912; /** * @constructor */ function MultipleCellsModel() { - var self = this; + const self = this; this.clockRunningProperty = new Property( true ); // @public // List of all cells that are being simulated. Some of these cells will be visible to the user at any given time, @@ -158,8 +158,8 @@ define( require => { // Update the average protein level. Note that only the visible cells are used for this calculation. This helps // convey the concept that the more cells there are, the more even the average level is. - var self = this; - var totalProteinCount = 0; + const self = this; + let totalProteinCount = 0; this.cellList.forEach( function( cell ) { cell.step( dt ); if ( self.visibleCellList.contains( cell ) ) { @@ -185,7 +185,7 @@ define( require => { // Step the model a bunch of times in order to allow it to reach a steady state. The number of times that are // needed to reach steady state was empirically determined. - for ( var i = 0; i < 1000; i++ ) { + for ( let i = 0; i < 1000; i++ ) { this.step( 0.016 ); } }, @@ -222,19 +222,19 @@ define( require => { // Loop, randomly generating positions of increasing distance from the center, until the cell is positioned in a // place that does not overlap with the existing cells. The overall bounding shape of the collection of cells is // elliptical, not circular. - for ( var i = 0; i < Math.ceil( Math.sqrt( this.cellList.length ) ); i++ ) { - var radius = ( i + 1 ) * Cell.DefaultCellSize.width * ( this.positionRandomizer.nextDouble() / 2 + .75 ); - for ( var j = 0; j < radius * Math.PI / ( Cell.DefaultCellSize.height * 2 ); j++ ) { - var angle = this.positionRandomizer.nextDouble() * 2 * Math.PI; + for ( let i = 0; i < Math.ceil( Math.sqrt( this.cellList.length ) ); i++ ) { + const radius = ( i + 1 ) * Cell.DefaultCellSize.width * ( this.positionRandomizer.nextDouble() / 2 + .75 ); + for ( let j = 0; j < radius * Math.PI / ( Cell.DefaultCellSize.height * 2 ); j++ ) { + const angle = this.positionRandomizer.nextDouble() * 2 * Math.PI; cell.positionX = radius * Math.cos( angle ); cell.positionY = radius * Math.sin( angle ); if ( !bounds.containsCoordinates( cell.positionX, cell.positionY ) ) { // Not in bounds. continue; } - var overlapDetected = false; - for ( var k = 0; k < this.cellList.length; k++ ) { - var existingCell = this.cellList[ k ]; + let overlapDetected = false; + for ( let k = 0; k < this.cellList.length; k++ ) { + const existingCell = this.cellList[ k ]; // new bounds if ( cell.bounds.shifted( cell.positionX, cell.positionY ) .intersectsBounds( existingCell.bounds.shifted( existingCell.positionX, existingCell.positionY ) ) ) { diff --git a/js/multiple-cells/view/ColorChangingCellNode.js b/js/multiple-cells/view/ColorChangingCellNode.js index 3271fa4c..f2f3ae1f 100644 --- a/js/multiple-cells/view/ColorChangingCellNode.js +++ b/js/multiple-cells/view/ColorChangingCellNode.js @@ -22,10 +22,10 @@ define( require => { const Util = require( 'DOT/Util' ); // constants - var NOMINAL_FILL_COLOR = new Color( 30, 30, 40 ); // Blue Gray - var FLORESCENT_FILL_COLOR = new Color( 200, 255, 58 ); - var STROKE = 2; - var STROKE_COLOR = Color.WHITE; + const NOMINAL_FILL_COLOR = new Color( 30, 30, 40 ); // Blue Gray + const FLORESCENT_FILL_COLOR = new Color( 200, 255, 58 ); + const STROKE = 2; + const STROKE_COLOR = Color.WHITE; /** * @param {Cell} cell @@ -35,7 +35,7 @@ define( require => { function ColorChangingCellNode( cell, modelViewTransform ) { Node.call( this ); - var cellBody = new Path( modelViewTransform.modelToViewShape( cell.getShape() ), { + const cellBody = new Path( modelViewTransform.modelToViewShape( cell.getShape() ), { fill: NOMINAL_FILL_COLOR, stroke: STROKE_COLOR, lineWidth: STROKE, @@ -44,7 +44,7 @@ define( require => { } ); cell.proteinCount.lazyLink( function( proteinCount ) { - var florescenceAmount = Util.clamp( ( proteinCount - Cell.ProteinLevelWhereColorChangeStarts ) / + const florescenceAmount = Util.clamp( ( proteinCount - Cell.ProteinLevelWhereColorChangeStarts ) / ( Cell.ProteinLevelWhereColorChangeCompletes - Cell.ProteinLevelWhereColorChangeStarts ), 0, 1.0 ); cellBody.fill = Color.interpolateRGBA( NOMINAL_FILL_COLOR, FLORESCENT_FILL_COLOR, florescenceAmount ); } ); diff --git a/js/multiple-cells/view/ControlPanelNode.js b/js/multiple-cells/view/ControlPanelNode.js index a73bb6f7..13eb6105 100644 --- a/js/multiple-cells/view/ControlPanelNode.js +++ b/js/multiple-cells/view/ControlPanelNode.js @@ -29,15 +29,15 @@ define( require => { */ function ControlPanelNode( title, controllers ) { - var controllerNodes = []; + const controllerNodes = []; - for ( var i = 0; i < controllers.length; i++ ) { - var controller = controllers[ i ]; - var label = new Text( controller.label, { + for ( let i = 0; i < controllers.length; i++ ) { + const controller = controllers[ i ]; + const label = new Text( controller.label, { font: new PhetFont( { size: 13 } ), maxWidth: 200 } ); - var controllerNode = new ControllerNode( + const controllerNode = new ControllerNode( controller.controlProperty, controller.minValue, controller.maxValue, @@ -56,7 +56,7 @@ define( require => { } ); } - var contentNode = new VBox( { + const contentNode = new VBox( { spacing: 5, children: controllerNodes } ); diff --git a/js/multiple-cells/view/FluorescentCellsPictureDialog.js b/js/multiple-cells/view/FluorescentCellsPictureDialog.js index cc94818b..102ce8d6 100644 --- a/js/multiple-cells/view/FluorescentCellsPictureDialog.js +++ b/js/multiple-cells/view/FluorescentCellsPictureDialog.js @@ -20,7 +20,7 @@ define( require => { const Text = require( 'SCENERY/nodes/Text' ); // constants - var IMAGE_WIDTH = 380; // in screen coordinates, empirically determined to look good + const IMAGE_WIDTH = 380; // in screen coordinates, empirically determined to look good // images const eColiImage = require( 'mipmap!GENE_EXPRESSION_ESSENTIALS/ecoli.jpg' ); @@ -30,14 +30,14 @@ define( require => { const imageCaptionString = require( 'string!GENE_EXPRESSION_ESSENTIALS/imageCaption' ); // constants - var TEXT_FONT = new PhetFont( 12 ); + const TEXT_FONT = new PhetFont( 12 ); /** * @constructor */ function FluorescentCellsPictureDialog() { - var imageNode = new Image( eColiImage, { + const imageNode = new Image( eColiImage, { minWidth: IMAGE_WIDTH, maxWidth: IMAGE_WIDTH } ); @@ -46,20 +46,20 @@ define( require => { // lines, but this was changed (see https://github.com/phetsims/gene-expression-essentials/issues/121) and they are // now combined. The strings have been left separate in the strings files so that translations don't need to be // modified. - var captionAndNoteNode = new RichText( imageCaptionString + ' ' + imageCaptionNoteString, { + const captionAndNoteNode = new RichText( imageCaptionString + ' ' + imageCaptionNoteString, { font: TEXT_FONT, lineWrap: IMAGE_WIDTH, centerX: imageNode.centerX, top: imageNode.bottom + 10, align: 'left' } ); - var children = [ + const children = [ imageNode, captionAndNoteNode, new Text( 'Image Copyright Dennis Kunkel Microscopy, Inc.', { font: TEXT_FONT } ) ]; - var content = new LayoutBox( { orientation: 'vertical', align: 'center', spacing: 10, children: children } ); + const content = new LayoutBox( { orientation: 'vertical', align: 'center', spacing: 10, children: children } ); Dialog.call( this, content, { topMargin: 20, diff --git a/js/multiple-cells/view/MultipleCellsScreenView.js b/js/multiple-cells/view/MultipleCellsScreenView.js index 23cbb491..440e7b07 100644 --- a/js/multiple-cells/view/MultipleCellsScreenView.js +++ b/js/multiple-cells/view/MultipleCellsScreenView.js @@ -56,7 +56,7 @@ define( require => { */ function MultipleCellsScreenView( model ) { ScreenView.call( this ); - var self = this; + const self = this; this.model = model; // Set up the model-canvas transform. The multiplier factors for the 2nd point can be adjusted to shift the center @@ -69,13 +69,13 @@ define( require => { ); // dialog constructed lazily because Dialog requires Sim bounds during construction - var dialog = null; + let dialog = null; - var buttonContent = new Text( showRealCellsString, { + const buttonContent = new Text( showRealCellsString, { font: new PhetFont( 18 ), maxWidth: 140 } ); - var showRealCellsButton = new RectangularPushButton( { + const showRealCellsButton = new RectangularPushButton( { content: buttonContent, touchAreaXDilation: 7, touchAreaYDilation: 7, @@ -99,7 +99,7 @@ define( require => { this.proteinLevelChartNode.left = showRealCellsButton.right + 10; // Add the Reset All button. - var resetAllButton = new ResetAllButton( { + const resetAllButton = new ResetAllButton( { listener: function() { model.reset(); concentrationControlPanel.expandedProperty.reset(); @@ -113,13 +113,13 @@ define( require => { this.addChild( resetAllButton ); // Add play/pause button. - var playPauseButton = new PlayPauseButton( model.clockRunningProperty, { + const playPauseButton = new PlayPauseButton( model.clockRunningProperty, { radius: 23, touchAreaDilation: 5 } ); this.addChild( playPauseButton ); - var stepButton = new StepForwardButton( { + const stepButton = new StepForwardButton( { isPlayingProperty: model.clockRunningProperty, listener: function() { model.stepInTime( 0.016 ); @@ -133,11 +133,11 @@ define( require => { playPauseButton.bottom = resetAllButton.bottom; stepButton.centerY = playPauseButton.centerY; - var cellLayer = new Node(); - var invisibleCellLayer = new Node(); // for performance improvement load all cells at start of the sim + const cellLayer = new Node(); + const invisibleCellLayer = new Node(); // for performance improvement load all cells at start of the sim this.addChild( cellLayer ); - var cellNumberController = new ControllerNode( + const cellNumberController = new ControllerNode( model.numberOfVisibleCellsProperty, 1, MultipleCellsModel.MaxCells, @@ -145,10 +145,10 @@ define( require => { manyString ); - var cellNumberControllerNode = new Node(); + const cellNumberControllerNode = new Node(); cellNumberControllerNode.addChild( cellNumberController ); - var cellNumberLabel = new Text( cellsString, { + const cellNumberLabel = new Text( cellsString, { font: new PhetFont( { size: 15, weight: 'bold' } ), maxWidth: 100 } ); @@ -157,7 +157,7 @@ define( require => { cellNumberLabel.centerX = cellNumberController.centerX; cellNumberLabel.bottom = cellNumberController.top - 5; - var cellNumberControllerPanel = new Panel( cellNumberControllerNode, { + const cellNumberControllerPanel = new Panel( cellNumberControllerNode, { cornerRadius: GEEConstants.CORNER_RADIUS, xMargin: 10, yMargin: 10, @@ -168,10 +168,10 @@ define( require => { cellNumberControllerPanel.bottom = resetAllButton.bottom; cellNumberControllerPanel.centerX = this.proteinLevelChartNode.centerX; - var cellNodes = []; + const cellNodes = []; - for ( var i = 0; i < model.cellList.length; i++ ) { - var cellNode = new ColorChangingCellNode( model.cellList[ i ], this.modelViewTransform ); + for ( let i = 0; i < model.cellList.length; i++ ) { + const cellNode = new ColorChangingCellNode( model.cellList[ i ], this.modelViewTransform ); cellNodes.push( cellNode ); invisibleCellLayer.addChild( cellNode ); } @@ -180,12 +180,12 @@ define( require => { cellLayer.addChild( cellNodes[ addedCellIndex ] ); model.visibleCellList.addItemRemovedListener( function removalListener( removedCell ) { - var removedCellIndex = model.cellList.indexOf( removedCell ); + const removedCellIndex = model.cellList.indexOf( removedCell ); if ( removedCellIndex === addedCellIndex ) { cellLayer.removeChild( cellNodes[ addedCellIndex ] ); model.visibleCellList.removeItemRemovedListener( removalListener ); cellLayer.setScaleMagnitude( 1 ); - var scaleFactor = Math.min( ( cellNumberControllerPanel.top - self.proteinLevelChartNode.bottom ) / cellLayer.height, 1 ); + const scaleFactor = Math.min( ( cellNumberControllerPanel.top - self.proteinLevelChartNode.bottom ) / cellLayer.height, 1 ); cellLayer.setScaleMagnitude( scaleFactor * 0.9 ); cellLayer.centerX = self.proteinLevelChartNode.centerX; cellLayer.centerY = self.proteinLevelChartNode.bottom + @@ -193,7 +193,7 @@ define( require => { } } ); cellLayer.setScaleMagnitude( 1 ); - var scaleFactor = Math.min( ( cellNumberControllerPanel.top - self.proteinLevelChartNode.bottom ) / cellLayer.height, 1 ); + const scaleFactor = Math.min( ( cellNumberControllerPanel.top - self.proteinLevelChartNode.bottom ) / cellLayer.height, 1 ); cellLayer.setScaleMagnitude( scaleFactor * 0.9 ); cellLayer.centerX = self.proteinLevelChartNode.centerX; cellLayer.centerY = self.proteinLevelChartNode.bottom + @@ -210,7 +210,7 @@ define( require => { addCellView( model.cellList.indexOf( cell ) ); } ); - var concentrationControllers = [ + const concentrationControllers = [ { label: positiveTranscriptionFactorString, controlProperty: model.transcriptionFactorLevelProperty, @@ -236,7 +236,7 @@ define( require => { concentrationControllers ); - var affinityControllers = [ + const affinityControllers = [ { label: positiveTranscriptionFactorString, controlProperty: model.transcriptionFactorAssociationProbabilityProperty, @@ -262,7 +262,7 @@ define( require => { affinityControllers ); - var degradationControllers = [ + const degradationControllers = [ { label: proteinString, controlProperty: model.proteinDegradationRateProperty, diff --git a/js/multiple-cells/view/ProteinLevelChartNode.js b/js/multiple-cells/view/ProteinLevelChartNode.js index 493ac05f..1431e20f 100644 --- a/js/multiple-cells/view/ProteinLevelChartNode.js +++ b/js/multiple-cells/view/ProteinLevelChartNode.js @@ -26,10 +26,10 @@ define( require => { const XYPlot = require( 'GRIDDLE/XYPlot' ); // constants - var PLOT_WIDTH = 400; - var PLOT_HEIGHT = 120; - var COLOR_KEY_WIDTH = 20; - var TIME_SPAN = 30; + const PLOT_WIDTH = 400; + const PLOT_HEIGHT = 120; + const COLOR_KEY_WIDTH = 20; + const TIME_SPAN = 30; // strings const averageProteinLevelString = require( 'string!GENE_EXPRESSION_ESSENTIALS/averageProteinLevel' ); @@ -44,11 +44,11 @@ define( require => { */ function ProteinLevelChartNode( averageProteinLevelProperty ) { - var contentNode = new Node(); + const contentNode = new Node(); this.simRunningTime = 0; this.timeOffset = 0; this.averageProteinLevelProperty = averageProteinLevelProperty; - var plot = new XYPlot( { + const plot = new XYPlot( { width: PLOT_WIDTH, height: PLOT_HEIGHT, minX: 0, @@ -78,7 +78,7 @@ define( require => { contentNode.addChild( plot ); // graph title - var titleNode = new Text( averageProteinLevelVsTimeString, { + const titleNode = new Text( averageProteinLevelVsTimeString, { font: new PhetFont( { size: 16, weight: 'bold' } ), maxWidth: PLOT_WIDTH } ); @@ -88,7 +88,7 @@ define( require => { titleNode.bottom = plot.top - 10; // x axis label - var xLabel = new Text( timeString, { + const xLabel = new Text( timeString, { font: new PhetFont( { size: 12 } ), maxWidth: PLOT_WIDTH } ); @@ -98,7 +98,7 @@ define( require => { xLabel.top = plot.bottom + 10; // y axis label - var proteinLevelColorKey = new Rectangle( plot.left, plot.top, COLOR_KEY_WIDTH, PLOT_HEIGHT, { + const proteinLevelColorKey = new Rectangle( plot.left, plot.top, COLOR_KEY_WIDTH, PLOT_HEIGHT, { fill: new LinearGradient( plot.left, plot.top, plot.left + COLOR_KEY_WIDTH, plot.top + PLOT_HEIGHT ) .addColorStop( 0, ColorChangingCellNode.FlorescentFillColor ) .addColorStop( 1, ColorChangingCellNode.NominalFillColor ), @@ -111,7 +111,7 @@ define( require => { proteinLevelColorKey.top = plot.top; proteinLevelColorKey.right = plot.left - 5; - var lotsNode = new Text( lotsString, { + const lotsNode = new Text( lotsString, { font: new PhetFont( 12 ), maxWidth: 50 } ); @@ -119,7 +119,7 @@ define( require => { lotsNode.centerY = proteinLevelColorKey.top; lotsNode.right = proteinLevelColorKey.left - 5; - var noneNode = new Text( noneString, { + const noneNode = new Text( noneString, { font: new PhetFont( 12 ), maxWidth: 50 } ); @@ -127,7 +127,7 @@ define( require => { noneNode.centerY = proteinLevelColorKey.bottom; noneNode.right = proteinLevelColorKey.left - 5; - var yLabelNode = new Text( averageProteinLevelString, { + const yLabelNode = new Text( averageProteinLevelString, { font: new PhetFont( 13 ), maxWidth: PLOT_HEIGHT + 10 } );