mirror of
https://github.com/Mottie/tablesorter.git
synced 2024-11-15 23:54:22 +00:00
a69a746fdf
Removed `$columnHeader` & replaced it with new `$headerIndexed` variable
7 lines
1.5 KiB
JavaScript
7 lines
1.5 KiB
JavaScript
/*! Metric parser
|
|
* Demo: http://jsfiddle.net/Mottie/abkNM/382/
|
|
* Set the metric name in the header (defaults to "m|meter"), e.g.
|
|
* <th data-metric-name="b|byte">HDD Size</th>
|
|
* <th data-metric-name="m|meter">Distance</th>
|
|
*/
|
|
!function(a){"use strict";var b={"Y|Yotta|yotta":[1e24,Math.pow(1024,8)],"Z|Zetta|zetta":[1e21,Math.pow(1024,7)],"E|Exa|exa":[1e18,Math.pow(1024,6)],"P|Peta|peta":[1e15,Math.pow(1024,5)],"T|Tera|tera":[1e12,Math.pow(1024,4)],"G|Giga|giga":[1e9,Math.pow(1024,3)],"M|Mega|mega":[1e6,Math.pow(1024,2)],"k|Kilo|kilo":[1e3,1024],"h|hecto":[100,100],"da|deka":[10,10],"d|deci":[.1,.1],"c|centi":[.01,.01],"m|milli":[.001,.001],"µ|micro":[1e-6,1e-6],"n|nano":[1e-9,1e-9],"p|pico":[1e-12,1e-12],"f|femto":[1e-15,1e-15],"a|atto":[1e-18,1e-18],"z|zepto":[1e-21,1e-21],"y|yocto":[1e-24,1e-24]},c="(\\d+)(\\s+)?([Zz]etta|[Ee]xa|[Pp]eta|[Tt]era|[Gg]iga|[Mm]ega|kilo|hecto|deka|deci|centi|milli|micro|nano|pico|femto|atto|zepto|yocto)(",d="(\\d+)(\\s+)?(Z|E|P|T|G|M|k|h|da|d|c|m|µ|n|p|f|a|z|y)(";a.tablesorter.addParser({id:"metric",is:function(){return!1},format:function(e,f,g,h){var i,j,k="m|meter",l=a.tablesorter.formatFloat(e.replace(/[^\w,. \-()]/g,""),f),m=f.config.$headerIndexed[h],n=m.data("metric");if(n||(j=(m.attr("data-metric-name")||k).split("|"),n=[j[1]||j[0].substring(1),j[0]],n[2]=new RegExp(c+n[0]+"|"+n[1]+")"),n[3]=new RegExp(d+n[1]+")"),m.data("metric",n)),j=e.match(n[2])||e.match(n[3]))for(k in b)if(j[3].match(k))return i=/^[b|bit|byte|o|octet]/.test(j[4])?1:0,l*b[k][i];return l},type:"numeric"})}(jQuery); |