<commit_before>import React, {Component} from 'react';
import PropTypes from 'prop-types';
import {omit} from 'ramda';

/**
 * A basic HTML input control for entering text, numbers, or passwords.
 *
 * Note that checkbox and radio types are supported through
 * the Checklist and RadioItems component. Dates, times, and file uploads
 * are also supported through separate components.
 */
export default class Input extends Component {
    constructor(props) {
        super(props);
        this.state = {value: props.value};
    }

    componentWillReceiveProps(nextProps) {
        this.setState({value: nextProps.value});
    }

    render() {
        const {fireEvent, setProps, type} = this.props;
        const {value} = this.state;
        return (
            <input
                onChange={e => {
                    this.setState({value: e.target.value});
                    if (setProps) {
                        if (type === 'number') {
                            setProps({value: Number(e.target.value)});
                        } else {
                            setProps({value: e.target.value});
                        }
                    }
                    if (fireEvent) {
                        fireEvent({event: 'change'});
                    }
                }}
                onBlur={() => {
                    if (fireEvent) {
                        fireEvent({event: 'blur'});
                    }
                }}
                value={value}
                {...omit(['fireEvent', 'setProps', 'value'], this.props)}
            />
        );
    }
}

Input.propTypes = {
    /**
     * The ID of this component, used to identify dash components
     * in callbacks. The ID needs to be unique across all of the
     * components in an app.
     */
    id: PropTypes.string,

    /**
     * The value of the input
     */
    value: PropTypes.string,

    /**
     * The input's inline styles
     */
    style: PropTypes.object,

    /**
     * The class of the input element
     */
    className: PropTypes.string,

    /**
     * The type of control to render.
     */
    type: PropTypes.oneOf([
        // Only allowing the input types with wide browser compatability
        'text',
        'number',
        'password',
        'email',
        'range',
        'search',
        'tel',
        'url',
        'hidden',
    ]),

    /**
     * This attribute indicates whether the value of the control can be automatically completed by the browser.
     */
    autocomplete: PropTypes.string,

    /**
     * The element should be automatically focused after the page loaded.
     */
    autofocus: PropTypes.string,

    /**
     * If true, the input is disabled and can't be clicked on.
     */
    disabled: PropTypes.bool,

    inputmode: PropTypes.oneOf([
        /**
         * Alphanumeric, non-prose content such as usernames and passwords.
         */
        'verbatim',

        /**
         * Latin-script input in the user's preferred language with typing aids such as text prediction enabled. For human-to-computer communication such as search boxes.
         */
        'latin',

        /**
         * As latin, but for human names.
         */
        'latin-name',

        /**
         * As latin, but with more aggressive typing aids. For human-to-human communication such as instant messaging or email.
         */
        'latin-prose',

        /**
         * As latin-prose, but for the user's secondary languages.
         */
        'full-width-latin',

        /**
         * Kana or romaji input, typically hiragana input, using full-width characters, with support for converting to kanji. Intended for Japanese text input.
         */
        'kana',

        /**
         * Katakana input, using full-width characters, with support for converting to kanji. Intended for Japanese text input.
         */
        'katakana',

        /**
         * Numeric input, including keys for the digits 0 to 9, the user's preferred thousands separator character, and the character for indicating negative numbers. Intended for numeric codes (e.g. credit card numbers). For actual numbers, prefer using type="number"
         */
        'numeric',

        /**
         * Telephone input, including asterisk and pound key. Use type="tel" if possible instead.
         */
        'tel',

        /**
         * Email input. Use type="email" if possible instead.
         */
        'email',

        /**
         * URL input. Use type="url" if possible instead.
         */
        'url',
    ]),

    /**
     * Identifies a list of pre-defined options to suggest to the user.
     * The value must be the id of a <datalist> element in the same document.
     * The browser displays only options that are valid values for this
     * input element.
     * This attribute is ignored when the type attribute's value is
     * hidden, checkbox, radio, file, or a button type.
     */
    list: PropTypes.string,

    /**
     * The maximum (numeric or date-time) value for this item, which must not be less than its minimum (min attribute) value.
     */
    max: PropTypes.string,

    /**
     * If the value of the type attribute is text, email, search, password, tel, or url, this attribute specifies the maximum number of characters (in UTF-16 code units) that the user can enter. For other control types, it is ignored. It can exceed the value of the size attribute. If it is not specified, the user can enter an unlimited number of characters. Specifying a negative number results in the default behavior (i.e. the user can enter an unlimited number of characters). The constraint is evaluated only when the value of the attribute has been changed.
     */
    maxlength: PropTypes.string,

    /**
     * The minimum (numeric or date-time) value for this item, which must not be greater than its maximum (max attribute) value.
     */
    min: PropTypes.string,

    /**
     * If the value of the type attribute is text, email, search, password, tel, or url, this attribute specifies the minimum number of characters (in Unicode code points) that the user can enter. For other control types, it is ignored.
     */
    minlength: PropTypes.string,

    /**
     * This Boolean attribute indicates whether the user can enter more than one value. This attribute applies when the type attribute is set to email or file, otherwise it is ignored.
     */
    multiple: PropTypes.string,

    /**
     * The name of the control, which is submitted with the form data.
     */
    name: PropTypes.string,

    /**
     * A regular expression that the control's value is checked against. The pattern must match the entire value, not just some subset. Use the title attribute to describe the pattern to help the user. This attribute applies when the value of the type attribute is text, search, tel, url, email, or password, otherwise it is ignored. The regular expression language is the same as JavaScript RegExp algorithm, with the 'u' parameter that makes it treat the pattern as a sequence of unicode code points. The pattern is not surrounded by forward slashes.
     */
    pattern: PropTypes.string,

    /**
     * A hint to the user of what can be entered in the control . The placeholder text must not contain carriage returns or line-feeds. Note: Do not use the placeholder attribute instead of a <label> element, their purposes are different. The <label> attribute describes the role of the form element (i.e. it indicates what kind of information is expected), and the placeholder attribute is a hint about the format that the content should take. There are cases in which the placeholder attribute is never displayed to the user, so the form must be understandable without it.
     */
    placeholder: PropTypes.string,

    /**
     * This attribute indicates that the user cannot modify the value of the control. The value of the attribute is irrelevant. If you need read-write access to the input value, do not add the "readonly" attribute. It is ignored if the value of the type attribute is hidden, range, color, checkbox, radio, file, or a button type (such as button or submit).
     */
    readonly: PropTypes.string,

    /**
     * This attribute specifies that the user must fill in a value before submitting a form. It cannot be used when the type attribute is hidden, image, or a button type (submit, reset, or button). The :optional and :required CSS pseudo-classes will be applied to the field as appropriate.
     */
    required: PropTypes.string,

    /**
     * The direction in which selection occurred. This is "forward" if the selection was made from left-to-right in an LTR locale or right-to-left in an RTL locale, or "backward" if the selection was made in the opposite direction. On platforms on which it's possible this value isn't known, the value can be "none"; for example, on macOS, the default direction is "none", then as the user begins to modify the selection using the keyboard, this will change to reflect the direction in which the selection is expanding.
     */
    selectionDirection: PropTypes.string,

    /**
     * The offset into the element's text content of the last selected character. If there's no selection, this value indicates the offset to the character following the current text input cursor position (that is, the position the next character typed would occupy).
     */
    selectionEnd: PropTypes.string,

    /**
     * The offset into the element's text content of the first selected character. If there's no selection, this value indicates the offset to the character following the current text input cursor position (that is, the position the next character typed would occupy).
     */
    selectionStart: PropTypes.string,

    /**
     * The initial size of the control. This value is in pixels unless the value of the type attribute is text or password, in which case it is an integer number of characters. Starting in, this attribute applies only when the type attribute is set to text, search, tel, url, email, or password, otherwise it is ignored. In addition, the size must be greater than zero. If you do not specify a size, a default value of 20 is used.' simply states "the user agent should ensure that at least that many characters are visible", but different characters can have different widths in certain fonts. In some browsers, a certain string with x characters will not be entirely visible even if size is defined to at least x.
     */
    size: PropTypes.string,

    /**
     * Setting the value of this attribute to true indicates that the element needs to have its spelling and grammar checked. The value default indicates that the element is to act according to a default behavior, possibly based on the parent element's own spellcheck value. The value false indicates that the element should not be checked.
     */
    spellcheck: PropTypes.string,

    /**
     * Works with the min and max attributes to limit the increments at which a numeric or date-time value can be set. It can be the string any or a positive floating point number. If this attribute is not set to any, the control accepts only values at multiples of the step value greater than the minimum.
     */
    step: PropTypes.string,

    /**
     * Dash-assigned callback that gets fired when the input changes.
     */
    fireEvent: PropTypes.func,

    /**
     * Dash-assigned callback that gets fired when the value changes.
     */
    setProps: PropTypes.func,

    dashEvents: PropTypes.oneOf(['blur', 'change']),
};
<commit_msg>Add `n_blur/n_submit` to Input.<commit_after>import React, {Component} from 'react';
import PropTypes from 'prop-types';
import {omit} from 'ramda';

/**
 * A basic HTML input control for entering text, numbers, or passwords.
 *
 * Note that checkbox and radio types are supported through
 * the Checklist and RadioItems component. Dates, times, and file uploads
 * are also supported through separate components.
 */
export default class Input extends Component {
    constructor(props) {
        super(props);
        this.state = {value: props.value};
    }

    componentWillReceiveProps(nextProps) {
        this.setState({value: nextProps.value});
    }

    render() {
        const {fireEvent, setProps, type} = this.props;
        const {value} = this.state;
        return (
            <input
                onChange={e => {
                    this.setState({value: e.target.value});
                    if (setProps) {
                        if (type === 'number') {
                            setProps({value: Number(e.target.value)});
                        } else {
                            setProps({value: e.target.value});
                        }
                    }
                    if (fireEvent) {
                        fireEvent({event: 'change'});
                    }
                }}
                onBlur={() => {
                    if (fireEvent) {
                        fireEvent({event: 'blur'});
                    }
                    if (setProps) {
                        setProps({
                            n_blur: this.props.n_blur + 1,
                            n_blur_timestamp: new Date(),
                        });
                    }
                }}
                onKeyUp={e => {
                    if (setProps && e.key === 'Enter') {
                        setProps({
                            n_submit: this.props.n_submit + 1,
                            n_submit_timestamp: new Date(),
                        });
                    }
                }}
                value={value}
                {...omit(['fireEvent', 'setProps', 'value'], this.props)}
            />
        );
    }
}

Input.defaultProps = {
    n_blur: 0,
    n_blur_timestamp: -1,
    n_submit: 0,
    n_submit_timestamp: -1,
};

