PageSourceSearch

https://my.absa.org/lib/jquery_tiki/tablesorter.js

js absa.org collected 2026-09-24 09:26:34 UTC 4,027 bytes, 107 lines download raw bytes

1/**
2 * $Id$
3 *
4 * Utilities used with tablesorter
5 */
6
7/**
8 * Fetch rows from an ajax pagination call
9 *
10 * @param data
11 * @param id
12 * @param addcol
13 * @param total
14 * @returns {{}}
15 */
16function tsAjaxGetRows (data, id, addcol, total)
17{
18    
19    //parse HTML string from entire page
20    var parsedpage = $.parseHTML(data), table = $(parsedpage).find(id), r = {};
21    //extract table body rows from html returned by smarty template file
22    r.rows = $(table).find('tbody tr');
23    //add any math total columns
24    if (addcol) {
25        $.each(addcol, function (key, value) {
26            $(r.rows).append('<td data-tsmath="row-' + value['formula'] + '" data-tsmath-filter="*"></td >');
27        });
28    }
29    //tablesorter needs total rows
30    r.total = total;
31    r.filteredRows = $(table).data('count');
32    r.headers = null;
33    return r;
34}
35
36/**
37 * Generate an ajax url
38 *
39 * @param url
40 * @param p
41 * @param a
42 * @returns {*}
43 */
44function tsAjaxUrl (url, p, a) {
45    var vars = {}, urlparams, oneparam, sorts = false, sortindex, sortkey = 'sort-', filterindex, filterkey = 'filter-',
46        params = [], dir, offset, newurl;
47    if (a.custom !== false) {
48        //parse out url parameters
49        urlparams = url.slice(url.indexOf('?') + 1).split('&');
50        for(var i = 0; i < urlparams.length; i++) {
51            oneparam = urlparams[i].split('=');
52            if (oneparam[0].search('sort') > -1) {
53                sortindex = parseInt(oneparam[0].substr(5, oneparam[0].length - 6));
54                if ($.isNumeric(sortindex)) {
55                    sortkey = a.colselector ? sortkey + $(a.tableid + ' th:eq(' + sortindex + ')').attr('id')
56                        : sortkey + sortindex;
57                    vars[sortkey] = oneparam[1];
58                }
59            } else if (oneparam[0].search('filter') > -1) {
60                filterindex = parseInt(oneparam[0].substr(7, oneparam[0].length - 8));
61                if ($.isNumeric(filterindex)) {
62                    filterkey = a.colselector ? filterkey + $(a.tableid + ' th:eq(' + filterindex + ')').attr('id')
63                        : filterkey + filterindex;
64                    vars[filterkey] = oneparam[1];
65                }
66            }
67        }
68        //iterate through url parameters
69        $.each(vars, function(key, value) {
70            //handle sort parameters
71            if (a.asort && key in a.asort) {
72                dir = value == 0 ? '_asc' : '_desc';
73                //add sort if not yet defined or add sort for multiple comma-separated sort parameters
74                !sorts ? sorts = a.asort[key] + dir : sorts += ',' + a.asort[key] + dir;
75            }
76            //handle column and external filter parameters
77            if ($.inArray(value, a.extfilters) > -1) {
78                params.push(decodeURIComponent(value));
79            } else if ($.isPlainObject(a.colfilters) && key in a.colfilters) {
80                a.colfilters[key] == value ? params.push(a.colfilters[key][value]) : params.push(a.colfilters[key] + '='
81                    + value);
82            }
83        });
84        //convert to tiki sort param sort parameter
85        if (sorts) {
86            params.push(a.sortparam + '=' + sorts);
87        }
88        //add any required params
89        if (a.requiredparams) {
90            $.each(a.requiredparams, function(key, value) {
91                params.push(key + '=' + value);
92            });
93        }
94        //offset parameter
95        offset = ((p.page * p.size) >= p.filteredRows) ? '' : '&' + a.offset + '=' + (p.page * p.size);
96        //build url, starting with no parameters
97        newurl = url.slice(0,url.indexOf('?'));
98        newurl = newurl + '?' + a.numrows + '=' + p.size + offset + '&tsAjax=y';
99        $.each(params, function(key, value) {
100            newurl = newurl + '&' + value;
101        });
102    } else {
103        offset = ((p.page * p.size) >= p.filteredRows) ? '' : '&' + a.offset + '=' + (p.page * p.size);
104        newurl = url + '&tsAjax=y' + offset + '&numrows=' + p.size;
105    }
106    return newurl;
107}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.