<commit_before>define([
    'uijet_dir/uijet',
    'resources'
], function (uijet, resources) {

    uijet.Adapter('TimelineChart', {
        set : function (legend_item_models) {
            var updated_models = legend_item_models.map(function (legend_item) {
                var muni = legend_item.get('muni'),
                    muni_id = muni.id,
                    nodes = legend_item.get('nodes'),
                    title = legend_item.get('title'),
                    type = legend_item.get('amount_type'),
                    color = legend_item.get('color'),
                    muni_name = muni.get('name'),
                    model = this.resource.get(legend_item.cid),
                    now = Date.now();

                if ( model ) {
                    model.set({
                        muni_id     : muni_id,
                        nodes       : nodes,
                        title       : title,
                        muni        : muni_name,
                        amount_type : type,
                        color       : color
                    });
                    if ( model.hasChanged() ) {
                        model.set({ updated : now });
                    }
                }
                else {
                    model = new resources.TimeSeriesModel({
                        id          : legend_item.id,
                        muni_id     : muni_id,
                        nodes       : nodes,
                        title       : title,
                        muni        : muni_name,
                        amount_type : type,
                        color       : color,
                        updated     : now
                    });
                }
                return model;
            }, this);

            return this.resource.set(updated_models)
                .fetch()
                .then(function () {
                    return uijet.Resource('NodesListState').get('normalize_by') && this.resource.recalcFactors();
                }.bind(this));
        }
    });

});
<commit_msg>Refactoring getters<commit_after>define([
    'uijet_dir/uijet',
    'resources'
], function (uijet, resources) {

    uijet.Adapter('TimelineChart', {
        set : function (legend_item_models) {
            var updated_models = legend_item_models.map(function (legend_item) {
                var attrs = legend_item.attributes,
                    muni = attrs.muni,
                    muni_id = muni.id,
                    nodes = attrs.nodes,
                    title = attrs.title,
                    type = attrs.amount_type,
                    color = attrs.color,
                    muni_name = muni.get('name'),
                    model = this.resource.get(legend_item.cid),
                    now = Date.now();

                if ( model ) {
                    model.set({
                        muni_id     : muni_id,
                        nodes       : nodes,
                        title       : title,
                        muni        : muni_name,
                        amount_type : type,
                        color       : color
                    });
                    if ( model.hasChanged() ) {
                        model.set({ updated : now });
                    }
                }
                else {
                    model = new resources.TimeSeriesModel({
                        id          : legend_item.id,
                        muni_id     : muni_id,
                        nodes       : nodes,
                        title       : title,
                        muni        : muni_name,
                        amount_type : type,
                        color       : color,
                        updated     : now
                    });
                }
                return model;
            }, this);

            return this.resource.set(updated_models)
                .fetch()
                .then(function () {
                    return uijet.Resource('NodesListState').get('normalize_by') && this.resource.recalcFactors();
                }.bind(this));
        }
    });

});
<|endoftext|>


<commit_before>renderer = {
  add_build: function(build) {
    var self = this;
    row = self.create_build_row( build );

    row[row.length-1].addClass( 'divide' );

    $.each( row, function(i,r) {
      $( '#builds' ).append( row[i] );
    } );

    if ( self.lastSuccessfulBuild && ( self.lastSuccessfulBuild.number == build.number ) ) {
      $( '#latest-stable' ).append( row[0].clone() );
    }

  },

  add_matrix_build: function(build, ignored) {
    var self = this;

    column = $( '.build-summary.build-' + build.number ).find( 'td.1_6_0' );
    column.removeClass( 'matrix-unknown' );

    if ( build.result == 'SUCCESS' ) {
      column.addClass( 'matrix-success' );
      column.append(
        $( 'Passed' )
      );
    } else if ( build.result == 'FAILURE' ) {
      column.addClass( 'matrix-failure' );
      column.append(
        $( 'Failed' )
      );
    }  else if ( build.result == 'ABORTED' ) {
      column.addClass( 'matrix-aborted' );
      column.append(
        $( 'Aborted' )
      );
    }  else if ( build.building ) {
      column.addClass( 'matrix-building' );
      column.append(
        $( 'Building' )
      );
    }

    var duration;

    if ( build.building ) {
      duration = new Date() - new Date( build.timestamp );
    } else {
      duration = build.duration;
    }

    duration = Math.floor( duration / ( 60 * 1000 ) );

    column.append( ': ' + duration + ' min' );

    self.populate_artifacts( build );

    row = $( '.build-' + build.number );

    if ( row.find( '.matrix' ).size() == row.find( '.matrix-success' ).size() ) {
      row.addClass( 'build-success' );
    }
    if ( row.find( '.matrix-failure' ).size() > 0 ) {
      row.addClass( 'build-failure' );
    }
    if ( row.find( '.matrix' ).size() == row.find( '.matrix-aborted' ).size() ) {
      row.addClass( 'build-aborted' );
      row.find( 'td *' ).hide();
      row.find( 'td .number' ).show();
      row.find( 'td .number a' ).show();
      $( '.build-' + build.number + '.build-details td *' ).hide();
    }

  },

  populate_artifacts: function(build) {
      var self = this;

      if ( build.result != 'SUCCESS' ) {
          return;
      }

      // Docs

      $( '.build-summary.build-' + build.number ).find( 'td.docs' ).
          append('Browse API');
  },

  format_size: function(val) {
      return Math.round(val/1024/1024) + " mb";
  },

  create_build_row: function(build) {
    var self = this;
    row = $( '
' ).append(
            $( '' ).append(
              $( '' + build.number + '' ),
              $( '' + self.build_date( build ) + " " + self.build_time( build ) + '' )
            ),
            $( '' ),
            $( '' ),
            $( '' )
          );

    if ( self.build_sha1( build ) ) {
      var sha = self.build_sha1(build)
      row.find( '.git').append(self.build_sha1_short(build) + ': ',
          $( 'Commits' ),
          " / ",
          $( 'Tree' ))
    }

    details_row = $( '
' ).append(
      $( '' )
    );

    if ( build.result == 'FAILURE' ) {
      if ( build.culprits.length > 0 ) {
        names = $.map( build.culprits, function(each,i) {
          return each.fullName;
        } );
        details_row.find( 'td' ).append( "Possible culprits: " + names.join( ', ' ) );
      }
    }

    if ( build.building ) {
      row.addClass( 'build-building' );
      details_row.addClass( 'build-building' );
      $('#build-currently-building').append( $( 'A build is currently in progress.' ) );
    }

    return [ row, details_row ];
  },

  build_date: function(build) {
     date = new Date( build.timestamp );
     return date.format( "dd mmmm yyyy" );
  },

  build_time: function(build) {
     date = new Date( build.timestamp );
     return date.format( "HH:MM" ) + ' US Eastern';
  },

  build_sha1: function(build) {
    if ( build.actions && build.actions.length >= 3 && build.actions[2].lastBuiltRevision ) {
      return build.actions[2].lastBuiltRevision.SHA1;
    }
    return null;
  },

  build_sha1_short: function(build) {
    if ( build.actions && build.actions.length >= 3 ) {
      return build.actions[2].lastBuiltRevision.SHA1.substring(0,8);
    }
    return null;
  },

  locate_artifact: function(build, filename) {
    result = null;
    var filename_regexp = new RegExp( filename );
    $.each( build.artifacts, function(i, artifact) {
      if ( artifact.relativePath.match( filename_regexp )  ) {
        result = artifact;
        return false;
      }
    } );
    return result;
  }

};

j = new Jenkins( renderer, 'http://projectodd.ci.cloudbees.com', 'immutant2-incremental',
                 [['', '1_6_0']] );
