diff --git a/index.html b/index.html index 1ead47ca..7f9739b6 100644 --- a/index.html +++ b/index.html @@ -4,6 +4,7 @@ Tinode example: chat web application in react.js + @@ -34,38 +35,8 @@ {hour12: false, year: 'numeric', month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit'}); } - /* BEGIN Login */ - var LoginNavbar = React.createClass({ - render: function() { - return ( - - ); - } - }) - - var LoginForm = React.createClass({ + /* BEGIN Login: a login form */ + var LoginView = React.createClass({ getInitialState: function() { return {login: '', password: ''}; }, @@ -77,7 +48,7 @@ }, handleSubmit: function(e) { e.preventDefault(); - this.props.onLogin(true); + this.props.onLogin(this.state.login, this.state.password); }, render: function() { return ( @@ -96,48 +67,186 @@ onChange={this.handlePasswordChange} required />
- + ); } }) - - var LoginView = React.createClass({ - render: function() { - return ( -
- - -
- ); - } - }) /* END Login */ - /* BEGIN Contact list (list of topics) */ + /* BEGIN Account registration */ + var CreateAccountView = React.createClass({ + getInitialState: function() { + return {login: '', password: '', password2: '', public: '', private: ''}; + }, + handleLoginChange: function(e) { + this.setState({login: e.target.value}); + }, + handlePasswordChange: function(e) { + this.setState({password: e.target.value}); + }, + handlePassword2Change: function(e) { + this.setState({password2: e.target.value}); + }, + handlePublicChange: function(e) { + this.setState({public: e.target.value}); + }, + handlePrivateChange: function(e) { + this.setState({private: e.target.value}); + }, + handleSubmit: function(e) { + e.preventDefault(); + if (this.state.password != this.state.password2) { - /*Contacts caption */ - var CurrentUser = React.createClass({ + } + this.props.onCreateAccount(this.state.login, this.state.password, this.state.public, this.state.private); + }, render: function() { return ( -