change digits function to use unicode 'thin space' as thousands seperator

This commit is contained in:
Jon Atkins 2013-12-18 22:41:55 +00:00 committed by Philipp Schaefer
parent d8dc9d4722
commit e9219c5e3a

View File

@ -122,7 +122,9 @@ window.convertCookieToLocalStorage = function(name) {
// add thousand separators to given number. // add thousand separators to given number.
// http://stackoverflow.com/a/1990590/1684530 by Doug Neiner. // http://stackoverflow.com/a/1990590/1684530 by Doug Neiner.
window.digits = function(d) { window.digits = function(d) {
return (d+"").replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1 "); // U+2009 - Thin Space. Recommended for use as a thousands separator...
// https://en.wikipedia.org/wiki/Space_(punctuation)#Table_of_spaces
return (d+"").replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1 ");
} }