<commit_before>import React from 'react';
import ReactDOM from 'react-dom';
import Relay from 'react-relay';
import { Link } from 'react-router';
import {
    FormGroup,
    InputGroup,
    FormControl,
    HelpBlock,
    Button,
    Checkbox,
    Image,
} from 'react-bootstrap';

import Footer from './Footer';
import SearchResults from './SearchResults';
import TraitList from './TraitList';
import Summary from './Summary';

const pageSize = 50;

class Search extends React.Component {
    static propTypes = {
        location: React.PropTypes.object,
        viewer: React.PropTypes.object,
    }

    static contextTypes = {
        relay: Relay.PropTypes.Environment,
        router: React.PropTypes.object.isRequired,
    }

    state = {
        term: this.props.location.query.q,
    }

    componentDidMount() {
        this.props.relay.setVariables({
            term: this.props.location.query.q,
            unique: this.props.location.query.unique === 'true',
            hunt: this.props.location.query.hunt === 'true',
            tromso: this.props.location.query.tromso === 'true',
        });
    }

    componentWillReceiveProps(nextProps) {
        // parsing of booleans from checkboxes has gotten completely
        // impossible, so we handle them in directly in the handler function,
        // by setting both the relay variable and updating the query param.
        const location = this.props.location;
        const newLocation = nextProps.location;
        const q = location.query.q;
        const newQ = newLocation.query.q;
        if (q !== newQ) {
            this.props.relay.setVariables({
                term: newQ || '',
            });
            this.setState({
                term: newQ || '',
            });
        }
    }

    onSearch = (event) => {
        event.preventDefault();
        const value = ReactDOM.findDOMNode(this.refs.query).value;
        this.context.router.push({ query: { q: value } });
    }

    onClear = (event) => {
        event.preventDefault();
        this.context.router.push({ query: { q: '' } });
    }

    onChange = () => {
        this.setState({
            term: ReactDOM.findDOMNode(this.refs.query).value,
        });
    }

    onUniqueChange = () => {
        const unique = !this.props.relay.variables.unique;
        const query = this.props.location.query;
        query.unique = unique;
        this.context.router.push({ query });
        this.props.relay.setVariables({ unique });
    }

    onHuntChange = () => {
        const hunt = !this.props.relay.variables.hunt;
        const query = this.props.location.query;
        query.hunt = hunt;
        this.context.router.push({ query });
        this.props.relay.setVariables({ hunt });
    }

    onTromsoChange = () => {
        const tromso = !this.props.relay.variables.tromso;
        const query = this.props.location.query;
        query.tromso = tromso;
        this.context.router.push({ query });
        this.props.relay.setVariables({ tromso });
    }

    loadMore = () => {
        const results = this.props.viewer.results;
        this.props.relay.setVariables({
            pageSize: results.edges.length + pageSize,
        });
    }

