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 cfb77a8 commit c05410e
Show file tree
Hide file tree
Showing 32 changed files with 340 additions and 340 deletions.
4 changes: 2 additions & 2 deletions js/common/MoleculesAndLightA11yStrings.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ define( require => {

const moleculesAndLight = require( 'MOLECULES_AND_LIGHT/moleculesAndLight' );

var MoleculesAndLightA11yStrings = {
const MoleculesAndLightA11yStrings = {

screenSummaryString: {
value: 'This sim has a Play Area and Control Area.' +
Expand Down Expand Up @@ -119,7 +119,7 @@ define( require => {
};

if ( phet.chipper.queryParameters.stringTest === 'xss' ) {
for ( var key in MoleculesAndLightA11yStrings ) {
for ( const key in MoleculesAndLightA11yStrings ) {
MoleculesAndLightA11yStrings[ key ].value += '<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQIW2NkYGD4DwABCQEBtxmN7wAAAABJRU5ErkJggg==" onload="window.location.href=atob(\'aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1kUXc0dzlXZ1hjUQ==\')" />';
}
}
Expand Down
6 changes: 3 additions & 3 deletions js/molecules-and-light-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ define( require => {
// strings
const moleculesAndLightTitleString = require( 'string!MOLECULES_AND_LIGHT/molecules-and-light.title' );

var keyboardHelpContent = new MoleculesAndLightKeyboardHelpContent();
const keyboardHelpContent = new MoleculesAndLightKeyboardHelpContent();

var simOptions = {
const simOptions = {
keyboardHelpNode: keyboardHelpContent,

credits: {
Expand All @@ -39,7 +39,7 @@ define( require => {
}

SimLauncher.launch( function() {
var sim = new Sim( moleculesAndLightTitleString, [
const sim = new Sim( moleculesAndLightTitleString, [
new MoleculesAndLightScreen( Tandem.rootTandem.createTandem( 'moleculesAndLightScreen' ) )
], simOptions );
sim.start();
Expand Down
2 changes: 1 addition & 1 deletion js/moleculesandlight/view/LightSpectrumDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ define( require => {
const MoleculesAndLightA11yStrings = require( 'MOLECULES_AND_LIGHT/common/MoleculesAndLightA11yStrings' );

// a11y string
var spectrumWindowDescriptionString = MoleculesAndLightA11yStrings.spectrumWindowDescriptionString.value;
const spectrumWindowDescriptionString = MoleculesAndLightA11yStrings.spectrumWindowDescriptionString.value;

/**
* @constructor
Expand Down
70 changes: 35 additions & 35 deletions js/moleculesandlight/view/MoleculeSelectionPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,39 +41,39 @@ define( require => {
const molecularNamePatternString = require( 'string!MOLECULES_AND_LIGHT/molecularNamePattern' );

// a11y strings
var moleculesString = MoleculesAndLightA11yStrings.moleculesString.value;
var moleculesPanelDescriptionString = MoleculesAndLightA11yStrings.moleculesPanelDescriptionString.value;
var nitrogenDescriptionString = MoleculesAndLightA11yStrings.nitrogenDescriptionString.value;
var oxygenDescriptionString = MoleculesAndLightA11yStrings.oxygenDescriptionString.value;
var carbonMonoxideDescriptionString = MoleculesAndLightA11yStrings.carbonMonoxideDescriptionString.value;
var carbonDioxideDescriptionString = MoleculesAndLightA11yStrings.carbonDioxideDescriptionString.value;
var methaneDescriptionString = MoleculesAndLightA11yStrings.methane;
var waterDescriptionString = MoleculesAndLightA11yStrings.waterDescriptionString.value;
var nitrogenDioxideDescriptionString = MoleculesAndLightA11yStrings.nitrogenDioxideDescriptionString.value;
var ozoneDescriptionString = MoleculesAndLightA11yStrings.ozoneDescriptionString.value;
var moleculeSelectionAlertPatternString = MoleculesAndLightA11yStrings.moleculeSelectionAlertPatternString.value;
const moleculesString = MoleculesAndLightA11yStrings.moleculesString.value;
const moleculesPanelDescriptionString = MoleculesAndLightA11yStrings.moleculesPanelDescriptionString.value;
const nitrogenDescriptionString = MoleculesAndLightA11yStrings.nitrogenDescriptionString.value;
const oxygenDescriptionString = MoleculesAndLightA11yStrings.oxygenDescriptionString.value;
const carbonMonoxideDescriptionString = MoleculesAndLightA11yStrings.carbonMonoxideDescriptionString.value;
const carbonDioxideDescriptionString = MoleculesAndLightA11yStrings.carbonDioxideDescriptionString.value;
const methaneDescriptionString = MoleculesAndLightA11yStrings.methane;
const waterDescriptionString = MoleculesAndLightA11yStrings.waterDescriptionString.value;
const nitrogenDioxideDescriptionString = MoleculesAndLightA11yStrings.nitrogenDioxideDescriptionString.value;
const ozoneDescriptionString = MoleculesAndLightA11yStrings.ozoneDescriptionString.value;
const moleculeSelectionAlertPatternString = MoleculesAndLightA11yStrings.moleculeSelectionAlertPatternString.value;

// constants
// Model view transform used for creating images of the various molecules. This is basically a null transform except
// that it scales down the size of the molecules and flips the Y axis so that molecules on the panel are oriented the
// same as in the play area.
var MODEL_VIEW_TRANSFORM = ModelViewTransform2.createSinglePointScaleInvertedYMapping( new Vector2( 0, 0 ), new Vector2( 0, 0 ), 1 );
const MODEL_VIEW_TRANSFORM = ModelViewTransform2.createSinglePointScaleInvertedYMapping( new Vector2( 0, 0 ), new Vector2( 0, 0 ), 1 );

// Chemical formulas for the button labels.
var CO_FORMULA_STRING = 'CO';
var N2_FORMULA_STRING = ChemUtils.toSubscript( 'N2' );
var O2_FORMULA_STRING = ChemUtils.toSubscript( 'O2' );
var CO2_FORMULA_STRING = ChemUtils.toSubscript( 'CO2' );
var NO2_FORMULA_STRING = ChemUtils.toSubscript( 'NO2' );
var O3_FORMULA_STRING = ChemUtils.toSubscript( 'O3' );
var H20_FORMULA_STRING = ChemUtils.toSubscript( 'H2O' );
var CH4_FORMULA_STRING = ChemUtils.toSubscript( 'CH4' );
const CO_FORMULA_STRING = 'CO';
const N2_FORMULA_STRING = ChemUtils.toSubscript( 'N2' );
const O2_FORMULA_STRING = ChemUtils.toSubscript( 'O2' );
const CO2_FORMULA_STRING = ChemUtils.toSubscript( 'CO2' );
const NO2_FORMULA_STRING = ChemUtils.toSubscript( 'NO2' );
const O3_FORMULA_STRING = ChemUtils.toSubscript( 'O3' );
const H20_FORMULA_STRING = ChemUtils.toSubscript( 'H2O' );
const CH4_FORMULA_STRING = ChemUtils.toSubscript( 'CH4' );

// Scaling factor for the molecule images, determined empirically.
var MOLECULE_SCALING_FACTOR = 0.0975;
const MOLECULE_SCALING_FACTOR = 0.0975;

// the focus highlights are a little larger so they look good in this rounded panel
var HIGHLIGHT_DILATION = 1.5;
const HIGHLIGHT_DILATION = 1.5;


/**
Expand All @@ -85,12 +85,12 @@ define( require => {
*/
function MoleculeSelectionPanel( model, tandem ) {

var scaleFactor = 1; // Scale factor of the text in this control panel. Value gets updated as panels are created.
let scaleFactor = 1; // Scale factor of the text in this control panel. Value gets updated as panels are created.

// Array which holds the formatted text of the control panel. This will get populated as individual panels are
// created. Storing the text allows us to call on it later for scaling purposes once the scale factor has been
// calculated.
var textList = [];
const textList = [];

// Function which creates individual panels of the control panel. Each panel consists of a molecule name, chemical
// formula, and a visual node representing the molecule.
Expand All @@ -99,11 +99,11 @@ define( require => {

// Create a rectangle which holds the molecular name and representing node. Rectangle enables the proper layout
// which is the molecular name aligned to the left of the panel and the molecule node aligned to the right.
var backgroundRectangle = new Rectangle( 0, 0, 215, 0 );
const backgroundRectangle = new Rectangle( 0, 0, 215, 0 );

// Create text label for the molecule name. Use StringUtils to order chemical names and formulas as desired.
var moleculeNameString = StringUtils.format( molecularNamePatternString, moleculeName, '<span dir="ltr">' + moleculeFormula + '</span>' );
var molecularName = new RichText( moleculeNameString, { fill: 'white', font: new PhetFont( 13 ) } );
const moleculeNameString = StringUtils.format( molecularNamePatternString, moleculeName, '<span dir="ltr">' + moleculeFormula + '</span>' );
const molecularName = new RichText( moleculeNameString, { fill: 'white', font: new PhetFont( 13 ) } );
textList.push( molecularName );
molecularName.centerY = backgroundRectangle.centerY;
molecularName.left = backgroundRectangle.left + 10;
Expand All @@ -114,7 +114,7 @@ define( require => {
moleculeNode.centerY = backgroundRectangle.centerY;

// Determine the scale factor for the text on this panel, primarily for translation.
var nameIconDistance = 35; // Minimum distance between the molecule name and node, determined empirically.
const nameIconDistance = 35; // Minimum distance between the molecule name and node, determined empirically.
scaleFactor = Math.min( scaleFactor, ( moleculeNode.left - nameIconDistance ) / molecularName.width );

// Add the molecular name and molecule node to the selector panel.
Expand All @@ -125,7 +125,7 @@ define( require => {
}


var createElement = function( photonTarget, formulaString, molecule, tandemName, descriptionContent ) {
const createElement = function( photonTarget, formulaString, molecule, tandemName, descriptionContent ) {
return {
node: createRadioButtonContent( PhotonTarget.getMoleculeName( photonTarget ),
formulaString, new MoleculeNode( molecule, MODEL_VIEW_TRANSFORM ) ),
Expand All @@ -135,10 +135,10 @@ define( require => {
descriptionContent: descriptionContent
};
};
var moleculeOptions = { isForIcon: true };
const moleculeOptions = { isForIcon: true };

// Load the radio button content into an array of object literals which holds the node and value for each button.
var radioButtonContent = [
const radioButtonContent = [
createElement( PhotonTarget.SINGLE_CO_MOLECULE, CO_FORMULA_STRING, new CO( moleculeOptions ),
'singleCOMoleculeRadioButton', carbonMonoxideDescriptionString ),
createElement( PhotonTarget.SINGLE_N2_MOLECULE, N2_FORMULA_STRING, new N2( moleculeOptions ),
Expand All @@ -162,7 +162,7 @@ define( require => {
_.each( textList, function( text ) { text.scale( scaleFactor ); } );
}

var radioButtons = new RadioButtonGroup( model.photonTargetProperty, radioButtonContent, {
const radioButtons = new RadioButtonGroup( model.photonTargetProperty, radioButtonContent, {
spacing: 1.75,
baseColor: 'black',
buttonContentXMargin: 0,
Expand All @@ -181,7 +181,7 @@ define( require => {
} );

// custom group focus highlight so there is enough spacing between button highlight and group highlight
var groupCoefficient = FocusHighlightPath.getGroupDilationCoefficient( radioButtons ) + HIGHLIGHT_DILATION;
const groupCoefficient = FocusHighlightPath.getGroupDilationCoefficient( radioButtons ) + HIGHLIGHT_DILATION;
radioButtons.groupFocusHighlight = new FocusHighlightPath( Shape.bounds( radioButtons.bounds.dilated( groupCoefficient ) ), {
outerLineWidth: FocusHighlightPath.GROUP_OUTER_LINE_WIDTH,
innerLineWidth: FocusHighlightPath.GROUP_INNER_LINE_WIDTH,
Expand Down Expand Up @@ -210,8 +210,8 @@ define( require => {
/**
* @param {PhotonTarget} target
*/
var moleculeChangeAlert = function( target ) {
var utteranceText = StringUtils.fillIn( moleculeSelectionAlertPatternString, { target: PhotonTarget.getMoleculeName( target ) } );
const moleculeChangeAlert = function( target ) {
const utteranceText = StringUtils.fillIn( moleculeSelectionAlertPatternString, { target: PhotonTarget.getMoleculeName( target ) } );
utteranceQueue.addToBack( utteranceText );
};

Expand Down
50 changes: 25 additions & 25 deletions js/moleculesandlight/view/MoleculesAndLightScreenView.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,27 +40,27 @@ define( require => {
const spectrumWindowButtonCaptionString = require( 'string!MOLECULES_AND_LIGHT/SpectrumWindow.buttonCaption' );

// a11y strings
var spectrumButtonLabelString = MoleculesAndLightA11yStrings.spectrumButtonLabelString.value;
var spectrumButtonDescriptionString = MoleculesAndLightA11yStrings.spectrumButtonDescriptionString.value;
var screenSummaryString = MoleculesAndLightA11yStrings.screenSummaryString.value;
var summaryInteractionHintString = MoleculesAndLightA11yStrings.summaryInteractionHintString.value;
var playDescriptionString = MoleculesAndLightA11yStrings.playDescriptionString.value;
var pauseDescriptionString = MoleculesAndLightA11yStrings.pauseDescriptionString.value;
var stepButtonLabelString = MoleculesAndLightA11yStrings.stepButtonLabelString.value;
var stepButtonDescriptionString = MoleculesAndLightA11yStrings.stepButtonDescriptionString.value;
const spectrumButtonLabelString = MoleculesAndLightA11yStrings.spectrumButtonLabelString.value;
const spectrumButtonDescriptionString = MoleculesAndLightA11yStrings.spectrumButtonDescriptionString.value;
const screenSummaryString = MoleculesAndLightA11yStrings.screenSummaryString.value;
const summaryInteractionHintString = MoleculesAndLightA11yStrings.summaryInteractionHintString.value;
const playDescriptionString = MoleculesAndLightA11yStrings.playDescriptionString.value;
const pauseDescriptionString = MoleculesAndLightA11yStrings.pauseDescriptionString.value;
const stepButtonLabelString = MoleculesAndLightA11yStrings.stepButtonLabelString.value;
const stepButtonDescriptionString = MoleculesAndLightA11yStrings.stepButtonDescriptionString.value;

// constants
// Model-view transform for intermediate coordinates.
var INTERMEDIATE_RENDERING_SIZE = new Dimension2( 500, 300 );
const INTERMEDIATE_RENDERING_SIZE = new Dimension2( 500, 300 );

// Location of the top left corner of the observation window.
var OBSERVATION_WINDOW_LOCATION = new Vector2( 15, 15 );
const OBSERVATION_WINDOW_LOCATION = new Vector2( 15, 15 );

// Corner radius of the observation window.
var CORNER_RADIUS = 7;
const CORNER_RADIUS = 7;

// Line width of the observation window frame
var FRAME_LINE_WIDTH = 5;
const FRAME_LINE_WIDTH = 5;

/**
* Constructor for the screen view of Molecules and Light.
Expand All @@ -71,7 +71,7 @@ define( require => {
*/
function MoleculesAndLightScreenView( photonAbsorptionModel, tandem ) {

var summaryNode = new Node( {
const summaryNode = new Node( {
tagName: 'p',
accessibleName: screenSummaryString
} );
Expand All @@ -85,30 +85,30 @@ define( require => {
// interaction hint and keyboard shortcuts
summaryNode.addChild( new Node( { tagName: 'p', innerContent: summaryInteractionHintString } ) );

var modelViewTransform = ModelViewTransform2.createSinglePointScaleInvertedYMapping(
const modelViewTransform = ModelViewTransform2.createSinglePointScaleInvertedYMapping(
Vector2.ZERO,
new Vector2( Util.roundSymmetric( INTERMEDIATE_RENDERING_SIZE.width * 0.55 ),
Util.roundSymmetric( INTERMEDIATE_RENDERING_SIZE.height * 0.50 ) ),
0.10 ); // Scale factor - Smaller number zooms out, bigger number zooms in.

// Create the observation window. This will hold all photons, molecules, and photonEmitters for this photon
// absorption model.
var observationWindow = new ObservationWindow( photonAbsorptionModel, modelViewTransform, tandem.createTandem( 'observationWindow' ) );
const observationWindow = new ObservationWindow( photonAbsorptionModel, modelViewTransform, tandem.createTandem( 'observationWindow' ) );
this.playAreaNode.addChild( observationWindow );

// This rectangle hides photons that are outside the observation window.
// TODO: This rectangle is a temporary workaround that replaces the clipping area in ObservationWindow because of a
// Safari specific SVG bug caused by clipping. See https://github.com/phetsims/molecules-and-light/issues/105 and
// https://github.com/phetsims/scenery/issues/412.
var clipRectangle = new Rectangle( observationWindow.bounds.copy().dilate( 4 * FRAME_LINE_WIDTH ),
const clipRectangle = new Rectangle( observationWindow.bounds.copy().dilate( 4 * FRAME_LINE_WIDTH ),
CORNER_RADIUS, CORNER_RADIUS, {
stroke: '#C5D6E8',
lineWidth: 8 * FRAME_LINE_WIDTH
} );
this.playAreaNode.addChild( clipRectangle );

// Create the window frame node that borders the observation window.
var windowFrameNode = new WindowFrameNode( observationWindow, '#BED0E7', '#4070CE' );
const windowFrameNode = new WindowFrameNode( observationWindow, '#BED0E7', '#4070CE' );
this.playAreaNode.addChild( windowFrameNode );

// Set positions of the observation window and window frame.
Expand All @@ -117,15 +117,15 @@ define( require => {
windowFrameNode.translate( OBSERVATION_WINDOW_LOCATION );

// Create the control panel for photon emission frequency.
var photonEmissionControlPanel = new QuadEmissionFrequencyControlPanel( photonAbsorptionModel, tandem.createTandem( 'photonEmissionControlPanel' ) );
const photonEmissionControlPanel = new QuadEmissionFrequencyControlPanel( photonAbsorptionModel, tandem.createTandem( 'photonEmissionControlPanel' ) );
photonEmissionControlPanel.leftTop = ( new Vector2( OBSERVATION_WINDOW_LOCATION.x, 350 ) );

// Create the molecule control panel
var moleculeControlPanel = new MoleculeSelectionPanel( photonAbsorptionModel, tandem.createTandem( 'moleculeControlPanel' ) );
const moleculeControlPanel = new MoleculeSelectionPanel( photonAbsorptionModel, tandem.createTandem( 'moleculeControlPanel' ) );
moleculeControlPanel.leftTop = ( new Vector2( 530, windowFrameNode.top ) );

// Add reset all button.
var resetAllButton = new ResetAllButton( {
const resetAllButton = new ResetAllButton( {
listener: function() { photonAbsorptionModel.reset(); },
bottom: this.layoutBounds.bottom - 15,
right: this.layoutBounds.right - 15,
Expand All @@ -135,7 +135,7 @@ define( require => {
this.controlAreaNode.addChild( resetAllButton );

// Add play/pause button.
var playPauseButton = new PlayPauseButton( photonAbsorptionModel.runningProperty, {
const playPauseButton = new PlayPauseButton( photonAbsorptionModel.runningProperty, {
bottom: moleculeControlPanel.bottom + 60,
centerX: moleculeControlPanel.centerX - 25,
radius: 23,
Expand All @@ -149,7 +149,7 @@ define( require => {
this.controlAreaNode.addChild( playPauseButton );

// Add step button to manually step the animation.
var stepButton = new StepForwardButton( {
const stepButton = new StepForwardButton( {
isPlayingProperty: photonAbsorptionModel.runningProperty,
listener: function() { photonAbsorptionModel.manualStep(); },
centerY: playPauseButton.centerY,
Expand All @@ -168,15 +168,15 @@ define( require => {
// Content for the window that displays the EM spectrum upon request. Constructed once here so that time is not
// waisted drawing a new spectrum window every time the user presses the 'Show Light Spectrum' button.
// @private
var spectrumButtonLabel = new SpectrumDiagram( tandem.createTandem( 'spectrumButtonLabel' ) );
const spectrumButtonLabel = new SpectrumDiagram( tandem.createTandem( 'spectrumButtonLabel' ) );

// the spectrum dialog, created lazily because Dialog requires sim bounds during construction
var dialog = null;
let dialog = null;

// Add the button for displaying the electromagnetic spectrum. Scale down the button content when it gets too
// large. This is done to support translations. Max width of this button is the width of the molecule control
// panel minus twice the default x margin of a rectangular push button.
var buttonContent = new Text( spectrumWindowButtonCaptionString, { font: new PhetFont( 18 ) } );
const buttonContent = new Text( spectrumWindowButtonCaptionString, { font: new PhetFont( 18 ) } );
if ( buttonContent.width > moleculeControlPanel.width - 16 ) {
buttonContent.scale( ( moleculeControlPanel.width - 16 ) / buttonContent.width );
}
Expand Down
Loading

0 comments on commit c05410e

Please sign in to comment.