<commit_before>var React = require('react');

var PutForm = React.createClass({
  getDefaultProps: function() {
      return {header: "A Put Form",
              fields: [{placeholder: "A placeholder", type: "text"},
                       {placeholder: "Another placeholder", type: "text"},
                       {placeholder: "Another placeholder", type: "text"}],
              url: "/unset/url",
              className: "putForm",
              buttonText: "Button"
             };
  },

  putContent: function(e) {
    // Query API for drinks using ingredient tied to primary key
    e.preventDefault();
    console.log('You submitted the button.');
    console.log('This was the passed eect: ');
    console.log(e)
    return null
    if(!e) {
      console.log('Set some error handler here');
      return null;
    }
    let xhr = new XMLHttpRequest();
    let url = this.props.drinksURL + pk.toString() + '.json'
    if(url==this.state.lastDrinkSearch){
      return
    }
    xhr.open("put", url, true);
    xhr.onload = function() {
      let ingredient = JSON.parse(e);
      xhr.send();
    }
  },

  render: function() {
    var formelements = this.props.fields
    return (
      <div className={this.props.className}>
        <h3>{this.props.header}</h3>
        <form onSubmit={this.putContent}>
          {formelements.map(function(elem) {
          return <input {...elem} />
          }, this)}
          <input type="submit" value={this.props.buttonText} />
        </form>
      </div>
    )
  }
});

module.exports = PutForm;<commit_msg>Fix comments.<commit_after>var React = require('react');

/* Super rad modular form submitter. It makes a put request to the url in the props. 
** Form fields dynamically set via the array in the fields property. Observe default
** props for more info.
** Or modify this obj as you need.
             {header: "A Put Form",
              fields: [{placeholder: "Email placeholder", type: "text", name: "Email"},
                       {placeholder: "Name placeholder", type: "text", name: "Name"},
                       {placeholder: "Addr placeholder", type: "text", name: "Address"}],
              url: "/unset/url",
              className: "putForm",
              buttonText: "Button"
             };
*/

var PutForm = React.createClass({
  getDefaultProps: function() {
      return {header: "A Put Form",
              fields: [{placeholder: "Email placeholder", type: "text", name: "Email"},
                       {placeholder: "Name placeholder", type: "text", name: "Name"},
                       {placeholder: "Addr placeholder", type: "text", name: "Address"}],
              url: "/unset/url",
              className: "putForm",
              buttonText: "Button"
             };
  },

  getInitialState: function() {
    return {}  
  },

  updateField: function(elem, event) {
    var name = elem.name;
    let value = event.target.value;
    this.setState({[elem.name]: value})
  },

  putContent: function(e) {
    // Make a PUT request from the content of the form, derived from this.state values,
    // to the address at this.props.url
    e.preventDefault();
    console.log('You submitted the button.');
    if(!e) {
      console.log('Set some error handler here');
      return null;
    }
    let xhr = new XMLHttpRequest();
    let url = this.props.url
    xhr.open("PUT", url, true);
    xhr.onload = function() {
      let ingredient = this.state;
      console.log(ingredient)
      xhr.send();
    }.bind(this);
    xhr.send();
  },

  render: function() {
    var formelements = this.props.fields
    return (
      <div className={this.props.className}>
        <h3>{this.props.header}</h3>
        <form onSubmit={this.putContent}>
          {formelements.map(function(elem, i) {
            var updateField = this.updateField.bind(this, elem)
            return <input key={i} onChange={updateField} {...elem} />
          }, this)}
          <input type="submit" value={this.props.buttonText} />
        </form>
      </div>
    )
  }
});

module.exports = PutForm;
{'fraction_non_alphanumeric': 0.14531595770838457, 'fraction_numerical': 0.0009835259404966806, 'mean_word_length': 2.1731669266770672, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, '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': '4132239', 'n_tokens_mistral': 1176, 'n_tokens_neox': 1157, 'n_words': 321}