/*** @jsx React.DOM */ var network_scores = createReactClass({ getInitialState: function(props) { return { songs: window.songs, attempts: window.attempts, players: window.players, 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 'Novice'; case 1: return 'Advanced'; case 2: return 'Exhaust'; case 3: return 'Infinite'; case 4: return 'Maximum'; default: return 'u broke it'; } }, renderScore: function(score) { has_stats = ( score.stats.critical > 0 || score.stats.near > 0 || score.stats.error > 0 ); return (
{score.grade} Score {score.points} {score.combo >= 0 ? <> Combo {score.combo} : null}
{has_stats ?
{score.stats.critical} / {score.stats.near} / {score.stats.error}
: null}
{score.clear_type}
); }, 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 }
{ this.state.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') );