    render() {
        const examples = (
            <p>
                Examples: <Link to="/search/?q=diabetes">diabetes</Link>
                , <Link to="/search/?q=rs3820706">rs3820706</Link>
                , <Link to="/search/?q=Chung S">Chung S</Link>
                , <Link to="/search/?q=2q23.3">2q23.3</Link>
                , <Link to="/search/?q=CACNB4">CACNB4</Link>
            </p>
        );
        const help = (
            <div style={{ display: 'flex' }}>
                <div style={{ flexGrow: '1' }}>
                    {examples}
                </div>
                <div>
                    <Checkbox
                        checked={this.props.relay.variables.unique}
                        inline
                        onChange={this.onUniqueChange}
                    >
                        Unique
                    </Checkbox>
                    <Checkbox
                        checked={this.props.relay.variables.hunt}
                        inline
                        onChange={this.onHuntChange}
                    >
                        Hunt
                    </Checkbox>
                    <Checkbox
                        checked={this.props.relay.variables.tromso}
                        inline
                        onChange={this.onTromsoChange}
                    >
                        Tromsø
                    </Checkbox>
                </div>
            </div>
        );
        return (
            <section>
                <div style={{ maxWidth: 800, margin: '0 auto' }}>
                    <form onSubmit={this.onSearch} onReset={this.onClear}>
                        <div style={{ display: 'flex' }}>
                            <div style={{ margin: '0 10px' }} className="hidden-xs">
                                <Image
                                    responsive
                                    src="/img/logo2_ntnu_u-slagord.jpg"
                                    style={{ marginTop: 28, width: 50 }}
                                /><commit_msg>Make logo non-responsive. It's a logo. It will hide on mobile.<commit_after>import React from 'react';
import ReactDOM from 'react-dom';
import Relay from 'react-relay';
import { Link } from 'react-router';
import {
    FormGroup,
    InputGroup,
    FormControl,
    HelpBlock,
    Button,
    Checkbox,
    Image,
} from 'react-bootstrap';

import Footer from './Footer';
import SearchResults from './SearchResults';
import TraitList from './TraitList';
import Summary from './Summary';

const pageSize = 50;

class Search extends React.Component {
    static propTypes = {
        location: React.PropTypes.object,
        viewer: React.PropTypes.object,
    }

    static contextTypes = {
        relay: Relay.PropTypes.Environment,
        router: React.PropTypes.object.isRequired,
    }

    state = {
        term: this.props.location.query.q,
    }

    componentDidMount() {
        this.props.relay.setVariables({
            term: this.props.location.query.q,
            unique: this.props.location.query.unique === 'true',
            hunt: this.props.location.query.hunt === 'true',
            tromso: this.props.location.query.tromso === 'true',
        });
    }

    componentWillReceiveProps(nextProps) {
        // parsing of booleans from checkboxes has gotten completely
        // impossible, so we handle them in directly in the handler function,
        // by setting both the relay variable and updating the query param.
        const location = this.props.location;
        const newLocation = nextProps.location;
        const q = location.query.q;
        const newQ = newLocation.query.q;
        if (q !== newQ) {
            this.props.relay.setVariables({
                term: newQ || '',
            });
            this.setState({
                term: newQ || '',
            });
        }
    }

    onSearch = (event) => {
        event.preventDefault();
        const value = ReactDOM.findDOMNode(this.refs.query).value;
        this.context.router.push({ query: { q: value } });
    }

    onClear = (event) => {
        event.preventDefault();
        this.context.router.push({ query: { q: '' } });
    }

    onChange = () => {
        this.setState({
            term: ReactDOM.findDOMNode(this.refs.query).value,
        });
    }

    onUniqueChange = () => {
        const unique = !this.props.relay.variables.unique;
        const query = this.props.location.query;
        query.unique = unique;
        this.context.router.push({ query });
        this.props.relay.setVariables({ unique });
    }

    onHuntChange = () => {
        const hunt = !this.props.relay.variables.hunt;
        const query = this.props.location.query;
        query.hunt = hunt;
        this.context.router.push({ query });
        this.props.relay.setVariables({ hunt });
    }

    onTromsoChange = () => {
        const tromso = !this.props.relay.variables.tromso;
        const query = this.props.location.query;
        query.tromso = tromso;
        this.context.router.push({ query });
        this.props.relay.setVariables({ tromso });
    }

    loadMore = () => {
        const results = this.props.viewer.results;
        this.props.relay.setVariables({
            pageSize: results.edges.length + pageSize,
        });
    }

    render() {
        const examples = (
            <p>
                Examples: <Link to="/search/?q=diabetes">diabetes</Link>
                , <Link to="/search/?q=rs3820706">rs3820706</Link>
                , <Link to="/search/?q=Chung S">Chung S</Link>
                , <Link to="/search/?q=2q23.3">2q23.3</Link>
                , <Link to="/search/?q=CACNB4">CACNB4</Link>
            </p>
        );
        const help = (
            <div style={{ display: 'flex' }}>
                <div style={{ flexGrow: '1' }}>
                    {examples}
                </div>
                <div>
                    <Checkbox
                        checked={this.props.relay.variables.unique}
                        inline
                        onChange={this.onUniqueChange}
                    >
                        Unique
                    </Checkbox>
                    <Checkbox
                        checked={this.props.relay.variables.hunt}
                        inline
                        onChange={this.onHuntChange}
                    >
                        Hunt
                    </Checkbox>
                    <Checkbox
                        checked={this.props.relay.variables.tromso}
                        inline
                        onChange={this.onTromsoChange}
                    >
                        Tromsø
                    </Checkbox>
                </div>
            </div>
        );
        return (
            <section>
                <div style={{ maxWidth: 800, margin: '0 auto' }}>
                    <form onSubmit={this.onSearch} onReset={this.onClear}>
                        <div style={{ display: 'flex' }}>
                            <div style={{ margin: '0 10px' }} className="hidden-xs">
                                <Image
                                    src="/img/logo2_ntnu_u-slagord.jpg"
                                    style={{ marginTop: 28, width: 50 }}
                                />
{'fraction_non_alphanumeric': 0.12352829472085074, 'fraction_numerical': 0.007406000759589822, 'mean_word_length': 1.4180440771349863, 'pattern_counts': {'":': 0, '<': 63, '<?xml version=': 0, '>': 77, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2726406', 'n_tokens_mistral': 2970, 'n_tokens_neox': 2819, 'n_words': 563}