<commit_msg>Restore git links to 2x builds.<commit_after>renderer = {
  add_build: function(build) {
    var self = this;
    row = self.create_build_row( build );
    row[row.length-1].addClass( 'divide' );

    $.each( row, function(i,r) {
      $( '#builds' ).append( row[i] );
    } );

    if ( self.lastSuccessfulBuild && ( self.lastSuccessfulBuild.number == build.number ) ) {
      $( '#latest-stable' ).append( row[0].clone() );
    }

  },

  add_matrix_build: function(build, ignored) {
    var self = this;

    column = $( '.build-summary.build-' + build.number ).find( 'td.1_6_0' );
    column.removeClass( 'matrix-unknown' );

    if ( build.result == 'SUCCESS' ) {
      column.addClass( 'matrix-success' );
      column.append(
        $( 'Passed' )
      );
    } else if ( build.result == 'FAILURE' ) {
      column.addClass( 'matrix-failure' );
      column.append(
        $( 'Failed' )
      );
    }  else if ( build.result == 'ABORTED' ) {
      column.addClass( 'matrix-aborted' );
      column.append(
        $( 'Aborted' )
      );
    }  else if ( build.building ) {
      column.addClass( 'matrix-building' );
      column.append(
        $( 'Building' )
      );
    }

    var duration;

    if ( build.building ) {
      duration = new Date() - new Date( build.timestamp );
    } else {
      duration = build.duration;
    }

    duration = Math.floor( duration / ( 60 * 1000 ) );

    column.append( ': ' + duration + ' min' );

    self.populate_artifacts( build );

    row = $( '.build-' + build.number );

    if ( row.find( '.matrix' ).size() == row.find( '.matrix-success' ).size() ) {
      row.addClass( 'build-success' );
    }
    if ( row.find( '.matrix-failure' ).size() > 0 ) {
      row.addClass( 'build-failure' );
    }
    if ( row.find( '.matrix' ).size() == row.find( '.matrix-aborted' ).size() ) {
      row.addClass( 'build-aborted' );
      row.find( 'td *' ).hide();
      row.find( 'td .number' ).show();
      row.find( 'td .number a' ).show();
      $( '.build-' + build.number + '.build-details td *' ).hide();
    }

  },

  populate_artifacts: function(build) {
      var self = this;

      if ( build.result != 'SUCCESS' ) {
          return;
      }

      // Docs

      $( '.build-summary.build-' + build.number ).find( 'td.docs' ).
          append('Browse API');
  },

  format_size: function(val) {
      return Math.round(val/1024/1024) + " mb";
  },

  create_build_row: function(build) {
    var self = this;
    row = $( '
' ).append(
            $( '' ).append(
              $( '' + build.number + '' ),
              $( '' + self.build_date( build ) + " " + self.build_time( build ) + '' )
            ),
            $( '' ),
            $( '' ),
            $( '' )
          );

    var sha = self.build_sha1(build)
    if (sha) {
      row.find('td.git').append(self.build_sha1_short(build) + ': ',
          $( 'Commits' ),
          " / ",
          $( 'Tree' ))
    }

    details_row = $( '
' ).append(
      $( '' )
    );

    if ( build.result == 'FAILURE' ) {
      if ( build.culprits.length > 0 ) {
        names = $.map( build.culprits, function(each,i) {
          return each.fullName;
        } );
        details_row.find( 'td' ).append( "Possible culprits: " + names.join( ', ' ) );
      }
    }

    if ( build.building ) {
      row.addClass( 'build-building' );
      details_row.addClass( 'build-building' );
      $('#build-currently-building').append( $( 'A build is currently in progress.' ) );
    }

    return [ row, details_row ];
  },

  build_date: function(build) {
     date = new Date( build.timestamp );
     return date.format( "dd mmmm yyyy" );
  },

  build_time: function(build) {
     date = new Date( build.timestamp );
     return date.format( "HH:MM" ) + ' US Eastern';
  },

  build_sha1: function(build) {
    if ( build.actions && build.actions.length >= 3 ) {
      var revision = build.actions[2].lastBuiltRevision
      if (!revision) {
          revision = build.actions[3].lastBuiltRevision
      }

      if (revision) {
          return revision.SHA1;
      }
    }
    return null;
  },

  build_sha1_short: function(build) {
    var sha = this.build_sha1(build)
    if (sha) {
      return sha.substring(0,8);
    }
    return null;
  },

  locate_artifact: function(build, filename) {
    result = null;
    var filename_regexp = new RegExp( filename );
    $.each( build.artifacts, function(i, artifact) {
      if ( artifact.relativePath.match( filename_regexp )  ) {
        result = artifact;
        return false;
      }
    } );
    return result;
  }

};

j = new Jenkins( renderer, 'http://projectodd.ci.cloudbees.com', 'immutant2-incremental',
                 [['', '1_6_0']] );
<|endoftext|>


<commit_before>import React from 'react';
import PropTypes from 'prop-types';
import ReactGA from 'react-ga';
import _ from 'lodash';
import { connect } from 'react-redux';
import Tabs, { Tab } from 'material-ui/Tabs';
import Typography from 'material-ui/Typography';
import { withStyles } from 'material-ui/styles';
import Grid from 'material-ui/Grid';
import Paper from 'material-ui/Paper';

import SingleStructureView from 'components/SingleStructureView';

import BarrierChart from 'components/BarrierChart';

import {
  FaExternalLink,
} from 'react-icons/lib/fa';
import {
  prettyPrintReference,
} from 'utils/functions';

const styles = (theme) => ({
  publicationEntry: {
  },
  tab: {
    backgroundColor: theme.palette.primary[50],
    textTransform: 'none',
  },
  paper: {
    marginTop: theme.spacing.unit,
    marginBottom: theme.spacing.unit,
    padding: 2 * theme.spacing.unit,
  },
  warning: {
    display: 'inline-block',
    backgroundColor: '#FEE994',
  },
});

function TabContainer(props) {
  return (<Typography component="div" style={{ padding: 8 * 3 }}>
    {props.children}
  </Typography>);
}

TabContainer.propTypes = {
  children: PropTypes.node.isRequired,
};

const initialState = {
  tabValue: 0,
};

class ReactionStructures extends React.Component { // eslint-disable-line react/prefer-stateless-function
  constructor(props) {
    super(props);
    this.state = initialState;
  }
  handleChange = (event, value) => {
    this.setState({
      tabValue: value,
    });
  }
  render() {
    let { tabValue } = this.state;
    tabValue = Math.min(tabValue, this.props.reactionSystems.length);
    return (
 {/* div necessary before wrapping ternary expression */}
      {_.isEmpty(this.props.selectedReaction) ? null :
      <Paper className={this.props.classes.paper}>
        <Grid container direction="column" width="100%">

{this.props.selectedReaction.Equation.replace('->', '→')}

          <BarrierChart {...this.props} />
          {this.props.loading ? null :

            {this.props.reactionSystems.length > 1 ?

                <Tabs
                  value={tabValue}
                  onChange={this.handleChange}
                  centered
                  indicatorColor="primary"
                  textColor="primary"
                  fullWidth
                  scrollButtons="auto"
                >
                  {this.props.reactionSystems.map((system, i) =>
                    <Tab
                      label={system.Formula} key={`reaction_tab_${i}`}
                      className={this.props.classes.tab}
                    />)}
                </Tabs>
                <TabContainer>
                  {tabValue === 0 && typeof this.props.reactionSystems[0] !== 'undefined' && <SingleStructureView selectedSystem={this.props.reactionSystems[0]} selectedUUID={this.props.reactionSystems[0].uniqueId} selectedPublication={this.props.publication} /> }
                  {tabValue === 1 && typeof this.props.reactionSystems[1] !== 'undefined' && <SingleStructureView selectedSystem={this.props.reactionSystems[1]} selectedUUID={this.props.reactionSystems[1].uniqueId} selectedPublication={this.props.publication} /> }
                  {tabValue === 2 && typeof this.props.reactionSystems[2] !== 'undefined' && <SingleStructureView selectedSystem={this.props.reactionSystems[2]} selectedUUID={this.props.reactionSystems[2].uniqueId} selectedPublication={this.props.publication} /> }
                  {tabValue === 3 && typeof this.props.reactionSystems[3] !== 'undefined' && <SingleStructureView selectedSystem={this.props.reactionSystems[3]} selectedUUID={this.props.reactionSystems[3].uniqueId} selectedPublication={this.props.publication} /> }
                  {tabValue === 4 && typeof this.props.reactionSystems[4] !== 'undefined' && <SingleStructureView selectedSystem={this.props.reactionSystems[4]} selectedUUID={this.props.reactionSystems[4].uniqueId} selectedPublication={this.props.publication} /> }
                  {tabValue === 5 && typeof this.props.reactionSystems[5] !== 'undefined' && <SingleStructureView selectedSystem={this.props.reactionSystems[5]} selectedUUID={this.props.reactionSystems[4].uniqueId} selectedPublication={this.props.publication} /> }
                  {tabValue === 6 && typeof this.props.reactionSystems[6] !== 'undefined' && <SingleStructureView selectedSystem={this.props.reactionSystems[6]} selectedUUID={this.props.reactionSystems[6].uniqueId} selectedPublication={this.props.publication} /> }
                  {tabValue === 7 && typeof this.props.reactionSystems[7] !== 'undefined' && <SingleStructureView selectedSystem={this.props.reactionSystems[7]} selectedUUID={this.props.reactionSystems[7].uniqueId} selectedPublication={this.props.publication} /> }
                  {tabValue === 8 && typeof this.props.reactionSystems[8] !== 'undefined' && <SingleStructureView selectedSystem={this.props.reactionSystems[8]} selectedUUID={this.props.reactionSystems[8].uniqueId} selectedPublication={this.props.publication} /> }
                  {tabValue === 9 && typeof this.props.reactionSystems[9] !== 'undefined' && <SingleStructureView selectedSystem={this.props.reactionSystems[9]} selectedUUID={this.props.reactionSystems[9].uniqueId} selectedPublication={this.props.publication} /> }
                  {tabValue === 10 && typeof this.props.reactionSystems[10] !== 'undefined' && <SingleStructureView selectedSystem={this.props.reactionSystems[10]} selectedUUID={this.props.reactionSystems[10].uniqueId} selectedPublication={this.props.publication} /> }
                  {tabValue === 11 && typeof this.props.reactionSystems[11] !== 'undefined' && <SingleStructureView selectedSystem={this.props.reactionSystems[11]} selectedUUID={this.props.reactionSystems[11].uniqueId} selectedPublication={this.props.publication} /> }
                  {tabValue === 12 && typeof this.props.reactionSystems[12] !== 'undefined' && <SingleStructureView selectedSystem={this.props.reactionSystems[12]} selectedUUID={this.props.reactionSystems[12].uniqueId} selectedPublication={this.props.publication} /> }
                </TabContainer>

             :

                  Warning: This reaction stems from an old dataset. Please consult the publication for details.

DFT Code: {this.props.selectedReaction.dftCode}

DFT Functional: {this.props.selectedReaction.dftFunctional}

{prettyPrintReference(this.props.publication)}

                  {_.isEmpty(this.props.publication.doi) ? null :

                            Source
                            <ReactGA.OutboundLink
                              eventLabel={`http://dx.doi.org/${this.props.publication.doi}`}
                              to={`http://dx.doi.org/${this.props.publication.doi}`}
                              target="_blank"
                            >
                              DOI: {this.props.publication.doi} <FaExternalLink />
                            </ReactGA.OutboundLink>

                  }

 <a href={`/publications/${this.props.publication.pubId}`}>
                  View all reactions in dataset

            }

          }
        </Grid>
      </Paper>
      }

    );
  }
}

ReactionStructures.propTypes = {
  loading: PropTypes.bool,
  reactionSystems: PropTypes.array.isRequired,
  selectedReaction: PropTypes.object,
  classes: PropTypes.object,
  publication: PropTypes.object,
};