Input.propTypes = {
    /**
     * The ID of this component, used to identify dash components
     * in callbacks. The ID needs to be unique across all of the
     * components in an app.
     */
    id: PropTypes.string,

    /**
     * The value of the input
     */
    value: PropTypes.string,

    /**
     * The input's inline styles
     */
    style: PropTypes.object,

    /**
     * The class of the input element
     */
    className: PropTypes.string,

    /**
     * The type of control to render.
     */
    type: PropTypes.oneOf([
        // Only allowing the input types with wide browser compatibility
        'text',
        'number',
        'password',
        'email',
        'range',
        'search',
        'tel',
        'url',
        'hidden',
    ]),

    /**
     * This attribute indicates whether the value of the control can be automatically completed by the browser.
     */
    autocomplete: PropTypes.string,

    /**
     * The element should be automatically focused after the page loaded.
     */
    autofocus: PropTypes.string,

    /**
     * If true, the input is disabled and can't be clicked on.
     */
    disabled: PropTypes.bool,

    inputmode: PropTypes.oneOf([
        /**
         * Alphanumeric, non-prose content such as usernames and passwords.
         */
        'verbatim',

        /**
         * Latin-script input in the user's preferred language with typing aids such as text prediction enabled. For human-to-computer communication such as search boxes.
         */
        'latin',

        /**
         * As latin, but for human names.
         */
        'latin-name',

        /**
         * As latin, but with more aggressive typing aids. For human-to-human communication such as instant messaging or email.
         */
        'latin-prose',

        /**
         * As latin-prose, but for the user's secondary languages.
         */
        'full-width-latin',

        /**
         * Kana or romaji input, typically hiragana input, using full-width characters, with support for converting to kanji. Intended for Japanese text input.
         */
        'kana',

        /**
         * Katakana input, using full-width characters, with support for converting to kanji. Intended for Japanese text input.
         */
        'katakana',

        /**
         * Numeric input, including keys for the digits 0 to 9, the user's preferred thousands separator character, and the character for indicating negative numbers. Intended for numeric codes (e.g. credit card numbers). For actual numbers, prefer using type="number"
         */
        'numeric',

        /**
         * Telephone input, including asterisk and pound key. Use type="tel" if possible instead.
         */
        'tel',

        /**
         * Email input. Use type="email" if possible instead.
         */
        'email',

        /**
         * URL input. Use type="url" if possible instead.
         */
        'url',
    ]),

    /**
     * Identifies a list of pre-defined options to suggest to the user.
     * The value must be the id of a <datalist> element in the same document.
     * The browser displays only options that are valid values for this
     * input element.
     * This attribute is ignored when the type attribute's value is
     * hidden, checkbox, radio, file, or a button type.
     */
    list: PropTypes.string,

    /**
     * The maximum (numeric or date-time) value for this item, which must not be less than its minimum (min attribute) value.
     */
    max: PropTypes.string,

    /**
     * If the value of the type attribute is text, email, search, password, tel, or url, this attribute specifies the maximum number of characters (in UTF-16 code units) that the user can enter. For other control types, it is ignored. It can exceed the value of the size attribute. If it is not specified, the user can enter an unlimited number of characters. Specifying a negative number results in the default behavior (i.e. the user can enter an unlimited number of characters). The constraint is evaluated only when the value of the attribute has been changed.
     */
    maxlength: PropTypes.string,

    /**
     * The minimum (numeric or date-time) value for this item, which must not be greater than its maximum (max attribute) value.
     */
    min: PropTypes.string,

    /**
     * If the value of the type attribute is text, email, search, password, tel, or url, this attribute specifies the minimum number of characters (in Unicode code points) that the user can enter. For other control types, it is ignored.
     */
    minlength: PropTypes.string,

    /**
     * This Boolean attribute indicates whether the user can enter more than one value. This attribute applies when the type attribute is set to email or file, otherwise it is ignored.
     */
    multiple: PropTypes.string,

    /**
     * The name of the control, which is submitted with the form data.
     */
    name: PropTypes.string,

    /**
     * A regular expression that the control's value is checked against. The pattern must match the entire value, not just some subset. Use the title attribute to describe the pattern to help the user. This attribute applies when the value of the type attribute is text, search, tel, url, email, or password, otherwise it is ignored. The regular expression language is the same as JavaScript RegExp algorithm, with the 'u' parameter that makes it treat the pattern as a sequence of unicode code points. The pattern is not surrounded by forward slashes.
     */
    pattern: PropTypes.string,

    /**
     * A hint to the user of what can be entered in the control . The placeholder text must not contain carriage returns or line-feeds. Note: Do not use the placeholder attribute instead of a <label> element, their purposes are different. The <label> attribute describes the role of the form element (i.e. it indicates what kind of information is expected), and the placeholder attribute is a hint about the format that the content should take. There are cases in which the placeholder attribute is never displayed to the user, so the form must be understandable without it.
     */
    placeholder: PropTypes.string,

    /**
     * This attribute indicates that the user cannot modify the value of the control. The value of the attribute is irrelevant. If you need read-write access to the input value, do not add the "readonly" attribute. It is ignored if the value of the type attribute is hidden, range, color, checkbox, radio, file, or a button type (such as button or submit).
     */
    readonly: PropTypes.string,

    /**
     * This attribute specifies that the user must fill in a value before submitting a form. It cannot be used when the type attribute is hidden, image, or a button type (submit, reset, or button). The :optional and :required CSS pseudo-classes will be applied to the field as appropriate.
     */
    required: PropTypes.string,

    /**
     * The direction in which selection occurred. This is "forward" if the selection was made from left-to-right in an LTR locale or right-to-left in an RTL locale, or "backward" if the selection was made in the opposite direction. On platforms on which it's possible this value isn't known, the value can be "none"; for example, on macOS, the default direction is "none", then as the user begins to modify the selection using the keyboard, this will change to reflect the direction in which the selection is expanding.
     */
    selectionDirection: PropTypes.string,

    /**
     * The offset into the element's text content of the last selected character. If there's no selection, this value indicates the offset to the character following the current text input cursor position (that is, the position the next character typed would occupy).
     */
    selectionEnd: PropTypes.string,

    /**
     * The offset into the element's text content of the first selected character. If there's no selection, this value indicates the offset to the character following the current text input cursor position (that is, the position the next character typed would occupy).
     */
    selectionStart: PropTypes.string,

    /**
     * The initial size of the control. This value is in pixels unless the value of the type attribute is text or password, in which case it is an integer number of characters. Starting in, this attribute applies only when the type attribute is set to text, search, tel, url, email, or password, otherwise it is ignored. In addition, the size must be greater than zero. If you do not specify a size, a default value of 20 is used.' simply states "the user agent should ensure that at least that many characters are visible", but different characters can have different widths in certain fonts. In some browsers, a certain string with x characters will not be entirely visible even if size is defined to at least x.
     */
    size: PropTypes.string,

    /**
     * Setting the value of this attribute to true indicates that the element needs to have its spelling and grammar checked. The value default indicates that the element is to act according to a default behavior, possibly based on the parent element's own spellcheck value. The value false indicates that the element should not be checked.
     */
    spellcheck: PropTypes.string,

    /**
     * Works with the min and max attributes to limit the increments at which a numeric or date-time value can be set. It can be the string any or a positive floating point number. If this attribute is not set to any, the control accepts only values at multiples of the step value greater than the minimum.
     */
    step: PropTypes.string,

    /**
     * Number of times the `Enter` key was pressed while the input had focus.
     */
    n_submit: PropTypes.number,
    /**
     * Last time that `Enter` was pressed.
     */
    n_submit_timestamp: PropTypes.number,

    /**
     * Number of times the input lost focus.
     */
    n_blur: PropTypes.number,
    /**
     * Last time the input lost focus.
     */
    n_blur_timestamp: PropTypes.number,

    /**
     * Dash-assigned callback that gets fired when the input changes.
     */
    fireEvent: PropTypes.func,

    /**
     * Dash-assigned callback that gets fired when the value changes.
     */
    setProps: PropTypes.func,

    dashEvents: PropTypes.oneOf(['blur', 'change']),
};
<|endoftext|>


<commit_before>var fs = require('fs');
var path = require('path');
var async = require('async');
var GitStatistics = require('../classes/gitStatistics.js');

function Updater(pathToReposDir) {
  self = this;
  this.pathToReposDir = pathToReposDir;

  this.statisticsSections = function(gitStatistics) {
    return [
    function(callback) {
      gitStatistics.updateRepo(function() {
        callback(null, null);
      });
    },
    function(callback) {
      gitStatistics.get10LatestCommits(function(latestCommits) {
        callback(null, { latestCommits: latestCommits });
      });
    },
    function(callback) {
      gitStatistics.getTop10Committers(function(top10Committers) {
        callback(null, { top10Committers: top10Committers });
      });
    }
  ]};

  this.updateData = function(done) {
    var repos = this.getAllRepos();
    var gitStatisticsArray = new Array();
    repos.forEach(function(repoName) {
      gitStatisticsArray.push(new GitStatistics(path.join(self.pathToReposDir, repoName)));
    });

    async.map(gitStatisticsArray, function(gitStatistics, repoCallback) {
      async.series(
        self.statisticsSections(gitStatistics),
        function(err, results) {
          var repoData = {};
          repoData[path.basename(gitStatistics.repoPath)] = {};
          self.formatResults(repoData[path.basename(gitStatistics.repoPath)], results);

          repoCallback(null, repoData);
        }
      );
    }, function(err, results) {
      var data = {};
      data.repos = repos;
      self.formatResults(data, results);

      self.calculateCombinedStatistics(data, function(combinedStatistics) {
        self.formatResults(data, [combinedStatistics]);
        data.repos.push('all');
        done(data);
      });
    });
  }

  this.getAllRepos = function() {
    var repos = new Array();
    var files = fs.readdirSync(self.pathToReposDir);
    files.forEach(function(file) {
      var repoPath = path.join(self.pathToReposDir, file);
      if(fs.lstatSync(repoPath).isDirectory()) {
        repos.push(file);
      }
    });

    return repos;
  }

  this.formatResults = function(data, results) {
    for (var i in results) {
      for (var c in results[i]) {
        data[c] = results[i][c];
      }
    }
  }

  this.calculateCombinedStatistics = function(data, callback) {
    var combinedStatistics = {};

    // latestCommits
    var allCommits = self.getCombinedStatisticsSection(data, 'latestCommits');
    allCommits.sort(function(a,b) { return new Date(a.date) - new Date(b.data) } );
    combinedStatistics.latestCommits = allCommits.slice(0, 10);

    // top10Committers
    var allCommitters = self.getCombinedStatisticsSection(data, 'top10Committers');
    allCommitters.sort(function(a,b) { return parseInt(a.numberOfCommits) - parseInt(b.numberOfCommits) } );
    combinedStatistics.top10Committers = allCommitters.slice(0, 10);

    callback({all: combinedStatistics});
  }

  this.getCombinedStatisticsSection = function(data, section) {
    var items = [];
    for(var i in data) {
      if(data[i] == 'repos') {
        continue;
      }

      for(var c in data[i][section]) {
        items.push(data[i][section][c]);
      }
    }
    return items;
  }
}

