<commit_before>'use strict';

import $ from 'jquery';
import React from 'react';
import { render } from 'react-dom';
import { Button, MenuItem, Dropdown } from 'react-bootstrap';

import Solitaire from 'solitaire';
import Multiplayer from 'multiplayer';

class SetApp extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      games: {}
    };
  }

  componentWillMount() {
    let onSuccess = function(response) {
      this.setState({
        'games': response
      });
    }.bind(this);
    let onError = function(response) {
      this.setState({
        'error': response
      });
    }.bind(this);
    $.get('/multiplayer/status').then(onSuccess, onError);
  }

  startSolitaire() {
    $.get('/solitaire').then((response) => {
      render(
        <Solitaire url="/solitaire" />, document.getElementById('content')
      );
    });
  }

  startMultiplayer(gameName) {
    return (evt) => {
      $.get('/multiplayer/go', {
        name: gameName
      }).then((response) => {
        render(
          <Multiplayer url="multiplayer" {...response} />, document.getElementById('content')
        );
      });
    };
  }

  render() {
    return (
      <div id="index-wrapper">
        <Button bsSize="large"
                bsStyle="default"
                key="solitaire"
                onClick={this.startSolitaire}
                id="solitaire_button">Solitaire Set</Button>
        <Dropdown id="multiplayer_button">
          <Button bsSize="large"
                  bsStyle="default"
                  key="multiplayer"
                  onClick={this.startMultiplayer()}>Multiplayer Set</Button>
          <Dropdown.Toggle bsSize="large"
                           disabled={!Object.keys(this.state.games).length} />
          <Dropdown.Menu><commit_msg>send a request for the active games when the dropdown menu is clicked<commit_after>'use strict';

import $ from 'jquery';
import React from 'react';
import { render } from 'react-dom';
import { Button, MenuItem, Dropdown } from 'react-bootstrap';

import Solitaire from 'solitaire';
import Multiplayer from 'multiplayer';

class SetApp extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      games: {}
    };
  }

  componentWillMount() {
    this.requestGamesStatus();
  }

  startSolitaire() {
    $.get('/solitaire').then((response) => {
      render(
        <Solitaire url="/solitaire" />, document.getElementById('content')
      );
    });
  }

  startMultiplayer(gameName) {
    return (evt) => {
      $.get('/multiplayer/go', {
        name: gameName
      }).then((response) => {
        render(
          <Multiplayer url="multiplayer" {...response} />, document.getElementById('content')
        );
      });
    };
  }

  requestGamesStatus() {
    let onSuccess = function(response) {
      this.setState({
        'games': response
      });
    }.bind(this);
    let onError = function(response) {
      this.setState({
        'error': response
      });
    }.bind(this);
    $.get('/multiplayer/status').then(onSuccess, onError);
  }

  render() {
    return (
      <div id="index-wrapper">
        <Button bsSize="large"
                bsStyle="default"
                key="solitaire"
                onClick={this.startSolitaire}
                id="solitaire_button">Solitaire Set</Button>
        <Dropdown id="multiplayer_button"
                  onToggle={(isOpen) => { isOpen && this.requestGamesStatus(); }}>
          <Button bsSize="large"
                  bsStyle="default"
                  key="multiplayer"
                  onClick={this.startMultiplayer()}>Multiplayer Set</Button>
          <Dropdown.Toggle bsSize="large" />
          <Dropdown.Menu>
{'fraction_non_alphanumeric': 0.14752342704149934, 'fraction_numerical': 0.0, 'mean_word_length': 2.2515230635335075, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 30, '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': '5073179', 'n_tokens_mistral': 1087, 'n_tokens_neox': 1066, 'n_words': 201}