mirror of
https://github.com/Mottie/tablesorter.git
synced 2024-12-05 05:04:20 +00:00
2 lines
890 B
JavaScript
2 lines
890 B
JavaScript
/*! Parser: distance */
|
|
!function(t){"use strict";var e=t.tablesorter;e.symbolRegex=/[\u215b\u215c\u215d\u215e\u00bc\u00bd\u00be]/g,e.processFractions=function(r,s){if(r){var a,n=0;r=t.trim(r.replace(/\"/,"")),/\s/.test(r)&&(n=e.formatFloat(r.split(" ")[0],s),r=t.trim(r.substring(r.indexOf(" "),r.length))),/\//g.test(r)?(a=r.split("/"),r=n+parseInt(a[0],10)/parseInt(a[1]||1,10)):e.symbolRegex.test(r)&&(r=n+r.replace(e.symbolRegex,function(t){return{"⅛":".125","⅜":".375","⅝":".625","⅞":".875","¼":".25","½":".5","¾":".75"}[t]}))}return r||0},t.tablesorter.addParser({id:"distance",is:function(){return!1},format:function(t,r){if(""===t)return"";var s=/^\s*\S*(\s+\S+)?\s*\'/.test(t)?t.split(/\'/):[0,t],a=e.processFractions(s[0],r),n=e.processFractions(s[1],r);return/[\'\"]/.test(t)?parseFloat(a)+(parseFloat(n)/12||0):parseFloat(a)+parseFloat(n)},type:"numeric"})}(jQuery); |