/*** @jsx React.DOM */ var valid_versions = Object.keys(window.versions); var pagenav = new History(valid_versions); var settings_view = React.createClass({ getInitialState: function(props) { var profiles = Object.keys(window.player); var version = pagenav.getInitialState(profiles[profiles.length - 1]); return { player: window.player, profiles: profiles, version: version, new_name: window.player[version].name, editing_name: false, }; }, componentDidMount: function() { pagenav.onChange(function(version) { this.setState({version: version}); }.bind(this)); }, saveName: function(event) { AJAX.post( Link.get('updatename'), { version: this.state.version, name: this.state.new_name, }, function(response) { var player = this.state.player; player[response.version].name = response.name; this.setState({ player: player, new_name: this.state.player[response.version].name, editing_name: false, }); }.bind(this) ); event.preventDefault(); }, renderName: function(player) { return ( { !this.state.editing_name ? {player.name} :
= '0'.charCodeAt(0) && c <= '9'.charCodeAt(0)) { c = 0xFF10 + (c - '0'.charCodeAt(0)); } else if(c >= 'A'.charCodeAt(0) && c <= 'Z'.charCodeAt(0)) { c = 0xFF21 + (c - 'A'.charCodeAt(0)); } else if(c >= 'a'.charCodeAt(0) && c <= 'z'.charCodeAt(0)) { c = 0xFF41 + (c - 'a'.charCodeAt(0)); } else if(c == '@'.charCodeAt(0)) { c = 0xFF20; } else if(c == ','.charCodeAt(0)) { c = 0xFF0C; } else if(c == '.'.charCodeAt(0)) { c = 0xFF0E; } else if(c == '_'.charCodeAt(0)) { c = 0xFF3F; } value = value + String.fromCharCode(c); } var nameRegex = new RegExp( "^[" + "\uFF20-\uFF3A" + // widetext A-Z and @ "\uFF41-\uFF5A" + // widetext a-z "\uFF10-\uFF19" + // widetext 0-9 "\uFF0C\uFF0E\uFF3F" + // widetext ,._ "\u3041-\u308D\u308F\u3092\u3093" + // hiragana "\u30A1-\u30ED\u30EF\u30F2\u30F3\u30FC" + // katakana "]*$" ); if (value.length <= 6 && nameRegex.test(value)) { this.setState({new_name: value}); } }.bind(this)} name="name" />
}
); }, render: function() { if (this.state.player[this.state.version]) { var player = this.state.player[this.state.version]; return (
{this.state.profiles.map(function(version) { return (

User Profile

{this.renderName(player)}
); } else { return (
You have no profile for {window.versions[this.state.version]}!
{this.state.profiles.map(function(version) { return (
); } }, }); ReactDOM.render( React.createElement(settings_view, null), document.getElementById('content') );