From b0b912ae35b2e303042627ba0b5170d7b7660efe Mon Sep 17 00:00:00 2001 From: Rob Garrison Date: Tue, 23 Feb 2016 11:50:44 -0600 Subject: [PATCH] Parser: Add huge number parser. See #1161 --- dist/js/parsers/parser-huge-numbers.min.js | 2 ++ js/parsers/parser-huge-numbers.js | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 dist/js/parsers/parser-huge-numbers.min.js create mode 100644 js/parsers/parser-huge-numbers.js diff --git a/dist/js/parsers/parser-huge-numbers.min.js b/dist/js/parsers/parser-huge-numbers.min.js new file mode 100644 index 00000000..0727dad9 --- /dev/null +++ b/dist/js/parsers/parser-huge-numbers.min.js @@ -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); \ No newline at end of file diff --git a/js/parsers/parser-huge-numbers.js b/js/parsers/parser-huge-numbers.js new file mode 100644 index 00000000..f23a699b --- /dev/null +++ b/js/parsers/parser-huge-numbers.js @@ -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 );