Skip to content

Commit

Permalink
var -> const using eslint auto fix, phetsims/tasks#1012
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Sep 19, 2019
1 parent 86fd61a commit d8b5ed3
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 35 deletions.
8 changes: 4 additions & 4 deletions js/function-builder-basics-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ define( require => {
const functionBuilderBasicsTitleString = require( 'string!FUNCTION_BUILDER_BASICS/function-builder-basics.title' );

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

var options = {
const options = {
credits: {
leadDesign: 'Amanda McGarry',
softwareDevelopment: 'Chris Malley (PixelZoom, Inc.)',
Expand All @@ -35,7 +35,7 @@ define( require => {

SimLauncher.launch( function() {

var screens = [
const screens = [
new PatternsScreen( tandem.createTandem( 'patternsScreen' ) ),
new FBBMysteryScreen( tandem.createTandem( 'mysteryScreen' ) )
];
Expand All @@ -44,7 +44,7 @@ define( require => {
screens.push( new TestScreen() );
}

var sim = new Sim( functionBuilderBasicsTitleString, screens, options );
const sim = new Sim( functionBuilderBasicsTitleString, screens, options );
sim.start();
} );
} );
2 changes: 1 addition & 1 deletion js/mystery/FBBMysteryScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ define( require => {
*/
function FBBMysteryScreen( tandem ) {

var options = {
const options = {
name: screenMysteryString,
backgroundColorProperty: new Property( FBColors.MYSTERY_SCREEN_BACKGROUND ),
homeScreenIcon: FBIconFactory.createMysteryScreenIcon( {
Expand Down
2 changes: 1 addition & 1 deletion js/mystery/model/FBBMysteryChallenges.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ define( require => {
const Shrink = require( 'FUNCTION_BUILDER/patterns/model/functions/Shrink' );
const Warhol = require( 'FUNCTION_BUILDER/patterns/model/functions/Warhol' );

var FBBMysteryChallenges = {
const FBBMysteryChallenges = {

// Index of the challenge in each pool that is display on startup and reset.
// This provides a reproducible challenge for the teacher.
Expand Down
20 changes: 10 additions & 10 deletions js/mystery/model/FBBMysteryScene.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ define( require => {

// limit scope of for-loop var using IIFE
(function() {
for ( var i = 0; i < challengePool.length; i++ ) {
for ( let i = 0; i < challengePool.length; i++ ) {

var challenge = challengePool[ i ]; // {ImageFunction[]}
const challenge = challengePool[ i ]; // {ImageFunction[]}

// validate challenge
assert && assert( challenge.length === options.numberOfSlots,
Expand All @@ -96,7 +96,7 @@ define( require => {
this.availableChallenges.splice( MysteryChallenges.DEFAULT_CHALLENGE_INDEX, 1 ); // remove the default challenge

// {HTMLImageElement[]} images for the input cards, in the order that they appear in the carousel
var cardContent = [
const cardContent = [
feetImage,
snowflakeImage,
butterflyImage,
Expand All @@ -112,7 +112,7 @@ define( require => {
];

// {FunctionCreator[]} function creators, in the order that functions appear in the carousel.
var functionCreators = [
const functionCreators = [
new FunctionCreator( Mirror ),
new FunctionCreator( Rotate90 ),
new FunctionCreator( Grayscale ),
Expand All @@ -124,9 +124,9 @@ define( require => {
new FunctionCreator( Warhol )
];

var builderWidth = Scene.computeBuilderWidth( options.numberOfSlots );
var builderX = ( FBConstants.SCREEN_VIEW_LAYOUT_BOUNDS.width / 2 ) - ( builderWidth / 2 );
var builder = new Builder( {
const builderWidth = Scene.computeBuilderWidth( options.numberOfSlots );
const builderX = ( FBConstants.SCREEN_VIEW_LAYOUT_BOUNDS.width / 2 ) - ( builderWidth / 2 );
const builder = new Builder( {
numberOfSlots: options.numberOfSlots,
width: builderWidth,
location: new Vector2( builderX, FBConstants.BUILDER_Y )
Expand Down Expand Up @@ -178,16 +178,16 @@ define( require => {

// remove the current challenge, so we don't select it twice in a row
if ( !FBQueryParameters.playAll ) {
var currentChallengeIndex = this.availableChallenges.indexOf( this.challengeProperty.get() );
const currentChallengeIndex = this.availableChallenges.indexOf( this.challengeProperty.get() );
this.availableChallenges.splice( currentChallengeIndex, 1 );
assert && assert( this.availableChallenges.length === this.challengePool.length - 1 );
}
}

// randomly select a challenge from the available pool
var challengeIndex = FBQueryParameters.playAll ? 0 : phet.joist.random.nextInt( this.availableChallenges.length );
const challengeIndex = FBQueryParameters.playAll ? 0 : phet.joist.random.nextInt( this.availableChallenges.length );
assert && assert( challengeIndex >= 0 && challengeIndex < this.availableChallenges.length );
var challenge = this.availableChallenges[ challengeIndex ];
const challenge = this.availableChallenges[ challengeIndex ];

// remove the challenge from the available pool
this.availableChallenges.splice( challengeIndex, 1 );
Expand Down
38 changes: 19 additions & 19 deletions js/mystery/view/FBBMysterySceneNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ define( require => {
const Text = require( 'SCENERY/nodes/Text' );

// constants
var QUESTION_MARK_COLORS = [ 'red', 'rgb( 0, 170, 255 )', 'green', 'orange', 'magenta' ];
const QUESTION_MARK_COLORS = [ 'red', 'rgb( 0, 170, 255 )', 'green', 'orange', 'magenta' ];

/**
* @param {MysteryScene} scene - model for this scene
Expand All @@ -52,7 +52,7 @@ define( require => {

}, options );

var self = this;
const self = this;

SceneNode.call( this, scene, layoutBounds, FBBMysteryFunctionNode, options );

Expand All @@ -64,24 +64,24 @@ define( require => {
// create a closure for slotNumber using an IIFE
(function() {

var slotNumber = i;
const slotNumber = i;

// Property associated with the slot
var revealProperty = new BooleanProperty( false );
const revealProperty = new BooleanProperty( false );
self.revealProperties.push( revealProperty );

// wire up Property to control the function that's in the slot
// unlink unnecessary, instances exist for lifetime of the sim
revealProperty.link( function( reveal ) {
var functionNode = self.builderNode.getFunctionNode( slotNumber );
const functionNode = self.builderNode.getFunctionNode( slotNumber );
if ( functionNode ) {
functionNode.identityVisibleProperty.set( reveal );
}
} );

// button below the slot
var slotLocation = scene.builder.slots[ slotNumber ].location;
var revealButton = new EyeToggleButton( revealProperty, {
const slotLocation = scene.builder.slots[ slotNumber ].location;
const revealButton = new EyeToggleButton( revealProperty, {
baseColor: FBColors.HIDDEN_FUNCTION,
scale: 0.75,
centerX: slotLocation.x,
Expand All @@ -97,7 +97,7 @@ define( require => {
}

// button for generating a new challenge
var generateButton = new RefreshButton( {
const generateButton = new RefreshButton( {
listener: function() { scene.nextChallenge(); },
xMargin: 18,
yMargin: 10,
Expand Down Expand Up @@ -165,7 +165,7 @@ define( require => {
* @override
*/
createCardContainers: function( scene, containerOptions ) {
var containers = [];
const containers = [];
scene.cardContent.forEach( function( cardImage ) {
containers.push( new CardContainer( ImageCard, ImageCardNode, cardImage, containerOptions ) );
} );
Expand Down Expand Up @@ -219,17 +219,17 @@ define( require => {
this.resetFunctions();
this.resetCards();

var functionConstructors = this.scene.challengeProperty.get(); // {constructor[]}
const functionConstructors = this.scene.challengeProperty.get(); // {constructor[]}

var questionMarkColors = this.getQuestionMarkColors( this.scene.builder.numberOfSlots );
const questionMarkColors = this.getQuestionMarkColors( this.scene.builder.numberOfSlots );

// transfer functions from carousel to builder, configured to match the challenge
var slotNumber = 0;
var answerText = '';
for ( var i = 0; i < functionConstructors.length; i++ ) {
let slotNumber = 0;
let answerText = '';
for ( let i = 0; i < functionConstructors.length; i++ ) {

// get a function node from the carousel
var functionNode = this.getFunctionNode( functionConstructors[ i ] );
const functionNode = this.getFunctionNode( functionConstructors[ i ] );

// change the color of its question mark
functionNode.setQuestionMarkColor( questionMarkColors[ i ] );
Expand Down Expand Up @@ -269,8 +269,8 @@ define( require => {
getFunctionNode: function( functionConstructor ) {

// get the container that has functions of the specified type
var functionContainer = null;
for ( var i = 0; i < this.functionContainers.length && !functionContainer; i++ ) {
let functionContainer = null;
for ( let i = 0; i < this.functionContainers.length && !functionContainer; i++ ) {
if ( this.functionContainers[ i ].getFunctionConstructor() === functionConstructor ) {
functionContainer = this.functionContainers[ i ];
}
Expand All @@ -291,11 +291,11 @@ define( require => {

assert && assert( numberOfColors <= QUESTION_MARK_COLORS.length );

var colors = [];
const colors = [];
while ( colors.length < numberOfColors ) {

// remove first color from the pool
var color = this.questionMarkColors[ 0 ];
const color = this.questionMarkColors[ 0 ];
this.questionMarkColors.splice( 0, 1 );

// prevent duplicate colors
Expand Down

0 comments on commit d8b5ed3

Please sign in to comment.