<commit_before>/*
 * HomePage
 *
 * This is the first thing users see of our App, at the '/' route
 */

import React, { Component, PropTypes } from 'react';
import Helmet from 'react-helmet';
import { connect } from 'react-redux';
import { Link } from 'react-router';
import { createStructuredSelector } from 'reselect';
import _ from 'underscore';
import { getProducts } from './actions';
import { selectProducts } from './selectors';
import Body from '../../components/styled/Body';
import H2 from '../../components/styled/H2';
import CatalogTable from '../../components/styled/CatalogTable';
import RaisedButton from 'material-ui/RaisedButton';

class CatalogPage extends Component {

  componentDidMount() {
    if (this.props.products.length === 0) {
      this.props.getProducts();
    }
  }

  renderProducts = () => {
    const { products } = this.props;
    return _.map(products, (product, i) => (

        <Link to={`/product/${product.Id}`}>{product.Name}</Link>

          <div className="image" style={{ backgroundImage: `url(${product.MainImageUri})` }} />

        {product.SKU}
        TBD
        {product.Price}
        {product.ShippingFee}
        <Link to={`/product/${product.Id}`}>Edit This Product</Link>

    ));
  };

  render() {
    return (

        <Helmet
          title="Catalog"
          meta={[
            { name: 'description', content: 'Catalog Page' },
          ]}
        />

Catalog

            <Link to={'product/create'}>
              <RaisedButton>
                Create
              </RaisedButton>
            </Link>

          <CatalogTable>

                Product Name
                Image
                SKU
                Inventory Available
                Retail Price
                Shipping Price

              {this.renderProducts()}

          </CatalogTable>

    );
  }
}

CatalogPage.propTypes = {
  products: PropTypes.array,
  getProducts: PropTypes.func,
};

export function mapDispatchToProps(dispatch) {
  return {
    getProducts: () => {
      dispatch(getProducts());
    },
  };
}

const mapStateToProps = createStructuredSelector({
  products: selectProducts(),
});

// Wrap the component to inject dispatch and state into it
export default connect(mapStateToProps, mapDispatchToProps)(CatalogPage);
<commit_msg>Add import button to catalog page<commit_after>/*
 * HomePage
 *
 * This is the first thing users see of our App, at the '/' route
 */

import React, { Component, PropTypes } from 'react';
import Helmet from 'react-helmet';
import { connect } from 'react-redux';
import { Link } from 'react-router';
import { createStructuredSelector } from 'reselect';
import _ from 'underscore';
import { getProducts } from './actions';
import { selectProducts } from './selectors';
import Body from '../../components/styled/Body';
import H2 from '../../components/styled/H2';
import CatalogTable from '../../components/styled/CatalogTable';
import FlatButton from 'material-ui/FlatButton';
import ContentAdd from 'material-ui/svg-icons/content/add';
import FileFileUpload from 'material-ui/svg-icons/file/file-upload';

class CatalogPage extends Component {

  componentDidMount() {
    if (this.props.products.length === 0) {
      this.props.getProducts();
    }
  }

  onCreateMenuOpen = () => {
    this.setState({
      openCreateMenu: true,
    });
  }

  renderProducts = () => {
    const { products } = this.props;
    return _.map(products, (product, i) => (

        <Link to={`/product/${product.Id}`}>{product.Name}</Link>

          <div className="image" style={{ backgroundImage: `url(${product.MainImageUri})` }} />

        {product.SKU}
        TBD
        {product.Price}
        {product.ShippingFee}
        <Link to={`/product/${product.Id}`}>Edit This Product</Link>

    ));
  };

  render() {
    return (

        <Helmet
          title="Catalog"
          meta={[
            { name: 'description', content: 'Catalog Page' },
          ]}
        />

Catalog

            <Link to="/product/create/">
              <FlatButton
                label="Create"
                labelPosition="before"
                icon={<ContentAdd />}
                onTouchTap={this.onCreateMenuOpen}
              />
            </Link>
            <Link to="/product/import/">
              <FlatButton
                label="Import"
                labelPosition="before"
                icon={<FileFileUpload />}
                onTouchTap={this.onCreateMenuOpen}
              />
            </Link>

          <CatalogTable>

                Product Name
                Image
                SKU
                Inventory Available
                Retail Price
                Shipping Price

              {this.renderProducts()}

          </CatalogTable>

    );
  }
}

CatalogPage.propTypes = {
  products: PropTypes.array,
  getProducts: PropTypes.func,
};

export function mapDispatchToProps(dispatch) {
  return {
    getProducts: () => {
      dispatch(getProducts());
    },
  };
}

const mapStateToProps = createStructuredSelector({
  products: selectProducts(),
});

// Wrap the component to inject dispatch and state into it
export default connect(mapStateToProps, mapDispatchToProps)(CatalogPage);
<|endoftext|>


<commit_before>/* eslint-disable no-console */
const commando = require('../src');
const path = require('path');
const oneLine = require('common-tags').oneLine;
const sqlite = require('sqlite');
const token = require('./auth').token;

const client = new commando.Client({
	owner: '90997305578106880',
	commandPrefix: 'cdev'
});

client
	.on('error', console.error)
	.on('warn', console.warn)
	.on('debug', console.log)
	.on('ready', () => {
		console.log(`Client ready; logged in as ${client.user.username}#${client.user.discriminator} (${client.user.id})`);
	})
	.on('disconnect', () => { console.warn('Disconnected!'); })
	.on('reconnect', () => { console.warn('Reconnecting...'); })
	.on('commandError', (cmd, err) => {
		if(err instanceof commando.FriendlyError) return;
		console.error(`Error in command ${cmd.groupID}:${cmd.memberName}`, err);
	})
	.on('commandBlocked', (msg, reason) => {
		console.log(oneLine`
			Command ${msg.command ? `${msg.command.groupID}:${msg.command.memberName}` : ''}
			blocked; ${reason}
		`);
	})
	.on('commandPrefixChange', (guild, prefix) => {
		console.log(oneLine`
			Prefix ${prefix === '' ? 'removed' : `changed to ${prefix || 'the default'}`}
			${guild ? `in guild ${guild.name} (${guild.id})` : 'globally'}.
		`);
	})
	.on('commandStatusChange', (guild, command, enabled) => {
		console.log(oneLine`
			Command ${command.groupID}:${command.memberName}
			${enabled ? 'enabled' : 'disabled'}
			${guild ? `in guild ${guild.name} (${guild.id})` : 'globally'}.
		`);
	})
	.on('groupStatusChange', (guild, group, enabled) => {
		console.log(oneLine`
			Group ${group.id}
			${enabled ? 'enabled' : 'disabled'}
			${guild ? `in guild ${guild.name} (${guild.id})` : 'globally'}.
		`);
	});

client.setProvider(
	sqlite.open(path.join(__dirname, 'database.sqlite3')).then(db => new commando.SQLiteProvider(db))
).catch(console.error);

client.registry
	.registerGroup('math', 'Math')
	.registerDefaults()
	.registerCommandsIn(path.join(__dirname, 'commands'));

client.login(token);
<commit_msg>Update bot.js<commit_after>/* eslint-disable no-console */
const commando = require('../src');
const path = require('path');
const oneLine = require('common-tags').oneLine;
const sqlite = require('sqlite');
const token = require('./auth').token;

const client = new commando.Client({
	owner: '90997305578106880',
	commandPrefix: 'cdev'
});

client
	.on('error', console.error)
	.on('warn', console.warn)
	.on('debug', console.log)
	.on('ready', () => {
		console.log(`Client ready; logged in as ${client.user.username}#${client.user.discriminator} (${client.user.id})`);
	})
	.on('disconnect', () => { console.warn('Disconnected!'); })
	.on('reconnecting', () => { console.warn('Reconnecting...'); })
	.on('commandError', (cmd, err) => {
		if(err instanceof commando.FriendlyError) return;
		console.error(`Error in command ${cmd.groupID}:${cmd.memberName}`, err);
	})
	.on('commandBlocked', (msg, reason) => {
		console.log(oneLine`
			Command ${msg.command ? `${msg.command.groupID}:${msg.command.memberName}` : ''}
			blocked; ${reason}
		`);
	})
	.on('commandPrefixChange', (guild, prefix) => {
		console.log(oneLine`
			Prefix ${prefix === '' ? 'removed' : `changed to ${prefix || 'the default'}`}
			${guild ? `in guild ${guild.name} (${guild.id})` : 'globally'}.
		`);
	})
	.on('commandStatusChange', (guild, command, enabled) => {
		console.log(oneLine`
			Command ${command.groupID}:${command.memberName}
			${enabled ? 'enabled' : 'disabled'}
			${guild ? `in guild ${guild.name} (${guild.id})` : 'globally'}.
		`);
	})
	.on('groupStatusChange', (guild, group, enabled) => {
		console.log(oneLine`
			Group ${group.id}
			${enabled ? 'enabled' : 'disabled'}
			${guild ? `in guild ${guild.name} (${guild.id})` : 'globally'}.
		`);
	});

client.setProvider(
	sqlite.open(path.join(__dirname, 'database.sqlite3')).then(db => new commando.SQLiteProvider(db))
).catch(console.error);

client.registry
	.registerGroup('math', 'Math')
	.registerDefaults()
	.registerCommandsIn(path.join(__dirname, 'commands'));

client.login(token);
<|endoftext|>


<commit_before>import {compose} from 'compose'
import {fromEvent, merge} from 'rxjs'
import PropTypes from 'prop-types'
import React from 'react'
import withForwardedRef from 'ref'
import withSubscriptions from 'subscription'

class BlurDetector extends React.Component {
    constructor(props) {
        super(props)
        this.ref = props.forwardedRef || React.createRef()
    }

    render() {
        const {className, style, children} = this.props
        return (

                {children}

        )
    }

