/*** @jsx React.DOM */ var network_scores = React.createClass({ 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 'Green (\u7FE0)'; case 1: return 'Orange (\u6A59)'; case 2: return 'Red (\u6731)'; default: return 'u broke it'; } }, convertChartLink: function(chart) { switch(chart) { case 0: return 'green'; case 1: return 'orange'; case 2: return 'red'; default: return 'nothing'; } }, renderScore: function(score) { return (
Score {score.points} {score.grade}
Combo {score.combo < 0 ? '-' : score.combo}
{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 Chart 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') );