<commit_before>/*eslint-env browser */
/*global require: false */
'use strict';

var React = require('react');
require('bootstrap/dist/css/bootstrap.css');
var Rx = require('rx');
var vcf = require('vcf.js');
require('rx.binding');
require('rx-dom');
require('css/custom.css');
var _ = require('underscore');
var brcaLogo = require('./img/brca_logo.png');
var ga4ghLogo = require('./img/ga4gh-logo-less.png');
var brcaLogoWithText = require('./img/BRCA-logo-with-text.png');
var hvpLogo = require('./img/hvp_logo.png');
var UNESCOLogo = require('./img/UNESCO-logo.jpg');
var ENIGMALogo = require('./img/enigma_logo.png');
var CIMBALogo = require('./img/cimba_logo.png');

var Markdown = require('react-remarkable');
var content = {
	home: require('../content/home.md'),
	'history': require('../content/history.md'),
	'brca1_2': require('../content/brca1_2.md'),
	'variation': require('../content/variationAndCancer.md')
};


var databaseUrl = require('file!../../enigma-database.tsv');

var {Well, Grid, Col, Row, Input, Button, Navbar, CollapsableNav, Nav, Table,
	NavItem, DropdownButton, MenuItem, Panel} = require('react-bootstrap');


var VariantTable = require('./VariantTable');
var {Navigation, State, Link, Route, RouteHandler,
	HistoryLocation, run, DefaultRoute} = require('react-router');

var merge = (...objs) => _.extend({}, ...objs);

function mergeInfo(row) {
	var info = _.object(_.map(_.pairs(row.INFO), ([k, v]) => ['INFO$' + k, v]));
	return merge(info, _.omit(row, ['INFO']));
}

// add unique id to variant table
function addId(data) {
	return _.map(data, (r, i) => merge({id: i}, r));
}

function cutTrailingNewLine(string) {
    if (string[string.length-1] === "\n") {
        return string.slice(0,string.length-1);
    }
    return string;
}

function readTsv(response) {
	var [header, ...records] = cutTrailingNewLine(response).split("\n");
	var keys = header.split("\t");
    var rows = _.map(records, row => row.split("\t"));
    return {
        records: addId(_.map(rows, row => _.object(keys, row)))
	};
}


var NavLink = React.createClass({
	render: function () {
		var {children, ...otherProps} = this.props;
		return (
			<li>
				<Link {...otherProps} role='button'>
					{children}
				</Link>
			</li>
		);
	}
});

var NavBarNew = React.createClass({
	close: function () {
		this.refs.about.setState({open: false});
	},
	render: function () {
		return (
			<Navbar>
				<a className="navbar-brand" href="http://brcaexchange.org">
					<img style={{marginBottom: 10, height: 28, width: 28, display: 'inline-block'}} src={brcaLogo} alt="brca logo"/>
					<span style={{margin: 10, fontSize: 30, color: "#FF3399"}}>
                    BRCA Exchange
                    </span>
				</a>
				<CollapsableNav>
					<Nav navbar>
						<NavLink to='/'>Home</NavLink>
						<DropdownButton ref='about' title='About'>
							<NavLink onClick={this.close} to='/about/history'>
								History of the BRCA Exchange
							</NavLink>
							<NavLink onClick={this.close} to='/about/brca1_2'>
								What are BRCA1 and BRCA2?
							</NavLink>
							<NavLink onClick={this.close} to='/about/variation'>
								BRCA Variation and Cancer
							</NavLink>
						</DropdownButton>
						<NavLink to='/variants'>Variants</NavLink>
					</Nav>
					<Nav navbar right>
						<NavItem href='#'><input placeholder="Search Variant"></input>
							<Button className='btn-xs' style={{border: 0}}>
								<span className="glyphicon glyphicon-search"></span>
							</Button>
						</NavItem>
					</Nav>
				</CollapsableNav>
			</Navbar>
        );
    }
});