const mapStateToProps = (state) => ({
  loading: state.get('energiesPageReducer').loading,
  reactionSystems: state.get('energiesPageReducer').reactionSystems,
  publication: state.get('energiesPageReducer').publication,
});

const mapDispatchToProps = () => ({
});

exports.ReactionStructures = withStyles(styles, { withTheme: true })(
connect(mapStateToProps, mapDispatchToProps)(ReactionStructures)

);
<commit_msg>update warning and color<commit_after>import React from 'react';
import PropTypes from 'prop-types';
import ReactGA from 'react-ga';
import _ from 'lodash';
import { connect } from 'react-redux';
import Tabs, { Tab } from 'material-ui/Tabs';
import Typography from 'material-ui/Typography';
import { withStyles } from 'material-ui/styles';
import Grid from 'material-ui/Grid';
import Paper from 'material-ui/Paper';

import SingleStructureView from 'components/SingleStructureView';

import BarrierChart from 'components/BarrierChart';

import {
  FaExternalLink,
} from 'react-icons/lib/fa';
import {
  prettyPrintReference,
} from 'utils/functions';

const styles = (theme) => ({
  publicationEntry: {
  },
  tab: {
    backgroundColor: theme.palette.primary[50],
    textTransform: 'none',
  },
  paper: {
    marginTop: theme.spacing.unit,
    marginBottom: theme.spacing.unit,
    padding: 2 * theme.spacing.unit,
  },
  warning: {
    display: 'inline-block',
    backgroundColor: theme.palette.sun[100],
  },
});

function TabContainer(props) {
  return (<Typography component="div" style={{ padding: 8 * 3 }}>
    {props.children}
  </Typography>);
}

TabContainer.propTypes = {
  children: PropTypes.node.isRequired,
};

const initialState = {
  tabValue: 0,
};

class ReactionStructures extends React.Component { // eslint-disable-line react/prefer-stateless-function
  constructor(props) {
    super(props);
    this.state = initialState;
  }
  handleChange = (event, value) => {
    this.setState({
      tabValue: value,
    });
  }
  render() {
    let { tabValue } = this.state;
    tabValue = Math.min(tabValue, this.props.reactionSystems.length);
    return (
 {/* div necessary before wrapping ternary expression */}
      {_.isEmpty(this.props.selectedReaction) ? null :
      <Paper className={this.props.classes.paper}>
        <Grid container direction="column" width="100%">

{this.props.selectedReaction.Equation.replace('->', '→')}

          <BarrierChart {...this.props} />
          {this.props.loading ? null :

            {this.props.reactionSystems.length > 1 ?

                <Tabs
                  value={tabValue}
                  onChange={this.handleChange}
                  centered
                  indicatorColor="primary"
                  textColor="primary"
                  fullWidth
                  scrollButtons="auto"
                >
                  {this.props.reactionSystems.map((system, i) =>
                    <Tab
                      label={system.Formula} key={`reaction_tab_${i}`}
                      className={this.props.classes.tab}
                    />)}
                </Tabs>
                <TabContainer>
                  {tabValue === 0 && typeof this.props.reactionSystems[0] !== 'undefined' && <SingleStructureView selectedSystem={this.props.reactionSystems[0]} selectedUUID={this.props.reactionSystems[0].uniqueId} selectedPublication={this.props.publication} /> }
                  {tabValue === 1 && typeof this.props.reactionSystems[1] !== 'undefined' && <SingleStructureView selectedSystem={this.props.reactionSystems[1]} selectedUUID={this.props.reactionSystems[1].uniqueId} selectedPublication={this.props.publication} /> }
                  {tabValue === 2 && typeof this.props.reactionSystems[2] !== 'undefined' && <SingleStructureView selectedSystem={this.props.reactionSystems[2]} selectedUUID={this.props.reactionSystems[2].uniqueId} selectedPublication={this.props.publication} /> }
                  {tabValue === 3 && typeof this.props.reactionSystems[3] !== 'undefined' && <SingleStructureView selectedSystem={this.props.reactionSystems[3]} selectedUUID={this.props.reactionSystems[3].uniqueId} selectedPublication={this.props.publication} /> }
                  {tabValue === 4 && typeof this.props.reactionSystems[4] !== 'undefined' && <SingleStructureView selectedSystem={this.props.reactionSystems[4]} selectedUUID={this.props.reactionSystems[4].uniqueId} selectedPublication={this.props.publication} /> }
                  {tabValue === 5 && typeof this.props.reactionSystems[5] !== 'undefined' && <SingleStructureView selectedSystem={this.props.reactionSystems[5]} selectedUUID={this.props.reactionSystems[4].uniqueId} selectedPublication={this.props.publication} /> }
                  {tabValue === 6 && typeof this.props.reactionSystems[6] !== 'undefined' && <SingleStructureView selectedSystem={this.props.reactionSystems[6]} selectedUUID={this.props.reactionSystems[6].uniqueId} selectedPublication={this.props.publication} /> }
                  {tabValue === 7 && typeof this.props.reactionSystems[7] !== 'undefined' && <SingleStructureView selectedSystem={this.props.reactionSystems[7]} selectedUUID={this.props.reactionSystems[7].uniqueId} selectedPublication={this.props.publication} /> }
                  {tabValue === 8 && typeof this.props.reactionSystems[8] !== 'undefined' && <SingleStructureView selectedSystem={this.props.reactionSystems[8]} selectedUUID={this.props.reactionSystems[8].uniqueId} selectedPublication={this.props.publication} /> }
                  {tabValue === 9 && typeof this.props.reactionSystems[9] !== 'undefined' && <SingleStructureView selectedSystem={this.props.reactionSystems[9]} selectedUUID={this.props.reactionSystems[9].uniqueId} selectedPublication={this.props.publication} /> }
                  {tabValue === 10 && typeof this.props.reactionSystems[10] !== 'undefined' && <SingleStructureView selectedSystem={this.props.reactionSystems[10]} selectedUUID={this.props.reactionSystems[10].uniqueId} selectedPublication={this.props.publication} /> }
                  {tabValue === 11 && typeof this.props.reactionSystems[11] !== 'undefined' && <SingleStructureView selectedSystem={this.props.reactionSystems[11]} selectedUUID={this.props.reactionSystems[11].uniqueId} selectedPublication={this.props.publication} /> }
                  {tabValue === 12 && typeof this.props.reactionSystems[12] !== 'undefined' && <SingleStructureView selectedSystem={this.props.reactionSystems[12]} selectedUUID={this.props.reactionSystems[12].uniqueId} selectedPublication={this.props.publication} /> }
                </TabContainer>

             :

                  Warning: Atomic geometries are not available for this reaction. Please consult the publication for details.

DFT Code: {this.props.selectedReaction.dftCode}

DFT Functional: {this.props.selectedReaction.dftFunctional}

{prettyPrintReference(this.props.publication)}

                  {_.isEmpty(this.props.publication.doi) ? null :

                            Source
                            <ReactGA.OutboundLink
                              eventLabel={`http://dx.doi.org/${this.props.publication.doi}`}
                              to={`http://dx.doi.org/${this.props.publication.doi}`}
                              target="_blank"
                            >
                              DOI: {this.props.publication.doi} <FaExternalLink />
                            </ReactGA.OutboundLink>

                  }

 <a href={`/publications/${this.props.publication.pubId}`}>
                  View all reactions in dataset

            }

          }
        </Grid>
      </Paper>
      }

    );
  }
}

ReactionStructures.propTypes = {
  loading: PropTypes.bool,
  reactionSystems: PropTypes.array.isRequired,
  selectedReaction: PropTypes.object,
  classes: PropTypes.object,
  publication: PropTypes.object,
};

const mapStateToProps = (state) => ({
  loading: state.get('energiesPageReducer').loading,
  reactionSystems: state.get('energiesPageReducer').reactionSystems,
  publication: state.get('energiesPageReducer').publication,
});

const mapDispatchToProps = () => ({
});

exports.ReactionStructures = withStyles(styles, { withTheme: true })(
connect(mapStateToProps, mapDispatchToProps)(ReactionStructures)

);
<|endoftext|>


<commit_before>//= require can.jquery-all

