Parser: Add huge number parser. See #1161

This commit is contained in:
Rob Garrison 2016-02-23 11:50:44 -06:00
parent b31a1a61cd
commit b0b912ae35
2 changed files with 23 additions and 0 deletions

View File

@ -0,0 +1,2 @@
/*! Parser: hugeNumbers - updated 2/23/2016 (v2.25.5) */
!function(a){"use strict";a.tablesorter.addParser({id:"hugeNumbers",is:function(){return!1},format:function(a){return a.replace(/\B(?=(\d{12})+(?!\d))/g,",")},type:"text"})}(jQuery);

View File

@ -0,0 +1,21 @@
/*! Parser: hugeNumbers - updated 2/23/2016 (v2.25.5) *//*
* See https://github.com/Mottie/tablesorter/issues/1161
*/
/*jshint jquery:true */
;( function( $ ) {
'use strict';
$.tablesorter.addParser({
id: 'hugeNumbers',
is : function() {
return false;
},
format : function( str ) {
// add commas every 12 digits; Number.MAX_SAFE_INTEGER is 16 digits long
// regex modified from: http://stackoverflow.com/a/2901298/145346
return str.replace(/\B(?=(\d{12})+(?!\d))/g, ",");
},
type : 'text'
});
})( jQuery );