<commit_before>$(document).ready(function() {

        /* Takes a query and updates the page. */
        $("#button").click(function() {

            /* Get query; language for the moment. */
            query = ($('#query').val());

            /* Put form values into an associative array. */
            queryArrayFormatJSON = $('form').serializeArray();
            queryArrayFormatJSON.push({'name': 'format', value: 'json'});

            queryStringFormatJSON = $.param(queryArrayFormatJSON);

            /* Fetch JSON and put in DOM. */
            Opps.fetchOppsToDOM(queryStringFormatJSON);

            var oldstart = 0, oldend = 0;
            $(queryArrayFormatJSON).each(function () {
                if(this.name == 'start') oldstart = parseInt(this.value);
                if(this.name == 'end') oldend = parseInt(this.value);
                })

            console.log(oldstart, oldend);

            diff = oldend - oldstart;

            prevPageQueryArray = $('form').serializeArray();
            $(prevPageQueryArray).each(function () {
                    if (this.name == 'start') this.value = oldstart - diff;
                    if (this.name == 'end') this.value = oldstart;
                    }
                    );

            prevPageQueryArray = $('form').serializeArray();
            $(prevPageQueryArray).each(function () {
                    if (this.name == 'start') this.value = oldend;
                    if (this.name == 'end') this.value = oldend + diff;
                    });

            /* Update navigation links to reflect new query. */
            $('#prev-page').attr('href', '/search/' + $.param(prevPageQueryArray));
            $('#next-page').attr('href', '/search/' + $.param(nextPageQueryArray));

            return false;
        });
});

Opps = {
    'oppsQueryURL': "http://localhost:8000/search/?",
    '$oppsDOMList': $('#opps ul'),
    'fetchOppsToDOM': function (queryString) {
        $('#opps li').remove();
        url = this.oppsQueryURL + queryString + "&jsoncallback=?";
        $.getJSON(url, this.jsonArrayToDocument);
    },
    'jsonArrayToDocument': function (jsonArray) {
        console.log(jsonArray);
        $(jsonArray).each( function() {
                $opp = $("<li>");
                $opp.addClass(this.model);
                $opp.attr('id', "opp-" + this.pk);

                // Heading
                $h3 = $("<h3>");
                $title = $("<span>").text(this.fields.title);
                $h3.append($title);
                $opp.append($h3);

                // Summary<commit_msg>Created an update method that takes a wacky jQuery serializeArray object and updates: the DOM with bugs, the prev page link, the next page link.<commit_after>$(document).ready(function() {

        function update(queryArray) {

            queryArray.push({'name': 'format', value: 'json'});

            queryStringFormatJSON = $.param(queryArray);

            /* Fetch JSON and put in DOM. */
            Opps.fetchOppsToDOM(queryStringFormatJSON);

            /* Update navigation links */
            var oldstart = 0, oldend = 0;
            $(queryArray).each(function () {
                if(this.name == 'start') oldstart = parseInt(this.value);
                if(this.name == 'end') oldend = parseInt(this.value);
                })

            console.log(oldstart, oldend);

            diff = oldend - oldstart;

            prevPageQueryArray = $('form').serializeArray();
            $(prevPageQueryArray).each(function () {
                    if (this.name == 'start') this.value = oldstart - diff;
                    if (this.name == 'end') this.value = oldstart;
                    }
                    );

            prevPageQueryArray = $('form').serializeArray();
            $(prevPageQueryArray).each(function () {
                    if (this.name == 'start') this.value = oldend;
                    if (this.name == 'end') this.value = oldend + diff;
                    });

            /* Update navigation links to reflect new query. */
            $('#prev-page').attr('href', '/search/' + $.param(prevPageQueryArray));
            $('#next-page').attr('href', '/search/' + $.param(nextPageQueryArray));

            return false;
        };

        /* Takes a query and updates the page. */
        $("#button").click(function() {
            /* Get query; language for the moment. */
            query = ($('#query').val());

            /* Put form values into an associative array. */
            update($('form').serializeArray());
            });


        $('#prev-page, #next-page').click(function() {
                
                });

});

Opps = {
    'oppsQueryURL': "http://localhost:8000/search/?",
    '$oppsDOMList': $('#opps ul'),
    'fetchOppsToDOM': function (queryString) {
        $('#opps li').remove();
        url = this.oppsQueryURL + queryString + "&jsoncallback=?";
        $.getJSON(url, this.jsonArrayToDocument);
    },
    'jsonArrayToDocument': function (jsonArray) {
        console.log(jsonArray);
        $(jsonArray).each( function() {
                $opp = $("<li>");
                $opp.addClass(this.model);
                $opp.attr('id', "opp-" + this.pk);

                // Heading
                $h3 = $("<h3>");
                $title = $("<span>").text(this.fields.title);
                $h3.append($title);
                $opp.append($h3);

                // Summary
{'fraction_non_alphanumeric': 0.16290588882773804, 'fraction_numerical': 0.00366905155017428, 'mean_word_length': 1.7057071960297767, 'pattern_counts': {'":': 0, '<': 9, '<?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': '893507', 'n_tokens_mistral': 1516, 'n_tokens_neox': 1431, 'n_words': 305}