    componentDidMount() {
        const {onBlur, addSubscription} = this.props
        if (onBlur) {
            addSubscription(
                merge(
                    fromEvent(document, 'mousedown'),
                    fromEvent(document, 'touchstart'),
                    fromEvent(document, 'focus'),
                ).subscribe(
                    e => this.onEvent(e)
                )
            )
        }
    }

    onEvent(e) {
        const {onBlur} = this.props
        const inside = this.ref.current.contains(e.target)
        if (!inside) {
            onBlur && onBlur(e)
        }
    }
}

export default compose(
    BlurDetector,
    withSubscriptions(),
    withForwardedRef()
)

BlurDetector.propTypes = {
    children: PropTypes.any.isRequired,
    className: PropTypes.string,
    style: PropTypes.object,
    onBlur: PropTypes.func
}
<commit_msg>Implemented BlurDetector nesting.<commit_after>import {compose} from 'compose'
import {filter} from 'rxjs/operators'
import {fromEvent, merge} from 'rxjs'
import {withContext} from 'context'
import PropTypes from 'prop-types'
import React from 'react'
import withForwardedRef from 'ref'
import withSubscriptions from 'subscription'

const BlurDetectorContext = React.createContext()

const withBlurDetectorContext = withContext(BlurDetectorContext, 'blurDetectorContext')

class BlurDetector extends React.Component {
    enabled = true

    constructor(props) {
        super(props)
        this.ref = props.forwardedRef || React.createRef()
    }

    render() {
        const {className, style, children} = this.props
        return (

                <BlurDetectorContext.Provider value={{enabled: enabled => this.enabled = enabled}}>
                    {children}
                </BlurDetectorContext.Provider>

        )
    }

    componentDidMount() {
        const {onBlur, addSubscription} = this.props
        this.setEnabled(false)
        if (onBlur) {
            addSubscription(
                merge(
                    fromEvent(document, 'mousedown'),
                    fromEvent(document, 'touchstart'),
                    fromEvent(document, 'focus'),
                ).pipe(
                    filter(() => this.enabled)
                ).subscribe(
                    e => this.onEvent(e)
                )
            )
        }
    }

    componentWillUnmount() {
        this.setEnabled(true)
    }

    setEnabled(enabled) {
        const {blurDetectorContext} = this.props
        if (blurDetectorContext) {
            blurDetectorContext.enabled(enabled)
        }
    }

    onEvent(e) {
        const {onBlur} = this.props
        const inside = this.ref.current.contains(e.target)
        if (!inside) {
            onBlur && onBlur(e)
        }
    }
}

export default compose(
    BlurDetector,
    withBlurDetectorContext(),
    withSubscriptions(),
    withForwardedRef(),
)

BlurDetector.propTypes = {
    children: PropTypes.any.isRequired,
    className: PropTypes.string,
    style: PropTypes.object,
    onBlur: PropTypes.func
}
<|endoftext|>


<commit_before>const assert = require('assert')
const spawn = require('child_process').spawn
const hepjs = require('hep-js')
const dgram = require('dgram')
const command = '../src/captagent'
const iptarget = '0.0.0.0'

/*
 * Start Captagent, Check Exit Code
 */
describe('CaptAgent HEP Basic', () => {
  let args = [
    "-n"
  ]

  let decoded
  let network
  var sipmessage = 'SIP/2.0 200 OK\r\nVia: SIP/2.0/UDP there.com:5060\r\nFrom: LittleGuy <sip:UserB@there.com>\r\nTo: LittleGuy <sip:UserB@there.com>\r\nCall-ID: 123456789@there.com\r\nCSeq: 2 REGISTER\r\n\r\n'
  var in_socket = dgram.createSocket('udp4')
  var out_socket = dgram.createSocket('udp4')

  before((done) => {

    let captagent = spawn(command, args);

    in_socket.on('message', (message,socket) => {
      decoded = hepjs.decapsulate(message);
      network = socket;
      captagent.kill();
    })
    in_socket.on('listening', function () {
	    captagent.stdout.on('data', (data) => {
	      if(!data.includes('ready')) return;
	      var udpmessage = new Buffer(sipmessage);
	      out_socket.send(udpmessage, 0, udpmessage.length, 5060, iptarget, function(err) {
	        if (err) throw err;
    	  });
    	})
    	captagent.on('close', () => {
		in_socket.close();
		out_socket.close();
		done()
	})

    })
    in_socket.bind(9061, iptarget)
  })

  it('HEP should originate from 127.0.0.1', () => {
    assert.ok(network.address === '127.0.0.1');
  })
  it('should return HEP data', () => {
    assert.ok(decoded.payload.length > 0);
  })
 })

<commit_msg>separate server/client conf<commit_after>const assert = require('assert')
const spawn = require('child_process').spawn
const hepjs = require('hep-js')
const dgram = require('dgram')
const command = '../src/captagent'
const ipserver = '127.0.0.1'
const iptarget = '127.0.0.1'

/*
 * Start Captagent, Check Exit Code
 */
describe('CaptAgent HEP Basic', () => {
  let args = [
    "-n"
  ]

  let decoded
  let network
  var sipmessage = 'SIP/2.0 200 OK\r\nVia: SIP/2.0/UDP there.com:5060\r\nFrom: LittleGuy <sip:UserB@there.com>\r\nTo: LittleGuy <sip:UserB@there.com>\r\nCall-ID: 123456789@there.com\r\nCSeq: 2 REGISTER\r\n\r\n'
  var in_socket = dgram.createSocket('udp4')
  var out_socket = dgram.createSocket('udp4')

  before((done) => {

    let captagent = spawn(command, args);

    in_socket.on('message', (message,socket) => {
      decoded = hepjs.decapsulate(message);
      network = socket;
      captagent.kill();
    })
    in_socket.on('listening', function () {
	    captagent.stdout.on('data', (data) => {
	      if(!data.includes('ready')) return;
	      var udpmessage = new Buffer(sipmessage);
	      out_socket.send(udpmessage, 0, udpmessage.length, 5060, iptarget, function(err) {
	        if (err) done()
    	  });
    	})
    	captagent.on('close', () => {
		in_socket.close();
		out_socket.close();
		done()
	})

    })
    in_socket.bind(9061, ipserver)
  })

  it('HEP should originate from 127.0.0.1', () => {
    assert.ok(network.address === '127.0.0.1');
  })
  it('should return HEP data', () => {
    assert.ok(decoded.payload.length > 0);
  })
 })

<|endoftext|>


<commit_before>const assert = require('assert')
const spawn = require('child_process').spawn
const hepjs = require('hep-js');
const dgram = require('dgram');
const command = '../src/captagent';

/*
 * Start Captagent, Check Exit Code
 */
describe('CaptAgent HEP Basic', () => {
  let args = [
    "-n"
  ]

  let decoded
  let network
  var sipmessage = 'SIP/2.0 200 OK\r\nVia: SIP/2.0/UDP there.com:5060\r\nFrom: LittleGuy <sip:UserB@there.com>\r\nTo: LittleGuy <sip:UserB@there.com>\r\nCall-ID: 123456789@there.com\r\nCSeq: 2 REGISTER\r\n\r\n'
  var in_socket = dgram.createSocket('udp4')
  var out_socket = dgram.createSocket('udp4')

  before((done) => {

    let captagent = spawn(command, args);

    in_socket.on('message', (message,socket) => {
      decoded = hepjs.decapsulate(message);
      network = socket;
      captagent.kill();
    })
    in_socket.on('listening', function () {
	    captagent.stdout.on('data', (data) => {
	      if(!data.includes('ready')) return;
	      var udpmessage = new Buffer(sipmessage);
	      out_socket.send(udpmessage, 0, udpmessage.length, 5060, '127.0.0.1', function(err) {
	        if (err) throw err;
    	  });
    	})
    	captagent.on('close', () => {
		in_socket.close();
		out_socket.close();
		done()
	})

    })
    in_socket.bind(9061, '127.0.0.1')
  })

  it('HEP should originate from 127.0.0.1', () => {
    assert.ok(network.address === '127.0.0.1');
  })
  it('should return HEP data', () => {
    assert.ok(decoded.payload.length > 0);
  })
 })

<commit_msg>try travis friendly interfaces<commit_after>const assert = require('assert')
const spawn = require('child_process').spawn
const hepjs = require('hep-js')
const dgram = require('dgram')
const command = '../src/captagent'
const iptarget = '0.0.0.0'

/*
 * Start Captagent, Check Exit Code
 */
describe('CaptAgent HEP Basic', () => {
  let args = [
    "-n"
  ]

  let decoded
  let network
  var sipmessage = 'SIP/2.0 200 OK\r\nVia: SIP/2.0/UDP there.com:5060\r\nFrom: LittleGuy <sip:UserB@there.com>\r\nTo: LittleGuy <sip:UserB@there.com>\r\nCall-ID: 123456789@there.com\r\nCSeq: 2 REGISTER\r\n\r\n'
  var in_socket = dgram.createSocket('udp4')
  var out_socket = dgram.createSocket('udp4')

  before((done) => {

    let captagent = spawn(command, args);

    in_socket.on('message', (message,socket) => {
      decoded = hepjs.decapsulate(message);
      network = socket;
      captagent.kill();
    })
    in_socket.on('listening', function () {
	    captagent.stdout.on('data', (data) => {
	      if(!data.includes('ready')) return;
	      var udpmessage = new Buffer(sipmessage);
	      out_socket.send(udpmessage, 0, udpmessage.length, 5060, iptarget, function(err) {
	        if (err) throw err;
    	  });
    	})
    	captagent.on('close', () => {
		in_socket.close();
		out_socket.close();
		done()
	})

    })
    in_socket.bind(9061, iptarget)
  })

  it('HEP should originate from 127.0.0.1', () => {
    assert.ok(network.address === '127.0.0.1');
  })
  it('should return HEP data', () => {
    assert.ok(decoded.payload.length > 0);
  })
 })