module.exports = Updater;<commit_msg>Added name of repo to combined statistics<commit_after>var fs = require('fs');
var path = require('path');
var async = require('async');
var GitStatistics = require('../classes/gitStatistics.js');

function Updater(pathToReposDir) {
  self = this;
  this.pathToReposDir = pathToReposDir;

  this.statisticsSections = function(gitStatistics) {
    return [
    function(callback) {
      gitStatistics.updateRepo(function() {
        callback(null, null);
      });
    },
    function(callback) {
      gitStatistics.get10LatestCommits(function(latestCommits) {
        callback(null, { latestCommits: latestCommits });
      });
    },
    function(callback) {
      gitStatistics.getTop10Committers(function(top10Committers) {
        callback(null, { top10Committers: top10Committers });
      });
    }
  ]};

  this.updateData = function(done) {
    var repos = this.getAllRepos();
    var gitStatisticsArray = new Array();
    repos.forEach(function(repoName) {
      gitStatisticsArray.push(new GitStatistics(path.join(self.pathToReposDir, repoName)));
    });

    async.map(gitStatisticsArray, function(gitStatistics, repoCallback) {
      async.series(
        self.statisticsSections(gitStatistics),
        function(err, results) {
          var repoData = {};
          repoData[path.basename(gitStatistics.repoPath)] = {};
          self.formatResults(repoData[path.basename(gitStatistics.repoPath)], results);

          repoCallback(null, repoData);
        }
      );
    }, function(err, results) {
      var data = {};
      data.repos = repos;
      self.formatResults(data, results);

      self.calculateCombinedStatistics(data, function(combinedStatistics) {
        self.formatResults(data, [combinedStatistics]);
        data.repos.push('all');
        done(data);
      });
    });
  }

  this.getAllRepos = function() {
    var repos = new Array();
    var files = fs.readdirSync(self.pathToReposDir);
    files.forEach(function(file) {
      var repoPath = path.join(self.pathToReposDir, file);
      if(fs.lstatSync(repoPath).isDirectory()) {
        repos.push(file);
      }
    });

    return repos;
  }

  this.formatResults = function(data, results) {
    for (var i in results) {
      for (var c in results[i]) {
        data[c] = results[i][c];
      }
    }
  }

  this.calculateCombinedStatistics = function(data, callback) {
    var combinedStatistics = {};

    // latestCommits
    var allCommits = self.getCombinedStatisticsSection(data, 'latestCommits');
    allCommits.sort(function(a,b) { return new Date(a.date) - new Date(b.data) } );
    combinedStatistics.latestCommits = allCommits.slice(0, 10);

    // top10Committers
    var allCommitters = self.getCombinedStatisticsSection(data, 'top10Committers');
    allCommitters.sort(function(a,b) { return parseInt(a.numberOfCommits) - parseInt(b.numberOfCommits) } );
    combinedStatistics.top10Committers = allCommitters.slice(0, 10);

    callback({all: combinedStatistics});
  }

  this.getCombinedStatisticsSection = function(data, section) {
    var items = [];
    for(var i in data) {
      if(data[i] == 'repos') {
        continue;
      }

      for(var c in data[i][section]) {
        var item = data[i][section][c];
        item.repo = i;
        items.push(item);
      }
    }
    return items;
  }
}

module.exports = Updater;<|endoftext|>


<commit_before>import React, { Component } from 'react';

class Instruction extends Component {
  render(){
    return (

You are about to take a color blind test. Look at the following images and input the number you think is presented.

     	 <Next/>

      );
  }
}

export default Instruction;

// Need start test button<commit_msg>Remove next tag<commit_after>import React, { Component } from 'react';

class Instruction extends Component {
  render(){
    return (

You are about to take a color blind test. Look at the following images and input the number you think is presented.

      );
  }
}

export default Instruction;

// Need start test button<|endoftext|>


<commit_before>// routes.js
// aoneill - 04/13/15

var cp = require('child_process');

module.exports.load = function(server) {
  // Home view
  server.get('/', function(req, res) {
    res.render('home');
  });

  // Git update endpoint
  server.post('/update', function(req, res) {
    var str = '';
    var git = cp.spawn('/usr/local/bin/aoneill.me-update',
      [__dirname]);

    git.stdout.on('data', function(chunk) {
      str += chunk;
    });

    git.stdout.on('end', function() {
      res.json({
        success: true,
        out: str
      });
    });
  });

  // Last route -- 404 Route
  server.get('/*', function(req, res) {
    res.send('404');
  });
}
<commit_msg>Changed 404 route to be ALL rather than just GET<commit_after>// routes.js
// aoneill - 04/13/15

var cp = require('child_process');

module.exports.load = function(server) {
  // Home view
  server.get('/', function(req, res) {
    res.render('home');
  });

  // Git update endpoint
  server.post('/update', function(req, res) {
    var str = '';
    var git = cp.spawn('/usr/local/bin/aoneill.me-update',
      [__dirname]);

    git.stdout.on('data', function(chunk) {
      str += chunk;
    });

    git.stdout.on('end', function() {
      res.json({
        success: true,
        out: str
      });
    });
  });

  // Last route -- 404 Route
  server.all('/*', function(req, res) {
    res.send('404');
  });
}
<|endoftext|>


<commit_before>import React, { PureComponent } from 'react'
import { find, toLower } from 'lodash'

import { withStyles } from '@material-ui/core/styles'
import MenuItem from '@material-ui/core/MenuItem'
import TextField from '@material-ui/core/TextField'

import getKeyDiff from '../utils/getKeyDiff'

const options = [
	{ key: 'C', label: 'C', value: 'c' },
	{ key: 'C#', label: 'C#', value: 'c#' },
	{ key: 'D', label: 'D', value: 'd' },
	{ key: 'Eb', label: 'Eb', value: 'eb' },
	{ key: 'E', label: 'E', value: 'e' },
	{ key: 'F', label: 'F', value: 'f' },
	{ key: 'F#', label: 'F#', value: 'f#' },
	{ key: 'G', label: 'G', value: 'g' },
	{ key: 'Ab', label: 'Ab', value: 'ab' },
	{ key: 'A', label: 'A', value: 'a' },
	{ key: 'Bb', label: 'Bb', value: 'bb' },
	{ key: 'B', label: 'B', value: 'b' },
]

const styles = theme => ({
	root: {
		minWidth: theme.spacing.unit * 9,
	},
})

class KeySelector extends PureComponent {
	state = {
		value: 'c',
	}

	componentDidMount() {
		this.handleProps(this.props)
	}

	componentWillReceiveProps(nextProps) {
		this.handleProps(nextProps)
	}

	handleChange = event => {
		const value = event.target.value
		const option = find(options, { value })

		this.setState({ value })

		if (this.props.onSelect) {
			this.props.onSelect(
				option,
				getKeyDiff(this.props.songKey, option.key)
			)
		}
	}

	handleProps = props => {
		const value = toLower(props.songKey)
		if (value !== this.state.value && find(options, { value })) {
			this.setState({ value })
		}
	}

	render() {
		const { classes, label } = this.props
		const { value } = this.state

		return (
			<TextField
				className={classes.root}
				select
				label={label}
				value={value}
				onChange={this.handleChange}
			>
				{options.map(option => (
					<MenuItem key={option.value} value={option.value}>
						{option.label}
					</MenuItem>
				))}
			</TextField>
		)
	}
}

export default withStyles(styles)(KeySelector)
<commit_msg>attempt to improve the key selector look<commit_after>import React, { PureComponent } from 'react'
import { find, toLower } from 'lodash'

import { withStyles } from '@material-ui/core/styles'
import MenuItem from '@material-ui/core/MenuItem'
import TextField from '@material-ui/core/TextField'

import getKeyDiff from '../utils/getKeyDiff'

const options = [
	{ key: 'C', label: 'C', value: 'c' },
	{ key: 'C#', label: 'C#', value: 'c#' },
	{ key: 'D', label: 'D', value: 'd' },
	{ key: 'Eb', label: 'Eb', value: 'eb' },
	{ key: 'E', label: 'E', value: 'e' },
	{ key: 'F', label: 'F', value: 'f' },
	{ key: 'F#', label: 'F#', value: 'f#' },
	{ key: 'G', label: 'G', value: 'g' },
	{ key: 'Ab', label: 'Ab', value: 'ab' },
	{ key: 'A', label: 'A', value: 'a' },
	{ key: 'Bb', label: 'Bb', value: 'bb' },
	{ key: 'B', label: 'B', value: 'b' },
]

const styles = theme => ({
	root: {
		// minWidth: theme.spacing.unit * 9,
	},
})

class KeySelector extends PureComponent {
	state = {
		value: 'c',
	}

	componentDidMount() {
		this.handleProps(this.props)
	}

	componentWillReceiveProps(nextProps) {
		this.handleProps(nextProps)
	}

	handleChange = event => {
		const value = event.target.value
		const option = find(options, { value })

		this.setState({ value })

		if (this.props.onSelect) {
			this.props.onSelect(
				option,
				getKeyDiff(this.props.songKey, option.key)
			)
		}
	}

	handleProps = props => {
		const value = toLower(props.songKey)
		if (value !== this.state.value && find(options, { value })) {
			this.setState({ value })
		}
	}

	render() {
		const { classes, label } = this.props
		const { value } = this.state

		return (
			<TextField
				className={classes.root}
				select
				label={label}
				value={value}
				onChange={this.handleChange}
			>
				{options.map(option => (
					<MenuItem key={option.value} value={option.value}>
						{option.label}
					</MenuItem>
				))}
			</TextField>
		)
	}
}

export default withStyles(styles)(KeySelector)
<|endoftext|>


<commit_before>/* eslint-disable no-undef */
import ActionSheet from '../../packages/ActionSheet/index.js'
import Vue from 'vue'

