<commit_before>(function($){

    /**
     * Handles the display-all functionality and filtering
     */
    var display_inventory = {

        host: window.apiRoute + "/displayInventory/",
        inventory: false,
        customerSelector: null,
        consolidated: false,

        /**
         * Go fetch everything and get it set up
         */
        init: function() {
            var self = this;

            $("#track_by").change(function() {
                $("#customer-filter").hide();
                $("#item-filter").hide();

                switch($("#track_by option:selected").val()) {
                    case "Customer":
                        $("#customer-filter").show();
                        break;
                    case "Item":
                        $("#item-filter").show();
                        break;
                    case "All":
                        self.showAllItems();
                        break;
                    default:
                        break;
                }
            });

            this.customerSelector = $("#customer").selectize({
                valueField: "label",
                labelField: "label",
                searchField: ["label"],
                render: {
                    option: function(item, escape) {
                        return "<div>" + escape(item.label) + "</div>";
                    }
                },
                load: function(query, callback) {
                    this.clearOptions();

                    if (!query.length) return callback();

                    $.getJSON(window.apiRoute + "/customerAutoComplete/" + encodeURIComponent(query), function(data) {
                        callback(data); // data = [{label:"customer 1"}, {label:"customer 2"}, ..]
                    });
                }
            });

            $("#customer").change(function() {
                self.searchCustomer($("#customer option:selected").text());
            });

            // Item search bar.
            // TODO should we use the same combobox as customer?
            $("#item").autocomplete({
                minLength: 1,
                source: function(request, response) {
                    $.getJSON(window.apiRoute + "/itemAutoComplete/" + encodeURIComponent(request.term), response); // data = [{label:"item 1"}, {label:"item 2"}, ..]
                },
                select: function(event, ui) {
                    // ui { label, value }
                    self.searchItem(ui.item.label);
                }
            });

            $("#item").keypress(function(e) {
                if (e.which == 13) {
                    self.searchItem($("#item").val());
                }
            });

            $("#search_item_button").click(function() {
                self.searchItem($("#item").val());
            });

        },

        searchItem: function(keyword) {
            if (!keyword) return;
<commit_msg>Adding the ability to set filters based on query string.<commit_after>(function($){

    /**
     * Handles the display-all functionality and filtering
     */

    var display_inventory = {

        host: window.apiRoute + "/displayInventory/",
        inventory: false,
        customerSelector: null,
        consolidated: false,

        /**
         * Go fetch everything and get it set up
         */
        init: function() {
            var self = this;

            $("#track_by").change(function() {
                $("#customer-filter").hide();
                $("#item-filter").hide();

                switch($("#track_by option:selected").val()) {
                    case "Customer":
                        $("#customer-filter").show();
                        break;
                    case "Item":
                        $("#item-filter").show();
                        break;
                    case "All":
                        self.showAllItems();
                        break;
                    default:
                        break;
                }
            });

            this.customerSelector = $("#customer").selectize({
                valueField: "label",
                labelField: "label",
                searchField: ["label"],
                render: {
                    option: function(item, escape) {
                        return "<div>" + escape(item.label) + "</div>";
                    }
                },
                load: function(query, callback) {
                    this.clearOptions();

                    if (!query.length) return callback();

                    $.getJSON(window.apiRoute + "/customerAutoComplete/" + encodeURIComponent(query), function(data) {
                        callback(data); // data = [{label:"customer 1"}, {label:"customer 2"}, ..]
                    });
                }
            });

            $("#customer").change(function() {
                self.searchCustomer($("#customer option:selected").text());
            });

            // Item search bar.
            // TODO should we use the same combobox as customer?
            $("#item").autocomplete({
                minLength: 1,
                source: function(request, response) {
                    $.getJSON(window.apiRoute + "/itemAutoComplete/" + encodeURIComponent(request.term), response); // data = [{label:"item 1"}, {label:"item 2"}, ..]
                },
                select: function(event, ui) {
                    // ui { label, value }
                    self.searchItem(ui.item.label);
                }
            });

            $("#item").keypress(function(e) {
                if (e.which == 13) {
                    self.searchItem($("#item").val());
                }
            });

            $("#search_item_button").click(function() {
                self.searchItem($("#item").val());
            });

            var query = window.location.search.substring(1).split('&', 1);
            var toSet = query[0];
            var setTo = query[1];

            switch(toLowerCase(toSet)){
                case "customer":
                    if(('#customer-filter').find('option[value="'+setTo+'"]').length > 0){
                        ('#customer-filter').val(setTo);
                    }
                    break;
                case "item":
                    if(('#item-filter').find('option[value="'+setTo+'"]').length > 0){
                        ('#item-filter').val(setTo);
                    }
                    break;
                case "all":
                    if(toLowerCase(setTo) == "true") {
                        self.showAllItems();
                    }
                    break;
                default:
                    // Do nothing
            }
        },

        searchItem: function(keyword) {
            if (!keyword) return;

{'fraction_non_alphanumeric': 0.1423144360023378, 'fraction_numerical': 0.0029222676797194622, 'mean_word_length': 1.1244568590937305, 'pattern_counts': {'":': 9, '<': 7, '<?xml version=': 0, '>': 9, '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': '7644770', 'n_tokens_mistral': 1642, 'n_tokens_neox': 1516, 'n_words': 307}