const React = require("react"); const teamspeakDefaults = { url: "ts3server://ensl.org/", password: "ns2gather", alien: { channel: "NS2 Gather/Gather #1/Alien", password: "ns2gather" }, marine: { channel: "NS2 Gather/Gather #1/Marine", password: "ns2gather" } }; const TeamSpeakButton = exports.TeamSpeakButton = React.createClass({ getInitialState() { return { open: false }; }, toggleOpen(e) { e.preventDefault(); this.setState({ open: !this.state.open }); }, getDefaultProps() { return teamspeakDefaults }, marineUrl() { return this.teamSpeakUrl(this.props.marine); }, alienUrl() { return this.teamSpeakUrl(this.props.alien); }, teamSpeakUrl(conn) { let params = `channel=${encodeURIComponent(conn.channel)}& channelpassword=${encodeURIComponent(conn.password)}`; return (`${this.props.url}?${params}`); }, chevron() { if (this.state.open) { return ; } else { return ; } }, render() { const open = this.state.open; let componentClass = ["treeview"]; let dropdown; if (open) { componentClass.push("active"); dropdown = ( ); } return (
  • Teamspeak {this.chevron()} {dropdown}
  • ); } });