/*** @jsx React.DOM */ var card_management = React.createClass({ getInitialState: function(props) { return { new_arcade: { name: '', description: '', paseli_enabled: window.paseli_enabled, paseli_infinite: window.paseli_infinite, mask_services_url: window.mask_services_url, owners: [null], }, arcades: window.arcades, usernames: window.usernames, editing_arcade: null, }; }, componentDidUpdate: function() { if (this.focus_element && this.focus_element != this.already_focused) { this.focus_element.focus(); this.already_focused = this.focus_element; } }, addNewArcade: function(event) { AJAX.post( Link.get('addarcade'), {arcade: this.state.new_arcade}, function(response) { this.setState({ arcades: response.arcades, new_arcade: { name: '', description: '', paseli_enabled: window.paseli_enabled, paseli_infinite: window.paseli_infinite, mask_services_url: window.mask_services_url, owners: [null], }, }); }.bind(this) ); event.preventDefault(); }, saveArcade: function(event) { AJAX.post( Link.get('updatearcade'), {arcade: this.state.editing_arcade}, function(response) { this.setState({ arcades: response.arcades, editing_arcade: null, }); }.bind(this) ); event.preventDefault(); }, deleteExistingArcade: function(event, arcadeid) { $.confirm({ escapeKey: 'Cancel', animation: 'none', closeAnimation: 'none', title: 'Delete Arcade', content: 'Are you sure you want to delete this arcade from the network?', buttons: { Delete: { btnClass: 'delete', action: function() { AJAX.post( Link.get('removearcade'), {arcadeid: arcadeid}, function(response) { this.setState({ arcades: response.arcades, }); }.bind(this) ); }.bind(this), }, Cancel: function() { }, } }); event.preventDefault(); }, renderEditButton: function(arcade) { if(this.state.editing_arcade) { if (this.state.editing_arcade.id == arcade.id) { return ( ); } else { return ; } } else { return ( ); } }, renderName: function(arcade) { if (this.state.editing_arcade && arcade.id == this.state.editing_arcade.id) { return (this.focus_element = c)} value={ this.state.editing_arcade.name } onChange={function(event) { var arcade = this.state.editing_arcade; arcade.name = event.target.value; this.setState({ editing_arcade: arcade, }); }.bind(this)} />; } else { return { arcade.name }; } }, sortName: function(a, b) { return a.name.localeCompare(b.name); }, renderDescription: function(arcade) { if (this.state.editing_arcade && arcade.id == this.state.editing_arcade.id) { return ; } else { return { arcade.description }; } }, sortDescription: function(a, b) { return a.description.localeCompare(b.description); }, renderOwners: function(arcade) { if (this.state.editing_arcade && arcade.id == this.state.editing_arcade.id) { return this.state.editing_arcade.owners.map(function(owner, index) { return (
1) { arcade.owners.splice(index, 1); } else { arcade.owners[index] = null; } } this.setState({ editing_arcade: arcade, }); }.bind(this)} />
); }.bind(this)) } else { return ( (arcade.owners.length > 0) ? : nobody ); } }, renderPaseliEnabled: function(arcade) { if (this.state.editing_arcade && arcade.id == this.state.editing_arcade.id) { return ; } else { return { arcade.paseli_enabled ? "yes" : "no" }; } }, renderPaseliInfinite: function(arcade) { if (this.state.editing_arcade && arcade.id == this.state.editing_arcade.id) { return ; } else { return { arcade.paseli_infinite ? "yes" : "no" }; } }, renderMaskServicesURL: function(arcade) { if (this.state.editing_arcade && arcade.id == this.state.editing_arcade.id) { return ; } else { return { arcade.mask_services_url ? "yes" : "no" }; } }, render: function() { return (

Add Arcade

Name Description Owners PASELI Enabled PASELI Infinite Mask Web Address
{ this.state.new_arcade.owners.map(function(owner, index) { return (
1) { arcade.owners.splice(index, 1); } else { arcade.owners[index] = null; } } this.setState({ new_arcade: arcade, }); }.bind(this)} />
); }.bind(this)) }
); }, }); ReactDOM.render( React.createElement(card_management, null), document.getElementById('content') );