<commit_before>import bridge from '../common/bridge';
import React from 'react';

export default class ServerForm extends React.Component {
  render() {
    return (
      <form onSubmit={this.connect.bind(this)}>
        <p>server: <input type='text' name='server' defaultValue='irc.freenode.net' /></p>
        <p>port: <input type='text' name='port' defaultValue='6667' /></p>
        <p>encoding: <input type='text' name='encoding' defaultValue='UTF-8' /></p>
        <p>nickname: <input type='text' name='nick' defaultValue='noraesae' /></p>
        <p>user name: <input type='text' name='username' defaultValue='noraesae' /></p>
        <p>real name: <input type='text' name='realname' defaultValue='noraesae' /></p>
        <p><button>connect</button></p>
      </form>
    );
  }

  formToJSON() {
    let form = React.findDOMNode(this);
    let inputs = form.querySelectorAll('input[type="text"]');
    return Array.prototype.reduce.call(inputs, function (obj, input) {
      obj[input.name] = input.value;
      return obj;
    }, {});
  }

  connect(e) {
    e.preventDefault();

    let data = this.formToJSON();
    this.props.connect(data);
    bridge.send('connect', data);
  }
}
<commit_msg>Stop propagation from server form inputs.<commit_after>import bridge from '../common/bridge';
import React from 'react';

class TextInput extends React.Component {
  render() {
    return <input type='text' name={this.props.name}
                  defaultValue={this.props.defaultValue}
                  onKeyDown={this.keydown.bind(this)} />;
  }
  keydown(e) {
    e.stopPropagation();
  }
}

export default class ServerForm extends React.Component {
  render() {
    return (
      <form onSubmit={this.connect.bind(this)}>
        <p>server: <TextInput name='server' defaultValue='irc.freenode.net' /></p>
        <p>port: <TextInput name='port' defaultValue='6667' /></p>
        <p>encoding: <TextInput name='encoding' defaultValue='UTF-8' /></p>
        <p>nickname: <TextInput name='nick' defaultValue='noraesae' /></p>
        <p>user name: <TextInput name='username' defaultValue='noraesae' /></p>
        <p>real name: <TextInput name='realname' defaultValue='noraesae' /></p>
        <p><button>connect</button></p>
      </form>
    );
  }

  formToJSON() {
    let form = React.findDOMNode(this);
    let inputs = form.querySelectorAll('input[type="text"]');
    return Array.prototype.reduce.call(inputs, function (obj, input) {
      obj[input.name] = input.value;
      return obj;
    }, {});
  }

  connect(e) {
    e.preventDefault();

    let data = this.formToJSON();
    this.props.connect(data);
    bridge.send('connect', data);
  }
}

{'fraction_non_alphanumeric': 0.17616191904047976, 'fraction_numerical': 0.0037481259370314842, 'mean_word_length': 3.2567783094098885, 'pattern_counts': {'":': 0, '<': 52, '<?xml version=': 0, '>': 52, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6504043', 'n_tokens_mistral': 878, 'n_tokens_neox': 855, 'n_words': 176}