/*** @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 'Basic'; case 1: return 'Advanced'; case 2: return 'Extreme'; case 3: return 'Hard Mode Basic'; case 4: return 'Hard Mode Advanced'; case 5: return 'Hard Mode Extreme'; default: return 'u broke it'; } }, renderScore: function(score) { has_stats = ( score.stats.perfect > 0 || score.stats.great > 0 || score.stats.good > 0 || score.stats.poor > 0 || score.stats.miss > 0 ); return (
Score {score.points} Combo {score.combo < 0 ? '-' : score.combo} {score.music_rate >= 0 ? <> Music Rate {score.music_rate <= 0 ? '-' : score.music_rate}% : null}
{has_stats ?
{score.stats.perfect} / {score.stats.great} / {score.stats.good} / {score.stats.poor} / {score.stats.miss}
: null}
{score.status}
); }, 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; } var diff = window.songs[attempt.songid].difficulties[attempt.chart]; var new_rating = ( window.songs[attempt.songid].difficulties[3] > 0 || window.songs[attempt.songid].difficulties[4] > 0 || window.songs[attempt.songid].difficulties[5] > 0 ); 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 }
{diff >= 9 && new_rating ? diff.toFixed(1) : diff.toFixed(0)}★
{ 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') );