<|endoftext|>


<commit_before>// Copyright (C) 2016 Goom Inc. All rights reserved.

import React, { PropTypes } from 'react';
import { Link } from 'react-router';

import { ajaxReturnPromise } from 'commons/redux/util/ajaxUtil';
import { constants } from 'commons/utils/constants';
import numberUtil from 'commons/utils/numberUtil';

export default React.createClass({
  contextTypes: {
    router: PropTypes.object,
  },
  getInitialState() {
    return {};
  },
  render() {
    const onChange = (e, key) => {
      const nextState = {};
      nextState[key] = e.target.value;
      this.setState(nextState);
    };
    const onlyNumberFieldOnChange = (e, key, maxLen) => {
      if (numberUtil.validateNumberInput(e.target.value, maxLen)) {
        onChange(e, key);
      }
    };
    const fields = [
      { name: '업체명', placeholder: '업체명을 입력해 주세요', key: 'name' },
      { name: '담당자명', placeholder: '담당자 성함을 입력해 주세요', key: 'contactName' },
      { name: 'E-mail', placeholder: 'E-mail을 입력해 주세요', key: 'email', type: 'email' },
      { name: '연락처', placeholder: "'-'를 제외한 숫자만 입력해 주세요", key: 'tel', onChange: (e) => onlyNumberFieldOnChange(e, 'tel', 15) },
      { name: '판매상가', key: 'building' },
      { name: '층', key: 'floor' },
      { name: '호수', key: 'flatNumber' },
      { name: '판매물품', placeholder: '예) 여성 의류, 신발, 가방 등', key: 'productType' },
    ];
    const renderField = (field) => (

{field.name}

        <input
          type={field.type || 'text'}
          value={this.state[field.key] || ''}
          onChange={field.onChange ? field.onChange : (e) => onChange(e, field.key)}
          placeholder={field.placeholder}
        />

    );
    const handleSubmit = (e) => {
      e.preventDefault();
      for (let i = 0; i < fields.length; i++) {
        const field = fields[i];
        if (!this.state[field.key]) {
          window.alert(`${field.name}을 입력해 주세요`);
          return;
        }
      }
      $('.button-next').prop('disabled', true);
      ajaxReturnPromise(null, 'post', '/api/v1/brands/inquiries', { data: this.state }).then(() => {
        window.alert(`입점 신청 문의가 완료되었습니다. 24시간 이내에 (${this.state.tel})으로 연락 드리겠습니다`);
        this.context.router.push('/');
      }, () => {
        $('.button-next').prop('disabled', false);
        window.alert('입점 신청 접수가 실패하였습니다. 다시 시도해 주세요');
      });
    };
    return (

        <img className="banner" src={`${constants.resourceRoot}/banner/seller-join-banner.jpg`} />
        <img className="join-why" src={`${constants.resourceRoot}/banner/seller-join-why.jpg`} />
        <img className="join-24" src={`${constants.resourceRoot}/banner/seller-join-24.jpg`} />
        <img className="join-process" src={`${constants.resourceRoot}/banner/seller-join-step.jpg`} />

          <img src={`${constants.resourceRoot}/main/seller-speech-icon.png`} />
          링크샵스 입점문의 및 상담 신청
          전화연결이 어려우신 분들은 문의를 남겨주시면 24시간 이내로 담당자가 연락 드리겠습니다

          <form className="join-request-form" onSubmit={handleSubmit}>
            {fields.map(renderField)}

              <Link to="/"><button type="reset" className="button-back">취소</button></Link>
              <button type="submit" className="button-next">상담신청</button>

          </form>
          <img className="banner-inquiry" src={`${constants.resourceRoot}/banner/seller-join-inquiry_20160518.jpg`} />

    );
  },
});
<commit_msg>Linkshops_brand -> 링크샵스 판매자 센터<commit_after>// Copyright (C) 2016 Goom Inc. All rights reserved.

import React, { PropTypes } from 'react';
import { Link } from 'react-router';

import { ajaxReturnPromise } from 'commons/redux/util/ajaxUtil';
import { constants } from 'commons/utils/constants';
import numberUtil from 'commons/utils/numberUtil';

export default React.createClass({
  contextTypes: {
    router: PropTypes.object,
  },
  getInitialState() {
    return {};
  },
  render() {
    const onChange = (e, key) => {
      const nextState = {};
      nextState[key] = e.target.value;
      this.setState(nextState);
    };
    const onlyNumberFieldOnChange = (e, key, maxLen) => {
      if (numberUtil.validateNumberInput(e.target.value, maxLen)) {
        onChange(e, key);
      }
    };
    const fields = [
      { name: '업체명', placeholder: '업체명을 입력해 주세요', key: 'name' },
      { name: '담당자명', placeholder: '담당자 성함을 입력해 주세요', key: 'contactName' },
      { name: 'E-mail', placeholder: 'E-mail을 입력해 주세요', key: 'email', type: 'email' },
      { name: '연락처', placeholder: "'-'를 제외한 숫자만 입력해 주세요", key: 'tel', onChange: (e) => onlyNumberFieldOnChange(e, 'tel', 15) },
      { name: '판매상가', key: 'building' },
      { name: '층', key: 'floor' },
      { name: '호수', key: 'flatNumber' },
      { name: '판매물품', placeholder: '예) 여성 의류, 신발, 가방 등', key: 'productType' },
    ];
    const renderField = (field) => (

{field.name}

        <input
          type={field.type || 'text'}
          value={this.state[field.key] || ''}
          onChange={field.onChange ? field.onChange : (e) => onChange(e, field.key)}
          placeholder={field.placeholder}
        />

    );
    const handleSubmit = (e) => {
      e.preventDefault();
      for (let i = 0; i < fields.length; i++) {
        const field = fields[i];
        if (!this.state[field.key]) {
          window.alert(`${field.name}을 입력해 주세요`);
          return;
        }
      }
      $('.button-next').prop('disabled', true);
      ajaxReturnPromise(null, 'post', '/api/v1/brands/inquiries', { data: this.state }).then(() => {
        window.alert(`입점 신청 문의가 완료되었습니다. 24시간 이내에 (${this.state.tel})으로 연락 드리겠습니다`);
        this.context.router.push('/');
      }, () => {
        $('.button-next').prop('disabled', false);
        window.alert('입점 신청 접수가 실패하였습니다. 다시 시도해 주세요');
      });
    };
    return (

        <img className="banner" src={`${constants.resourceRoot}/banner/seller-join-banner.jpg`} />
        <img className="join-why" src={`${constants.resourceRoot}/banner/seller-join-why.jpg`} />
        <img className="join-24" src={`${constants.resourceRoot}/banner/seller-join-24.jpg`} />
        <img className="join-process" src={`${constants.resourceRoot}/banner/seller-join-step.jpg`} />

          <img src={`${constants.resourceRoot}/main/seller-speech-icon.png`} />
          링크샵스 입점문의 및 상담 신청
          전화연결이 어려우신 분들은 문의를 남겨주시면 24시간 이내로 담당자가 연락 드리겠습니다

          <form className="join-request-form" onSubmit={handleSubmit}>
            {fields.map(renderField)}

              <Link to="/"><button type="reset" className="button-back">취소</button></Link>
              <button type="submit" className="button-next">상담신청</button>

          </form>
          <img className="banner-inquiry" src={`${constants.resourceRoot}/banner/seller-join-inquiry_20160530.jpg`} />

    );
  },
});
<|endoftext|>


<commit_before>const webpack = require('webpack');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const PurifyCSSPlugin = require('purifycss-webpack-plugin');

exports.devServer = function(options) {
  return {
    devServer: {
      // Enable history API fallback so HTML5 History API based
      // routing works. This is a good default that will come
      // in handy in more complicated setups.
      historyApiFallback: true,

      // Unlike the cli flag, this doesn't set
      // HotModuleReplacementPlugin!
      hot: true,
      inline: true,

      // Display only errors to reduce the amount of output.
      stats: 'errors-only',

      // Parse host and port from env to allow customization.
      //
      // If you use Vagrant or Cloud9, set
      // host: options.host || '0.0.0.0';
      //
      // 0.0.0.0 is available to all network devices
      // unlike default `localhost`.
      host: options.host, // Defaults to `localhost`
      port: options.port // Defaults to 8080
    },
    plugins: [
      // Enable multi-pass compilation for enhanced performance
      // in larger projects. Good default.
      new webpack.HotModuleReplacementPlugin({
        // Disabled as this won't work with React HMR and html-webpack-template
        //multiStep: true
      })
    ]
  };
}

exports.setupCSS = function(paths) {
  return {
    module: {
      rules: [
        {
          test: /\.css$/,
          use: ['style-loader', 'css-loader'],
          include: paths
        }
      ]
    }
  };
}

exports.minify = function() {
  return {
    plugins: [
      new webpack.optimize.UglifyJsPlugin({
        compress: {
          warnings: false
        }
      })
    ]
  };
}

exports.setFreeVariable = function(key, value) {
  const env = {};
  env[key] = JSON.stringify(value);

  return {
    plugins: [
      new webpack.DefinePlugin(env)
    ]
  };
}

exports.extractBundle = function(options) {
  const entry = {};
  entry[options.name] = options.entries;

  return {
    // Define an entry point needed for splitting.
    entry: entry,
    plugins: [
      // Extract bundle and manifest files. Manifest is
      // needed for reliable caching.
      new webpack.optimize.CommonsChunkPlugin({
        names: [options.name, 'manifest']
      })
    ]
  };
}

exports.clean = function(path) {
  return {
    plugins: [
      new CleanWebpackPlugin([path], {
        root: process.cwd()
      })
    ]
  };
}