can.Control("CMS.Controllers.AddWidget", {
  defaults : {
    widget_descriptors : null
    , minimum_widget_height : 100
  }
}, {

  ".dropdown-menu > * click" : function(el, ev) {
    var descriptor = this.options.widget_descriptors[el.attr("class")];
    this.addWidgetByDescriptor(descriptor);
  }

  , ".dropdown-toggle click" : function() {
      setTimeout(this.proxy("repositionMenu"), 10);
    }
  , "{window} resize" : "repositionMenu"
  , "{window} scroll" : "repositionMenu"

  , repositionMenu : function(el, ev) {
    var $dropdown = this.element.find(".dropdown-menu:visible")
    if(!$dropdown.length)
      return;

    $dropdown.css({"position" : "", "top" : "", "bottom" : "" });
    if($dropdown.offset().top < window.scrollY) {
      $dropdown.css({
        "position" : "absolute"
        , "top" : window.scrollY - this.element.find(".dropdown-toggle").offset().top
        , "bottom" : $(".dropdown-menu:visible").css("bottom", -window.scrollY - 443 + this.element.find(".dropdown-toggle").offset().top - this.element.find(".dropdown-toggle").height() )
      })
    }
  }

  , addWidgetByDescriptor : function(descriptor) {
    var that = this;
    if(descriptor && !$("#" + descriptor.object_type + "_list_widget").length) {
      $("
").insertBefore(that.element).cms_controllers_dashboard_widgets(descriptor).trigger("sortreceive");
    }
  }

  , addWidgetByName : function(widget_name) {
    this.addWidgetByDescriptor(this.options.widget_descriptors[widget_name]);
  }
})<commit_msg>Adding a quick "please don't change this CSS" message for the add button<commit_after>//= require can.jquery-all

can.Control("CMS.Controllers.AddWidget", {
  defaults : {
    widget_descriptors : null
    , minimum_widget_height : 100
  }
}, {

  ".dropdown-menu > * click" : function(el, ev) {
    var descriptor = this.options.widget_descriptors[el.attr("class")];
    this.addWidgetByDescriptor(descriptor);
  }

  , ".dropdown-toggle click" : function() {
      setTimeout(this.proxy("repositionMenu"), 10);
    }
  , "{window} resize" : "repositionMenu"
  , "{window} scroll" : "repositionMenu"

  , repositionMenu : function(el, ev) {
    var $dropdown = this.element.find(".dropdown-menu:visible")
    if(!$dropdown.length)
      return;

    $dropdown.css({"position" : "", "top" : "", "bottom" : "" });
    //NOTE: if the position property of the dropdown toggle button is changed to "static" (it is current "relative"),
    //  this code will fail.  Please do not remove the relative positioning from ".dropdown-toggle" --BM 3/1/2013
    if($dropdown.offset().top < window.scrollY) {
      $dropdown.css({
        "position" : "absolute"
        , "top" : window.scrollY - this.element.find(".dropdown-toggle").offset().top
        , "bottom" : $(".dropdown-menu:visible").css("bottom", -window.scrollY - 443 + this.element.find(".dropdown-toggle").offset().top - this.element.find(".dropdown-toggle").height() )
      })
    }
  }

  , addWidgetByDescriptor : function(descriptor) {
    var that = this;
    if(descriptor && !$("#" + descriptor.object_type + "_list_widget").length) {
      $("
").insertBefore(that.element).cms_controllers_dashboard_widgets(descriptor).trigger("sortreceive");
    }
  }

  , addWidgetByName : function(widget_name) {
    this.addWidgetByDescriptor(this.options.widget_descriptors[widget_name]);
  }
})<|endoftext|>


<commit_before>import commonjs from 'rollup-plugin-commonjs'
import resolve from 'rollup-plugin-node-resolve'
import typescript from 'rollup-plugin-typescript'
import uglify from 'rollup-plugin-uglify'

const plugins = [
  resolve(),
  commonjs(),
  typescript({
    typescript: require('typescript')
  }),
  uglify()
]

export default [
  {
    context: 'window',
    input: './src/ts/inline.ts',
    output: {
      file: './layouts/partials/inline.js',
      format: 'es'
    },
    plugins
  },
  {
    context: 'window',
    input: './src/ts/main.ts',
    output: {
      file: './static/js/main.js',
      format: 'es'
    },
    plugins
  },
  {
    context: 'window',
    input: './src/ts/sw.ts',
    output: {
      file: './static/sw.js',
      format: 'es'
    },
    plugins
  }
]
<commit_msg>Fix uglify plugin use<commit_after>import commonjs from 'rollup-plugin-commonjs'
import resolve from 'rollup-plugin-node-resolve'
import typescript from 'rollup-plugin-typescript'
import { uglify } from 'rollup-plugin-uglify'

const plugins = [
  resolve(),
  commonjs(),
  typescript({
    typescript: require('typescript')
  }),
  uglify()
]

export default [
  {
    context: 'window',
    input: './src/ts/inline.ts',
    output: {
      file: './layouts/partials/inline.js',
      format: 'es'
    },
    plugins
  },
  {
    context: 'window',
    input: './src/ts/main.ts',
    output: {
      file: './static/js/main.js',
      format: 'es'
    },
    plugins
  },
  {
    context: 'window',
    input: './src/ts/sw.ts',
    output: {
      file: './static/sw.js',
      format: 'es'
    },
    plugins
  }
]
<|endoftext|>


<commit_before>const path = require('path');

module.exports = {
  "parser": "babel-eslint",
  "env": {
    "browser": true,
    "jest": true,
  },
  "settings": {
    "import/resolver": {
      node: {
        paths: [path.resolve(__dirname, './src')],
      },
    },
  },
  "rules": {
    "max-len": ["error", { "code": 180, "ignoreTemplateLiterals": true, "ignoreStrings": true }],
    "no-mixed-operators": ["error", {
      "allowSamePrecedence": true
    }],
    "no-shadow": 1,
    "import/named": ["error"],
    "jsx-a11y/anchor-is-valid": ["warn", {
      "components": ["Link"],
      "specialLink": ["to"],
    }],
    "react/no-array-index-key": 1,
    "react/require-default-props": 0,
    'import/no-extraneous-dependencies': [
      "error",
      {
        devDependencies: [
          '.storybook/**',
          'src/stories/**'
        ]
      }
    ],
    "react/sort-comp": [2],

  },
  "overrides": [
    {
      "files": ["./src/**/*.ts","./src/**/*.tsx"],
      "env": { "browser": true, "jest": true},
      "extends": [
        "airbnb",
        "plugin:@typescript-eslint/recommended",
      ],
      "parser": "@typescript-eslint/parser",
      "parserOptions": {
        "ecmaFeatures": { "jsx": true },
        "sourceType": "module",
        "project": "./tsconfig.json"
      },
      "plugins": ["react", "@typescript-eslint"],
      "rules": {
        "@typescript-eslint/consistent-type-definitions": ["error", "type"],
        "@typescript-eslint/no-inferrable-types": ["error", {"ignoreProperties": true, "ignoreParameters": false}],
        "@typescript-eslint/interface-name-prefix": ["error", { "prefixWithI": "never" }],
        "@typescript-eslint/explicit-function-return-type": "off",
        "no-useless-constructor": "off",
        "@typescript-eslint/no-useless-constructor": "error",
        "@typescript-eslint/prefer-optional-chain": "error",
        "@typescript-eslint/prefer-nullish-coalescing": "error",
        'react/jsx-filename-extension': [1, { 'extensions': ['.ts', '.tsx'] }],
        "import/prefer-default-export": "off"
      },
    }
  ]
};
<commit_msg>Added common linting rules to share across all JS/JSX/TS/TSX files<commit_after>const path = require('path');

const commonRules = {
  "max-len": ["error", { "code": 180, "ignoreTemplateLiterals": true, "ignoreStrings": true }],
  "no-mixed-operators": ["error", {
    "allowSamePrecedence": true
  }],
  "no-shadow": 1,
  "jsx-a11y/anchor-is-valid": ["warn", {
    "components": ["Link"],
    "specialLink": ["to"],
  }],
  "react/no-array-index-key": 1,
  "react/require-default-props": 0,
  'import/no-extraneous-dependencies': [
    "error",
    {
      devDependencies: [
        '.storybook/**',
        'src/stories/**'
      ]
    }
  ],
  "react/sort-comp": [2]
}

module.exports = {
  "parser": "babel-eslint",
  "env": {
    "browser": true,
    "jest": true,
  },
  "settings": {
    "import/resolver": {
      node: {
        paths: [path.resolve(__dirname, './src')],
      },
    },
  },
  "rules": {
    ...commonRules,
    "import/named": ["error"],
  },
  "overrides": [
    {
      "files": ["./src/**/*.ts","./src/**/*.tsx"],
      "env": { "browser": true, "jest": true},
      "extends": [
        "airbnb",
        "plugin:@typescript-eslint/recommended",
      ],
      "parser": "@typescript-eslint/parser",
      "parserOptions": {
        "ecmaFeatures": { "jsx": true },
        "sourceType": "module",
        "project": "./tsconfig.json"
      },
      "plugins": ["react", "@typescript-eslint"],
      "rules": {
        ...commonRules,
        "@typescript-eslint/consistent-type-definitions": ["error", "type"],
        "@typescript-eslint/no-inferrable-types": ["error", {"ignoreProperties": true, "ignoreParameters": false}],
        "@typescript-eslint/interface-name-prefix": ["error", { "prefixWithI": "never" }],
        "@typescript-eslint/explicit-function-return-type": "off",
        "no-useless-constructor": "off",
        "@typescript-eslint/no-useless-constructor": "error",
        "@typescript-eslint/prefer-optional-chain": "error",
        "@typescript-eslint/prefer-nullish-coalescing": "error",
        'react/jsx-filename-extension': [1, { 'extensions': ['.ts', '.tsx'] }],
        "import/prefer-default-export": "off"
      },
    }
  ]
};
<|endoftext|>


<commit_before>/**
 * Created by ismailrei on 1/24/17.
 */
var appEtudiant = angular.module('appEtudiant', []);

appEtudiant.controller('etudiantController', ['$scope', '$http', function ($scope, $http) {
    $scope.json=null;
    $scope.etudiants={};
    var refrech = function () {
        $http({
            method: 'GET',
            url: 'listEtudiant'
        }).then(function (success) {
            $scope.etudiants = success.data;
        }, function (error) {

        });
    };

    refrech();
    $scope.addCsv=function(){
        var id=0;
        $scope.json=JSON.parse($scope.json);
        angular.forEach($scope.json,function(value,key){
           if(value.id)
           {
               $scope.etudiant=value;
               $scope.etudiants[key]=value;
               $scope.addorUpdateEtudiant;
           }

        })

    }
    $scope.addorUpdateEtudiant = function () {
        $http({
            method: 'POST',
            url: 'addOrUpdateEtudiant',
            data: "newEtudiant="+$scope.etudiant
        }).then(function (success) {
            refrech();
        }, function (error) {

        });
    }

    $scope.deleteEtudiant = function (id) {
        $http({
            method: 'DELETE',
            url: 'deleteEtudiant?id=' + id,

        }).then(function (success) {
            refrech();
        }, function (error) {

        });
    }

    $scope.edit = function (id) {
        $http({
            method: 'GET',
            url: 'editEtudiant?id='+id
        }).then(function (success) {
            $scope.etudiant = success.data;
        }, function (error) {

        });
    }

    $scope.deselect = function() {
        $scope.etudiant = "";
    }

}]);<commit_msg>[MP] update etudiant controller<commit_after>/**
 * Created by ismailrei on 1/24/17.
 */
var appEtudiant = angular.module('appEtudiant', []);

appEtudiant.controller('etudiantController', ['$scope', '$http', function ($scope, $http) {
    $scope.json=null;
    $scope.etudiants={};
    var refrech = function () {
        $http({
            method: 'GET',
            url: 'listEtudiants'
        }).then(function (success) {
            $scope.etudiants = success.data;
        }, function (error) {

        });
    };
    $scope.affecter=function(){
        $scope.json=JSON.parse($scope.json);
        var data = angular.toJson($scope.json);
        $http({
            method: 'POST',
            url: 'addOrUpdateEtudiant',
            data: "newEtudiant="+data,
            headers: {'Content-Type': 'application/x-www-form-urlencoded'}
        }).then(function (success) {
            refrech();
        }, function (error) {

        });
    }
    refrech();
    $scope.addCsv=function(){
        var id=0;
        $scope.json=JSON.parse($scope.json);
        console.log("test3");
        angular.forEach($scope.json,function(value,key){
           if(value.cne)
           {
               $scope.etudiant=value;
               $scope.addorUpdateEtudiant();
           }
        })

    }
    $scope.addorUpdateEtudiant = function () {
        var data = angular.toJson($scope.etudiant);
        $http({
            method: 'POST',
            url: 'addOrUpdateEtudiant',
            data: "newEtudiant="+data,
            headers: {'Content-Type': 'application/x-www-form-urlencoded'}
        }).then(function (success) {
            refrech();
        }, function (error) {

        });
    }

    $scope.deleteEtudiant = function (id) {
        $http({
            method: 'DELETE',
            url: 'deleteEtudiant?id=' + id,

        }).then(function (success) {
            refrech();
        }, function (error) {

        });
    }

    $scope.edit = function (id) {
        $http({
            method: 'GET',
            url: 'editEtudiant?id='+id
        }).then(function (success) {
            $scope.etudiant = success.data;
        }, function (error) {

        });
    }

    $scope.deselect = function() {
        $scope.etudiant = "";
    }

}]);<|endoftext|>


<commit_before>var marioLayer = new Kinetic.Layer();
var canvas = document.getElementById('container');
var mario;
var stopTime = false;
var marioImageObj = new Image();

marioImageObj.onload = function () {
    mario = new Kinetic.Sprite({
        x: 8,
        y: 388,
        image: marioImageObj,
        animation: 'stayRight',
        animations: {
            walkRight: [
              50, 0, 50, 150
            ],
            stayRight: [
                0, 0, 50, 150
            ],
            jumpRight: [
                100, 0, 50, 150
            ],
            bigJumpRight: [
                100, 30, 50, 150
            ],
            dead: [
                300, 0, 50, 150
            ],
            stayLeft: [
                250, 0, 50, 150
            ],
            walkLeft: [
                200, 0, 50, 150
            ],
            jumpLeft: [
                150, 0, 50, 150
            ],
        },
        frameRate: 7,
        frameIndex: 0,
        direction: 'right'
    });

    marioLayer.add(mario);

    stage.add(marioLayer);

    mario.start();

    var frameCount = 0;

    mario.on('frameIndexChange', function (evt) {
        if (!isElevated && elevation !== 0 && !nextIsFlat()) {
            var next = gameObjects.filter(function (o) {
                return (o.y - mario.getAttr('y') - 150) > 0 && // bottom of mario higher than top of obstacle
                    mario.getAttr('x') + 50 >= o.x &&      // Left side of mario compared to Right side of obstacle
                    mario.getAttr('x') < o.x + o.width;
            })[0];
            if (next) {     // if next to mario there is an obstacle
                var old = mario.getAttr('y');
                if (mario.direction === 'right') {
                    mario.move({
                        x: 8,
                        y: next.y - mario.getAttr('y') - 150
                    });
                } else {
                    mario.move({
                        x: -8,
                        y: next.y - mario.getAttr('y') - 150
                    });
                }
                elevation -= (mario.getAttr('y') - old) / 32;
            } else {        // if next to mario there is no obstacle
                if (mario.direction === 'right') {
                    mario.move({
                        x: 8,
                        y: 32 * elevation
                    });
                } else {
                    mario.move({
                        x: -8,
                        y: 32 * elevation
                    });
                }
                elevation = 0;
            }
        }
        if ((mario.animation() === 'walkRight') && ++frameCount > 2) {
            if (!isStuck) {
                mario.move({
                    x: 8,
                    y: 0
                });
            }
            mario.animation('stayRight');
            frameCount = 0;
        } else if ((mario.animation() === 'walkLeft') && ++frameCount > 2) {
            if (!isStuck) {
                mario.move({
                    x: -8,
                    y: 0
                });
            }
            mario.animation('stayLeft');
            frameCount = 0;
        } else if ((mario.animation() === 'jumpRight' || mario.animation() === 'bigJumpRight') && ++frameCount > 2) {
            mario.move({
                x: 32,
                y: 0
            });
            if (isElevated && nextIsSmallPipe()) {
                mario.move({
                    x: 0,
                    y: -64
                });
                elevation += 2;
            } else if (isElevated) {
                mario.move({
                    x: 0,
                    y: -32
                });
                elevation++;
            }
            mario.animation('stayRight');
            frameCount = 0;
        } else if (mario.animation() === 'jumpLeft' && ++frameCount > 2) {
            mario.move({
                x: -32,
                y: 0
            });
            if (isElevated && nextIsSmallPipe()) {
                mario.move({
                    x: 0,
                    y: -64
                });
                elevation += 2;
            } else if (isElevated) {
                mario.move({
                    x: 0,
                    y: -32
                });
                elevation++;
            }
            mario.animation('stayLeft');
            frameCount = 0;
        }
    });

    function onKeyDown(ev) {
        if (ev.keyCode === 39 && mario.getAttr('x') <= canvas.getAttribute('width') - 70) {
            mario.animation('walkRight');
            mario.direction = 'right';
            if (mario.getAttr('x') > 200) {
                window.scrollBy(5, 0);
            }
        } else if (ev.keyCode === 34 && mario.getAttr('x') <= canvas.getAttribute('width') - 70) {
            mario.animation('jumpRight');
            mario.direction = 'right';
            if (mario.getAttr('x') > 200) {
                window.scrollBy(10, 0);
            }
        } else if (ev.keyCode === 33 && mario.getAttr('x') >= 32) {
            mario.animation('jumpLeft');
            mario.direction = 'left';
        } else if (ev.keyCode === 38 && mario.getAttr('x') <= canvas.getAttribute('width') - 70) {
            mario.animation('bigJumpRight');
            mario.direction = 'right';
            if (mario.getAttr('x') > 200) {
                window.scrollBy(10, 0);
            }
        } else if ((ev.keyCode === 37 && mario.getAttr('x') >= 8)) {
            mario.direction = 'left';
            if (mario.animation() !== 'stayLeft') {
                mario.animation('stayLeft');
            } else {
                mario.animation('walkLeft');
            }
        }
        if (mario.getAttr('x') > 1950) {        // if mario successfully reached the end of the level
            endScreenLayer.draw();
            document.body.removeEventListener('keydown', onKeyDown, false);
            scrollTo(0, 0);
            stopTime = true;
            gameOver();
        }
        collisionDispatcher();
    }

    var isStuck = false;
    var elevation = 0;
    var isElevated = false;

    function nextIsHigher() {  // if next to mario is higher obstacle
        return gameObjects.some(function (o) {
            return (o.y - mario.getAttr('y') - 150) < 0 && // bottom of mario equal to bottom of obstacle
                (o.y - mario.getAttr('y') - 150) > -65 &&
                mario.getAttr('x') + 50 >= o.x &&      // Left side of mario compared to Right side of obstacle
                mario.getAttr('x') < o.x + o.width - 10; // Right side of mario compared to Left side of obstacle
        });
    }

    function nextIsSmallPipe() {
        return gameObjects.some(function (o) {
            return (o.y - mario.getAttr('y') - 150) < 0 &&
                (o.y - mario.getAttr('y') - 150) > -65 &&
                mario.getAttr('x') + 50 >= o.x &&
                mario.getAttr('x') < o.x + o.width - 10 &&
                o.type === 'pipeSmall';
        });
    }

    function nextIsFlat() {  // if next to mario is flat obstacle
        return gameObjects.some(function (o) {
            return (o.y - mario.getAttr('y') - 150) === 0 && // bottom of mario equal to top of obstacle
                mario.getAttr('x') + 50 >= o.x &&      // Left side of mario compared to Right side of obstacle
                mario.getAttr('x') < o.x + o.width - 20; // Right side of mario compared to Left side of obstacle
        });
    }

    function isMarioXInObstacle(obstacle) {
        return mario.getAttr('x') + 50 >= obstacle.x && mario.getAttr('x') < obstacle.x + obstacle.width - 5;
    }

    function collisionDispatcher() {
        var k;
        for (k = 0; k < gameObjects.length; k++) {
            if (isMarioXInObstacle(gameObjects[k])) {
                if ((mario.animation() === 'jumpRight' || mario.animation() === 'bigJumpRight' || mario.animation() === 'jumpLeft') && nextIsHigher()) { // trying to jumpRight over obstacle
                    isElevated = true;
                    return;
                } else if (nextIsHigher()) {
                    isStuck = true;                     // trying to enter obstacle
                    return;
                } else if (mario.animation() === 'bigJumpRight') {
                    if (mario.getAttr('y') - gameObjects[k].y + 32 < 105 &&
                        Math.abs(mario.getAttr('x') + 25 - gameObjects[k].x) - 16 < 5 &&
                        gameObjects[k].type === 'bonusBlock') {

                        bonusAnimation(gameObjects[k].x, gameObjects[k].y);
                        currentScores += 30;
                        displayScore();
                    }
                }
            }
            isStuck = false;
            isElevated = false;
        }

        for (k = 0; k < enemies.length; k++) {
            if (mario.getAttr('x') + 50 >= enemies[k].getAttr('x') &&
                mario.getAttr('x') + 20 < enemies[k].getAttr('x') &&
                (mario.animation() === 'jumpRight' || mario.animation() === 'bigJumpRight' || mario.animation() === 'jumpLeft')) {
                enemies[k].animation('smashed');
                currentScores += 50;
                displayScore();
            } else if (mario.getAttr('x') + 50 >= enemies[k].getAttr('x') &&
                mario.getAttr('x') + 30 < enemies[k].getAttr('x') &&
                !(mario.animation() === 'jumpRight' || mario.animation() === 'bigJumpRight' || mario.animation() === 'jumpLeft') &&
                enemies[k].animation() !== 'smashed') {
                console.log('Mario is eaten!');
                mario.move({
                    x: -mario.getAttr('x') + 8,
                    y: 0
                });
                window.scrollTo(0, 0);
                remainingLives--;
                remainingLivesField.setText(remainingLives);
                lives.draw();

                // if mario dead
                if (remainingLives === -1) {
                    remainingLivesField.setText(0); //number to show on the screen
                    lives.draw(); //showing the number on the screen

                    endScreenLayer.draw();
                    document.body.removeEventListener('keydown', onKeyDown, false);
                    stopTime = true;
                    gameOver();
                }
                currentScores = 0; //null the scores
                displayScore(); //display the nulled scores
                mario.animation('dead');
            }
        }
    }

    document.body.addEventListener('keydown', onKeyDown, false);

};
marioImageObj.src = 'Images/mario1.png';

function bonusAnimation(bonusX, bonusY) {
    var coinsLayer = new Kinetic.Layer();
    var coinImage = new Image();
    coinImage.src = 'Images/game-objects/coin.png';
    var coin = new Kinetic.Sprite({
        x: bonusX + 8,
        y: bonusY - 32,
        image: coinImage,
        animation:
        'rotate',
        animations: {
            rotate: [
                    // x, y, width, height (2 frames)
                    0, 0, 20, 20,
                    25, 0, 20, 20,
                    45, 0, 20, 20,
                    65, 0, 20, 20
            ]
        },
        frameRate: 4,
        frameIndex: 0
    });

    coinsLayer.add(coin);
    coin.start();
    stage.add(coinsLayer);
}

function displayScore() {
    currentScoresField.setText(currentScores);
    score.draw();
}

function gameOver() {
    var userName = prompt('Enter your name: ', 'unnamed');

    var allScores = localStorage.getItem('scores');
    if (!allScores) {
        allScores = [];
    } else {
        allScores = JSON.parse(allScores);
    }

    if (allScores.length === 0) {
        allScores.push({ name: userName, score: currentScores });
    } else {
        if (currentScores < allScores[allScores.length - 1].score) {
            allScores.push({ name: userName, score: currentScores });
        } else {
            for (var i = 0; i < allScores.length; i++) {
                if (allScores[i].score < currentScores) {
                    allScores.splice(i, 0, { name: userName, score: currentScores });
                    break;
                }
            }
        }
    }

    localStorage.removeItem('scores');
    localStorage.setItem('scores', JSON.stringify(allScores));

    var highScoresLayer = new Kinetic.Layer();
    var highScores = new Kinetic.Text({
        x: 900,
        y: 100,
        text: "scores",
        fontSize: 25,
        fontFamily: 'Arial Black',
        fill: 'white'
    });

    highScoresLayer.add(highScores);
    stage.add(highScoresLayer);
    showScore();//display the highScores

    function showScore() {
        var highScoresText = 'HIGHSCORES TABLE \n\n'

        if (allScores.length > 10) {
            allScores.length = 10;
        }
        for (var i = 0; i < allScores.length; i++) {
            highScoresText += allScores[i].name + " --> " + allScores[i].score + '\n';
        }

        highScores.setText(highScoresText);
        highScoresLayer.draw();
    }

    return false;
}<commit_msg>a little bit of formatting of the high scores table<commit_after>var marioLayer = new Kinetic.Layer();
var canvas = document.getElementById('container');
var mario;
var stopTime = false;
var marioImageObj = new Image();

marioImageObj.onload = function () {
    mario = new Kinetic.Sprite({
        x: 8,
        y: 388,
        image: marioImageObj,
        animation: 'stayRight',
        animations: {
            walkRight: [
              50, 0, 50, 150
            ],
            stayRight: [
                0, 0, 50, 150
            ],
            jumpRight: [
                100, 0, 50, 150
            ],
            bigJumpRight: [
                100, 30, 50, 150
            ],
            dead: [
                300, 0, 50, 150
            ],
            stayLeft: [
                250, 0, 50, 150
            ],
            walkLeft: [
                200, 0, 50, 150
            ],
            jumpLeft: [
                150, 0, 50, 150
            ],
        },
        frameRate: 7,
        frameIndex: 0,
        direction: 'right'
    });

    marioLayer.add(mario);

    stage.add(marioLayer);

    mario.start();

    var frameCount = 0;

    mario.on('frameIndexChange', function (evt) {
        if (!isElevated && elevation !== 0 && !nextIsFlat()) {
            var next = gameObjects.filter(function (o) {
                return (o.y - mario.getAttr('y') - 150) > 0 && // bottom of mario higher than top of obstacle
                    mario.getAttr('x') + 50 >= o.x &&      // Left side of mario compared to Right side of obstacle
                    mario.getAttr('x') < o.x + o.width;
            })[0];
            if (next) {     // if next to mario there is an obstacle
                var old = mario.getAttr('y');
                if (mario.direction === 'right') {
                    mario.move({
                        x: 8,
                        y: next.y - mario.getAttr('y') - 150
                    });
                } else {
                    mario.move({
                        x: -8,
                        y: next.y - mario.getAttr('y') - 150
                    });
                }
                elevation -= (mario.getAttr('y') - old) / 32;
            } else {        // if next to mario there is no obstacle
                if (mario.direction === 'right') {
                    mario.move({
                        x: 8,
                        y: 32 * elevation
                    });
                } else {
                    mario.move({
                        x: -8,
                        y: 32 * elevation
                    });
                }
                elevation = 0;
            }
        }
        if ((mario.animation() === 'walkRight') && ++frameCount > 2) {
            if (!isStuck) {
                mario.move({
                    x: 8,
                    y: 0
                });
            }
            mario.animation('stayRight');
            frameCount = 0;
        } else if ((mario.animation() === 'walkLeft') && ++frameCount > 2) {
            if (!isStuck) {
                mario.move({
                    x: -8,
                    y: 0
                });
            }
            mario.animation('stayLeft');
            frameCount = 0;
        } else if ((mario.animation() === 'jumpRight' || mario.animation() === 'bigJumpRight') && ++frameCount > 2) {
            mario.move({
                x: 32,
                y: 0
            });
            if (isElevated && nextIsSmallPipe()) {
                mario.move({
                    x: 0,
                    y: -64
                });
                elevation += 2;
            } else if (isElevated) {
                mario.move({
                    x: 0,
                    y: -32
                });
                elevation++;
            }
            mario.animation('stayRight');
            frameCount = 0;
        } else if (mario.animation() === 'jumpLeft' && ++frameCount > 2) {
            mario.move({
                x: -32,
                y: 0
            });
            if (isElevated && nextIsSmallPipe()) {
                mario.move({
                    x: 0,
                    y: -64
                });
                elevation += 2;
            } else if (isElevated) {
                mario.move({
                    x: 0,
                    y: -32
                });
                elevation++;
            }
            mario.animation('stayLeft');
            frameCount = 0;
        }
    });

    function onKeyDown(ev) {
        if (ev.keyCode === 39 && mario.getAttr('x') <= canvas.getAttribute('width') - 70) {
            mario.animation('walkRight');
            mario.direction = 'right';
            if (mario.getAttr('x') > 200) {
                window.scrollBy(5, 0);
            }
        } else if (ev.keyCode === 34 && mario.getAttr('x') <= canvas.getAttribute('width') - 70) {
            mario.animation('jumpRight');
            mario.direction = 'right';
            if (mario.getAttr('x') > 200) {
                window.scrollBy(10, 0);
            }
        } else if (ev.keyCode === 33 && mario.getAttr('x') >= 32) {
            mario.animation('jumpLeft');
            mario.direction = 'left';
        } else if (ev.keyCode === 38 && mario.getAttr('x') <= canvas.getAttribute('width') - 70) {
            mario.animation('bigJumpRight');
            mario.direction = 'right';
            if (mario.getAttr('x') > 200) {
                window.scrollBy(10, 0);
            }
        } else if ((ev.keyCode === 37 && mario.getAttr('x') >= 8)) {
            mario.direction = 'left';
            if (mario.animation() !== 'stayLeft') {
                mario.animation('stayLeft');
            } else {
                mario.animation('walkLeft');
            }
        }
        if (mario.getAttr('x') > 1950) {        // if mario successfully reached the end of the level
            endScreenLayer.draw();
            document.body.removeEventListener('keydown', onKeyDown, false);
            scrollTo(0, 0);
            stopTime = true;
            gameOver();
        }
        collisionDispatcher();
    }

    var isStuck = false;
    var elevation = 0;
    var isElevated = false;

    function nextIsHigher() {  // if next to mario is higher obstacle
        return gameObjects.some(function (o) {
            return (o.y - mario.getAttr('y') - 150) < 0 && // bottom of mario equal to bottom of obstacle
                (o.y - mario.getAttr('y') - 150) > -65 &&
                mario.getAttr('x') + 50 >= o.x &&      // Left side of mario compared to Right side of obstacle
                mario.getAttr('x') < o.x + o.width - 10; // Right side of mario compared to Left side of obstacle
        });
    }

    function nextIsSmallPipe() {
        return gameObjects.some(function (o) {
            return (o.y - mario.getAttr('y') - 150) < 0 &&
                (o.y - mario.getAttr('y') - 150) > -65 &&
                mario.getAttr('x') + 50 >= o.x &&
                mario.getAttr('x') < o.x + o.width - 10 &&
                o.type === 'pipeSmall';
        });
    }

    function nextIsFlat() {  // if next to mario is flat obstacle
        return gameObjects.some(function (o) {
            return (o.y - mario.getAttr('y') - 150) === 0 && // bottom of mario equal to top of obstacle
                mario.getAttr('x') + 50 >= o.x &&      // Left side of mario compared to Right side of obstacle
                mario.getAttr('x') < o.x + o.width - 20; // Right side of mario compared to Left side of obstacle
        });
    }

    function isMarioXInObstacle(obstacle) {
        return mario.getAttr('x') + 50 >= obstacle.x && mario.getAttr('x') < obstacle.x + obstacle.width - 5;
    }

    function collisionDispatcher() {
        var k;
        for (k = 0; k < gameObjects.length; k++) {
            if (isMarioXInObstacle(gameObjects[k])) {
                if ((mario.animation() === 'jumpRight' || mario.animation() === 'bigJumpRight' || mario.animation() === 'jumpLeft') && nextIsHigher()) { // trying to jumpRight over obstacle
                    isElevated = true;
                    return;
                } else if (nextIsHigher()) {
                    isStuck = true;                     // trying to enter obstacle
                    return;
                } else if (mario.animation() === 'bigJumpRight') {
                    if (mario.getAttr('y') - gameObjects[k].y + 32 < 105 &&
                        Math.abs(mario.getAttr('x') + 25 - gameObjects[k].x) - 16 < 5 &&
                        gameObjects[k].type === 'bonusBlock') {

                        bonusAnimation(gameObjects[k].x, gameObjects[k].y);
                        currentScores += 30;
                        displayScore();
                    }
                }
            }
            isStuck = false;
            isElevated = false;
        }

        for (k = 0; k < enemies.length; k++) {
            if (mario.getAttr('x') + 50 >= enemies[k].getAttr('x') &&
                mario.getAttr('x') + 20 < enemies[k].getAttr('x') &&
                (mario.animation() === 'jumpRight' || mario.animation() === 'bigJumpRight' || mario.animation() === 'jumpLeft')) {
                enemies[k].animation('smashed');
                currentScores += 50;
                displayScore();
            } else if (mario.getAttr('x') + 50 >= enemies[k].getAttr('x') &&
                mario.getAttr('x') + 30 < enemies[k].getAttr('x') &&
                !(mario.animation() === 'jumpRight' || mario.animation() === 'bigJumpRight' || mario.animation() === 'jumpLeft') &&
                enemies[k].animation() !== 'smashed') {
                console.log('Mario is eaten!');
                mario.move({
                    x: -mario.getAttr('x') + 8,
                    y: 0
                });
                window.scrollTo(0, 0);
                remainingLives--;
                remainingLivesField.setText(remainingLives);
                lives.draw();

                // if mario dead
                if (remainingLives === -1) {
                    remainingLivesField.setText(0); //number to show on the screen
                    lives.draw(); //showing the number on the screen

                    endScreenLayer.draw();
                    document.body.removeEventListener('keydown', onKeyDown, false);
                    stopTime = true;
                    gameOver();
                }
                currentScores = 0; //null the scores
                displayScore(); //display the nulled scores
                mario.animation('dead');
            }
        }
    }

    document.body.addEventListener('keydown', onKeyDown, false);

};
marioImageObj.src = 'Images/mario1.png';

function bonusAnimation(bonusX, bonusY) {
    var coinsLayer = new Kinetic.Layer();
    var coinImage = new Image();
    coinImage.src = 'Images/game-objects/coin.png';
    var coin = new Kinetic.Sprite({
        x: bonusX + 8,
        y: bonusY - 32,
        image: coinImage,
        animation:
        'rotate',
        animations: {
            rotate: [
                    // x, y, width, height (2 frames)
                    0, 0, 20, 20,
                    25, 0, 20, 20,
                    45, 0, 20, 20,
                    65, 0, 20, 20
            ]
        },
        frameRate: 4,
        frameIndex: 0
    });

    coinsLayer.add(coin);
    coin.start();
    stage.add(coinsLayer);
}

function displayScore() {
    currentScoresField.setText(currentScores);
    score.draw();
}

function gameOver() {
    var userName = prompt('Enter your name: ', 'unnamed');

    var allScores = localStorage.getItem('scores');
    if (!allScores) {
        allScores = [];
    } else {
        allScores = JSON.parse(allScores);
    }

    if (allScores.length === 0) {
        allScores.push({ name: userName, score: currentScores });
    } else {
        if (currentScores < allScores[allScores.length - 1].score) {
            allScores.push({ name: userName, score: currentScores });
        } else {
            for (var i = 0; i < allScores.length; i++) {
                if (allScores[i].score < currentScores) {
                    allScores.splice(i, 0, { name: userName, score: currentScores });
                    break;
                }
            }
        }
    }

    localStorage.removeItem('scores');
    localStorage.setItem('scores', JSON.stringify(allScores));

    var highScoresLayer = new Kinetic.Layer();
    var highScores = new Kinetic.Text({
        x: 900,
        y: 100,
        text: "scores",
        fontSize: 25,
        fontFamily: 'Arial Black',
        fill: 'white'
    });

    highScoresLayer.add(highScores);
    stage.add(highScoresLayer);
    showScore();//display the highScores

    function showScore() {
        var highScoresText = 'HIGHSCORES TABLE \n\n';

        if (allScores.length > 10) {
            allScores.length = 10;
        }
        for (var i = 0; i < allScores.length; i++) {
            highScoresText += (i + 1) + '. ' + allScores[i].name + " --> " + allScores[i].score + '\n';
        }

        highScores.setText(highScoresText);
        highScoresLayer.draw();
    }

    return false;
}<|endoftext|>


<commit_before>import React from 'react';
import PropTypes from 'prop-types';
import { Autobind } from 'es-decorators';

// Components
import Select from 'components/form/SelectInput';
import Icon from 'components/ui/Icon';

class SubscriptionSelector extends React.Component {
  constructor(props) {
    super(props);

    this.state = {
      selectedDataset: null,
      selectedType: null,
      index: props.index
    };
  }

  componentWillReceiveProps(newProps) {
    if (newProps.data) {
      const { selectedDataset, selectedType, index } = newProps.data;
      this.setState({
        selectedDataset,
        selectedType,
        index
      });
    }
  }

  @Autobind
  handleDatasetSelected(value) {
    const { datasets } = this.props;

    const typeOptions = value ?
      Object.keys(
        datasets.find(val => val.id === value).attributes.subscribable)
        .map(val => ({ value: val, label: val }))
      : [];

    if (!this.state.selectedType) {
      this.setState({
        selectedDataset: value,
        selectedType: typeOptions[0],
        typeOptions
      },
      () => this.props.onUpdate(this.state));
    } else {
      this.setState({
        selectedDataset: value,
        typeOptions
      },
      () => this.props.onUpdate(this.state));
    }
  }

  @Autobind
  handleTypeSelected(type) {
    this.setState({ selectedType: type },
      () => this.props.onUpdate(this.state));
  }

  @Autobind
  handleRemove() {
    this.props.onRemove(this.props.index);
  }

  render() {
    const { datasets } = this.props;
    const { selectedDataset, selectedType, typeOptions } = this.state;

    const datasetOptions = (datasets.length > 0) ?
      datasets.map(val => ({ label: val.attributes.name, value: val.id, id: val.id }))
      : [];

    return (

 { this.el = node; }}>
        <Select
          properties={{
            name: 'dataset',
            value: selectedDataset,
            default: selectedDataset,
            placeholder: 'Select a dataset'
          }}
          options={datasetOptions}
          onChange={this.handleDatasetSelected}
        />
        <Select
          properties={{
            name: 'type',
            value: selectedType,
            default: selectedType,
            placeholder: 'Select a type'
          }}
          options={typeOptions}
          onChange={this.handleTypeSelected}
        />
        <button
          className="c-btn -b"
          onClick={() => this.props.onRemove(this.props.index)}
        >
          Delete
        </button>

    );
  }
}

SubscriptionSelector.propTypes = {
  datasets: PropTypes.array.isRequired,
  index: PropTypes.string,
  // CALLBACKS
  onRemove: PropTypes.func.isRequired,
  onUpdate: PropTypes.func.isRequired
};

export default SubscriptionSelector;
<commit_msg>fix data load in edit mode<commit_after>import React from 'react';
import PropTypes from 'prop-types';
import { Autobind } from 'es-decorators';

// Components
import Select from 'components/form/SelectInput';

class SubscriptionSelector extends React.Component {
  constructor(props) {
    super(props);

    this.state = {
      selectedDataset: null,
      selectedType: null,
      index: props.index,
      typeOptions: []
    };
  }

  componentWillReceiveProps(newProps) {
    if (newProps.data) {
      const { selectedDataset, selectedType, index } = newProps.data;
      const typeOptions = selectedDataset ?
        Object.keys(
          newProps.datasets.find(val => val.id === selectedDataset).attributes.subscribable)
          .map(val => ({ value: val, label: val }))
        : [];
      this.setState({
        selectedDataset,
        selectedType,
        index,
        typeOptions
      });
    }
  }

  @Autobind
  handleDatasetSelected(value) {
    const { datasets } = this.props;

    const typeOptions = value ?
      Object.keys(
        datasets.find(val => val.id === value).attributes.subscribable)
        .map(val => ({ value: val, label: val }))
      : [];

    if (!this.state.selectedType) {
      this.setState({
        selectedDataset: value,
        selectedType: typeOptions[0].value,
        typeOptions
      },
      () => this.props.onUpdate(this.state));
    } else {
      this.setState({
        selectedDataset: value,
        typeOptions
      },
      () => this.props.onUpdate(this.state));
    }
  }

  @Autobind
  handleTypeSelected(type) {
    this.setState({ selectedType: type },
      () => this.props.onUpdate(this.state));
  }

  @Autobind
  handleRemove() {
    this.props.onRemove(this.props.index);
  }

  render() {
    const { datasets } = this.props;
    const { selectedDataset, selectedType, typeOptions } = this.state;

    const datasetOptions = (datasets.length > 0) ?
      datasets.map(val => ({ label: val.attributes.name, value: val.id, id: val.id }))
      : [];

    return (

 { this.el = node; }}>
        <Select
          properties={{
            name: 'dataset',
            value: selectedDataset,
            default: selectedDataset,
            placeholder: 'Select a dataset'
          }}
          options={datasetOptions}
          onChange={this.handleDatasetSelected}
        />
        <Select
          properties={{
            name: 'type',
            value: selectedType,
            default: selectedType,
            placeholder: 'Select a type'
          }}
          options={typeOptions}
          onChange={this.handleTypeSelected}
        />
        <button
          className="c-btn -b"
          onClick={() => this.props.onRemove(this.props.index)}
        >
          Delete
        </button>

    );
  }
}

