mirror of
https://github.com/Mottie/tablesorter.git
synced 2024-11-15 23:54:22 +00:00
2 lines
1.1 KiB
JavaScript
2 lines
1.1 KiB
JavaScript
/*! Parser: roman - updated 6/28/MMXIV (v2.17.3) */
|
|
!function(r){"use strict";var t=/^M*(?:D?C{0,3}|C[MD])(?:L?X{0,3}|X[CL])(?:V?I{0,3}|I[XV])$/i,e=/\b([MCDLXVI]+\b)/gi,n={I:1,V:5,X:10,L:50,C:100,D:500,M:1e3};r.tablesorter.addParser({id:"roman",is:function(){return!1},format:function(r){var e,i=r.toUpperCase().split(""),a=0;if(!r||!t.test(r))return r;for(;i.length;)a+=(e=n[i.shift()])*(e<n[i[0]]?-1:1);return a},type:"numeric"}),r.tablesorter.addParser({id:"roman-ignore",is:function(){return!1},format:function(i,a,o,s){var u,f,c=a.config,p=r.isArray(c.roman_ignore)?c.roman_ignore[s]:0,m=(isNaN(p)?r.trim(i.replace(p,"")):r.trim(i.substring(0,i.length-p))).match(e),l=0;if(!t.test(m))return i;for(m=(f=m[0]).toUpperCase().split("");m.length;)(u=n[m.shift()])&&(l+=u*(u<n[m[0]]?-1:1));return l?i.replace(f,l):i},type:"text"}),r.tablesorter.addParser({id:"roman-extract",is:function(){return!1},format:function(i){var a,o=r.grep(i.split(/\b/),function(r,e){return t.test(r)?r:""}).join("").match(e),s=0;if(!(o?t.test(o):0))return i;for(o=o[0].toUpperCase().split("");o.length;)(a=n[o.shift()])&&(s+=a*(a<n[o[0]]?-1:1));return s||i},type:"numeric"})}(jQuery); |