<commit_before>// --
// Core.UI.Table.Sort.js - table sorting functions
// Copyright (C) 2001-2010 OTRS AG, http://otrs.org/\n";
// --
// $Id: Core.UI.Table.Sort.js,v 1.2 2010-07-16 06:53:24 mn Exp $
// --
// This software comes with ABSOLUTELY NO WARRANTY. For details, see
// the enclosed file COPYING for license information (AGPL). If you
// did not receive this file, see http://www.gnu.org/licenses/agpl.txt.
// --

"use strict";

var Core = Core || {};
Core.UI = Core.UI || {};
Core.UI.Table = Core.UI.Table || {};

/**
 * @namespace
 * @exports TargetNS as Core.UI.TableSort
 * @description
 *      This namespace contains all functions for client side table sorting
 */
Core.UI.Table.Sort = (function (TargetNS) {
    /**
     * @function
     * @description
     *      This function initializes the table sorting.
     * @param {jQueryObject} $Table The table element which should be sorted
     * @param {Function} Finished A optional function, called after the sorting
     * @return nothing
     */
    TargetNS.Init = function ($Table, Finished) {
        if (isJQueryObject($Table)) {
            var $SortableColumns = $Table.find('th.Sortable'),
                $InitialSorting = $SortableColumns.filter('.InitialSorting'),
                Headers = {},
                InitialSort = [],
                ColumnCount = 0;

            // Only start, if there are columns that allow sorting
            if ($SortableColumns.length) {
                // Get all columns which should not be sorted
                $Table.find('th').each(function () {
                    if (!$(this).hasClass('Sortable')) {
                        Headers[ColumnCount] = { sorter: false };
                    }
                    ColumnCount++;
                });

                //Get the column, which should be sorted initially (can be only one)
                if ($InitialSorting.length === 1) {
                    // Initially sort the specified column ascending
                    InitialSort = [[$InitialSorting.index(), 0]];
                }

                $Table.tablesorter({
                    headers: Headers,
                    sortList: InitialSort
                });

                if ($.isFunction(Finished)) {
                    $Table.bind('sortEnd', Finished);
                }
            }
        }
    };

    return TargetNS;
}(Core.UI.Table.Sort || {}));<commit_msg>Improved table sorting (not complete yet).<commit_after>// --
// Core.UI.Table.Sort.js - table sorting functions
// Copyright (C) 2001-2010 OTRS AG, http://otrs.org/\n";
// --
// $Id: Core.UI.Table.Sort.js,v 1.3 2010-08-12 09:26:44 mg Exp $
// --
// This software comes with ABSOLUTELY NO WARRANTY. For details, see
// the enclosed file COPYING for license information (AGPL). If you
// did not receive this file, see http://www.gnu.org/licenses/agpl.txt.
// --

"use strict";

var Core = Core || {};
Core.UI = Core.UI || {};
Core.UI.Table = Core.UI.Table || {};

/**
 * @namespace
 * @exports TargetNS as Core.UI.TableSort
 * @description
 *      This namespace contains all functions for client side table sorting
 */
Core.UI.Table.Sort = (function (TargetNS) {
    /**
     * @function
     * @description
     *      This function initializes the table sorting.
     * @param {jQueryObject} $Table The table element which should be sorted
     * @param {Function} Finished A optional function, called after the sorting
     * @return nothing
     */
    TargetNS.Init = function ($Table, Finished) {
        if (isJQueryObject($Table)) {
            var $SortableColumns = $Table.find('th.Sortable'),
                $InitialSorting = $SortableColumns.filter('.InitialSorting'),
                Headers = {},
                InitialSort = [],
                ColumnCount = 0;

            // Only start, if there are columns that allow sorting
            if ($SortableColumns.length) {
                // Get all columns which should not be sorted
                $Table.find('th').each(function () {
                    if (!$(this).hasClass('Sortable')) {
                        Headers[ColumnCount] = { sorter: false };
                    }
                    ColumnCount++;
                });

                //Get the column, which should be sorted initially (can be only one)
                if ($InitialSorting.length === 1) {
                    // Initially sort the specified column ascending
                    InitialSort = [[$InitialSorting.index(), 0]];
                }

                $Table.tablesorter({
                    headers: Headers,
                    sortList: InitialSort,
                    textExtraction: 'complex'
                });

                if ($.isFunction(Finished)) {
                    $Table.bind('sortEnd', Finished);
                }
            }
        }
    };

    return TargetNS;
}(Core.UI.Table.Sort || {}));
{'fraction_non_alphanumeric': 0.12740286298568507, 'fraction_numerical': 0.011042944785276074, 'mean_word_length': 1.685886875343218, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '6333340', 'n_tokens_mistral': 1380, 'n_tokens_neox': 1253, 'n_words': 367}