Modify sorttable.js to be able to sort column with both value and percentage as numeric.

This commit is contained in:
Darold 2012-12-16 17:24:07 +01:00
parent 377c02aafb
commit 99d2f6f5f0
2 changed files with 23 additions and 22 deletions

View File

@ -1,4 +1,4 @@
.\" Automatically generated by Pod::Man 2.26 (Pod::Simple 3.07)
.\" Automatically generated by Pod::Man 2.22 (Pod::Simple 3.07)
.\"
.\" Standard preamble:
.\" ========================================================================
@ -38,8 +38,6 @@
. ds PI \(*p
. ds L" ``
. ds R" ''
. ds C`
. ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
@ -50,24 +48,17 @@
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
.ie \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. nr % 0
. rr F
.\}
.el \{\
. de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{
. if \nF \{
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. if !\nF==2 \{
. nr % 0
. nr F 2
. \}
. \}
.\}
.rr rF
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear. Run. Save yourself. No user-serviceable parts.
@ -133,7 +124,7 @@
.\" ========================================================================
.\"
.IX Title "SQUIDANALYZER 1"
.TH SQUIDANALYZER 1 "2012-12-10" "perl v5.10.1" "User Contributed Perl Documentation"
.TH SQUIDANALYZER 1 "2012-12-16" "perl v5.10.1" "User Contributed Perl Documentation"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l

View File

@ -264,8 +264,18 @@ sorttable = {
return aa-bb;
},
sort_alpha: function(a,b) {
if (a[0]==b[0]) return 0;
if (a[0]<b[0]) return -1;
// SquidAnalyzer: remove percentage for numeric sort
if (a[0].replace(/ <.*\(.*%\).*/, '')) {
b[0].replace(/ <.*\(.*%\).*/,'');
aa = parseFloat(a[0].replace(/[^0-9.-]/g,''));
if (isNaN(aa)) aa = 0;
bb = parseFloat(b[0].replace(/[^0-9.-]/g,''));
if (isNaN(bb)) bb = 0;
return aa-bb;
} else {
if (a[0]==b[0]) return 0;
if (a[0]<b[0]) return -1;
}
return 1;
},
sort_ddmm: function(a,b) {