<commit_before>/** @jsx React.DOM */

define(function (require) {

    var React = require('react'),
        Backbone = require('backbone'),
        _ = require('underscore'),
        ImageCollection = require('collections/ApplicationCollection'),
        ImageList = require('components/common/image/ImageList.react'),
        stores = require('stores');
    var timer,
        timerDelay = 100;

    return React.createClass({


        //
        // Mounting & State
        // ----------------
        //a

        propTypes: {
            onPrevious: React.PropTypes.func.isRequired,
            onNext: React.PropTypes.func.isRequired
        },

        getInitialState: function () {
            return this.getState();
        },

        getState: function () {
            var query = this.state ? this.state.query : null,
                images;
            if (query) {
                images = stores.ApplicationStore.fetchWhere({
                    search: query
                });
            } else {
                images = stores.ApplicationStore.getAll();
            }

            return {
                query: query,
                images: images,
                tags: stores.TagStore.getAll(),

                resultsPerPage: 20,
                page: 1
            }
        },

        updateState: function () {
            if (this.isMounted()) this.setState(this.getState());
        },

        componentDidMount: function () {
            stores.ApplicationStore.addChangeListener(this.updateState);
            stores.TagStore.addChangeListener(this.updateState);
            this.focusSearchInput();
        },

        componentWillUnmount: function () {
            stores.ApplicationStore.removeChangeListener(this.updateState);
            stores.TagStore.removeChangeListener(this.updateState);
        },

        //
        // Internal Modal Callbacks
        // ------------------------
        //

        handleSearch: function (query) {
            if (timer) clearTimeout(timer);
            timer = setTimeout(function () {
                query = this.state.query;
                if (query) {
                    this.setState({
                        images: stores.ApplicationStore.fetchWhere({
                            search: query
                        })
                    });
                } else {
                    this.setState({
                        images: stores.ApplicationStore.getAll()
                    });
                }
            }.bind(this), timerDelay);
        },

        handleChange: function (e) {
            this.setState({query: e.target.value});
        },

        handleKeyUp: function (e) {
            //if (e.keyCode == 13 && this.state.query.length) {
            //if (this.state.query.length) {
            this.handleSearch(this.state.query);
            //}
        },

        showImageDetails: function (image) {
            this.props.onNext({application: image});
        },

        //
        // Callbacks
        //

        onBack: function () {
            this.props.onPrevious({});
        },

        handleLoadMoreImages: function () {
            this.setState({page: this.state.page + 1});
        },

        //
        // Render
        // ------
        //

        renderFilterDescription: function (query) {
            var message;

            if (query) {
                message = 'Showing results for "' + query + '"';
            } else {
                message = "Showing all images"
            }

            return (
                <div className="filter-description">{message}</div>
            )
        },

        renderNoResultsFor: function (query) {
            var message = 'No images found matching "' + query + '"';

            return (
                <div className="filter-description">{message}</div>
            )
        },
<commit_msg>Changed text to represent that not ALL images are available<commit_after>/** @jsx React.DOM */

define(function (require) {

    var React = require('react'),
        Backbone = require('backbone'),
        _ = require('underscore'),
        ImageCollection = require('collections/ApplicationCollection'),
        ImageList = require('components/common/image/ImageList.react'),
        stores = require('stores');
    var timer,
        timerDelay = 100;

    return React.createClass({


        //
        // Mounting & State
        // ----------------
        //a

        propTypes: {
            onPrevious: React.PropTypes.func.isRequired,
            onNext: React.PropTypes.func.isRequired
        },

        getInitialState: function () {
            return this.getState();
        },

        getState: function () {
            var query = this.state ? this.state.query : null,
                images;
            if (query) {
                images = stores.ApplicationStore.fetchWhere({
                    search: query
                });
            } else {
                images = stores.ApplicationStore.getAll();
            }

            return {
                query: query,
                images: images,
                tags: stores.TagStore.getAll(),

                resultsPerPage: 20,
                page: 1
            }
        },

        updateState: function () {
            if (this.isMounted()) this.setState(this.getState());
        },

        componentDidMount: function () {
            stores.ApplicationStore.addChangeListener(this.updateState);
            stores.TagStore.addChangeListener(this.updateState);
            this.focusSearchInput();
        },

        componentWillUnmount: function () {
            stores.ApplicationStore.removeChangeListener(this.updateState);
            stores.TagStore.removeChangeListener(this.updateState);
        },

        //
        // Internal Modal Callbacks
        // ------------------------
        //

        handleSearch: function (query) {
            if (timer) clearTimeout(timer);
            timer = setTimeout(function () {
                query = this.state.query;
                if (query) {
                    this.setState({
                        images: stores.ApplicationStore.fetchWhere({
                            search: query
                        })
                    });
                } else {
                    this.setState({
                        images: stores.ApplicationStore.getAll()
                    });
                }
            }.bind(this), timerDelay);
        },

        handleChange: function (e) {
            this.setState({query: e.target.value});
        },

        handleKeyUp: function (e) {
            //if (e.keyCode == 13 && this.state.query.length) {
            //if (this.state.query.length) {
            this.handleSearch(this.state.query);
            //}
        },

        showImageDetails: function (image) {
            this.props.onNext({application: image});
        },

        //
        // Callbacks
        //

        onBack: function () {
            this.props.onPrevious({});
        },

        handleLoadMoreImages: function () {
            this.setState({page: this.state.page + 1});
        },

        //
        // Render
        // ------
        //

        renderFilterDescription: function (query) {
            var message;

            if (query) {
                message = 'Showing results for "' + query + '"';
            } else {
                message = "Showing first 20 images"
            }

            return (
                <div className="filter-description">{message}</div>
            )
        },

        renderNoResultsFor: function (query) {
            var message = 'No images found matching "' + query + '"';

            return (
                <div className="filter-description">{message}</div>
            )
        },

{'fraction_non_alphanumeric': 0.12441165246151889, 'fraction_numerical': 0.0025442055718102024, 'mean_word_length': 1.231620777746239, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '6652472', 'n_tokens_mistral': 1951, 'n_tokens_neox': 1846, 'n_words': 342}