describe('ActionSheet', () => {
  let vm

  it('actionsheet initial 默认样式', done => {
    vm = ActionSheet({
      title: '测试标题',
      content: {
        items: [
            {title: '测试正文条目1'},
            {title: '测试正文条目2'}
        ]
      }
    })
    Vue.nextTick(() => {
      const $dom = document.querySelector('.wd-actionsheet')
      expect($dom).to.exist
      vm.value = false
      setTimeout(() => {
        done()
      }, 500)
    })
  })

  it('actionsheet title 标题', done => {
    vm = ActionSheet({
      title: '测试标题',
      content: {
        items: [
          {title: '测试正文条目1'},
          {title: '测试正文条目2'}
        ]
      }
    })
    Vue.nextTick(() => {
      const $title = document.querySelector('.wd-actionsheet-header')
      expect($title.textContent).to.equal('测试标题')
      vm.value = false
      setTimeout(() => {
        done()
      }, 500)
    })
  })

  it('actionsheet isShowTitle 是否显示标题', done => {
    vm = ActionSheet({
      title: '测试标题',
      isShowTitle: false,
      content: {
        items: [
          {title: '测试正文条目1'},
          {title: '测试正文条目2'}
        ]
      }
    })
    Vue.nextTick(() => {
      const $title = document.querySelector('.wd-actionsheet-header')
      expect($title).to.not.exist
      vm.value = false
      setTimeout(() => {
        done()
      }, 500)
    })
  })

  it('actionsheet maxDisplay 最大显示条数', done => {
    vm = ActionSheet({
      title: '测试标题',
      isShowTitle: false,
      maxDisplay: 5,
      content: {
        items: [
          {title: '测试正文条目1'},
          {title: '测试正文条目2'},
          {title: '测试正文条目3'},
          {title: '测试正文条目4'},
          {title: '测试正文条目5'},
          {title: '测试正文条目6'},
          {title: '测试正文条目7'},
          {title: '测试正文条目8'}
        ]
      }
    })
    Vue.nextTick(() => {
      const $listHeight = document.querySelector('.wd-actionsheet-list').offsetHeight
      const $itemHeight = document.querySelector('.wd-actionsheet-listitem').offsetHeight
      expect(vm.maxDisplay).to.equal(5)
      expect($itemHeight * 5).to.equal($listHeight)
      vm.value = false
      setTimeout(() => {
        done()
      }, 500)
    })
  })

  it('actionsheet textAlign 对齐方式', done => {
    vm = ActionSheet({
      title: '测试标题',
      textAlign: 'center',
      content: {
        items: [
          {title: '测试正文条目1'},
          {title: '测试正文条目2'}
        ]
      }
    })
    Vue.nextTick(() => {
      const $content = document.querySelector('.wd-actionsheet-content')
      expect(window.getComputedStyle($content).getPropertyValue('text-align')).to.equal('center')
      vm.value = false
      setTimeout(() => {
        done()
      }, 500)
    })
  })

  it('actionsheet content type-radio 正文单选类型', done => {
    vm = ActionSheet({
      title: '测试标题',
      content: {
        type: 'radio',
        items: [
          {title: '测试正文条目1'},
          {title: '测试正文条目2'}
        ]
      }
    })
    Vue.nextTick(() => {
      const $itemFirst = document.querySelector('ul.wd-actionsheet-list > li:nth-child(1)')
      const $itemSecond = document.querySelector('ul.wd-actionsheet-list > li:nth-child(2)')
      $itemFirst.click()
      $itemSecond.click()
      setTimeout(() => {
        vm.value = false
        setTimeout(() => {
          expect(Array.prototype.slice.call($itemFirst.classList)).to.not.include('checked')
          expect(Array.prototype.slice.call($itemSecond.classList)).to.include('checked')
          done()
        }, 500)
      }, 200)
    })
  })

  it('actionsheet content type-checklist 正文多选类型', done => {
    vm = ActionSheet({
      title: '测试标题',
      content: {
        type: 'checklist',
        items: [
          {title: '测试正文条目1'},
          {title: '测试正文条目2'}
        ]
      }
    })
    Vue.nextTick(() => {
      const $itemFirst = document.querySelector('ul.wd-actionsheet-list > li:nth-child(1) > label')
      const $itemSecond = document.querySelector('ul.wd-actionsheet-list > li:nth-child(2) > label')
      $itemFirst.click()
      $itemSecond.click()
      expect($itemFirst.querySelector('input:checked').value).to.equal('测试正文条目1')
      expect($itemSecond.querySelector('input:checked').value).to.equal('测试正文条目2')
      vm.value = false
      setTimeout(() => {
        done()
      }, 500)
    })
  })

  it('actionsheet content items-两列 正文两列数据', done => {
    vm = ActionSheet({
      title: '测试标题',
      content: {
        type: 'checklist',
        items: [
          {
            title: '测试正文主条目1',
            subtitle: '测试正文副条目1'
          },
          {
            title: '测试正文主条目2',
            subtitle: '测试正文副条目2'
          },
        ]
      }
    })
    Vue.nextTick(() => {
      const $item = document.querySelectorAll('ul.wd-actionsheet-list > li:nth-child(1) > label > span')
      expect($item.length).to.equal(2)
      vm.value = false
      setTimeout(() => {
        done()
      }, 500)
    })
  })

  it('actionsheet content radio-defaultValue 单选默认选中', done => {
    vm = ActionSheet({
      title: '测试标题',
      content: {
        type: 'radio',
        items: [
          {title: '测试正文条目1'},
          {title: '测试正文条目2'}
        ],
        defaultValue: [1]
      }
    })
    Vue.nextTick(() => {
      const $itemSecond = document.querySelector('ul.wd-actionsheet-list > li:nth-child(2)')
      expect(Array.prototype.slice.call($itemSecond.classList)).to.include('checked')
      vm.value = false
      setTimeout(() => {
        done()
      }, 500)
    })
  })

  it('actionsheet content radio-defaultValue 多选默认选中', done => {
    vm = ActionSheet({
      title: '测试标题',
      content: {
        type: 'checklist',
        items: [
          {
            title: '测试正文主条目1',
            subtitle: '测试正文副条目1'
          },
          {
            title: '测试正文主条目2',
            subtitle: '测试正文副条目2'
          },
        ],
        defaultValue: [0, 1]
      }
    })
    Vue.nextTick(() => {
      const $itemFirst = document.querySelector('ul.wd-actionsheet-list > li:nth-child(1) > label')
      const $itemSecond = document.querySelector('ul.wd-actionsheet-list > li:nth-child(2) > label')
      expect($itemFirst.querySelector('input:checked').value).to.equal('测试正文主条目1')
      expect($itemSecond.querySelector('input:checked').value).to.equal('测试正文主条目2')
      vm.value = false
      setTimeout(() => {
        done()
      }, 500)
    })
  })

  it('actionsheet content defaultValue容错功能', done => {
    vm = ActionSheet({
      title: '测试标题',
      content: {
        type: 'checklist',
        items: [
          {
            title: '测试正文主条目1',
            subtitle: '测试正文副条目1'
          },
          {
            title: '测试正文主条目2',
            subtitle: '测试正文副条目2'
          },
          {
            title: '测试正文主条目3',
            subtitle: '测试正文副条目3'
          }
        ],
        defaultValue: [4, 1, '1', 1, 2]   //过滤字符串及重复项和越界项,过滤结果[1, 2]
      }
    })
    Vue.nextTick(() => {
      const $itemSecond = document.querySelector('ul.wd-actionsheet-list > li:nth-child(2) > label')
      const $itemThird = document.querySelector('ul.wd-actionsheet-list > li:nth-child(3) > label')
      expect($itemSecond.querySelector('input:checked').value).to.equal('测试正文主条目2')
      expect($itemThird.querySelector('input:checked').value).to.equal('测试正文主条目3')
      vm.value = false
      setTimeout(() => {
        done()
      }, 500)
    })
  })

  it('actionsheet confirmText 主操作文字', done => {
    vm = ActionSheet({
      title: '测试标题',
      confirmText: '测试主操作文字',
      content: {
        items: [
          {title: '测试正文条目1'},
          {title: '测试正文条目2'}
        ]
      }
    })
    Vue.nextTick(() => {
      const $confirmButton = document.querySelector('.wd-actionsheet-footer > span:nth-child(2)')
      expect($confirmButton.textContent).to.equal('测试主操作文字')
      vm.value = false
      setTimeout(() => {
        done()
      }, 500)
    })
  })

  it('actionsheet cancelText 辅操作文字', done => {
    vm = ActionSheet({
      title: '测试标题',
      cancelText: '测试辅操作文字',
      content: {
        items: [
          {title: '测试正文条目1'},
          {title: '测试正文条目2'}
        ]
      }
    })
    Vue.nextTick(() => {
      const $cancelButton = document.querySelector('.wd-actionsheet-footer > span:nth-child(1)')
      expect($cancelButton.textContent).to.equal('测试辅操作文字')
      vm.value = false
      setTimeout(() => {
        done()
      }, 500)
    })
  })

  it('actionsheet isShowConfirmButton 是否展示主操作按钮', done => {
    vm = ActionSheet({
      title: '测试标题',
      isShowConfirmButton: false,
      content: {
        items: [
          {title: '测试正文条目1'},
          {title: '测试正文条目2'}
        ]
      }
    })
    Vue.nextTick(() => {
      const $buttons = document.querySelectorAll('.wd-actionsheet-footer > span')
      expect($buttons.length).to.equal(1)
      vm.value = false
      setTimeout(() => {
        done()
      }, 500)
    })
  })

  it('actionsheet maskColor 蒙版颜色', done => {
    vm = ActionSheet({
      title: '测试标题',
      maskColor: '#eee',
      content: {
        items: [
          {title: '测试正文条目1'},
          {title: '测试正文条目2'}
        ]
      }
    })
    setTimeout(() => {
      const $mask = document.querySelector('.wd-mask')
      expect($mask.style.backgroundColor).to.equal('rgb(238, 238, 238)')
      vm.value = false
      setTimeout(() => {
        done()
      }, 500)
    }, 200)
  })

  it('actionsheet maskOpacity 蒙版透明度', done => {
    vm = ActionSheet({
      title: '测试标题',
      maskOpacity: 0.7,
      content: {
        items: [
          {title: '测试正文条目1'},
          {title: '测试正文条目2'}
        ]
      }
    })
    setTimeout(() => {
      const $mask = document.querySelector('.wd-mask')
      expect($mask.style.opacity).to.equal('0.7')
      vm.value = false
      setTimeout(() => {
        done()
      }, 500)
    }, 200)
  })

  it('actionsheet onItemClick 执行点击操作项的回调函数', done => {
    vm = ActionSheet({
      title: '测试标题',
      content: {
        items: [
          {title: '测试正文条目1'},
          {title: '测试正文条目2'}
        ]
      },
      isShowConfirmButton: false,
      onItemClick: (instance, data) => {
        document.body.testToken = data.datas
        instance.value = false
      }
    })
    Vue.nextTick(() => {
      const $itemFirst = document.querySelector('ul.wd-actionsheet-list > li:nth-child(1) > span')
      $itemFirst.click()
      setTimeout(() => {
        expect(document.body.testToken).to.equal('测试正文条目1')
        delete document.body.testToken
        done()
      }, 500)
    })
  })

  it('actionsheet onConfirm 确认选择时的回调函数', done => {
    vm = ActionSheet({
      title: '测试标题',
      content: {
        type: 'radio',
        items: [
          {title: '测试正文条目1'},
          {title: '测试正文条目2'}
        ]
      },
      onConfirm: (instance, data) => {
        document.body.testToken = data.datas.value
        instance.value = false
      }
    })
    Vue.nextTick(() => {
      const $confirmButton = document.querySelector('.wd-actionsheet-footer > span:nth-child(2)')
      const $itemFirst = document.querySelector('ul.wd-actionsheet-list > li:nth-child(1) > span')
      $itemFirst.click()
      $confirmButton.click()
      Vue.nextTick(() => {
        setTimeout(() => {
          expect(document.body.testToken).to.equal('测试正文条目1')
          delete document.body.testToken
          done()
        }, 500)
      })
    })
  })

  it('actionsheet onCancel 执行辅操作时的回调函数', done => {
    vm = ActionSheet({
      title: '测试标题',
      content: {
        items: [
          {title: '测试正文条目1'},
          {title: '测试正文条目2'}
        ]
      },
      onCancel: (instance) => {
        document.body.testToken = 'cancel'
        instance.value = false
      },
    })
    setTimeout(() => {
      const $cancelButton = document.querySelector('.wd-actionsheet-footer > span:nth-child(1)')
      $cancelButton.click()
      expect(document.body.testToken).to.equal('cancel')
      setTimeout(() => {
        delete document.body.testToken
        done()
      }, 500)
    }, 200)
  })

  it('actionsheet onShow 窗体出现后的回调函数', done => {
    vm = ActionSheet({
      title: '测试标题',
      content: {
        items: [
          {title: '测试正文条目1'},
          {title: '测试正文条目2'}
        ]
      },
      onShow(instance) {
        instance.testToken = 'show'
        instance.value = false
      },
    })
    setTimeout(() => {
      expect(vm.testToken).to.equal('show')
      setTimeout(() => {
        delete document.body.testToken
        done()
      }, 500)
    }, 400)
  })

  it('actionsheet onHide 窗体隐藏后的回调函数', done => {
    vm = ActionSheet({
      title: '测试标题',
      content: {
        items: [
          {title: '测试正文条目1'},
          {title: '测试正文条目2'}
        ]
      },
      onHide(instance) {
        instance.testToken = 'hide'
        instance.value = false
      },
    })
    Vue.nextTick(() => {
      const $cancelButton = document.querySelector('.wd-actionsheet-footer > span:nth-child(1)')
      $cancelButton.click()
      setTimeout(() => {
        expect(vm.testToken).to.equal('hide')
        delete document.body.testToken
        done()
      }, 500)
    })
  })

  it('actionsheet onMaskClick 点击 Mask 时的回调函数', done => {
    vm = ActionSheet({
      title: '测试标题',
      content: {
        items: [
          {title: '测试正文条目1'},
          {title: '测试正文条目2'}
        ]
      },
      onMaskClick(instance) {
        instance.testToken = 'maskClick'
        instance.value = false
      },
    })
    setTimeout(() => {
      const $mask = document.querySelector('.wd-mask')
      $mask.click()
      expect(vm.testToken).to.equal('maskClick')
      setTimeout(() => {
        done()
      }, 500)
    }, 200)
  })
})
<commit_msg>[feat]actionsheet changes<commit_after>/* eslint-disable no-undef */
import ActionSheet from '../../packages/ActionSheet/index.js'
import Vue from 'vue'