exports.extractCSS = function(paths) {
  return {
    module: {
      rules: [
        // Extract CSS during build
        {
          test: /\.css$/,
          loader: ExtractTextPlugin.extract({
            fallbackLoader: 'style-loader',
            loader: 'css-loader'
          }),
          include: paths
        }
      ]
    },
    plugins: [
      // Output extracted CSS to a file
      new ExtractTextPlugin('[name].[chunkhash].css')
    ]
  };
}

exports.purifyCSS = function(paths) {
  return {
    plugins: [
      new PurifyCSSPlugin({
        basePath: process.cwd(),
        // `paths` is used to point PurifyCSS to files not
        // visible to Webpack. This expects glob patterns so
        // we adapt here.
        paths: paths.map(path => `${path}/*`),
        // Walk through only html files within node_modules. It
        // picks up .js files by default!
        resolveExtensions: ['.html']
      }),
    ]
  }
}
<commit_msg>Match parts with the book<commit_after>const webpack = require('webpack');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const PurifyCSSPlugin = require('purifycss-webpack-plugin');

exports.devServer = function(options) {
  return {
    devServer: {
      // Enable history API fallback so HTML5 History API based
      // routing works. This is a good default that will come
      // in handy in more complicated setups.
      historyApiFallback: true,

      // Unlike the cli flag, this doesn't set
      // HotModuleReplacementPlugin!
      hot: true,
      inline: true,

      // Display only errors to reduce the amount of output.
      stats: 'errors-only',

      // Parse host and port from env to allow customization.
      //
      // If you use Vagrant or Cloud9, set
      // host: options.host || '0.0.0.0';
      //
      // 0.0.0.0 is available to all network devices
      // unlike default `localhost`.
      host: options.host, // Defaults to `localhost`
      port: options.port // Defaults to 8080
    },
    plugins: [
      // Enable multi-pass compilation for enhanced performance
      // in larger projects. Good default.
      new webpack.HotModuleReplacementPlugin({
        // Disabled as this won't work with html-webpack-template yet
        //multiStep: true
      })
    ]
  };
}

exports.setupCSS = function(paths) {
  return {
    module: {
      rules: [
        {
          test: /\.css$/,
          use: ['style-loader', 'css-loader'],
          include: paths
        }
      ]
    }
  };
}

exports.minify = function() {
  return {
    plugins: [
      new webpack.optimize.UglifyJsPlugin({
        compress: {
          warnings: false
        }
      })
    ]
  };
}

exports.setFreeVariable = function(key, value) {
  const env = {};
  env[key] = JSON.stringify(value);

  return {
    plugins: [
      new webpack.DefinePlugin(env)
    ]
  };
}

exports.extractBundle = function(options) {
  const entry = {};
  entry[options.name] = options.entries;

  return {
    // Define an entry point needed for splitting.
    entry: entry,
    plugins: [
      // Extract bundle and manifest files. Manifest is
      // needed for reliable caching.
      new webpack.optimize.CommonsChunkPlugin({
        names: [options.name, 'manifest']
      })
    ]
  };
}

exports.clean = function(path) {
  return {
    plugins: [
      new CleanWebpackPlugin([path], {
        // Without `root` CleanWebpackPlugin won't point to our
        // project and will fail to work.
        root: process.cwd()
      })
    ]
  };
}

exports.extractCSS = function(paths) {
  return {
    module: {
      rules: [
        // Extract CSS during build
        {
          test: /\.css$/,
          loader: ExtractTextPlugin.extract({
            fallbackLoader: 'style-loader',
            loader: 'css-loader'
          }),
          include: paths
        }
      ]
    },
    plugins: [
      // Output extracted CSS to a file
      new ExtractTextPlugin('[name].[chunkhash].css')
    ]
  };
}

exports.purifyCSS = function(paths) {
  return {
    plugins: [
      new PurifyCSSPlugin({
        basePath: process.cwd(),
        // `paths` is used to point PurifyCSS to files not
        // visible to Webpack. This expects glob patterns so
        // we adapt here.
        paths: paths.map(path => `${path}/*`),
        // Walk through only html files within node_modules. It
        // picks up .js files by default!
        resolveExtensions: ['.html']
      }),
    ]
  }
}
<|endoftext|>


<commit_before>'use strict';
window.parseFile = fileList => {
  require('blob-to-buffer')(fileList[0].slice(0), (err, result) => {
    document.getElementById('output').innerHTML = JSON.stringify(err || require('.').parseBuffer(result), null, 4);
  });
};
<commit_msg>Improved error handling for browser parser<commit_after>'use strict';
function setOutput (obj) {
  document.getElementById('output').innerHTML = obj instanceof Error ? obj : JSON.stringify(obj, null, 4);
}
window.parseFile = fileList => {
  require('blob-to-buffer')(fileList[0].slice(0), (blobErr, result) => {
    try {
      setOutput(blobErr || require('.').parseBuffer(result), null, 4);
    } catch (parseErr) {
      setOutput(parseErr);
    }
  });
};
<|endoftext|>


<commit_before>// require ../support/jquery
// require esphinx_ui
// require esphinx/support/ajax
// require esphinx/support/function
// require esphinx/support/array
// require esphinx/observer

"use strict";

var
    jQuery,
    esPhinx,
    Singleton,
    Ajax,
    Constructor;