SubscriptionSelector.propTypes = {
  datasets: PropTypes.array.isRequired,
  index: PropTypes.string,
  data: PropTypes.object,
  // CALLBACKS
  onRemove: PropTypes.func.isRequired,
  onUpdate: PropTypes.func.isRequired
};

export default SubscriptionSelector;
<|endoftext|>


<commit_before>import React, { Component } from 'react';
import { connect } from 'react-redux';
import { Link } from 'react-router';
import { push } from 'react-router-redux';

import actions from '../actions/index.js';
import { forkRecipe, fetchRecipes, fetchRecipe } from '../utils/utils';
import RecipeContainer from './RecipeContainer';
import '../scss/_main.scss';
import '../scss/_mainRecipe.scss';

import Like from './Like.js';
class MainRecipe extends Component {
  componentDidMount() {
    const { getRecipe, id } = this.props;
    if (id) {
      getRecipe(id);
    }
  }

  componentWillUpdate(nextProps) {
    const currId = this.props.id;
    const { getRecipe, id } = nextProps;
    if (+currId !== +id) {
      getRecipe(id);
    }
  }

  render() {
    const { user, navToEdit, recipe, onForkClick, historyRecipes, } = this.props;
    let forkButton;
    if (user.id) {
      forkButton = <button className="btn-fork" onClick={ onForkClick.bind(null, recipe.id, user.id) }>Fork</button>;
    } else {
      forkButton = <button className="btn-fork" disabled>Fork</button>;
    }

    let editButton;
    if (user.id === recipe.author && user.id !== null) {
      editButton = <button
      className="btn-toggle-edit"
      onClick={(e) => {
        e.preventDefault();
        e.stopPropagation();
        navToEdit(user);
      }}>Edit Recipe</button>;
    } else {
      editButton = <button className="btn-toggle-edit" disabled>Edit Recipe</button>
    }

    return (

        {/*
THIS IS THE USER: {user.displayName}

THIS IS THE RECIPE AUTHOR: {recipe.author}

THIS IS THE RECIPE PARENT: {recipe.parent}

THIS IS THE RECIPE HISTORY: {recipe.fork_history}

THIS IS THE RECIPE ID: {recipe.id}
*/}
        {editButton}
        {forkButton}
        <Like recipeID={recipe.id} userID={user.id} />
        {/*<Link to="/recipe/15">GO TO RECIPE 15</Link>*/}

{recipe.title}

                {recipe.images.map((image) =>

)}

                <RecipeContainer
                  className="fork-history"
                  type="Recipe History"
                  recipes={historyRecipes}
                />

Servings: {recipe.yield + ' ' + recipe.yield_unit}

 tags: {recipe.tags.map(t =>  {t} )}

 Ingredients

                {recipe.ingredients.map((i) =>
 {i}
)}

 Prep | Time: {recipe.prep_time}

              {recipe.prep_steps.map((s) =>
 {s}
)}

 Cook | Time: {recipe.cook_time}

              {recipe.cook_steps.map((s) =>
 {s}
)}

 Finish

              {recipe.finish_steps.map((s) =>
 {s}
)}

 Documentation

    );
  }
}

