Skip to content

Commit

Permalink
Utils: handle formatting parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
SoulRiaper committed Dec 5, 2024
1 parent dbf176d commit 407a258
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions source-web/js/common/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,15 +216,15 @@ function zeroPref (n) {
return n > 9 ? String(n) : '0' + n;
}

Util.formatValue = function (value) {
Util.formatValue = function (value, options = {}) {
let formatted;
switch (true) {
case value instanceof Date:
formatted = formatDate(value);
break;
case value instanceof Number:
case typeof value === 'number':
formatted = formatNumber(value);
formatted = formatNumber(value, options.unspaceNumber == 'true');
break;
case value instanceof String:
case typeof value === 'string':
Expand Down Expand Up @@ -283,11 +283,11 @@ function formatDate (date) {
* @param {number} n
* @return {string}
*/
function formatNumber (n) {
function formatNumber (n, unspace) {
return Number(n).toLocaleString('ru-RU', {
minimumFractionDigits: 0,
maximumFractionDigits: 20,
}).replace(/\s/g, ' ');
}).replace(/\s/g, unspace ? '' : ' ');
}

/*
Expand Down

0 comments on commit 407a258

Please sign in to comment.