describe('ActionSheet', () => {
  let vm

  it('actionsheet initial 默认样式', done => {
    vm = ActionSheet({
      title: '测试标题',
      content: {
        items: [
            {title: '测试正文条目1'},
            {title: '测试正文条目2'}
        ]
      }
    })
    Vue.nextTick(() => {
      const $dom = document.querySelector('.wd-actionsheet')
      expect($dom).to.exist
      vm.value = false
      setTimeout(() => {
        done()
      }, 500)
    })
  })

  it('actionsheet title 标题', done => {
    vm = ActionSheet({
      title: '测试标题',
      content: {
        items: [
          {title: '测试正文条目1'},
          {title: '测试正文条目2'}
        ]
      }
    })
    Vue.nextTick(() => {
      const $title = document.querySelector('.wd-actionsheet-header')
      expect($title.textContent).to.equal('测试标题')
      vm.value = false
      setTimeout(() => {
        done()
      }, 500)
    })
  })

  it('actionsheet isShowTitle 是否显示标题', done => {
    vm = ActionSheet({
      title: '测试标题',
      isShowTitle: false,
      content: {
        items: [
          {title: '测试正文条目1'},
          {title: '测试正文条目2'}
        ]
      }
    })
    Vue.nextTick(() => {
      const $title = document.querySelector('.wd-actionsheet-header')
      expect($title).to.not.exist
      vm.value = false
      setTimeout(() => {
        done()
      }, 500)
    })
  })

  it('actionsheet textAlign 对齐方式', done => {
    vm = ActionSheet({
      title: '测试标题',
      textAlign: 'center',
      content: {
        items: [
          {title: '测试正文条目1'},
          {title: '测试正文条目2'}
        ]
      }
    })
    Vue.nextTick(() => {
      const $content = document.querySelector('.wd-actionsheet-content')
      expect(window.getComputedStyle($content).getPropertyValue('text-align')).to.equal('center')
      vm.value = false
      setTimeout(() => {
        done()
      }, 500)
    })
  })

  it('actionsheet content type-radio 正文单选类型', done => {
    vm = ActionSheet({
      title: '测试标题',
      content: {
        type: 'radio',
        items: [
          {title: '测试正文条目1'},
          {title: '测试正文条目2'}
        ]
      }
    })
    Vue.nextTick(() => {
      const $itemFirst = document.querySelector('ul.wd-actionsheet-list > li:nth-child(1)')
      const $itemSecond = document.querySelector('ul.wd-actionsheet-list > li:nth-child(2)')
      $itemFirst.click()
      $itemSecond.click()
      setTimeout(() => {
        vm.value = false
        setTimeout(() => {
          expect(Array.prototype.slice.call($itemFirst.classList)).to.not.include('checked')
          expect(Array.prototype.slice.call($itemSecond.classList)).to.include('checked')
          done()
        }, 500)
      }, 200)
    })
  })

  it('actionsheet content type-checklist 正文多选类型', done => {
    vm = ActionSheet({
      title: '测试标题',
      content: {
        type: 'checklist',
        items: [
          {title: '测试正文条目1'},
          {title: '测试正文条目2'}
        ]
      }
    })
    Vue.nextTick(() => {
      const $itemFirst = document.querySelector('ul.wd-actionsheet-list > li:nth-child(1) > label')
      const $itemSecond = document.querySelector('ul.wd-actionsheet-list > li:nth-child(2) > label')
      $itemFirst.click()
      $itemSecond.click()
      expect($itemFirst.querySelector('input:checked').value).to.equal('测试正文条目1')
      expect($itemSecond.querySelector('input:checked').value).to.equal('测试正文条目2')
      vm.value = false
      setTimeout(() => {
        done()
      }, 500)
    })
  })

  it('actionsheet content items-两列 正文两列数据', done => {
    vm = ActionSheet({
      title: '测试标题',
      content: {
        type: 'checklist',
        items: [
          {
            title: '测试正文主条目1',
            subtitle: '测试正文副条目1'
          },
          {
            title: '测试正文主条目2',
            subtitle: '测试正文副条目2'
          },
        ]
      }
    })
    Vue.nextTick(() => {
      const $item = document.querySelectorAll('ul.wd-actionsheet-list > li:nth-child(1) > label > span')
      expect($item.length).to.equal(2)
      vm.value = false
      setTimeout(() => {
        done()
      }, 500)
    })
  })

  it('actionsheet content radio-defaultValue 单选默认选中', done => {
    vm = ActionSheet({
      title: '测试标题',
      content: {
        type: 'radio',
        items: [
          {title: '测试正文条目1'},
          {title: '测试正文条目2'}
        ],
        defaultValue: [1]
      }
    })
    Vue.nextTick(() => {
      const $itemSecond = document.querySelector('ul.wd-actionsheet-list > li:nth-child(2)')
      expect(Array.prototype.slice.call($itemSecond.classList)).to.include('checked')
      vm.value = false
      setTimeout(() => {
        done()
      }, 500)
    })
  })

  it('actionsheet content radio-defaultValue 多选默认选中', done => {
    vm = ActionSheet({
      title: '测试标题',
      content: {
        type: 'checklist',
        items: [
          {
            title: '测试正文主条目1',
            subtitle: '测试正文副条目1'
          },
          {
            title: '测试正文主条目2',
            subtitle: '测试正文副条目2'
          },
        ],
        defaultValue: [0, 1]
      }
    })
    Vue.nextTick(() => {
      const $itemFirst = document.querySelector('ul.wd-actionsheet-list > li:nth-child(1) > label')
      const $itemSecond = document.querySelector('ul.wd-actionsheet-list > li:nth-child(2) > label')
      expect($itemFirst.querySelector('input:checked').value).to.equal('测试正文主条目1')
      expect($itemSecond.querySelector('input:checked').value).to.equal('测试正文主条目2')
      vm.value = false
      setTimeout(() => {
        done()
      }, 500)
    })
  })

  it('actionsheet content defaultValue容错功能', done => {
    vm = ActionSheet({
      title: '测试标题',
      content: {
        type: 'checklist',
        items: [
          {
            title: '测试正文主条目1',
            subtitle: '测试正文副条目1'
          },
          {
            title: '测试正文主条目2',
            subtitle: '测试正文副条目2'
          },
          {
            title: '测试正文主条目3',
            subtitle: '测试正文副条目3'
          }
        ],
        defaultValue: [4, 1, '1', 1, 2]   //过滤字符串及重复项和越界项,过滤结果[1, 2]
      }
    })
    Vue.nextTick(() => {
      const $itemSecond = document.querySelector('ul.wd-actionsheet-list > li:nth-child(2) > label')
      const $itemThird = document.querySelector('ul.wd-actionsheet-list > li:nth-child(3) > label')
      expect($itemSecond.querySelector('input:checked').value).to.equal('测试正文主条目2')
      expect($itemThird.querySelector('input:checked').value).to.equal('测试正文主条目3')
      vm.value = false
      setTimeout(() => {
        done()
      }, 500)
    })
  })

  it('actionsheet confirmText 主操作文字', done => {
    vm = ActionSheet({
      title: '测试标题',
      confirmText: '测试主操作文字',
      content: {
        items: [
          {title: '测试正文条目1'},
          {title: '测试正文条目2'}
        ]
      }
    })
    Vue.nextTick(() => {
      const $confirmButton = document.querySelector('.wd-actionsheet-footer > span:nth-child(2)')
      expect($confirmButton.textContent).to.equal('测试主操作文字')
      vm.value = false
      setTimeout(() => {
        done()
      }, 500)
    })
  })

  it('actionsheet cancelText 辅操作文字', done => {
    vm = ActionSheet({
      title: '测试标题',
      cancelText: '测试辅操作文字',
      content: {
        items: [
          {title: '测试正文条目1'},
          {title: '测试正文条目2'}
        ]
      }
    })
    Vue.nextTick(() => {
      const $cancelButton = document.querySelector('.wd-actionsheet-footer > span:nth-child(1)')
      expect($cancelButton.textContent).to.equal('测试辅操作文字')
      vm.value = false
      setTimeout(() => {
        done()
      }, 500)
    })
  })

  it('actionsheet isShowConfirmButton 是否展示主操作按钮', done => {
    vm = ActionSheet({
      title: '测试标题',
      isShowConfirmButton: false,
      content: {
        items: [
          {title: '测试正文条目1'},
          {title: '测试正文条目2'}
        ]
      }
    })
    Vue.nextTick(() => {
      const $buttons = document.querySelectorAll('.wd-actionsheet-footer > span')
      expect($buttons.length).to.equal(1)
      vm.value = false
      setTimeout(() => {
        done()
      }, 500)
    })
  })

  it('actionsheet maskColor 蒙版颜色', done => {
    vm = ActionSheet({
      title: '测试标题',
      maskColor: '#eee',
      content: {
        items: [
          {title: '测试正文条目1'},
          {title: '测试正文条目2'}
        ]
      }
    })
    setTimeout(() => {
      const $mask = document.querySelector('.wd-mask')
      expect($mask.style.backgroundColor).to.equal('rgb(238, 238, 238)')
      vm.value = false
      setTimeout(() => {
        done()
      }, 500)
    }, 200)
  })

  it('actionsheet maskOpacity 蒙版透明度', done => {
    vm = ActionSheet({
      title: '测试标题',
      maskOpacity: 0.7,
      content: {
        items: [
          {title: '测试正文条目1'},
          {title: '测试正文条目2'}
        ]
      }
    })
    setTimeout(() => {
      const $mask = document.querySelector('.wd-mask')
      expect($mask.style.opacity).to.equal('0.7')
      vm.value = false
      setTimeout(() => {
        done()
      }, 500)
    }, 200)
  })

  it('actionsheet onItemClick 执行点击操作项的回调函数', done => {
    vm = ActionSheet({
      title: '测试标题',
      content: {
        items: [
          {title: '测试正文条目1'},
          {title: '测试正文条目2'}
        ]
      },
      isShowConfirmButton: false,
      onItemClick: (instance, data) => {
        document.body.testToken = data.datas
        instance.value = false
      }
    })
    Vue.nextTick(() => {
      const $itemFirst = document.querySelector('ul.wd-actionsheet-list > li:nth-child(1) > span')
      $itemFirst.click()
      setTimeout(() => {
        expect(document.body.testToken).to.equal('测试正文条目1')
        delete document.body.testToken
        done()
      }, 500)
    })
  })

  it('actionsheet onConfirm 确认选择时的回调函数', done => {
    vm = ActionSheet({
      title: '测试标题',
      content: {
        type: 'radio',
        items: [
          {title: '测试正文条目1'},
          {title: '测试正文条目2'}
        ]
      },
      onConfirm: (instance, data) => {
        document.body.testToken = data.datas.value
        instance.value = false
      }
    })
    Vue.nextTick(() => {
      const $confirmButton = document.querySelector('.wd-actionsheet-footer > span:nth-child(2)')
      const $itemFirst = document.querySelector('ul.wd-actionsheet-list > li:nth-child(1) > span')
      $itemFirst.click()
      $confirmButton.click()
      Vue.nextTick(() => {
        setTimeout(() => {
          expect(document.body.testToken).to.equal('测试正文条目1')
          delete document.body.testToken
          done()
        }, 500)
      })
    })
  })

  it('actionsheet onCancel 执行辅操作时的回调函数', done => {
    vm = ActionSheet({
      title: '测试标题',
      content: {
        items: [
          {title: '测试正文条目1'},
          {title: '测试正文条目2'}
        ]
      },
      onCancel: (instance) => {
        document.body.testToken = 'cancel'
        instance.value = false
      },
    })
    setTimeout(() => {
      const $cancelButton = document.querySelector('.wd-actionsheet-footer > span:nth-child(1)')
      $cancelButton.click()
      expect(document.body.testToken).to.equal('cancel')
      setTimeout(() => {
        delete document.body.testToken
        done()
      }, 500)
    }, 200)
  })

  it('actionsheet onShow 窗体出现后的回调函数', done => {
    vm = ActionSheet({
      title: '测试标题',
      content: {
        items: [
          {title: '测试正文条目1'},
          {title: '测试正文条目2'}
        ]
      },
      onShow(instance) {
        instance.testToken = 'show'
        instance.value = false
      },
    })
    setTimeout(() => {
      expect(vm.testToken).to.equal('show')
      setTimeout(() => {
        delete document.body.testToken
        done()
      }, 500)
    }, 400)
  })

  it('actionsheet onHide 窗体隐藏后的回调函数', done => {
    vm = ActionSheet({
      title: '测试标题',
      content: {
        items: [
          {title: '测试正文条目1'},
          {title: '测试正文条目2'}
        ]
      },
      onHide(instance) {
        instance.testToken = 'hide'
        instance.value = false
      },
    })
    Vue.nextTick(() => {
      const $cancelButton = document.querySelector('.wd-actionsheet-footer > span:nth-child(1)')
      $cancelButton.click()
      setTimeout(() => {
        expect(vm.testToken).to.equal('hide')
        delete document.body.testToken
        done()
      }, 500)
    })
  })

  it('actionsheet onMaskClick 点击 Mask 时的回调函数', done => {
    vm = ActionSheet({
      title: '测试标题',
      content: {
        items: [
          {title: '测试正文条目1'},
          {title: '测试正文条目2'}
        ]
      },
      onMaskClick(instance) {
        instance.testToken = 'maskClick'
        instance.value = false
      },
    })
    setTimeout(() => {
      const $mask = document.querySelector('.wd-mask')
      $mask.click()
      expect(vm.testToken).to.equal('maskClick')
      setTimeout(() => {
        done()
      }, 500)
    }, 200)
  })

  it('actionsheet maxDisplay 最大显示条数', done => {
    vm = ActionSheet({
      title: '测试标题',
      isShowTitle: false,
      maxDisplay: 5,
      content: {
        items: [
          {title: '测试正文条目1'},
          {title: '测试正文条目2'},
          {title: '测试正文条目3'},
          {title: '测试正文条目4'},
          {title: '测试正文条目5'},
          {title: '测试正文条目6'},
          {title: '测试正文条目7'},
          {title: '测试正文条目8'}
        ]
      }
    })
    Vue.nextTick(() => {
      const $listHeight = document.querySelector('.wd-actionsheet-list').offsetHeight
      const $itemHeight = document.querySelector('.wd-actionsheet-listitem').offsetHeight
      expect(vm.maxDisplay).to.equal(5)
      expect($itemHeight * 5).to.equal($listHeight)
      vm.value = false
      setTimeout(() => {
        done()
      }, 500)
    })
  })
})
<|endoftext|>


