/*** @jsx React.DOM */
var valid_versions = Object.keys(window.versions);
var pagenav = new History(valid_versions);
var jubility_view = createReactClass({
getInitialState: function(props) {
var profiles = Object.keys(window.player);
return {
player: window.player,
songs: window.songs,
profiles: profiles,
version: pagenav.getInitialState(profiles[profiles.length - 1]),
};
},
componentDidMount: function() {
pagenav.onChange(function(version) {
this.setState({version: version});
}.bind(this));
this.refreshProfile();
},
refreshProfile: function() {
AJAX.get(
Link.get('refresh'),
function(response) {
var profiles = Object.keys(response.player);
this.setState({
player: response.player,
profiles: profiles,
});
setTimeout(this.refreshProfile, 5000);
}.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';
}
},
renderJubilityBreakdown: function(player) {
if (this.state.version == 13) // festo
return (
{this.renderFestoJubilityTable(player, true)}
{this.renderFestoJubilityTable(player, false)}
);
if (this.state.version == 12) // clan
return (
{this.renderClanJubilityTable(player)}
);
return null;
},
renderClanJubilityTable: function(player) {
if (typeof player.chart === 'undefined' || player.chart.length == 0) {
return null;
}
return(
Chart breakdown
Individual song jubility gets averaged to calculate player total jubility.
{ this.state.songs[entry.songid].name }
);
}.bind(this),
},
{
name: 'Hard Mode',
render: function(entry) { return entry.hard_mode ? 'Yes' : 'No'; }
},
{
name: 'Jubility',
render: function(entry) { return (entry.value / 100.0).toFixed(2); },
sort: function(a, b) {
return a.value - b.value;
},
reverse: true,
},
]}
defaultsort='Jubility'
rows={player.chart}
/>
);
},
renderFestoJubilityTable: function(player, pickup) {
if (pickup == true)
jubilityChart = player.pick_up_chart;
else
jubilityChart = player.common_chart;
if (typeof jubilityChart === 'undefined' || jubilityChart.length == 0) {
return null;
}
return(
{pickup == true ? Pick up chart breakdown : Common chart breakdown }
Individual song jubility gets added to calculate total jubility.
{ this.state.songs[entry.music_id].name }
);
}.bind(this),
},
{
name: 'Hard Mode',
render: function(entry) { return entry.seq >= 3 ? 'Yes' : 'No'; }
},
{
name: 'Music Rate',
render: function(entry) { return entry.music_rate.toFixed(1) + '%'; },
sort: function(a, b) {
return a.music_rate - b.music_rate;
},
reverse: true,
},
{
name: 'Jubility',
render: function(entry) { return entry.value.toFixed(1); },
sort: function(a, b) {
return a.value - b.value;
},
reverse: true,
},
]}
defaultsort='Jubility'
rows={jubilityChart}
/>
);
},
renderJubility: function(player) {
return(
// version == prop ( No Jubility )
this.state.version == 10 ?
This version of jubeat doesn't support Jubility
:
// version == qubell ( No Jubility )
this.state.version == 11 ?
This version of jubeat doesn't support Jubility
:
// version == festo
this.state.version == 13 ?
{(player.common_jubility+player.pick_up_jubility).toFixed(1)}
{player.common_jubility.toFixed(1)}
{player.pick_up_jubility.toFixed(1)}
:
// Default which version >= Saucer except qubell and festo
this.state.version >= 8 ?
{player.jubility / 100}
:
This version of jubeat doesn't support Jubility
)
},
render: function() {
if (this.state.player[this.state.version]) {
var player = this.state.player[this.state.version];
var item = Object.keys(window.versions).map(function(k){
return window.versions[k]
})
return (
{player.name}'s jubility
{this.state.profiles.map(function(version) {
if (version < 12) {
// No breakdown here, no point in displaying.
return null;
}
return (
);
}.bind(this))}
{this.renderJubility(player)}
{this.renderJubilityBreakdown(player)}
);
} else {
var item = Object.keys(window.versions).map(function(k){
return window.versions[k]
})
return (
This player has no profile for {window.versions[this.state.version]}!
);
}
},
});
ReactDOM.render(
React.createElement(jubility_view, null),
document.getElementById('content')
);