/*** @jsx React.DOM */ var network_scores = createReactClass({ getInitialState: function(props) { return { songs: window.songs, attempts: window.attempts, players: window.players, versions: window.versions, loading: true, offset: 0, limit: 10, }; }, componentDidMount: function() { this.refreshScores(); }, refreshScores: function() { AJAX.get( Link.get('refresh'), function(response) { this.setState({ attempts: response.attempts, players: response.players, loading: false, }); // Refresh every 15 seconds setTimeout(this.refreshScores, 15000); }.bind(this) ); }, convertChart: function(chart) { switch(chart) { case 0: return 'SP Beginner'; case 1: return 'SP Basic'; case 2: return 'SP Difficult'; case 3: return 'SP Expert'; case 4: return 'SP Challenge'; case 6: return 'SP Basic'; case 7: return 'SP Difficult'; case 8: return 'SP Expert'; case 9: return 'SP Challenge'; default: return 'u broke it'; } }, renderScore: function(score) { return (
{score.rank} {score.points}
{ score.combo >= 0 ?
Combo {score.combo}
: null }
{score.halo}
); }, render: function() { return (
{ window.shownames ? : null } {this.state.attempts.map(function(attempt, index) { if (index < this.state.offset || index >= this.state.offset + this.state.limit) { return null; } return ( { window.shownames ? : null } ); }.bind(this))}
NameTimestamp Song / Artist Difficulty Score
{ this.state.players[attempt.userid].name }
{ window.shownewrecords && attempt.raised ? new high score! : null }
{ this.state.songs[attempt.songid].name }
{ this.state.songs[attempt.songid].artist }
{window.songs[attempt.songid].difficulties[attempt.chart]}
{ this.renderScore(attempt) }
{ this.state.offset > 0 ? : null } { (this.state.offset + this.state.limit) < this.state.attempts.length ? = this.state.attempts.length) { return } this.setState({offset: page}); }.bind(this)}/> : this.state.loading ? loading more scores... : null }
); }, }); ReactDOM.render( React.createElement(network_scores, null), document.getElementById('content') );