'use strict'; const remote = require('electron').remote; const settings = require('../common/settings'); const Grid = ReactBootstrap.Grid; const Row = ReactBootstrap.Row; const Col = ReactBootstrap.Col; const Input = ReactBootstrap.Input; const Button = ReactBootstrap.Button; const ListGroup = ReactBootstrap.ListGroup; const ListGroupItem = ReactBootstrap.ListGroupItem; const Glyphicon = ReactBootstrap.Glyphicon; var SettingsPage = React.createClass({ getInitialState: function() { var config; try { config = settings.readFileSync(this.props.configFile); } catch (e) { config = settings.loadDefault(); } return { teams: config.teams, hideMenuBar: config.hideMenuBar }; }, handleTeamsChange: function(teams) { this.setState({ teams: teams }); }, handleSave: function() { var config = { teams: this.state.teams, hideMenuBar: this.state.hideMenuBar, version: settings.version }; settings.writeFileSync(this.props.configFile, config); if (process.platform === 'win32' || process.platform === 'linux') { var currentWindow = remote.getCurrentWindow(); currentWindow.setAutoHideMenuBar(config.hideMenuBar); currentWindow.setMenuBarVisibility(!config.hideMenuBar); } window.location = './index.html'; }, handleCancel: function() { window.location = './index.html'; }, handleChangeHideMenuBar: function() { this.setState({ hideMenuBar: this.refs.hideMenuBar.getChecked() }); }, render: function() { var teams_row = (

Teams

); var options = []; if (process.platform === 'win32' || process.platform === 'linux') { options.push(); } var options_row = (options.length > 0) ? (

Options

{ options }
) : null; return ( { teams_row } { options_row } { ' ' } ); } }); var TeamList = React.createClass({ handleTeamRemove: function(index) { console.log(index); var teams = this.props.teams; teams.splice(index, 1); this.props.onTeamsChange(teams); }, handleTeamAdd: function(team) { var teams = this.props.teams; teams.push(team); this.props.onTeamsChange(teams); }, render: function() { var thisObj = this; var teamNodes = this.props.teams.map(function(team, i) { var handleTeamRemove = function() { thisObj.handleTeamRemove(i); }; return ( ); }); return ( { teamNodes } ); } }); var TeamListItem = React.createClass({ handleTeamRemove: function() { this.props.onTeamRemove(); }, render: function() { var style = { left: { "display": 'inline-block' } }; return (

{ this.props.name }

{ this.props.url }

); } }); var TeamListItemNew = React.createClass({ getInitialState: function() { return { name: '', url: '' }; }, handleSubmit: function(e) { console.log('submit'); e.preventDefault(); this.props.onTeamAdd({ name: this.state.name, url: this.state.url }); this.setState(this.getInitialState()); }, handleNameChange: function(e) { console.log('name'); this.setState({ name: e.target.value }); }, handleURLChange: function(e) { console.log('url'); this.setState({ url: e.target.value }); }, render: function() { return (
{ ' ' }
{ ' ' }
{ ' ' }
{ ' ' }
); } }); var configFile = remote.getGlobal('config-file'); var contextMenu = require('./menus/context'); var menu = contextMenu.createDefault(); window.addEventListener('contextmenu', function(e) { menu.popup(remote.getCurrentWindow()); }, false); ReactDOM.render( , document.getElementById('content') );