const mapStateToProps = (state, ownProps) => {
  return {

    user: state.user,
    recipe: state.recipe,
    fork_history: state.recipe.fork_history || [],
    historyRecipes: state.recipe.historyRecipes,
    id: ownProps.params.id,
  };
};

const mapDispatchToProps = (dispatch) => {
  return {
    onForkClick: (recipeID, userID) => {
      forkRecipe(recipeID, userID, (newRecipe) => {
        dispatch(actions.forkRecipe(newRecipe));
        dispatch(push(`/recipe/${newRecipe.id}`));
      });
    },

    navToEdit: (user) => {
      dispatch(push('/search'));
    },

    getRecipe: (recipeID) => {
      fetchRecipe(recipeID, (recipe) => {
        dispatch(actions.setRecipe(recipe));
        fetchRecipes(recipe.fork_history, (recipes) => {
          dispatch(actions.setRecipeHistory(recipes));
        });
      });
    },
  };
};

export default connect(
  mapStateToProps,
  mapDispatchToProps
)(MainRecipe);
<commit_msg>fix redirect bug, now points to /create<commit_after>import React, { Component } from 'react';
import { connect } from 'react-redux';
import { Link } from 'react-router';
import { push } from 'react-router-redux';

import actions from '../actions/index.js';
import { forkRecipe, fetchRecipes, fetchRecipe } from '../utils/utils';
import RecipeContainer from './RecipeContainer';
import '../scss/_main.scss';
import '../scss/_mainRecipe.scss';