(function ($module) {

    $module.extend({

        windows: {
            modal: {
                // functions are objects in js
                new: function (contentSource, options) {

                    var
                        ModalConstructor = $module.windows.modal.new,
                        self = this,

                        $ = jQuery,
                        ajax = Ajax,
                        body = $("body"),

                        modal,
                        mask,
                        main,
                        container,
                        btnClose,
                        btnHide,
                        headers,
                        params,
                        asynchronousAnswer,
                        calledBack,
                        imgControl,

                        maskTransitionDuration = function (mask) {
                            return parseFloat(mask
                                .css("transition-duration")) * 1000;
                        },

                        restartTransition = function (mask) {
                            mask.css("transition", "opacity 0s");
                        },

                        resolveParams = function () {
                            options = options || {};

                            if (typeof options.windowController !== "boolean") {
                                options.windowController = true;
                            }

                            if (typeof options.remote !== "boolean") {
                                options.remote = true;
                            }
                        },

                        resolveHeaderActions = function (main, options) {
                            var
                                header,
                                actions;

                            if (options.windowController) {
                                header = $("");
                                actions = $("

").addClass("actions");
                                btnClose = $('')
                                    .addClass("btn-close");
                                btnHide = $('')
                                    .addClass("btn-hide");

                                header.append(actions);
                                actions.append(btnClose);
                                actions.append(btnHide);

                                main
                                    .prepend(header)
                                    .css({
                                        "max-height": $(window).height(),
                                        "max-width": $(document).width()
                                    });

                                bindHeaderEventListeners();
                            }
                        },

                        bindHeaderEventListeners = function () {
                            // $(document).off("keydown").on("keydown", function (e) {
                            //     if (e.keyCode === 27) {
                            //         self.hide();
                            //     }
                            // });

                            btnHide.click(function () {
                                self.hide();
                            });

                            btnClose.click(function () {
                                self.close();
                            });
                        },

                        observeContent = function () {
                            var
                                imgs,
                                length = 0;

                            esPhinx(main[0]).observe(function (observer) {
                                imgs = main.find("img");
                                if (imgs.length) {
                                    imgs.each(function (i, img) {
                                        esPhinx(img).on("load", function () {
                                            length += 1;
                                        });
                                    });

                                    FlowControl.new({
                                        condition: function (condition) {
                                            if (options.remote) {
                                                // debugger
                                                if (!asynchronousAnswer) {
                                                    self.show();
                                                }
                                            } else {
                                                if (!calledBack) {
                                                    calledBack = true;
                                                    if (options.loading) {
                                                        options.loading(main);
                                                    }
                                                    self.show();
                                                }
                                            }

                                            condition(length === imgs.length);
                                        },
                                        ready: function () {
                                            if (!asynchronousAnswer) {
                                                container.html(contentSource);
                                                main.html(container);
                                            }

                                            length = 0;
                                            resolveHeaderActions(main, options);

                                            if (options.complete) {
                                                self.hide(false);
                                                // debugger
                                                options.complete(self);
                                            }
                                        }
                                    })

                                } else {
                                    resolveHeaderActions(main, options);

                                    if (options.complete) {
                                        options.complete(self);
                                    }
                                }

                                // talvez tenha que remanejar o disconnect
                                observer.disconnect();
                            });
                        },

                        create = function (remote) {
                            modal = $("

")
                                .addClass("esphinx ui modal");
                            main = $("")
                                .addClass("basicss hidden");
                            mask = $("

")
                                .addClass("basicss fixed transparent mask");
                            container = $("

").addClass("container");

                            modal
                                .append(mask)
                                .append(main);

                            body.append(modal);

                            observeContent();

                            if (options.remote) {
                                headers = options.header || options.headers || null;
                                params = options.param || options.params || null;
                                ajax.new(contentSource, {
                                    params: params,
                                    headers: headers,
                                    processing: function () {
                                        if (!calledBack) {
                                            calledBack = true;
                                            if (options.loading) {
                                                // debugger
                                                options.loading(main);
                                            }
                                        }
                                    },
                                    success: function (a) {
                                        if (options.success) {
                                            options.success(main);
                                        }
                                        asynchronousAnswer = a;
                                        // if (!options.loading) {
                                        //     container.html(asynchronousAnswer);
                                        //     // because this is asynchronous, it processes independently
                                        //     self.hide(false);
                                        //     main.html(container);
                                        // }
                                        container.html(asynchronousAnswer);
                                        // because this is asynchronous, it processes independently
                                        self.hide(false);
                                        main.html(container);
                                    }
                                });
                            } else {
                                container.html(contentSource);
                                main.html(container);
                            }

                        };

                    // global scope (public)
                    this.close = function () {
                        main.hide();

                        restartTransition(mask);
                        if (options.fadeOut) {
                            mask.css("transition", "opacity " + options.fadeOut);
                        }
                        mask.addClass("transparent");

                        setTimeout(function () {
                            modal.remove();
                        }, maskTransitionDuration(mask));

                        self.deleteSingleton();
                    };

                    this.hide = function (animation = true) {
                        main.hide();

                        restartTransition(mask);

                        if (animation) {
                            if (options.fadeOut) {
                                mask.css("transition", "opacity " + options.fadeOut);
                                setTimeout(function () {
                                    modal.css("z-index", -1);
                                }, maskTransitionDuration(mask));
                            }
                        }

                        mask.addClass("transparent");
                    };

                    this.show = function () {
                        modal.css("z-index", 0);

                        restartTransition(mask);
                        if (options.fadeIn) {
                            mask.css("transition", "opacity " + options.fadeIn);
                        }
                        mask.removeClass("transparent");

                        main.centralizeAt($(document));
                        main.show();
                        // debugger
                    };

                    if (!(this instanceof ModalConstructor)) {
                        self = Singleton.exists(ModalConstructor, arguments);
                        if (self) {
                            self.show();
                        } else {
                            return ModalConstructor.singleton(arguments);
                        }
                    // that "else" will should to exit for the "show" method can be used by who instanciates it
                    } else {
                        resolveParams();
                        create();
                    }

                    return self;
                }
            }
        }
    });

}(esPhinx.ui));
<commit_msg>improves modal<commit_after>// require ../support/jquery
// require esphinx_ui
// require esphinx/support/ajax
// require esphinx/support/function
// require esphinx/support/array
// require esphinx/observer

"use strict";

var
    jQuery,
    esPhinx,
    Singleton,
    Ajax,
    Constructor;

(function ($module) {

    $module.extend({

        windows: {
            modal: {
                // functions are objects in js
                new: function (contentSource, options) {

                    var
                        ModalConstructor = $module.windows.modal.new,
                        self = this,

                        $ = jQuery,
                        ajax = Ajax,
                        body = $("body"),

                        modal,
                        mask,
                        main,
                        container,
                        btnClose,
                        btnHide,
                        headers,
                        params,
                        asynchronousAnswer,
                        calledBack,
                        imgControl,

                        maskTransitionDuration = function (mask) {
                            return parseFloat(mask
                                .css("transition-duration")) * 1000;
                        },

                        restartTransition = function (mask) {
                            mask.css("transition", "opacity 0s");
                        },

                        resolveParams = function () {
                            options = options || {};

                            if (typeof options.windowController !== "boolean") {
                                options.windowController = true;
                            }

                            if (typeof options.remote !== "boolean") {
                                options.remote = true;
                            }
                        },

                        resolveHeaderActions = function (main, options) {
                            var
                                header,
                                actions;

                            if (options.windowController) {
                                header = $("");
                                actions = $("

").addClass("actions");
                                btnClose = $('')
                                    .addClass("btn-close");
                                btnHide = $('')
                                    .addClass("btn-hide");

                                header.append(actions);
                                actions.append(btnClose);
                                actions.append(btnHide);

                                main
                                    .prepend(header)
                                    .css({
                                        "max-height": $(window).height(),
                                        "max-width": $(document).width()
                                    });

                                bindHeaderEventListeners();
                            }
                        },

                        bindHeaderEventListeners = function () {
                            // $(document).off("keydown").on("keydown", function (e) {
                            //     if (e.keyCode === 27) {
                            //         self.hide();
                            //     }
                            // });

                            btnHide.click(function () {
                                self.hide();
                            });

                            btnClose.click(function () {
                                self.close();
                            });
                        },

                        observeContent = function () {
                            var
                                imgs,
                                length = 0;

                            esPhinx(main[0]).observe(function (observer) {
                                imgs = main.find("img");
                                if (imgs.length) {
                                    imgs.each(function (i, img) {
                                        esPhinx(img).on("load", function () {
                                            length += 1;
                                        });
                                    });

                                    FlowControl.new({
                                        condition: function (condition) {
                                            if (!options.remote) {
                                                if (!calledBack) {
                                                    calledBack = true;
                                                    if (options.loading) {
                                                        options.loading(main);
                                                    }
                                                    self.show();
                                                }
                                            }

                                            condition(length === imgs.length);
                                        },
                                        ready: function () {
                                            if (!asynchronousAnswer) {
                                                container.html(contentSource);
                                                main.html(container);
                                            }

                                            length = 0;
                                            resolveHeaderActions(main, options);

                                            if (options.complete) {
                                                self.hide(false);
                                                // debugger
                                                options.complete(self);
                                            }
                                        }
                                    })

                                } else {
                                    resolveHeaderActions(main, options);

                                    if (options.complete) {
                                        options.complete(self);
                                    }
                                }

                                // talvez tenha que remanejar o disconnect
                                observer.disconnect();
                            });
                        },

                        create = function (remote) {
                            modal = $("

")
                                .addClass("esphinx ui modal");
                            main = $("")
                                .addClass("basicss hidden");
                            mask = $("

")
                                .addClass("basicss fixed transparent mask");
                            container = $("

").addClass("container");

                            modal
                                .append(mask)
                                .append(main);

                            body.append(modal);

                            observeContent();

                            if (options.remote) {
                                headers = options.header || options.headers || null;
                                params = options.param || options.params || null;
                                ajax.new(contentSource, {
                                    params: params,
                                    headers: headers,
                                    processing: function () {
                                        if (!calledBack) {
                                            calledBack = true;
                                            if (options.loading) {
                                                options.loading(main);
                                                // because here the processing is asynchronous, it's not linear
                                                self.show();
                                            }
                                        }
                                    },
                                    success: function (a) {
                                        if (options.success) {
                                            options.success(main);
                                        }
                                        asynchronousAnswer = a;
                                        container.html(asynchronousAnswer);
                                        // because here the processing is asynchronous, it's not linear
                                        self.hide(false);
                                        main.html(container);
                                    }
                                });
                            } else {
                                container.html(contentSource);
                                main.html(container);
                            }

                        };

                    // global scope (public)
                    this.close = function () {
                        main.hide();

                        restartTransition(mask);
                        if (options.fadeOut) {
                            mask.css("transition", "opacity " + options.fadeOut);
                        }
                        mask.addClass("transparent");

                        setTimeout(function () {
                            modal.remove();
                        }, maskTransitionDuration(mask));

                        self.deleteSingleton();
                    };

                    this.hide = function (animation = true) {
                        main.hide();

                        restartTransition(mask);

                        if (animation) {
                            if (options.fadeOut) {
                                mask.css("transition", "opacity " + options.fadeOut);
                                setTimeout(function () {
                                    modal.css("z-index", -1);
                                }, maskTransitionDuration(mask));
                            }
                        }

                        mask.addClass("transparent");
                    };

                    this.show = function () {
                        modal.css("z-index", 0);

                        restartTransition(mask);
                        if (options.fadeIn) {
                            mask.css("transition", "opacity " + options.fadeIn);
                        }
                        mask.removeClass("transparent");

                        main.centralizeAt($(document));
                        main.show();
                        // debugger
                    };

                    if (!(this instanceof ModalConstructor)) {
                        self = Singleton.exists(ModalConstructor, arguments);
                        if (self) {
                            self.show();
                        } else {
                            return ModalConstructor.singleton(arguments);
                        }
                    // that "else" will should to exit for the "show" method can be used by who instanciates it
                    } else {
                        resolveParams();
                        create();
                    }

                    return self;
                }
            }
        }
    });

}(esPhinx.ui));
<|endoftext|>


<commit_before>// This is a SerGIS JSON Game Data file.
// See http://sergisproject.github.io/docs/json.html

/*
NOTE:
 - Since we can't load a JSON file unless running on a real web server (impractical for development),
   we're loading this as an actual JavaScript file, hence the assignment to SERGIS_JSON_DATA on the line below.

 - Comments (like these) technically are NOT valid JSON. Make sure to remove all the comments in this file when converting back to JSON.
*/

/*
ARCGIS NOTES:
 - ArcGIS Basemap options are:
   "streets", "satellite", "hybrid", "topo", "gray", "oceans", "osm", "national-geographic"
*/

// For a production environment, get rid of these comments and the assignment below, and set the location of this file in lib/backends/local.js.
var SERGIS_JSON_DATA = {
    "jumpingBackAllowed": true,
    "onJumpBack": "hide",
    "jumpingForwardAllowed": true,
    "showActionsInUserOrder": false,

    "promptList": [
        // First prompt:
        {
            // "prompt" is a SerGIS JSON Prompt Object
            "prompt": {
                "title": "Malmö",
                // Each item in the "contents" array is a SerGIS JSON Content Object
                "contents": [
                    {"type": "text", "value": "Which district should be given priority in an evacuation?"}
                ],
                // "map" is a SerGIS JSON Map Object
                "map": {
                    "latitude": 55.6,
                    "longitude": 13,
                    "zoom": 10,
                    "frontendInfo": {
                        "arcgis": {
                            "basemap": "streets",
                            // Providing one layer will show only that layer.
                            // Providing multiple layers will allow the user to choose between them, with none being visible by default.
                            "layers": [
                                {
                                    "name": "Overcrowding",
                                    "opacity": 0.9,
                                    "urls": [
                                        "http://geoapps64.main.ad.rit.edu:6080/arcgis/rest/services/malmo/MALM_Trygghet_levnadsf_trangbodd_12_SWE/MapServer"
                                        // MALM_Trygghet_levnadsf_trångbodd_12_SWE
                                    ]
                                },
                                {
                                    "name": "Illness",
                                    "opacity": 0.9,
                                    "urls": [
                                        "http://geoapps64.main.ad.rit.edu:6080/arcgis/rest/services/malmo/MALM_Trygghet_levnadsf_ohalsa_02_11_SWE/MapServer"
                                        // MALM_Trygghet_levnadsf_ohälsa_02_11_SWE
                                    ]
                                },
                                {
                                    "name": "Injury",
                                    "opacity": 0.8,
                                    "urls": [
                                        "http://geoapps64.main.ad.rit.edu:6080/arcgis/rest/services/malmo/Malmo_test/MapServer"
                                        // MALM_Trygghet_levnadsf_kränkning_12_SWE
                                    ]
                                },
                            ]
                        }
                    }
                },
                "randomizeChoices": true,
                // Each item in the "choices" array is a SerGIS JSON Content Object
                "choices": [
                    {"type": "text", "value": "Väster"},
                    {"type": "text", "value": "Innerstaden"},
                    {"type": "text", "value": "Norr"},
                    {"type": "text", "value": "Söder"},
                    {"type": "text", "value": "Öster"}
                ]
            },
            "actionList": [
                {
                    // Each item in the "actions" array is a SerGIS JSON Action Object
                    "actions": [
                        {
                            "name": "explain",
                            "data": [
                                {"type": "text", "value": "Good choice!"}
                            ]
                        }
                    ],
                    "pointValue": 2
                },
                {
                    // Each item in the "actions" array is a SerGIS JSON Action Object
                    "actions": [
                        {
                            "name": "explain",
                            "data": [
                                {"type": "text", "value": "Good choice!"}
                            ]
                        }
                    ],
                    "pointValue": 2
                },
                {
                    // Each item in the "actions" array is a SerGIS JSON Action Object
                    "actions": [
                        {
                            "name": "explain",
                            "data": [
                                {"type": "text", "value": "Good choice!"}
                            ]
                        }
                    ],
                    "pointValue": 2
                },
                {
                    // Each item in the "actions" array is a SerGIS JSON Action Object
                    "actions": [
                        {
                            "name": "explain",
                            "data": [
                                {"type": "text", "value": "Good choice!"}
                            ]
                        }
                    ],
                    "pointValue": 2
                },
                {
                    // Each item in the "actions" array is a SerGIS JSON Action Object
                    "actions": [
                        {
                            "name": "explain",
                            "data": [
                                {"type": "text", "value": "Good choice!"}
                            ]
                        }
                    ],
                    "pointValue": 2
                }
            ]
        },

        // All of the following prompts are just for testing; they're not actually related to Malmo.

        // Second prompt:
        {
            // "prompt" is a SerGIS JSON Prompt Object
            "prompt": {
                "title": "Introduction",
                // Each item in the "contents" array is a SerGIS JSON Content Object
                "contents": [
                    {"type": "html", "value": "Hello World!"},
                    {"type": "text", "value": "Note how the choice positions are randomized for this prompt. Also, each choice's content is defined in a different way."},
                    {"type": "html", "value": "Select "Choice NUMBER 1" to see an example of a buffer and an explanation."}
                ],
                // "map" is a SerGIS JSON Map Object
                "map": {
                    "latitude": 55.6,
                    "longitude": 13,
                    "zoom": 5,
                    "frontendInfo": {
                        "arcgis": {
                            "basemap": "streets",
                            "layers": [
                                {
                                    "name": "Malmo",
                                    "urls": [
                                        "http://geoapps64.main.ad.rit.edu:6080/arcgis/rest/services/malmo/Malmo_test/MapServer"
                                    ]
                                }
                            ]
                        }
                    }
                },
                "randomizeChoices": true,
                // Each item in the "choices" array is a SerGIS JSON Content Object
                "choices": [
                    // First choice:
                    {"type": "html", "value": "Choice NUMBER 1"},
                    // Second choice:
                    {"type": "text", "value": "Choice <2>"},
                    // Third choice:
                    {"type": "image", "value": "http://www.text2image.com/user_images/text2image_R45488_20141117_035359.jpg"}
                ]
            },
            "actionList": [
                // First choice's actions:
                {
                    // Each item in the "actions" array is a SerGIS JSON Action Object
                    "actions": [
                        // This is an "explain" action
                        {
                            "name": "explain",
                            "data": [
                                {"type": "text", "value": "Good choice! Once you click \"Continue\", a polygon will be drawn and a buffer will be placed around it."}
                            ]
                        },
                        // This is a "draw" action (specific to the "arcgis" frontend)
                        {
                            "name": "draw",
                            "frontend": "arcgis",
                            "data": [
                                "firstPromptDrawing",
                                "polygon",
                                [
                                    {
                                        "latitude": 55.6,
                                        "longitude": 12
                                    },
                                    {
                                        "latitude": 57,
                                        "longitude": 14
                                    },
                                    {
                                        "latitude": 55.6,
                                        "longitude": 15
                                    }
                                ]
                            ]
                        },
                        // This is an "explain" action
                        {
                            "name": "explain",
                            "data": [
                                {"type": "text", "value": "There's a polygon! Next we'll buffer it..."}
                            ]
                        },
                        // This is a "buffer" action (specific to the "arcgis" frontend)
                        {
                            "name": "buffer",
                            "frontend": "arcgis",
                            "data": [
                                50,
                                "statute_mile",
                                "firstPromptDrawing"
                            ]
                        },
                        // This is an "explain" action
                        {
                            "name": "explain",
                            "data": [
                                {"type": "html", "value": "Here's another explanation after the Map Action happened!"},
                                {"type": "text", "value": "Notice the polygon & the 50-mile buffer..."}
                            ]
                        }
                    ],
                    "pointValue": 5
                },
                // Second choice's actions:
                {
                    // Each item in the "actions" array is a SerGIS JSON Action Object
                    "actions": [],
                    "pointValue": 2
                },
                // Third choice's actions:
                {
                    // Each item in the "actions" array is a SerGIS JSON Action Object
                    "actions": [],
                    "pointValue": 2
                }
            ]
        },

        // Third prompt:
        {
            // "prompt" is a SerGIS JSON Prompt Object
            "prompt": {
                "title": "Legal Crap Test",
                // Each item in the "contents" array is a SerGIS JSON Content Object
                "contents": [
                    {"type": "text", "value": "You must agree to this legal crap to continue."},
                    {"type": "html", "value": "This is just to show what happens if...
a) no actions are provided ("I Agree"), and
b) goto[0] ("I Disagree")."},
                    {"type": "text", "value": "Clicking \"I Disagree\" will take you back to the first prompt, but note how the response to the second prompt (i.e. the buffer) is now gone. This is due to the \"onJumpBack\": \"hide\" setting in the JSON file. (\"jumpingBackAllowed\", \"onJumpBack\", \"jumpingForwardAllowed\", and \"showActionsInUserOrder\" are settings in the JSON file that give you fine-grained control over how users are able to jump between questions and what happens when they do.)", "style": "font-size: 85%"}
                ],
                // "map" is a SerGIS JSON Map Object
                "map": {
                    "latitude": 30,
                    "longitude": -20,
                    "zoom": 3,
                    "frontendInfo": {
                        "arcgis": {
                            "basemap": "national-geographic"
                        }
                    }
                },
                "choices": [
                    // First choice:
                    {"type": "text", "value": "I Agree"},
                    // Second choice:
                    {"type": "text", "value": "I Disagree"}
                ]
            },
            "actionList": [
                // First choice's actions:
                {
                    // No actions, so doesn't do anything before going on to the next prompt
                    // (You could provide an empty array, but not providing anything works just as well)
                    // (Just make sure that there's an empty object here to hold the place in actionList)
                    //"actions": []
                },
                // Second choice's actions:
                {
                    // Each item in the "actions" array is a SerGIS JSON Action Object
                    "actions": [
                        {"name": "goto", "data": [0]}
                    ]
                }
            ]
        },

        // Fourth prompt:
        {
            // "prompt" is a SerGIS JSON Prompt Object
            "prompt": {
                "title": "Test Questions",
                // Each item in the "contents" array is a SerGIS JSON Content Object
                "contents": [
                    {"type": "text", "value": "Hello World! (menos HTML parsing)"},
                    {"type": "html", "value": "Hello World! (con HTML parsing)"},
                    {"type": "image", "value": "http://upload.wikimedia.org/wikipedia/commons/thumb/8/80/Wikipedia-logo-v2.svg/70px-Wikipedia-logo-v2.svg.png"},
                    {"type": "youtube", "value": "dQw4w9WgXcQ"},
                    {"type": "text", "value": "Note the \"Continue\" button (since we didn't provide any choices)"}
                ],
                // "map" is a SerGIS JSON Map Object
                "map": {
                    "latitude": 55.6,
                    "longitude": 13,
                    "zoom": 5,
                    "frontendInfo": {
                        "arcgis": {
                            "basemap": "hybrid"
                        }
                    }
                }
            }
        }
    ]
}
<commit_msg>Updated data<commit_after>// This is a SerGIS JSON Game Data file.
// See http://sergisproject.github.io/docs/json.html

/*
NOTE:
 - Since we can't load a JSON file unless running on a real web server (impractical for development),
   we're loading this as an actual JavaScript file, hence the assignment to SERGIS_JSON_DATA on the line below.

 - Comments (like these) technically are NOT valid JSON. Make sure to remove all the comments in this file when converting back to JSON.
*/

/*
ARCGIS NOTES:
 - ArcGIS Basemap options are:
   "streets", "satellite", "hybrid", "topo", "gray", "oceans", "osm", "national-geographic"
*/

// For a production environment, get rid of these comments and the assignment below, and set the location of this file in lib/backends/local.js.
var SERGIS_JSON_DATA = {
    "jumpingBackAllowed": true,
    "onJumpBack": "hide",
    "jumpingForwardAllowed": true,
    "showActionsInUserOrder": false,

    "promptList": [
        // First prompt:
        {
            // "prompt" is a SerGIS JSON Prompt Object
            "prompt": {
                "title": "Malmö",
                // Each item in the "contents" array is a SerGIS JSON Content Object
                "contents": [
                    {"type": "text", "value": "Which district should be given priority in an evacuation?"}
                ],
                // "map" is a SerGIS JSON Map Object
                "map": {
                    "latitude": 55.58,
                    "longitude": 13,
                    "zoom": 11,
                    "frontendInfo": {
                        "arcgis": {
                            "basemap": "streets",
                            // Providing one layer will show only that layer.
                            // Providing multiple layers will allow the user to choose between them, with none being visible by default.
                            "layers": [
                                {
                                    "name": "Accidents (by jenks)",
                                    "opacity": 0.83,
                                    "urls": [
                                        //"http://geoapps64.main.ad.rit.edu:6080/arcgis/rest/services/malmo/Malmo_test/MapServer"
                                        "http://geoapps64.main.ad.rit.edu:6080/arcgis/rest/services/malmo/accidents_jenks/MapServer"
                                    ]
                                },
                                {
                                    "name": "Illness (by jenks)",
                                    "opacity": 0.83,
                                    "urls": [
                                        "http://geoapps64.main.ad.rit.edu:6080/arcgis/rest/services/malmo/illness_jenks/MapServer"
                                    ]
                                },
                                {
                                    "name": "Accidents (by equal interval)",
                                    "opacity": 0.83,
                                    "urls": [
                                        "http://geoapps64.main.ad.rit.edu:6080/arcgis/rest/services/malmo/accidents_equalinterval/MapServer"
                                    ]
                                },
                                {
                                    "name": "Illness (by geometric interval)",
                                    "opacity": 0.83,
                                    "urls": [
                                        "http://geoapps64.main.ad.rit.edu:6080/arcgis/rest/services/malmo/illness_geometricinterval/MapServer"
                                    ]
                                }
                            ]
                        }
                    }
                },
                "randomizeChoices": true,
                // Each item in the "choices" array is a SerGIS JSON Content Object
                "choices": [
                    {"type": "text", "value": "Väster"},
                    {"type": "text", "value": "Innerstaden"},
                    {"type": "text", "value": "Norr"},
                    {"type": "text", "value": "Söder"},
                    {"type": "text", "value": "Öster"}
                ]
            },
            "actionList": [
                {
                    // Each item in the "actions" array is a SerGIS JSON Action Object
                    "actions": [
                        {
                            "name": "explain",
                            "data": [
                                {"type": "text", "value": "Good choice!"}
                            ]
                        }
                    ],
                    "pointValue": 2
                },
                {
                    // Each item in the "actions" array is a SerGIS JSON Action Object
                    "actions": [
                        {
                            "name": "explain",
                            "data": [
                                {"type": "text", "value": "Good choice!"}
                            ]
                        }
                    ],
                    "pointValue": 2
                },
                {
                    // Each item in the "actions" array is a SerGIS JSON Action Object
                    "actions": [
                        {
                            "name": "explain",
                            "data": [
                                {"type": "text", "value": "Good choice!"}
                            ]
                        }
                    ],
                    "pointValue": 2
                },
                {
                    // Each item in the "actions" array is a SerGIS JSON Action Object
                    "actions": [
                        {
                            "name": "explain",
                            "data": [
                                {"type": "text", "value": "Good choice!"}
                            ]
                        }
                    ],
                    "pointValue": 2
                },
                {
                    // Each item in the "actions" array is a SerGIS JSON Action Object
                    "actions": [
                        {
                            "name": "explain",
                            "data": [
                                {"type": "text", "value": "Good choice!"}
                            ]
                        }
                    ],
                    "pointValue": 2
                }
            ]
        },

        // All of the following prompts are just for testing; they're not actually related to Malmo.

        // Second prompt:
        {
            // "prompt" is a SerGIS JSON Prompt Object
            "prompt": {
                "title": "Introduction",
                // Each item in the "contents" array is a SerGIS JSON Content Object
                "contents": [
                    {"type": "html", "value": "Hello World!"},
                    {"type": "text", "value": "Note how the choice positions are randomized for this prompt. Also, each choice's content is defined in a different way."},
                    {"type": "html", "value": "Select "Choice NUMBER 1" to see an example of a buffer and an explanation."}
                ],
                // "map" is a SerGIS JSON Map Object
                "map": {
                    "latitude": 55.6,
                    "longitude": 13,
                    "zoom": 5,
                    "frontendInfo": {
                        "arcgis": {
                            "basemap": "streets",
                            "layers": [
                                {
                                    "name": "Malmo",
                                    "urls": [
                                        "http://geoapps64.main.ad.rit.edu:6080/arcgis/rest/services/malmo/Malmo_test/MapServer"
                                    ]
                                }
                            ]
                        }
                    }
                },
                "randomizeChoices": true,
                // Each item in the "choices" array is a SerGIS JSON Content Object
                "choices": [
                    // First choice:
                    {"type": "html", "value": "Choice NUMBER 1"},
                    // Second choice:
                    {"type": "text", "value": "Choice <2>"},
                    // Third choice:
                    {"type": "image", "value": "http://www.text2image.com/user_images/text2image_R45488_20141117_035359.jpg"}
                ]
            },
            "actionList": [
                // First choice's actions:
                {
                    // Each item in the "actions" array is a SerGIS JSON Action Object
                    "actions": [
                        // This is an "explain" action
                        {
                            "name": "explain",
                            "data": [
                                {"type": "text", "value": "Good choice! Once you click \"Continue\", a polygon will be drawn and a buffer will be placed around it."}
                            ]
                        },
                        // This is a "draw" action (specific to the "arcgis" frontend)
                        {
                            "name": "draw",
                            "frontend": "arcgis",
                            "data": [
                                "firstPromptDrawing",
                                "polygon",
                                [
                                    {
                                        "latitude": 55.6,
                                        "longitude": 12
                                    },
                                    {
                                        "latitude": 57,
                                        "longitude": 14
                                    },
                                    {
                                        "latitude": 55.6,
                                        "longitude": 15
                                    }
                                ]
                            ]
                        },
                        // This is an "explain" action
                        {
                            "name": "explain",
                            "data": [
                                {"type": "text", "value": "There's a polygon! Next we'll buffer it..."}
                            ]
                        },
                        // This is a "buffer" action (specific to the "arcgis" frontend)
                        {
                            "name": "buffer",
                            "frontend": "arcgis",
                            "data": [
                                50,
                                "statute_mile",
                                "firstPromptDrawing"
                            ]
                        },
                        // This is an "explain" action
                        {
                            "name": "explain",
                            "data": [
                                {"type": "html", "value": "Here's another explanation after the Map Action happened!"},
                                {"type": "text", "value": "Notice the polygon & the 50-mile buffer..."}
                            ]
                        }
                    ],
                    "pointValue": 5
                },
                // Second choice's actions:
                {
                    // Each item in the "actions" array is a SerGIS JSON Action Object
                    "actions": [],
                    "pointValue": 2
                },
                // Third choice's actions:
                {
                    // Each item in the "actions" array is a SerGIS JSON Action Object
                    "actions": [],
                    "pointValue": 2
                }
            ]
        },

        // Third prompt:
        {
            // "prompt" is a SerGIS JSON Prompt Object
            "prompt": {
                "title": "Legal Crap Test",
                // Each item in the "contents" array is a SerGIS JSON Content Object
                "contents": [
                    {"type": "text", "value": "You must agree to this legal crap to continue."},
                    {"type": "html", "value": "This is just to show what happens if...
a) no actions are provided ("I Agree"), and
b) goto[0] ("I Disagree")."},
                    {"type": "text", "value": "Clicking \"I Disagree\" will take you back to the first prompt, but note how the response to the second prompt (i.e. the buffer) is now gone. This is due to the \"onJumpBack\": \"hide\" setting in the JSON file. (\"jumpingBackAllowed\", \"onJumpBack\", \"jumpingForwardAllowed\", and \"showActionsInUserOrder\" are settings in the JSON file that give you fine-grained control over how users are able to jump between questions and what happens when they do.)", "style": "font-size: 85%"}
                ],
                // "map" is a SerGIS JSON Map Object
                "map": {
                    "latitude": 30,
                    "longitude": -20,
                    "zoom": 3,
                    "frontendInfo": {
                        "arcgis": {
                            "basemap": "national-geographic"
                        }
                    }
                },
                "choices": [
                    // First choice:
                    {"type": "text", "value": "I Agree"},
                    // Second choice:
                    {"type": "text", "value": "I Disagree"}
                ]
            },
            "actionList": [
                // First choice's actions:
                {
                    // No actions, so doesn't do anything before going on to the next prompt
                    // (You could provide an empty array, but not providing anything works just as well)
                    // (Just make sure that there's an empty object here to hold the place in actionList)
                    //"actions": []
                },
                // Second choice's actions:
                {
                    // Each item in the "actions" array is a SerGIS JSON Action Object
                    "actions": [
                        {"name": "goto", "data": [0]}
                    ]
                }
            ]
        },

        // Fourth prompt:
        {
            // "prompt" is a SerGIS JSON Prompt Object
            "prompt": {
                "title": "Test Questions",
                // Each item in the "contents" array is a SerGIS JSON Content Object
                "contents": [
                    {"type": "text", "value": "Hello World! (menos HTML parsing)"},
                    {"type": "html", "value": "Hello World! (con HTML parsing)"},
                    {"type": "image", "value": "http://upload.wikimedia.org/wikipedia/commons/thumb/8/80/Wikipedia-logo-v2.svg/70px-Wikipedia-logo-v2.svg.png"},
                    {"type": "youtube", "value": "dQw4w9WgXcQ"},
                    {"type": "text", "value": "Note the \"Continue\" button (since we didn't provide any choices)"}
                ],
                // "map" is a SerGIS JSON Map Object
                "map": {
                    "latitude": 55.6,
                    "longitude": 13,
                    "zoom": 5,
                    "frontendInfo": {
                        "arcgis": {
                            "basemap": "hybrid"
                        }
                    }
                }
            }
        }
    ]
}
<|endoftext|>


<commit_before>/* eslint-disable no-new-wrappers */
'use strict';

// MODULES //

var tape = require( 'tape' );
var isArray = require( '@stdlib/assert/is-array' );
var tokenize = require( './../lib' );

// TESTS //

tape( 'main export is a function', function test( t ) {
	t.ok( true, __filename );
	t.equal( typeof tokenize, 'function', 'main export is a function' );
	t.end();
});

tape( 'if the first argument is not a string primitive, the function throws an error', function test( t ) {
	var values;
	var i;

	values = [
		new String( 'beep' ),
		5,
		null,
		true,
		undefined,
		NaN,
		[],
		{},
		function noop() {}
	];

	for ( i = 0; i < values.length; i++ ) {
		t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] );
	}
	t.end();

	function badValue( value ) {
		return function badValue() {
			tokenize( value );
		};
	}
});

tape( 'if the second argument is not a boolean primitive, the function throws an error', function test( t ) {
	var values;
	var i;

	values = [
		new String( 'beep' ),
		5,
		null,
		'abc',
		undefined,
		NaN,
		[],
		{},
		function noop() {}
	];

	for ( i = 0; i < values.length; i++ ) {
		t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] );
	}
	t.end();

	function badValue( value ) {
		return function badValue() {
			tokenize( 'beep Boop', value );
		};
	}
});

tape( 'the function tokenizes a string', function test( t ) {
	var expected;
	var actual;
	var str;

	str = 'Hello World!';
	expected = [ 'Hello', 'World', '!' ];
	actual = tokenize( str );
	t.deepEqual( actual, expected, 'returns an array of tokens' );

	str = 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod.';
	expected = [
		'Lorem',
		'ipsum',
		'dolor',
		'sit',
		'amet',
		',',
		'consetetur',
		'sadipscing',
		'elitr',
		',',
		'sed',
		'diam',
		'nonumy',
		'eirmod',
		'.'
	];
	actual = tokenize( str );
	t.deepEqual( actual, expected, 'returns an array of tokens' );

	str = 'Hello Mrs. Maple, could you call me back?';
	expected = [ 'Hello', 'Mrs.', 'Maple', ',', 'could', 'you', 'call', 'me', 'back', '?' ];
	actual = tokenize( str );
	t.deepEqual( actual, expected, 'returns an array of tokens' );

	str = 'William Shakespeare (04/26/1564 (baptised) – 04/23/1616)';
	expected = [ 'William', 'Shakespeare', '(', '04/26/1564', '(', 'baptised', ')', '–', '04/23/1616', ')' ];
	actual = tokenize( str );
	t.deepEqual( actual, expected, 'returns an array of tokens' );

	t.end();
});

tape( 'the function tokenizes a string (preserving whitespace)', function test( t ) {
	var expected;
	var actual;
	var str;

	str = 'Hello World!';
	expected = [ 'Hello', ' ', 'World', '!' ];
	actual = tokenize( str, true );
	t.deepEqual( actual, expected, 'returns an array of tokens' );

	str = 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr,\nsed diam nonumy eirmod.';
	expected = [
		'Lorem',
		' ',
		'ipsum',
		' ',
		'dolor',
		' ',
		'sit',
		' ',
		'amet',
		',',
		' ',
		'consetetur',
		' ',
		'sadipscing',
		' ',
		'elitr',
		',',
		'\n',
		'sed',
		' ',
		'diam',
		' ',
		'nonumy',
		' ',
		'eirmod',
		'.'
	];
	actual = tokenize( str, true );
	t.deepEqual( actual, expected, 'returns an array of tokens' );

	str = 'Hello Mrs. Maple, could you call me back?';
	expected = [ 'Hello', ' ', 'Mrs.', ' ', 'Maple', ',', ' ', 'could', ' ', 'you', ' ', 'call', ' ', 'me', ' ', 'back', '?' ];
	actual = tokenize( str, true );
	t.deepEqual( actual, expected, 'returns an array of tokens' );

	str = 'William Shakespeare (04/26/1564 (baptised) – 04/23/1616)';
	expected = [
		'William',
		' ',
		'Shakespeare',
		'(',
		'04/26/1564',
		' ',
		'(',
		'baptised',
		')',
		' ',
		'–',
		' ',
		'04/23/1616',
		')'
	];
	actual = tokenize( str );
	t.deepEqual( actual, expected, 'returns an array of tokens' );

	t.end();
});

tape( 'the function returns an emptry array if provided an empty string', function test( t ) {
	var out = tokenize( '' );
	t.equal( isArray( out ), true, 'returns an array' );
	t.equal( out.length, 0, 'array length is zero' );
	t.end();
});
<commit_msg>Fix test<commit_after>/* eslint-disable no-new-wrappers */
'use strict';

// MODULES //

var tape = require( 'tape' );
var isArray = require( '@stdlib/assert/is-array' );
var tokenize = require( './../lib' );

// TESTS //

tape( 'main export is a function', function test( t ) {
	t.ok( true, __filename );
	t.equal( typeof tokenize, 'function', 'main export is a function' );
	t.end();
});

tape( 'if the first argument is not a string primitive, the function throws an error', function test( t ) {
	var values;
	var i;

	values = [
		new String( 'beep' ),
		5,
		null,
		true,
		undefined,
		NaN,
		[],
		{},
		function noop() {}
	];

	for ( i = 0; i < values.length; i++ ) {
		t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] );
	}
	t.end();

	function badValue( value ) {
		return function badValue() {
			tokenize( value );
		};
	}
});

