/*** @jsx React.DOM */
var valid_versions = Object.keys(window.versions);
var pagenav = new History(valid_versions);
var menu_option_names = {
'alphabet': 'alphabet folders',
'difficulty': 'difficulty folders',
'disable_song_preview': 'disable song previews',
'effector_lock': 'lock effector',
'grade': 'grade folders',
'hide_play_count': 'hide play count on profile',
'rival_info': 'rival info box',
'rival_played': 'rival played folders',
'rival_win_lose': 'rival win/lose folders',
'status': 'status folders',
};
var valid_menu_options = [
'grade',
'status',
'difficulty',
'alphabet',
'rival_played',
'rival_win_lose',
'rival_info',
'hide_play_count',
'disable_song_preview',
'effector_lock',
];
var theme_option_names = {
'beam': 'Note Beam',
'bgm': 'Menu BGM',
'burst': 'Note Burst',
'frame': 'Frame',
'full_combo': 'Full Combo Effect',
'judge': 'Judge Font',
'noteskin': 'Note Skin',
'towel': 'Lane Cover',
'turntable': 'Turntable Decal',
'voice': 'Menu Announcer Voice',
'pacemaker': 'Pacemaker Skin',
'effector_preset': 'Effector Preset',
};
var settings_view = React.createClass({
getInitialState: function(props) {
var profiles = Object.keys(window.player);
var version = pagenav.getInitialState(profiles[profiles.length - 1]);
return {
player: window.player,
profiles: profiles,
version: version,
menu_changed: {},
theme_changed: {},
menu_saving: {},
theme_saving: {},
menu_saved: {},
theme_saved: {},
new_name: window.player[version].name,
editing_name: false,
new_prefecture: window.player[version].prefecture,
editing_prefecture: false,
};
},
componentDidMount: function() {
pagenav.onChange(function(version) {
this.setState({version: version});
}.bind(this));
},
setMenuChanged: function(val) {
this.state.menu_changed[this.state.version] = val;
return this.state.menu_changed;
},
setMenuSaving: function(val) {
this.state.menu_saving[this.state.version] = val;
return this.state.menu_saving;
},
setMenuSaved: function(val) {
this.state.menu_saved[this.state.version] = val;
return this.state.menu_saved;
},
setThemeChanged: function(val) {
this.state.theme_changed[this.state.version] = val;
return this.state.theme_changed;
},
setThemeSaving: function(val) {
this.state.theme_saving[this.state.version] = val;
return this.state.theme_saving;
},
setThemeSaved: function(val) {
this.state.theme_saved[this.state.version] = val;
return this.state.theme_saved;
},
saveMenuOptions: function(event) {
this.setState({menu_saving: this.setMenuSaving(true), menu_saved: this.setMenuSaved(false)});
AJAX.post(
Link.get('updateflags'),
{
version: this.state.version,
flags: this.state.player[this.state.version].flags,
},
function(response) {
var player = this.state.player;
player[response.version].flags = response.flags;
this.setState({
player: player,
menu_saving: this.setMenuSaving(false),
menu_saved: this.setMenuSaved(true),
menu_changed: this.setMenuChanged(false),
});
}.bind(this)
);
event.preventDefault();
},
saveThemeOptions: function(event) {
this.setState({theme_saving: this.setThemeSaving(true), theme_saved: this.setThemeSaved(false)});
AJAX.post(
Link.get('updatesettings'),
{
version: this.state.version,
settings: this.state.player[this.state.version].settings,
},
function(response) {
var player = this.state.player;
player[response.version].settings = response.settings;
this.setState({
player: player,
theme_saving: this.setThemeSaving(false),
theme_saved: this.setThemeSaved(true),
theme_changed: this.setThemeChanged(false),
});
}.bind(this)
);
event.preventDefault();
},
saveDJName: function(event) {
AJAX.post(
Link.get('updatename'),
{
version: this.state.version,
name: this.state.new_name,
},
function(response) {
var player = this.state.player;
player[response.version].name = response.name;
this.setState({
player: player,
new_name: this.state.player[response.version].name,
editing_name: false,
});
}.bind(this)
);
event.preventDefault();
},
savePrefecture: function(event) {
AJAX.post(
Link.get('updateprefecture'),
{
version: this.state.version,
prefecture: this.state.new_prefecture,
},
function(response) {
var player = this.state.player;
player[response.version].prefecture = response.prefecture;
this.setState({
player: player,
new_prefecture: this.state.player[response.version].prefecture,
editing_prefecture: false,
});
}.bind(this)
);
event.preventDefault();
},
leaveArcade: function(event) {
AJAX.post(
Link.get('leavearcade'),
{
version: this.state.version,
},
function(response) {
var player = this.state.player;
player[response.version].arcade = "";
this.setState({
player: player,
});
}.bind(this)
);
event.preventDefault();
},
renderDJName: function(player) {
return (