import Like from './Like.js';
class MainRecipe extends Component {
  componentDidMount() {
    const { getRecipe, id } = this.props;
    if (id) {
      getRecipe(id);
    }
  }

  componentWillUpdate(nextProps) {
    const currId = this.props.id;
    const { getRecipe, id } = nextProps;
    if (+currId !== +id) {
      getRecipe(id);
    }
  }

  render() {
    const { user, navToEdit, recipe, onForkClick, historyRecipes, } = this.props;
    let forkButton;
    if (user.id) {
      forkButton = <button className="btn-fork" onClick={ onForkClick.bind(null, recipe.id, user.id) }>Fork</button>;
    } else {
      forkButton = <button className="btn-fork" disabled>Fork</button>;
    }

    let editButton;
    if (user.id === recipe.author && user.id !== null) {
      editButton = <button
      className="btn-toggle-edit"
      onClick={(e) => {
        e.preventDefault();
        e.stopPropagation();
        navToEdit(user);
      }}>Edit Recipe</button>;
    } else {
      editButton = <button className="btn-toggle-edit" disabled>Edit Recipe</button>
    }

    return (

        {/*
THIS IS THE USER: {user.displayName}

THIS IS THE RECIPE AUTHOR: {recipe.author}

THIS IS THE RECIPE PARENT: {recipe.parent}

THIS IS THE RECIPE HISTORY: {recipe.fork_history}

THIS IS THE RECIPE ID: {recipe.id}
*/}
        {editButton}
        {forkButton}
        <Like recipeID={recipe.id} userID={user.id} />
        {/*<Link to="/recipe/15">GO TO RECIPE 15</Link>*/}

{recipe.title}

                {recipe.images.map((image) =>

)}

                <RecipeContainer
                  className="fork-history"
                  type="Recipe History"
                  recipes={historyRecipes}
                />

Servings: {recipe.yield + ' ' + recipe.yield_unit}

 tags: {recipe.tags.map(t =>  {t} )}

 Ingredients

                {recipe.ingredients.map((i) =>
 {i}
)}

 Prep | Time: {recipe.prep_time}

              {recipe.prep_steps.map((s) =>
 {s}
)}

 Cook | Time: {recipe.cook_time}

              {recipe.cook_steps.map((s) =>
 {s}
)}

 Finish

              {recipe.finish_steps.map((s) =>
 {s}
)}

 Documentation

    );
  }
}

const mapStateToProps = (state, ownProps) => {
  return {

    user: state.user,
    recipe: state.recipe,
    fork_history: state.recipe.fork_history || [],
    historyRecipes: state.recipe.historyRecipes,
    id: ownProps.params.id,
  };
};

const mapDispatchToProps = (dispatch) => {
  return {
    onForkClick: (recipeID, userID) => {
      forkRecipe(recipeID, userID, (newRecipe) => {
        dispatch(actions.forkRecipe(newRecipe));
        dispatch(push(`/recipe/${newRecipe.id}`));
      });
    },

    navToEdit: (user) => {
      dispatch(push('/create'));
    },

    getRecipe: (recipeID) => {
      fetchRecipe(recipeID, (recipe) => {
        dispatch(actions.setRecipe(recipe));
        fetchRecipes(recipe.fork_history, (recipes) => {
          dispatch(actions.setRecipeHistory(recipes));
        });
      });
    },
  };
};

export default connect(
  mapStateToProps,
  mapDispatchToProps
)(MainRecipe);
<|endoftext|>