/*** @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 'SPN'; case 1: return 'SPH'; case 2: return 'SPA'; case 3: return 'DPN'; case 4: return 'DPH'; case 5: return 'DPA'; case 6: return 'BEGINNER'; default: return 'u broke it'; } }, renderScore: function(score) { var topscore = window.songs[score.songid].notecounts[score.chart] * 2; var percent = score.points / topscore; var grade = parseInt(9.0 * percent); var grades = [ "F", "F", "E", "D", "C", "B", "A", "AA", "AAA", "MAX", ]; return (
{topscore > 0 ?
{grades[grade]} {(percent * 100).toFixed(2)}%
: null }
EX {score.points} M {score.miss_count < 0 ? '-' : score.miss_count}
{score.status}
); }, render: function() { return (
{ window.showdjnames ? : null } { window.showdjnames ? : null } {this.state.attempts.map(function(attempt, index) { if (index < this.state.offset || index >= this.state.offset + this.state.limit) { return null; } return ( { window.showdjnames ? : null } { window.showdjnames ? : null } ); }.bind(this))}
DJ NameArcadeTimestamp Song / Artist Difficulty Score
{ this.state.players[attempt.userid].name }{ this.state.players[attempt.userid].arcade }
{ 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].genre }
{attempt.chart == 6 ? this.convertChart(attempt.chart) : { this.convertChart(attempt.chart) } }
{attempt.chart == 6 ? null : {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') );