<commit_before>var blogger = require('./models/blogger').Blogger;
var authentication = require('./authentication');
var ensureAuthenticated = authentication.ensureAuthenticated;

module.exports = function(app) {
    authentication.serveOAuthRoutes(app);

    app.get('/', function(req, res) {
		console.log("/ called");

        res.render('index', {
            title: 'Index / CS Blogs',
            user: req.user
        });
    });

    app.get('/login', function(req, res) {
		console.log("/login called");

        res.render('login', {
            title: 'Login / CS Blogs'
        });
    });

    app.get('/profile', ensureAuthenticated, function(req, res) {
		console.log("/profile called");
		console.log('\n\n\n\nREQ.USER in profile', req.user);

		if(req.user.userProvider && req.user.userId) {
			console.log("Registered user");
			console.log("Blogger user: %j", req.user);
			var nameTitle = req.user.firstName + ' ' + req.user.lastName + ' / CS Blogs';
            res.render('profile', {
                title: nameTitle,
                blogger: req.user,
				user: req.user
            });
		}
		else {
			console.log("Not a registered user");
			console.log("Passport.js user: %j", req.user);
			res.redirect('/register');
		}
    });

    app.route('/account')
        .get(ensureAuthenticated, function(req, res) {
			console.log("/account called");

            res.render('register', {
                title: 'Account / CS Blogs',
                submitText: 'Update profile',
                user: req.user
            });
        })
        .post(ensureAuthenticated, function(req, res) {});

    app.get('/bloggers', function(req, res) {
		console.log("/bloggers called");

        blogger.find({}, function(error, allBloggers) {
            if (error || !allBloggers) {
                internalError(res, error ? error : "No bloggers found.");
            } else {
                res.render('bloggers', {
                    title: 'Bloggers / CS Blogs',
                    bloggers: allBloggers,
                    user: req.user
                });
            }
        });
    });

    app.get('/bloggers/:vanityurl', function(req, res) {
		console.log("/bloggers/:vanityurl called")
        renderBlogger(req, res);
    });

    app.get('/b/:vanityurl', function(req, res) {
		console.log("/b/:vanityurl called");
        renderBlogger(req, res);
    });

    function renderBlogger(req, res) {
        var userVanityUrl = req.params.vanityurl;

        blogger.findOne({vanityUrl: userVanityUrl}, function(error, profile) {
            if (error || !profile) {
                internalError(res, error ? error : 'Blogger profile not found.');
            }
            else {
                var nameTitle = profile.firstName + ' ' + profile.lastName + ' / CS Blogs';
                res.render('profile', {
                    title: nameTitle,
                    blogger: profile,
                    user: req.user
                });
            }
        });
    }

    app.route('/register')
        .get(ensureAuthenticated, function(req, res) {
			console.log("/register GET called");

            var usersName = req.user.displayName.split(' ');
            req.user.firstname = usersName[0];
            req.user.lastname = usersName[1];
            res.render('register', {
                title: 'Register / CS Blogs',
                submitText: 'Add your blog',
                user: req.user
            });
        })
        .post(ensureAuthenticated, function(req, res) {
			console.log("/register POST called");

            newBlogger = new blogger({
                userProvider: req.user.provider,
                userId: req.user.id,
                firstName: req.body.first_name,
                lastName: req.body.last_name,
                avatarUrl: req.user._json.avatar_url,
                emailAddress: req.body.email,
                feedUrl: req.body.feed_url,
                blogWebsiteUrl: req.body.blog_url,
                websiteUrl: req.body.site_url,
                cvUrl: req.body.cv_url,
                githubProfile: req.body.github_name,
                twitterProfile: req.body.twitter_name,
                linkedInProfile: req.body.linkedIn_name,
                bio: req.body.bio,
                vanityUrl: req.body.vanity_url,
                validated: false
            });
            newBlogger.save();

			req.session.passport.user = newBlogger;
            res.redirect('/profile');
    });

    app.get('/blogs', function(req, res) {
		console.log("/blogs called");

        var blogs = require('./test-data/blogs.json');
        res.render('blogs', {
            title: 'Blogs / CS Blogs',
            content: blogs,
            user: req.user
        });
    });

	app.get('/logout', function(req, res) {
		console.log("/logout called");
	  	req.logout();
	  	res.redirect('/');
	});

    // Handle error 404
    app.use(function(req, res) {
		console.error("ERROR 404. Request: %j", req);

        res.status(404);
        res.render('error', {
            title: 'Error 404 / CS Blogs',
            errorCode: 404,
            errorMessage: 'Page Not Found',
            user: req.user
        });
    });

    // Handle error 500
    app.use(function(error, req, res, next) {
		console.error("ERROR 500. Error: %j", error);
        internalError(res, error);
    });

    function internalError(res, errorMessage) {
        res.status(500);
        res.render('error', {
            title: 'Error 500 / CS Blogs',
            errorCode: 500,
            errorMessage: errorMessage
        });
    }
}
<commit_msg>Normalise logins from Wordpress and Github to pass a Blogger object to register rather than use Github variable names<commit_after>var blogger = require('./models/blogger').Blogger;
var authentication = require('./authentication');
var ensureAuthenticated = authentication.ensureAuthenticated;

