<commit_before>/**
 * Created by myth on 10/24/15.
 */

var GalleryDashboard = (function ($, tools) {

    /* Private fields */

    var SEARCH_ENDPOINT = '/api/v1/images/'
    var search_field, search_button, result_table, years

    years = $('.dashboard-gallery-year')
    search_field = $('#dashboard-gallery-search-query')
    search_button = $('#dashboard-gallery-search-button')
    result_table = $('#dashboard-gallery-table')

    /* Private functions */

    /**
     * Generic API helper function that only takes on an URI
     * @param uri Relative URI on the endpoint
     */
    var doRequest = function (uri) {
        last_request = uri

        var success = function (data) {
            Gallery.draw(data)
        }
        var error = function (xhr, statusText, thrownError) {
            tools.showStatusMessage('Det oppstod en uventet feil: ' + statusText, 'alert-danger')
        }
        // Trigger AJAX request with query
        tools.ajax('GET', uri, null, success, error, 'json')
    }

    /* Public API */
    return {
        /**
         * Initializes the Gallery Dashboard Module by binding event listeners
         * to search field, button and years filters.
         */
        init: function () {
            search_field.on('keypress', function (e) {
                if (e.keyCode === 13) {
                    e.preventDefault()
                    e.stopPropagation()
                    Gallery.search($(this).val())
                }
            })

            search_button.on('click', function(e) {
                e.preventDefault()
                Gallery.search(search_field.val())
            })

            years.on('click', function (e) {
                e.preventDefault()
                Gallery.filter($(this).text())
            })
        },

        /**
         * Perform a text query search by using the ResponsiveImage API
         * @param query: A search query as text
         */
        search: function (query) {
            doRequest(SEARCH_ENDPOINT + '?query=' + query)
        },

        /**
         * Perform a filter search on a year by using the ResponsiveImage API
         * @param year: A year filter as text
         */
        filter: function (year) {
            doRequest(SEARCH_ENDPOINT + '?year=' + year)
        },

        /**
         * Render a list of search results by providing the returned results
         * from a ResponsiveImage API call.
         * @param data: A JSON object result in Django REST Framework format
         */
        draw: function (data) {
            var html = '';

            if (!data.results.length) html = '<tr><td colspan="4">Ingen bilder matchet søket...</td></tr>'
            else {
                for (var i = 0; i < data.results.length; i++) {
                    var t = moment(data.results[i].timestamp)

                    html += '<tr><td>'
                    html +=   '<a href="' + data.results[i].original + '">'
                    html +=     '<img src="' + data.results[i].thumb + '" alt title="' + data.results[i].name + '">'
                    html += '</a></td><td>'
                    html +=   '<a href="' + data.results[i].id + '/">' + data.results[i].name + '</a>'
                    html += '</td><td>'
                    html +=   data.results[i].description
                    html += '</td><td>'
                    html +=   t.format('YYYY-MM-DD HH:MM:SS')
                    html += '</td></tr>'
                }
            }
            result_table.html(html)
        }
    }
})(jQuery, Dashboard.tools)

GalleryDashboard.init()
<commit_msg>Fix incorrect js module invocation<commit_after>/**
 * Created by myth on 10/24/15.
 */

var GalleryDashboard = (function ($, tools) {

    /* Private fields */

    var SEARCH_ENDPOINT = '/api/v1/images/'
    var search_field, search_button, result_table, years

    years = $('.dashboard-gallery-year')
    search_field = $('#dashboard-gallery-search-query')
    search_button = $('#dashboard-gallery-search-button')
    result_table = $('#dashboard-gallery-table')

    /* Private functions */

    /**
     * Generic API helper function that only takes on an URI
     * @param uri Relative URI on the endpoint
     */
    var doRequest = function (uri) {
        last_request = uri

        var success = function (data) {
            Gallery.draw(data)
        }
        var error = function (xhr, statusText, thrownError) {
            tools.showStatusMessage('Det oppstod en uventet feil: ' + statusText, 'alert-danger')
        }
        // Trigger AJAX request with query
        tools.ajax('GET', uri, null, success, error, 'json')
    }

    /* Public API */
    return {
        /**
         * Initializes the Gallery Dashboard Module by binding event listeners
         * to search field, button and years filters.
         */
        init: function () {
            search_field.on('keypress', function (e) {
                if (e.keyCode === 13) {
                    e.preventDefault()
                    e.stopPropagation()
                    GalleryDashboard.search($(this).val())
                }
            })

            search_button.on('click', function(e) {
                e.preventDefault()
                GalleryDashboard.search(search_field.val())
            })

            years.on('click', function (e) {
                e.preventDefault()
                GalleryDashboard.filter($(this).text())
            })
        },

        /**
         * Perform a text query search by using the ResponsiveImage API
         * @param query: A search query as text
         */
        search: function (query) {
            doRequest(SEARCH_ENDPOINT + '?query=' + query)
        },

        /**
         * Perform a filter search on a year by using the ResponsiveImage API
         * @param year: A year filter as text
         */
        filter: function (year) {
            doRequest(SEARCH_ENDPOINT + '?year=' + year)
        },

        /**
         * Render a list of search results by providing the returned results
         * from a ResponsiveImage API call.
         * @param data: A JSON object result in Django REST Framework format
         */
        draw: function (data) {
            var html = '';

            if (!data.results.length) html = '<tr><td colspan="4">Ingen bilder matchet søket...</td></tr>'
            else {
                for (var i = 0; i < data.results.length; i++) {
                    var t = moment(data.results[i].timestamp)

                    html += '<tr><td>'
                    html +=   '<a href="' + data.results[i].original + '">'
                    html +=     '<img src="' + data.results[i].thumb + '" alt title="' + data.results[i].name + '">'
                    html += '</a></td><td>'
                    html +=   '<a href="' + data.results[i].id + '/">' + data.results[i].name + '</a>'
                    html += '</td><td>'
                    html +=   data.results[i].description
                    html += '</td><td>'
                    html +=   t.format('YYYY-MM-DD HH:MM:SS')
                    html += '</td></tr>'
                }
            }
            result_table.html(html)
        }
    }
})(jQuery, Dashboard.tools)

GalleryDashboard.init()

{'fraction_non_alphanumeric': 0.13388429752066117, 'fraction_numerical': 0.0030303030303030303, 'mean_word_length': 1.557590700951039, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 41, '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': '5269202', 'n_tokens_mistral': 2020, 'n_tokens_neox': 1931, 'n_words': 516}