var Home = React.createClass({
	getInitialState() {
		return {
			index: 0,
			direction: null
		};
	},

	handleSelect(selectedIndex, selectedDirection) {
		this.setState({<commit_msg>add navbar mobile collapsing<commit_after>/*eslint-env browser */
/*global require: false */
'use strict';

var React = require('react');
require('bootstrap/dist/css/bootstrap.css');
var Rx = require('rx');
var vcf = require('vcf.js');
require('rx.binding');
require('rx-dom');
require('css/custom.css');
var _ = require('underscore');
var brcaLogo = require('./img/brca_logo.png');
var ga4ghLogo = require('./img/ga4gh-logo-less.png');
var brcaLogoWithText = require('./img/BRCA-logo-with-text.png');
var hvpLogo = require('./img/hvp_logo.png');
var UNESCOLogo = require('./img/UNESCO-logo.jpg');
var ENIGMALogo = require('./img/enigma_logo.png');
var CIMBALogo = require('./img/cimba_logo.png');

var Markdown = require('react-remarkable');
var content = {
	home: require('../content/home.md'),
	'history': require('../content/history.md'),
	'brca1_2': require('../content/brca1_2.md'),
	'variation': require('../content/variationAndCancer.md')
};


var databaseUrl = require('file!../../enigma-database.tsv');

var {Well, Grid, Col, Row, Input, Button, Navbar, CollapsableNav, Nav, Table,
	NavItem, DropdownButton, MenuItem, Panel} = require('react-bootstrap');


var VariantTable = require('./VariantTable');
var {Navigation, State, Link, Route, RouteHandler,
	HistoryLocation, run, DefaultRoute} = require('react-router');

var merge = (...objs) => _.extend({}, ...objs);

function mergeInfo(row) {
	var info = _.object(_.map(_.pairs(row.INFO), ([k, v]) => ['INFO$' + k, v]));
	return merge(info, _.omit(row, ['INFO']));
}

// add unique id to variant table
function addId(data) {
	return _.map(data, (r, i) => merge({id: i}, r));
}

function cutTrailingNewLine(string) {
    if (string[string.length-1] === "\n") {
        return string.slice(0,string.length-1);
    }
    return string;
}

function readTsv(response) {
	var [header, ...records] = cutTrailingNewLine(response).split("\n");
	var keys = header.split("\t");
    var rows = _.map(records, row => row.split("\t"));
    return {
        records: addId(_.map(rows, row => _.object(keys, row)))
	};
}


var NavLink = React.createClass({
	render: function () {
		var {children, ...otherProps} = this.props;
		return (
			<li>
				<Link {...otherProps} role='button'>
					{children}
				</Link>
			</li>
		);
	}
});

var NavBarNew = React.createClass({
	close: function () {
		this.refs.about.setState({open: false});
	},
	render: function () {
		return (
			<Navbar toggleNavKey={0}>
				<a className="navbar-brand" href="http://brcaexchange.org">
					<span style={{margin: 10, fontSize: 30, color: "#FF3399"}}>
                    BRCA Exchange
                    </span>
				</a>
				<CollapsableNav eventKey={0}>
					<Nav navbar>
						<NavLink eventKey={1} to='/'>Home</NavLink>
						<DropdownButton eventKey={2} ref='about' title='About'>
							<NavLink onClick={this.close} to='/about/history'>
								History of the BRCA Exchange
							</NavLink>
							<NavLink onClick={this.close} to='/about/brca1_2'>
								What are BRCA1 and BRCA2?
							</NavLink>
							<NavLink onClick={this.close} to='/about/variation'>
								BRCA Variation and Cancer
							</NavLink>
						</DropdownButton>
						<NavLink eventKey={3} to='/variants'>Variants</NavLink>
					</Nav>
					<Nav navbar right>
						<NavItem eventKey={1} href='#'><input placeholder="Search Variant"></input>
							<Button className='btn-xs' style={{border: 0}}>
								<span className="glyphicon glyphicon-search"></span>
							</Button>
						</NavItem>
					</Nav>
				</CollapsableNav>
			</Navbar>
        );
    }
});

var Home = React.createClass({
	getInitialState() {
		return {
			index: 0,
			direction: null
		};
	},

	handleSelect(selectedIndex, selectedDirection) {
		this.setState({
{'fraction_non_alphanumeric': 0.19102171306780338, 'fraction_numerical': 0.007726122285866524, 'mean_word_length': 3.4347312463083286, 'pattern_counts': {'":': 0, '<': 76, '<?xml version=': 0, '>': 86, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4955428', 'n_tokens_mistral': 2922, 'n_tokens_neox': 2524, 'n_words': 544}