<commit_before>/** @jsx React.DOM */
var ArtistList = React.createClass({
  render: function() {
    var createItem = function(itemText) {
      return <li>{itemText}</li>;
    };
    return <ul>{this.props.items.map(createItem)}</ul>;
  }
});

var ArtistApp = React.createClass({
  acceptableArtists: [
    'skrillex', 'odesza'
  ],
  getInitialState: function() {
    return {items: [], text: ''};
  },
  onChange: function(e) {
    this.setState({text: e.target.value});
  },
  handleSubmit: function(e) {
    e.preventDefault();

    var query = this.state.text;

    var reactLand = this;
    $.ajax({
      url: 'https://api.spotify.com/v1/search',
      data: {
        q: query,
        type: 'artist'
      },
      success: function (response) {
        console.log(response);
        if(response.artists.items.length > 0) {
          var nextItems = reactLand.state.items.concat([reactLand.state.text + " " + response.artists.items[0].popularity]);
          var nextText = '';
          reactLand.setState({items: nextItems, text: nextText});
        } else {
          alert("can't find artist sorry");
        }
      },
      failure: function (response) {
        alert("can't find artist sorry");
      }
    });<commit_msg>tidy up<commit_after>/** @jsx React.DOM */
var ArtistList = React.createClass({
  render: function() {
    var createItem = function(itemText) {
      return <li>{itemText}</li>;
    };
    return <ul>{this.props.items.map(createItem)}</ul>;
  }
});

var ArtistApp = React.createClass({
  getInitialState: function() {
    return {items: [], text: ''};
  },
  onChange: function(e) {
    this.setState({text: e.target.value});
  },
  handleSubmit: function(e) {
    e.preventDefault();

    if(this.state.text == '') {
      return;
    }

    this.searchArtist(this.state.text);
  },
  searchArtist: function(query) {
    var me = this;
    $.ajax({
      url: 'https://api.spotify.com/v1/search',
      data: {
        q: this.state.text,
        type: 'artist'
      },
      success: function (response) {
        console.log(response);
        if(response.artists.items.length > 0) {
          me.success(response.artists.items[0])
        } else {
          me.failure();
        }
      },
    });
  },
  success: function(artist) {
    var nextItems = this.state.items.concat([artist.name + " (" + artist.popularity + ")"]);
    var nextText = '';
    this.setState({items: nextItems, text: nextText});
  },
  failure: function() {
    alert("can't find artist sorry")
{'fraction_non_alphanumeric': 0.17123559793404847, 'fraction_numerical': 0.0023837902264600714, 'mean_word_length': 2.4827109266943292, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, 'https://': 2, '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': '2670914', 'n_tokens_mistral': 818, 'n_tokens_neox': 814, 'n_words': 149}