module.exports = function(app) {
    authentication.serveOAuthRoutes(app);

    app.get('/', function(req, res) {
		console.log("/ called");

        res.render('index', {
            title: 'Index / CS Blogs',
            user: req.user
        });
    });

    app.get('/login', function(req, res) {
		console.log("/login called");

        res.render('login', {
            title: 'Login / CS Blogs'
        });
    });

    app.get('/profile', ensureAuthenticated, function(req, res) {
		console.log("/profile called");
		console.log('\n\n\n\nREQ.USER in profile', req.user);

		if(req.user.userProvider && req.user.userId) {
			console.log("Registered user");
			console.log("Blogger user: %j", req.user);
			var nameTitle = req.user.firstName + ' ' + req.user.lastName + ' / CS Blogs';
            res.render('profile', {
                title: nameTitle,
                blogger: req.user,
				user: req.user
            });
		}
		else {
			console.log("Not a registered user");
			console.log("Passport.js user: %j", req.user);
			res.redirect('/register');
		}
    });

    app.route('/account')
        .get(ensureAuthenticated, function(req, res) {
			console.log("/account called");

            res.render('register', {
                title: 'Account / CS Blogs',
                submitText: 'Update profile',
                user: req.user
            });
        })
        .post(ensureAuthenticated, function(req, res) {});

    app.get('/bloggers', function(req, res) {
		console.log("/bloggers called");

        blogger.find({}, function(error, allBloggers) {
            if (error || !allBloggers) {
                internalError(res, error ? error : "No bloggers found.");
            } else {
                res.render('bloggers', {
                    title: 'Bloggers / CS Blogs',
                    bloggers: allBloggers,
                    user: req.user
                });
            }
        });
    });

    app.get('/bloggers/:vanityurl', function(req, res) {
		console.log("/bloggers/:vanityurl called")
        renderBlogger(req, res);
    });

    app.get('/b/:vanityurl', function(req, res) {
		console.log("/b/:vanityurl called");
        renderBlogger(req, res);
    });

    function renderBlogger(req, res) {
        var userVanityUrl = req.params.vanityurl;

        blogger.findOne({vanityUrl: userVanityUrl}, function(error, profile) {
            if (error || !profile) {
                internalError(res, error ? error : 'Blogger profile not found.');
            }
            else {
                var nameTitle = profile.firstName + ' ' + profile.lastName + ' / CS Blogs';
                res.render('profile', {
                    title: nameTitle,
                    blogger: profile,
                    user: req.user
                });
            }
        });
    }

    app.route('/register')
        .get(ensureAuthenticated, function(req, res) {
			console.log("/register GET called");

			if(req.user.userProvider && req.user.userId) {
				//Already registered user doing an edit.
	            res.render('register', {
	                title: 'Edit Account / CS Blogs',
	                submitText: 'Update',
	                user: req.user
	            });
			}
			else {
				//User is logged in with an account, but not registered.
				//We need to parse thier data out and put it into the form
				//to aid them filling it in.
				switch(req.user.provider) {
					case 'github':
			            var usersName = req.user.displayName.split(' ');
			            var userAsBlogger = new blogger({
							avatarUrl: 		req.user._json.avatar_url,
			                firstName: 		usersName[0],
			                lastName: 		usersName[1],
			                emailAddress: 	req.user._json.email,
			                blogWebsiteUrl: req.user._json.blog,
			                githubProfile: 	req.user._json.login,
			                bio: 			req.user._json.bio,
			                vanityUrl: 		req.user.username,
			            });
						break;
					case 'Wordpress':
			            var userAsBlogger = new blogger({
							avatarUrl: 		req.user._json.avatar_URL,
			                emailAddress: 	req.user._json.email,
			                blogWebsiteUrl: "http://" + req.user._json.user + ".wordpress.com",
			                vanityUrl: 		req.user._json.display_name,
			            });
						break;
				}

	            res.render('register', {
	                title: 'Register / CS Blogs',
	                submitText: 'Register',
	                user: userAsBlogger
	            });
			}
        })
        .post(ensureAuthenticated, function(req, res) {
			console.log("/register POST called");

			//VALIDATE FIELDS HERE

            newBlogger = new blogger({
                userProvider: req.user.provider,
                userId: req.user.id,
                firstName: req.body.firstName,
                lastName: req.body.lastName,
                emailAddress: req.body.emailAddress,
                feedUrl: req.body.feedUrl,
                blogWebsiteUrl: req.body.blogWebsiteUrl,
                websiteUrl: req.body.websiteUrl,
                cvUrl: req.body.cvUrl,
                githubProfile: req.body.githubProfile,
                twitterProfile: req.body.twitterProfile,
                linkedInProfile: req.body.linkedInProfile,
                bio: req.body.bio,
                vanityUrl: req.body.vanityUrl,
                validated: false
            });

			switch(req.user.provider) {
				case 'github':
					newBlogger.avatarUrl = req.user._json.avatar_url;
				case 'Wordpress':
					newBlogger.avatarUrl = req.user._json.avatar_URL;
			}

            newBlogger.save();
			req.session.passport.user = newBlogger;
            res.redirect('/profile');
    });

    app.get('/blogs', function(req, res) {
		console.log("/blogs called");

        var blogs = require('./test-data/blogs.json');
        res.render('blogs', {
            title: 'Blogs / CS Blogs',
            content: blogs,
            user: req.user
        });
    });

	app.get('/logout', function(req, res) {
		console.log("/logout called");
	  	req.logout();
	  	res.redirect('/');
	});

    // Handle error 404
    app.use(function(req, res) {
		console.error("ERROR 404. Request: %j", req);

        res.status(404);
        res.render('error', {
            title: 'Error 404 / CS Blogs',
            errorCode: 404,
            errorMessage: 'Page Not Found',
            user: req.user
        });
    });

    // Handle error 500
    app.use(function(error, req, res, next) {
		console.error("ERROR 500. Error: %j", error);
        internalError(res, error);
    });

    function internalError(res, errorMessage) {
        res.status(500);
        res.render('error', {
            title: 'Error 500 / CS Blogs',
            errorCode: 500,
            errorMessage: errorMessage
        });
    }
}
<|endoftext|>


<commit_before>
/**

  data-editor

**/

//
//  Dependencies
//

var chalk = require("chalk");

//
//  Exports
//

module.exports = {

  /**

    Writes a list of data directories being used.

  **/

  list: function() {

    var editor = require("./config-editor"),
        data   = (editor.get("data") || []).slice(0),
        str;

    console.log("");
    if (!data.length)
      console.log(chalk.cyan("   Info:"), "there are no data directories in your project");
    else {
      str = chalk.yellow(data.pop());
      if (data.length) {
        for (var i = 0; i < data.length; i++) data[i] = chalk.yellow(data[i]);
        str = (data.join(", ") + " and " + str).replace(/\s\s+/g, "");
      }
      console.log(chalk.cyan("   Info:"), "current data directories include", str);
    }

    console.log("");

  },

  /**

    Adds a data folder and acknolwedges with confirmation.

    @param {String} folder The location of the data directory

  **/

  add: function(folder) {

    var editor = require("./config-editor"),
        data   = (editor.get("data") || []).slice(0);

    console.log("");

    if (data.indexOf(folder) > -1) {
      console.log("   " + chalk.red("No Change:") + " your data directories already include " + chalk.yellow(folder));
    } else {
      data.push(folder);
      editor.set("data", data);
      editor.save();
      console.log("   " + chalk.cyan("Added:") + " sneakers now includes " + chalk.yellow(folder) + " in your data directory");
    }

    console.log("");

  },

  /**

    Removes a data folder and acknolwedges with confirmation.

    @param {String} folder The location of the data directory

  **/

  remove: function(folder) {

    var editor = require("./config-editor"),
        data   = (editor.get("data") || []).slice(0);

    console.log("");

    if (data.indexOf(folder) === -1) {
      console.log("   " + chalk.red("No Change:") + " your data directories didn't include " + chalk.yellow(folder));
    } else {
      data.splice(data.indexOf(folder))
      editor.set("data", data);
      editor.save();
      console.log("   " + chalk.cyan("Removed:") + " sneakers no longer includes " + chalk.yellow(folder) + " in your data directory");
    }

    console.log("");

  }

};
<commit_msg>data-editor#list: indents consistent with pipelines and routes<commit_after>
/**

  data-editor

**/

//
//  Dependencies
//

var chalk = require("chalk");

//
//  Exports
//

