<commit_before>define([
        "app",
        "jquery",
        "react",
        "lib/minpubsub",
], function(app, $, react, pubsub) {
    var LoginForm = react.createFactory(react.createClass({
                getInitialState: function() {
                    return {name: ""};
                },

                handleSubmit: function(event) {
                    // Avoid default http post
                    event.preventDefault();

                    var name = this.refs.name.getDOMNode().value;
                    var password = this.refs.password.getDOMNode().value;

                    this.refs.name.getDOMNode().value = "";
                    this.refs.password.getDOMNode().value = "";

                    this.props.conn.attemptLogin(name, password);
                },

                handleNameChange: function(event) {
                    this.setState({name: event.target.value});
                },

                render: function() {
                    var disabled = this.props.disabled;

                    var name = this.state.name;

                    var nameId = "name";
                    var passwordId = "password";

                    var loginForm = react.DOM.form({
                            onSubmit: this.handleSubmit,
                            id: "login",
                    },

                    react.DOM.div({},
                        react.DOM.label({
                                htmlFor: nameId,
                        }, "Actor Name"),

                        react.DOM.input({
                                id:  nameId,
                                ref: "name",

                                type:     "text",
                                required: true,
                                value:    name,
                                onChange: this.handleNameChange,
                                disabled: disabled
                        })
                    ),

                    react.DOM.div({},
                        react.DOM.label({
                                htmlFor: passwordId,
                        }, "Password"),

                        react.DOM.input({
                                id:  passwordId,
                                ref: "password",

                                type: "password",
                                required: true,
                                disabled: disabled
                        })
                    ),

                    react.DOM.div({},
                        react.DOM.input({
                                type: "submit",
                                value: "login",
                                disabled: disabled
                        })
                    ));

                    return loginForm;
                }
    }));

    var CreateActorForm = react.createFactory(react.createClass({
                getInitialState: function() {
                    return {password:""};
                },

                handleSubmit: function(event) {
                    // Avoid default http post
                    event.preventDefault();

                    var name = this.props.actor.name;
                    var password = this.props.actor.password;

                    this.props.conn.createActor(name, password);
                },

                handlePasswordChange: function(event) {
                    this.setState({password: event.target.value});
                },

                render: function() {
                    var passwordId = "password";

                    var password = <PASSWORD>;

                    var disabled = true;
                    var color = "red";

                    if (password === this.props.actor.password) {
                        disabled = false;
                        color = "green";
                    }

                    var createActorForm = react.DOM.form({
                            onSubmit: this.handleSubmit,
                            id: "createActor"
                    },
                        react.DOM.div({},
                            react.DOM.span({},
                                "Creating: " + this.props.actor.name
                            )
                        ),

                        react.DOM.div({},
                            react.DOM.label({<commit_msg>[game/ui/login] set focuses for the login and create forms<commit_after>define([
        "app",
        "jquery",
        "react",
        "lib/minpubsub",
], function(app, $, react, pubsub) {
    var LoginForm = react.createFactory(react.createClass({
                getInitialState: function() {
                    return {name: ""};
                },

                handleSubmit: function(event) {
                    // Avoid default http post
                    event.preventDefault();

                    var name = this.refs.name.getDOMNode().value;
                    var password = this.refs.password.getDOMNode().value;

                    this.refs.name.getDOMNode().value = "";
                    this.refs.password.getDOMNode().value = "";

                    this.props.conn.attemptLogin(name, password);
                },

                handleNameChange: function(event) {
                    this.setState({name: event.target.value});
                },

                componentDidMount: function() {
                    if (this.state.name === "") {
                        $(this.refs.name.getDOMNode()).focus();
                    } else {
                        $(this.refs.password.getDOMNode()).focus();
                    }

                },

                render: function() {
                    var disabled = this.props.disabled;

                    var name = this.state.name;

                    var nameId = "name";
                    var passwordId = "password";

                    var loginForm = react.DOM.form({
                            onSubmit: this.handleSubmit,
                            id: "login",
                    },

                    react.DOM.div({},
                        react.DOM.label({
                                htmlFor: nameId,
                        }, "Actor Name"),

                        react.DOM.input({
                                id:  nameId,
                                ref: "name",

                                type:     "text",
                                required: true,
                                value:    name,
                                onChange: this.handleNameChange,
                                disabled: disabled
                        })
                    ),

                    react.DOM.div({},
                        react.DOM.label({
                                htmlFor: passwordId,
                        }, "Password"),

                        react.DOM.input({
                                id:  passwordId,
                                ref: "password",

                                type: "password",
                                required: true,
                                disabled: disabled
                        })
                    ),

                    react.DOM.div({},
                        react.DOM.input({
                                type: "submit",
                                value: "login",
                                disabled: disabled
                        })
                    ));

                    return loginForm;
                }
    }));

    var CreateActorForm = react.createFactory(react.createClass({
                getInitialState: function() {
                    return {password:""};
                },

                handleSubmit: function(event) {
                    // Avoid default http post
                    event.preventDefault();

                    var name = this.props.actor.name;
                    var password = this.props.actor.password;

                    this.props.conn.createActor(name, password);
                },

                handlePasswordChange: function(event) {
                    this.setState({password: event.target.value});
                },

                componentDidMount: function() {
                    $(this.refs.password.getDOMNode()).focus();
                },

                render: function() {
                    var passwordId = "password";

                    var password = <PASSWORD>;

                    var disabled = true;
                    var color = "red";

                    if (password === this.props.actor.password) {
                        disabled = false;
                        color = "green";
                    }

                    var createActorForm = react.DOM.form({
                            onSubmit: this.handleSubmit,
                            id: "createActor"
                    },
                        react.DOM.div({},
                            react.DOM.span({},
                                "Creating: " + this.props.actor.name
                            )
                        ),

                        react.DOM.div({},
                            react.DOM.label({
{'fraction_non_alphanumeric': 0.09464305117896338, 'fraction_numerical': 0.0, 'mean_word_length': 0.7544796035074343, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2085769', 'n_tokens_mistral': 2040, 'n_tokens_neox': 1794, 'n_words': 345}