~ubuntu-branches/ubuntu/saucy/phpmyadmin/saucy-proposed

« back to all changes in this revision

Viewing changes to js/server_status_sorter.js

  • Committer: Package Import Robot
  • Author(s): Thijs Kinkhorst
  • Date: 2013-08-04 13:24:37 UTC
  • mfrom: (1.2.44)
  • Revision ID: package-import@ubuntu.com-20130804132437-jznw8efwy4hr1nms
Tags: 4:4.0.5-1
* New upstream release.
  - Fixes security issue PMASA-2013-10.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
function initTableSorter(a){var b,c;switch(a){case"statustabs_queries":b=$("#serverstatusqueriesdetails");c={sortList:[[3,1]],widgets:["fast-zebra"],headers:{1:{sorter:"fancyNumber"},2:{sorter:"fancyNumber"}}};break;case"statustabs_allvars":b=$("#serverstatusvariables");c={sortList:[[0,0]],widgets:["fast-zebra"],headers:{1:{sorter:"withinSpanNumber"}}};break}b.tablesorter(c);b.find("tr:first th").append('<img class="icon sortableIcon" src="themes/dot.gif" alt="">')}$(function(){$.tablesorter.addParser({id:"fancyNumber",is:function(a){return/^[0-9]?[0-9,\.]*\s?(k|M|G|T|%)?$/.test(a)},format:function(c){var a=jQuery.tablesorter.formatFloat(c.replace(PMA_messages.strThousandsSeparator,"").replace(PMA_messages.strDecimalSeparator,"."));var b=1;switch(c.charAt(c.length-1)){case"%":b=-2;break;case"k":b=3;break;case"M":b=6;break;case"G":b=9;break;case"T":b=12;break}return a*Math.pow(10,b)},type:"numeric"});$.tablesorter.addParser({id:"withinSpanNumber",is:function(a){return/<span class="original"/.test(a)},format:function(c,d,b){var a=b.innerHTML.match(/<span(\s*style="display:none;"\s*)?\s*class="original">(.*)?<\/span>/);return(a&&a.length>=3)?a[2]:0},type:"numeric"});$.tablesorter.addWidget({id:"fast-zebra",format:function(a){if(a.config.debug){var b=new Date()}$("tr:even",a.tBodies[0]).removeClass(a.config.widgetZebra.css[0]).addClass(a.config.widgetZebra.css[1]);$("tr:odd",a.tBodies[0]).removeClass(a.config.widgetZebra.css[1]).addClass(a.config.widgetZebra.css[0]);if(a.config.debug){$.tablesorter.benchmark("Applying Fast-Zebra widget",b)}}})});
 
 
b'\\ No newline at end of file'
 
1
// TODO: tablesorter shouldn't sort already sorted columns
 
2
function initTableSorter(tabid) {
 
3
    var $table, opts;
 
4
    switch(tabid) {
 
5
        case 'statustabs_queries':
 
6
            $table = $('#serverstatusqueriesdetails');
 
7
            opts = {
 
8
                sortList: [[3, 1]],
 
9
                widgets: ['fast-zebra'],
 
10
                headers: {
 
11
                    1: { sorter: 'fancyNumber' },
 
12
                    2: { sorter: 'fancyNumber' }
 
13
                }
 
14
            };
 
15
            break;
 
16
        case 'statustabs_allvars':
 
17
            $table = $('#serverstatusvariables');
 
18
            opts = {
 
19
                sortList: [[0, 0]],
 
20
                widgets: ['fast-zebra'],
 
21
                headers: {
 
22
                    1: { sorter: 'withinSpanNumber' }
 
23
                }
 
24
            };
 
25
            break;
 
26
    }
 
27
    $table.tablesorter(opts);
 
28
    $table.find('tr:first th')
 
29
        .append('<img class="icon sortableIcon" src="themes/dot.gif" alt="">');
 
30
}
 
31
 
 
32
$(function () {
 
33
    $.tablesorter.addParser({
 
34
        id: "fancyNumber",
 
35
        is: function(s) {
 
36
            return /^[0-9]?[0-9,\.]*\s?(k|M|G|T|%)?$/.test(s);
 
37
        },
 
38
        format: function(s) {
 
39
            var num = jQuery.tablesorter.formatFloat(
 
40
                s.replace(PMA_messages['strThousandsSeparator'], '')
 
41
                 .replace(PMA_messages['strDecimalSeparator'], '.')
 
42
            );
 
43
 
 
44
            var factor = 1;
 
45
            switch (s.charAt(s.length - 1)) {
 
46
                case '%': factor = -2; break;
 
47
                // Todo: Complete this list (as well as in the regexp a few lines up)
 
48
                case 'k': factor = 3; break;
 
49
                case 'M': factor = 6; break;
 
50
                case 'G': factor = 9; break;
 
51
                case 'T': factor = 12; break;
 
52
            }
 
53
 
 
54
            return num * Math.pow(10, factor);
 
55
        },
 
56
        type: "numeric"
 
57
    });
 
58
 
 
59
    $.tablesorter.addParser({
 
60
        id: "withinSpanNumber",
 
61
        is: function(s) {
 
62
            return /<span class="original"/.test(s);
 
63
        },
 
64
        format: function(s, table, html) {
 
65
            var res = html.innerHTML.match(/<span(\s*style="display:none;"\s*)?\s*class="original">(.*)?<\/span>/);
 
66
            return (res && res.length >= 3) ? res[2] : 0;
 
67
        },
 
68
        type: "numeric"
 
69
    });
 
70
 
 
71
    // faster zebra widget: no row visibility check, faster css class switching, no cssChildRow check
 
72
    $.tablesorter.addWidget({
 
73
        id: "fast-zebra",
 
74
        format: function (table) {
 
75
            if (table.config.debug) {
 
76
                var time = new Date();
 
77
            }
 
78
            $("tr:even", table.tBodies[0])
 
79
                .removeClass(table.config.widgetZebra.css[0])
 
80
                .addClass(table.config.widgetZebra.css[1]);
 
81
            $("tr:odd", table.tBodies[0])
 
82
                .removeClass(table.config.widgetZebra.css[1])
 
83
                .addClass(table.config.widgetZebra.css[0]);
 
84
            if (table.config.debug) {
 
85
                $.tablesorter.benchmark("Applying Fast-Zebra widget", time);
 
86
            }
 
87
        }
 
88
    });
 
89
});