module.exports = {

  /**

    Writes a list of data directories being used.

  **/

  list: function() {

    var editor = require("./config-editor"),
        data   = (editor.get("data") || []).slice(0),
        str;

    console.log("");
    console.log(chalk.cyan(" Data:"));
    console.log("");

    if (!data.length)
      console.log("   There are no data directories in your project");
    else {
      str = chalk.yellow(data.pop());
      if (data.length) {
        for (var i = 0; i < data.length; i++) data[i] = chalk.yellow(data[i]);
        str = (data.join(", ") + " and " + str).replace(/\s\s+/g, "");
      }
      console.log("   Current data directories include", str);
    }

    console.log("");

  },

  /**

    Adds a data folder and acknolwedges with confirmation.

    @param {String} folder The location of the data directory

  **/

  add: function(folder) {

    var editor = require("./config-editor"),
        data   = (editor.get("data") || []).slice(0);

    console.log("");

    if (data.indexOf(folder) > -1) {
      console.log("   " + chalk.red("No Change:") + " your data directories already include " + chalk.yellow(folder));
    } else {
      data.push(folder);
      editor.set("data", data);
      editor.save();
      console.log("   " + chalk.cyan("Added:") + " sneakers now includes " + chalk.yellow(folder) + " in your data directory");
    }

    console.log("");

  },

  /**

    Removes a data folder and acknolwedges with confirmation.

    @param {String} folder The location of the data directory

  **/

  remove: function(folder) {

    var editor = require("./config-editor"),
        data   = (editor.get("data") || []).slice(0);

    console.log("");

    if (data.indexOf(folder) === -1) {
      console.log("   " + chalk.red("No Change:") + " your data directories didn't include " + chalk.yellow(folder));
    } else {
      data.splice(data.indexOf(folder))
      editor.set("data", data);
      editor.save();
      console.log("   " + chalk.cyan("Removed:") + " sneakers no longer includes " + chalk.yellow(folder) + " in your data directory");
    }

    console.log("");

  }

};
<|endoftext|>


<commit_before>var _ = require('lodash'),
    utils =  require('../../../utils'),
    driver = utils.getDriver(),
    C = driver.constants;

module.exports = function(object, intent, {roomObjects, roomController, gameTime, eventLog}) {

    if(object.type != 'creep') {
        return;
    }
    if(object.spawning) {
        return;
    }

    var target = roomObjects[intent.id];
    if(!target || target.type != 'creep' || target.spawning) {
        return;
    }
    if(Math.abs(target.x - object.x) > 3 || Math.abs(target.y - object.y) > 3) {
        return;
    }
    if(roomController && roomController.user != object.user && roomController.safeMode > gameTime) {
        return;
    }

    var healPower = utils.calcBodyEffectiveness(object.body, C.HEAL, 'rangedHeal', C.RANGED_HEAL_POWER);

    target._healToApply = (target._healToApply || 0) + healPower;

    object.actionLog.rangedHeal = {x: target.x, y: target.y};
    target.actionLog.healed = {x: object.x, y: object.y};

    eventLog.push({event: C.EVENT_HEAL, objectId: object._id, data: {targetId: target._id, amount: healPower, healType: C.EVENT_HEAL_TYPE_RANGED}});
};<commit_msg>hotfix(processor): Creep.rangedHeal on Power Creeps<commit_after>var _ = require('lodash'),
    utils =  require('../../../utils'),
    driver = utils.getDriver(),
    C = driver.constants;

module.exports = function(object, intent, {roomObjects, roomController, gameTime, eventLog}) {

    if(object.type != 'creep') {
        return;
    }
    if(object.spawning) {
        return;
    }

    var target = roomObjects[intent.id];
    if(!target || (target.type != 'creep' && target.type != 'powerCreep') || target.spawning) {
        return;
    }
    if(Math.abs(target.x - object.x) > 3 || Math.abs(target.y - object.y) > 3) {
        return;
    }
    if(roomController && roomController.user != object.user && roomController.safeMode > gameTime) {
        return;
    }

    var healPower = utils.calcBodyEffectiveness(object.body, C.HEAL, 'rangedHeal', C.RANGED_HEAL_POWER);

    target._healToApply = (target._healToApply || 0) + healPower;

    object.actionLog.rangedHeal = {x: target.x, y: target.y};
    target.actionLog.healed = {x: object.x, y: object.y};

    eventLog.push({event: C.EVENT_HEAL, objectId: object._id, data: {targetId: target._id, amount: healPower, healType: C.EVENT_HEAL_TYPE_RANGED}});
};<|endoftext|>


<commit_before>import React, { Component } from 'react';
import PropTypes from 'prop-types';
import cx from 'classnames';
import FocusTrap from 'focus-trap-react';
import ModalHeader from './ModalHeader';
import ModalFooter from './ModalFooter';
import ModalContent from './ModalContent';
import { getContentId, getTitleId } from './utils';

class Modal extends Component {
  onClose = (evt) => {
    evt.stopPropagation();
    const { onClose } = this.props;
    if (onClose) { onClose(); }
  }

  onKeyUp = (evt) => {
    const { key } = evt;
    if (key === 'Escape') { this.onClose(evt); }
  }

  cloneWithProps = (child) => {
    const { id, onClose } = this.props;
    const type = child.type;

    if (type === ModalContent) {
      const contentId = getContentId(id);
      return React.cloneElement(child, { id: contentId });
    }

    if (type === ModalFooter) {
      return React.cloneElement(child, {
        onClose: onClose ? this.onClose : null
      });
    }

    return child;
  }

  render() {
    const {
      children,
      className,
      id,
      open,
      onClose,
      prompt,
      size,
      tagline,
      title,
      transitionStyle,
      ...rest
    } = this.props;

    const titleId = title ? getTitleId(id) : null;
    const contentId = getContentId(id);

    const sldsClasses = cx(
      'slds-modal',
      { [`slds-${transitionStyle}`]: open },
      { [`slds-modal_${size}`]: !!size },
      { 'slds-modal_prompt': !!prompt },
      className
    );

    return (

          <FocusTrap className="slds-modal__container" active={open}>
            <ModalHeader
              id={titleId}
              onClose={onClose ? this.onClose : null}
              theme={prompt}
              tagline={tagline}
              title={title}
            />
            {React.Children.map(children, this.cloneWithProps)}
          </FocusTrap>

    );
  }
}

Modal.defaultProps = {
  className: null,
  open: false,
  prompt: null,
  onClose: null,
  size: null,
  tagline: null,
  title: null,
  transitionStyle: 'fade-in-open',
};

Modal.propTypes = {
  /**
   * Sets the animation style when the modal open.
   * Can be one of: 'fade-in-open', 'slide-up-saving', 'slide-up-open', 'slide-down-cancel'
   */
  transitionStyle: PropTypes.oneOf([
    'fade-in-open',
    'slide-up-saving',
    'slide-up-open',
    'slide-down-cancel'
  ]),
  /**
   * ModalContent and optionally a ModalFooter
   */
  children: PropTypes.node.isRequired,
  /**
   * className that will be merged
   */
  className: PropTypes.string,
  /**
   * Callback that is triggered when `x` is clicked or `esc` is pressed. Will be passed to a `ModalFooter` if present
   */
  onClose: PropTypes.func,
  /**
   * id that is used to link Moal aria-tags to each other
   */
  id: PropTypes.string.isRequired,
  /**
   * Opens the Modal and renders the backdrop
   */
  open: PropTypes.bool,
  /**
   * Size of modal. Can be `medium` or `large`
   */
  size: PropTypes.oneOf(['medium', 'large']),
  /**
   * Tagline. Can be a string or an element
   */
  tagline: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
  /**
   * Title
   */
  title: PropTypes.string,
  /**
   * (PRIVATE) used by Prompt component
   */
  prompt: PropTypes.string,
};

export default Modal;
<commit_msg>Pass SyntheticEvent to Modal.onClose callback<commit_after>import React, { Component } from 'react';
import PropTypes from 'prop-types';
import cx from 'classnames';
import FocusTrap from 'focus-trap-react';
import ModalHeader from './ModalHeader';
import ModalFooter from './ModalFooter';
import ModalContent from './ModalContent';
import { getContentId, getTitleId } from './utils';

class Modal extends Component {
  onClose = (evt) => {
    evt.stopPropagation();
    const { onClose } = this.props;
    if (onClose) { onClose(evt); }
  }

  onKeyUp = (evt) => {
    const { key } = evt;
    if (key === 'Escape') { this.onClose(evt); }
  }

  cloneWithProps = (child) => {
    const { id, onClose } = this.props;
    const type = child.type;

    if (type === ModalContent) {
      const contentId = getContentId(id);
      return React.cloneElement(child, { id: contentId });
    }

    if (type === ModalFooter) {
      return React.cloneElement(child, {
        onClose: onClose ? this.onClose : null
      });
    }

    return child;
  }

  render() {
    const {
      children,
      className,
      id,
      open,
      onClose,
      prompt,
      size,
      tagline,
      title,
      transitionStyle,
      ...rest
    } = this.props;

    const titleId = title ? getTitleId(id) : null;
    const contentId = getContentId(id);

    const sldsClasses = cx(
      'slds-modal',
      { [`slds-${transitionStyle}`]: open },
      { [`slds-modal_${size}`]: !!size },
      { 'slds-modal_prompt': !!prompt },
      className
    );

    return (

          <FocusTrap className="slds-modal__container" active={open}>
            <ModalHeader
              id={titleId}
              onClose={onClose ? this.onClose : null}
              theme={prompt}
              tagline={tagline}
              title={title}
            />
            {React.Children.map(children, this.cloneWithProps)}
          </FocusTrap>

    );
  }
}

Modal.defaultProps = {
  className: null,
  open: false,
  prompt: null,
  onClose: null,
  size: null,
  tagline: null,
  title: null,
  transitionStyle: 'fade-in-open',
};

Modal.propTypes = {
  /**
   * Sets the animation style when the modal open.
   * Can be one of: 'fade-in-open', 'slide-up-saving', 'slide-up-open', 'slide-down-cancel'
   */
  transitionStyle: PropTypes.oneOf([
    'fade-in-open',
    'slide-up-saving',
    'slide-up-open',
    'slide-down-cancel'
  ]),
  /**
   * ModalContent and optionally a ModalFooter
   */
  children: PropTypes.node.isRequired,
  /**
   * className that will be merged
   */
  className: PropTypes.string,
  /**
   * Callback that is triggered when `x` is clicked or `esc` is pressed. Will be passed to a `ModalFooter` if present
   */
  onClose: PropTypes.func,
  /**
   * id that is used to link Moal aria-tags to each other
   */
  id: PropTypes.string.isRequired,
  /**
   * Opens the Modal and renders the backdrop
   */
  open: PropTypes.bool,
  /**
   * Size of modal. Can be `medium` or `large`
   */
  size: PropTypes.oneOf(['medium', 'large']),
  /**
   * Tagline. Can be a string or an element
   */
  tagline: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
  /**
   * Title
   */
  title: PropTypes.string,
  /**
   * (PRIVATE) used by Prompt component
   */
  prompt: PropTypes.string,
};

export default Modal;
<|endoftext|>