| 1 |
|
| 2 |
|
| 3 |
. |
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
;(function($) { |
| 8 |
'use strict'; |
| 9 |
|
| 10 |
var ts = $.tablesorter; |
| 11 |
ts.symbolRegex = /[\u215b\u215c\u215d\u215e\u00bc\u00bd\u00be]/g; |
| 12 |
ts.processFractions = function(n, table) { |
| 13 |
if (n) { |
| 14 |
var t, p = 0; |
| 15 |
n = $.trim(n.replace(/\"/, '')); |
| 16 |
|
| 17 |
if (/\s/.test(n)) { |
| 18 |
p = ts.formatFloat(n.split(' ')[0], table); |
| 19 |
|
| 20 |
n = $.trim(n.substring(n.indexOf(' '), n.length)); |
| 21 |
} |
| 22 |
|
| 23 |
if (/\//g.test(n)) { |
| 24 |
t = n.split('/'); |
| 25 |
|
| 26 |
n = p + parseInt(t[0], 10) / parseInt(t[1] || 1, 10); |
| 27 |
|
| 28 |
} else if (ts.symbolRegex.test(n)) { |
| 29 |
n = p + n.replace(ts.symbolRegex, function(m) { |
| 30 |
return { |
| 31 |
'\u215b' : '.125', |
| 32 |
'\u215c' : '.375', |
| 33 |
'\u215d' : '.625', |
| 34 |
'\u215e' : '.875', |
| 35 |
'\u00bc' : '.25', |
| 36 |
'\u00bd' : '.5', |
| 37 |
'\u00be' : '.75' |
| 38 |
}[m]; |
| 39 |
}); |
| 40 |
} |
| 41 |
} |
| 42 |
return n || 0; |
| 43 |
}; |
| 44 |
|
| 45 |
$.tablesorter.addParser({ |
| 46 |
id: 'distance', |
| 47 |
is: function() { |
| 48 |
|
| 49 |
return false; |
| 50 |
}, |
| 51 |
format: function(s, table) { |
| 52 |
if (s === '') { return ''; } |
| 53 |
|
| 54 |
' |
| 55 |
var d = (/^\s*\S*(\s+\S+)?\s*\'/.test(s)) ? s.split(/\'/) : [ 0, s ], |
| 56 |
f = ts.processFractions(d[0], table), |
| 57 |
i = ts.processFractions(d[1], table); |
| 58 |
return (/[\'\"]/).test(s) ? parseFloat(f) + (parseFloat(i) / 12 || 0) : parseFloat(f) + parseFloat(i); |
| 59 |
}, |
| 60 |
type: 'numeric' |
| 61 |
}); |
| 62 |
|
| 63 |
})(jQuery); |