tape( 'if the second argument is not a boolean primitive, the function throws an error', function test( t ) {
	var values;
	var i;

	values = [
		new String( 'beep' ),
		5,
		null,
		'abc',
		undefined,
		NaN,
		[],
		{},
		function noop() {}
	];

	for ( i = 0; i < values.length; i++ ) {
		t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] );
	}
	t.end();

	function badValue( value ) {
		return function badValue() {
			tokenize( 'beep Boop', value );
		};
	}
});

tape( 'the function tokenizes a string', function test( t ) {
	var expected;
	var actual;
	var str;

	str = 'Hello World!';
	expected = [ 'Hello', 'World', '!' ];
	actual = tokenize( str );
	t.deepEqual( actual, expected, 'returns an array of tokens' );

	str = 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod.';
	expected = [
		'Lorem',
		'ipsum',
		'dolor',
		'sit',
		'amet',
		',',
		'consetetur',
		'sadipscing',
		'elitr',
		',',
		'sed',
		'diam',
		'nonumy',
		'eirmod',
		'.'
	];
	actual = tokenize( str );
	t.deepEqual( actual, expected, 'returns an array of tokens' );

	str = 'Hello Mrs. Maple, could you call me back?';
	expected = [ 'Hello', 'Mrs.', 'Maple', ',', 'could', 'you', 'call', 'me', 'back', '?' ];
	actual = tokenize( str );
	t.deepEqual( actual, expected, 'returns an array of tokens' );

	str = 'William Shakespeare (04/26/1564 (baptised) – 04/23/1616)';
	expected = [ 'William', 'Shakespeare', '(', '04/26/1564', '(', 'baptised', ')', '–', '04/23/1616', ')' ];
	actual = tokenize( str );
	t.deepEqual( actual, expected, 'returns an array of tokens' );

	t.end();
});

