/*** @jsx React.DOM */ var account_management = React.createClass({ getInitialState: function(props) { return { email: window.email, new_email: window.email, email_password: '', editing_email: false, username: window.username, editing_pin: false, new_pin: '', editing_password: false, old_password: '', new_password1: '', new_password2: '', }; }, saveEmail: function(event) { AJAX.post( Link.get('updateemail'), { email: this.state.new_email, password: this.state.email_password, }, function(response) { this.setState({ email: response.email, new_email: response.email, email_password: '', editing_email: false, }); }.bind(this) ); event.preventDefault(); }, savePin: function(event) { AJAX.post( Link.get('updatepin'), {pin: this.state.new_pin}, function(response) { this.setState({ new_pin: '', editing_pin: false, }); }.bind(this) ); event.preventDefault(); }, savePassword: function(event) { AJAX.post( Link.get('updatepassword'), { old: this.state.old_password, new1: this.state.new_password1, new2: this.state.new_password2, }, function(response) { this.setState({ old_password: '', new_password1: '', new_password2: '', editing_password: false, }); }.bind(this) ); event.preventDefault(); }, renderUsername: function() { return ( { this.state.username } ); }, renderPassword: function() { return ( { !this.state.editing_password ? •••••• :
}
); }, renderEmail: function() { return ( { !this.state.editing_email ? { this.state.email } :
}
); }, renderPIN: function() { return ( { !this.state.editing_pin ? •••• :
}
); }, render: function() { return (
{this.renderUsername()} {this.renderPassword()} {this.renderEmail()} {this.renderPIN()}
); }, }); ReactDOM.render( React.createElement(account_management, null), document.getElementById('content') );