var ReactBootstrap = require('react-bootstrap') , Button = ReactBootstrap.Button , ButtonGroup = ReactBootstrap.ButtonGroup , Glyphicon = ReactBootstrap.Glyphicon , Modal = ReactBootstrap.Modal , Input = ReactBootstrap.Input var React = require('react'); var SafeStateChangeMixin = require('../common/SafeStateChangeMixin.js'); var SetIntervalMixin = require("../common/SetIntervalMixin.js"); module.exports = GenerateAccountModalButton = React.createClass({ mixins: [SafeStateChangeMixin], getInitialState: function () { return { isModalOpen: false, username: "", checkedUsername: "", available: false, }; }, handleUsernameChange: function(e) { this.setState({username: e.target.value}); var thisComponent = this; if(e.target.value.length){ Twister.checkUsernameAvailable(e.target.value,function(result){ thisComponent.setStateSafe({ checkedUsername: e.target.value, available: result }); }) } }, handleToggle: function () { this.setState({ isModalOpen: !this.state.isModalOpen }); }, handleGenerateAccount: function (e) { e.preventDefault(); var newusername = this.state.username; Twister.generateClientSideAccount(newusername,function(newaccount){ console.log(newaccount._name); var event = new CustomEvent('newaccountbyuser',{detail: newaccount}); //alert("scrolled to bottom") window.dispatchEvent(event); }) this.handleToggle(); return; }, render: function() { var showAvailable = ( ); if(this.state.username.length==0){ showAvailable = (
try a username
); }else{ if((this.state.username==this.state.checkedUsername)){ if(this.state.available){ showAvailable = ({this.state.username + " is available"}
) }else{ showAvailable = ({this.state.username + " is allready taken"}
) } }else{ showAvailable = (checking ...
); } } return ( ); } });