<commit_before>import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { toastr } from 'react-redux-toastr';
import _ from 'underscore';

import Avatar from './Avatar.jsx';
import * as actions from './actions';

class InnerGameList extends React.Component {
    constructor() {
        super();

        this.joinGame = this.joinGame.bind(this);
    }

    joinGame(event, game) {
        event.preventDefault();

        if(!this.props.username) {
            toastr.error('Please login before trying to join a game');
            return;
        }

        if(game.needsPassword) {
            this.props.joinPasswordGame(game, 'Join');
        } else {
            this.props.socket.emit('joingame', game.id);
        }
    }

    canWatch(game) {
        return !this.props.currentGame && game.allowSpectators;
    }

    watchGame(event, game) {
        event.preventDefault();

        if(!this.props.username) {
            toastr.error('Please login before trying to watch a game');
            return;
        }

        if(game.needsPassword) {
            this.props.joinPasswordGame(game, 'Watch');
        } else {
            this.props.socket.emit('watchgame', game.id);
        }
    }

    removeGame(event, game) {
        event.preventDefault();

        this.props.socket.emit('removegame', game.id);
    }

    render() {
        let gameList = _.map(this.props.games, game => {
            let firstPlayer = true;
            let gameRow = [];

            _.each(game.players, player => {
                let playerElement = null;

                if(firstPlayer) {
                    gameRow.push(
                        <span className='col-xs-4 col-sm-3 game-row-avatar'>
                            <span className='hidden-xs col-sm-3 game-row-avatar'>
                                <Avatar emailHash={ player.emailHash } forceDefault={ player.settings ? player.settings.disableGravatar : false } />
                            </span>
                            <span className='player-name col-sm-8'>{ player.name }</span>
                        </span>);
                    gameRow.push();
                    gameRow.push(<span className={ 'hidden-xs col-xs-1 game-icon icon-clan-' + player.faction } />);

                    firstPlayer = false;
                } else {
                    gameRow.push(<span className='col-xs-1 game-row-vs text-center'><b> vs </b></span>);
                    gameRow.push(<span className={ 'hidden-xs col-xs-1 game-icon icon-clan-' + player.faction } />);
                    gameRow.push(
                        <span className='col-xs-4 col-sm-3 game-row-avatar'>
                            <span className='player-name col-sm-8'>{ player.name }</span>
                            <span className='hidden-xs game-row-avatar pull-right col-sm-3'>
                                <Avatar emailHash={ player.emailHash } forceDefault={ player.settings ? player.settings.disableGravatar : false } />
                            </span>
                        </span>);
                }

                return playerElement;
            });

            let gameTitle = '';

            if(game.needsPassword) {
                gameTitle += '[Private] ';
            }

            if(game.gameType) {
                gameTitle += '[' + game.gameType + '] ';
            }

            gameTitle += game.name;

            return (
                <div key={ game.id } className={ 'game-row' + (game.node && this.props.isAdmin ? ' ' + game.node : '') }>
                    <span className='col-xs-12 game-title'>
                        { this.props.isAdmin ? <a href='#' className='glyphicon glyphicon-remove' onClick={ event => this.removeGame(event, game) } /> : null }
                        <b>{ gameTitle }</b> { game.clocks.type !== 'none' ? <img src='/img/free-clock-icon-png.png' className='clock-icon' /> : null }<commit_msg>Update develop with on server changes<commit_after>import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { toastr } from 'react-redux-toastr';
import _ from 'underscore';

import Avatar from './Avatar.jsx';
import * as actions from './actions';

class InnerGameList extends React.Component {
    constructor() {
        super();

        this.joinGame = this.joinGame.bind(this);
    }

    joinGame(event, game) {
        event.preventDefault();

        if(!this.props.username) {
            toastr.error('Please login before trying to join a game');
            return;
        }

        if(game.needsPassword) {
            this.props.joinPasswordGame(game, 'Join');
        } else {
            this.props.socket.emit('joingame', game.id);
        }
    }

    canWatch(game) {
        return !this.props.currentGame && game.allowSpectators;
    }

    watchGame(event, game) {
        event.preventDefault();

        if(!this.props.username) {
            toastr.error('Please login before trying to watch a game');
            return;
        }

        if(game.needsPassword) {
            this.props.joinPasswordGame(game, 'Watch');
        } else {
            this.props.socket.emit('watchgame', game.id);
        }
    }

    removeGame(event, game) {
        event.preventDefault();

        this.props.socket.emit('removegame', game.id);
    }

    render() {
        let gameList = _.map(this.props.games, game => {
            let firstPlayer = true;
            let gameRow = [];

            _.each(game.players, player => {
                let playerElement = null;

                if(firstPlayer) {
                    gameRow.push(
                        <span className='col-xs-4 col-sm-3 game-row-avatar'>
                            <span className='hidden-xs col-sm-3 game-row-avatar'>
                                <Avatar emailHash={ player.emailHash } forceDefault={ player.settings ? player.settings.disableGravatar : false } />
                            </span>
                            <span className='player-name col-sm-8'>{ player.name }</span>
                        </span>);
                    gameRow.push();
                    gameRow.push(<span className={ 'hidden-xs col-xs-1 game-icon icon-clan-' + player.faction } />);

                    firstPlayer = false;
                } else {
                    gameRow.push(<span className='col-xs-1 game-row-vs text-center'><b> vs </b></span>);
                    gameRow.push(<span className={ 'hidden-xs col-xs-1 game-icon icon-clan-' + player.faction } />);
                    gameRow.push(
                        <span className='col-xs-4 col-sm-3 game-row-avatar'>
                            <span className='player-name col-sm-8'>{ player.name }</span>
                            <span className='hidden-xs game-row-avatar pull-right col-sm-3'>
                                <Avatar emailHash={ player.emailHash } forceDefault={ player.settings ? player.settings.disableGravatar : false } />
                            </span>
                        </span>);
                }

                return playerElement;
            });

            let gameTitle = '';

            if(game.needsPassword) {
                gameTitle += '[Private] ';
            }

            if(game.gameType) {
                gameTitle += '[' + game.gameType + '] ';
            }

            gameTitle += game.name;

            return (
                <div key={ game.id } className={ 'game-row' + (game.node && this.props.isAdmin ? ' ' + game.node : '') }>
                    <span className='col-xs-12 game-title'>
                        { this.props.isAdmin ? <a href='#' className='glyphicon glyphicon-remove' onClick={ event => this.removeGame(event, game) } /> : null }
                        <b>{ gameTitle }</b> { game.clocks && game.clocks.type !== 'none' ? <img src='/img/free-clock-icon-png.png' className='clock-icon' /> : null }
{'fraction_non_alphanumeric': 0.13579937304075235, 'fraction_numerical': 0.0032601880877742946, 'mean_word_length': 1.534477279949158, 'pattern_counts': {'":': 0, '<': 55, '<?xml version=': 0, '>': 61, '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': '6495969', 'n_tokens_mistral': 2247, 'n_tokens_neox': 2136, 'n_words': 432}