tape( 'the function tokenizes a string (preserving whitespace)', function test( t ) {
	var expected;
	var actual;
	var str;

	str = 'Hello World!';
	expected = [ 'Hello', ' ', 'World', '!' ];
	actual = tokenize( str, true );
	t.deepEqual( actual, expected, 'returns an array of tokens' );

	str = 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr,\nsed diam nonumy eirmod.';
	expected = [
		'Lorem',
		' ',
		'ipsum',
		' ',
		'dolor',
		' ',
		'sit',
		' ',
		'amet',
		',',
		' ',
		'consetetur',
		' ',
		'sadipscing',
		' ',
		'elitr',
		',',
		'\n',
		'sed',
		' ',
		'diam',
		' ',
		'nonumy',
		' ',
		'eirmod',
		'.'
	];
	actual = tokenize( str, true );
	t.deepEqual( actual, expected, 'returns an array of tokens' );

	str = 'Hello Mrs. Maple, could you call me back?';
	expected = [ 'Hello', ' ', 'Mrs.', ' ', 'Maple', ',', ' ', 'could', ' ', 'you', ' ', 'call', ' ', 'me', ' ', 'back', '?' ];
	actual = tokenize( str, true );
	t.deepEqual( actual, expected, 'returns an array of tokens' );

	str = 'William Shakespeare (04/26/1564 (baptised) – 04/23/1616)';
	expected = [
		'William',
		' ',
		'Shakespeare',
		' ',
		'(',
		'04/26/1564',
		' ',
		'(',
		'baptised',
		')',
		' ',
		'–',
		' ',
		'04/23/1616',
		')'
	];
	actual = tokenize( str, true );
	t.deepEqual( actual, expected, 'returns an array of tokens' );

	t.end();
});

tape( 'the function returns an emptry array if provided an empty string', function test( t ) {
	var out = tokenize( '' );
	t.equal( isArray( out ), true, 'returns an array' );
	t.equal( out.length, 0, 'array length is zero' );
	t.end();
});
<|endoftext|>