Skip to content
Snippets Groups Projects
Commit 9bddfd45 authored by Quoc Huy Nguyen Dinh's avatar Quoc Huy Nguyen Dinh
Browse files

Indentation

parent d5dfb254
No related branches found
No related tags found
3 merge requests!137Closes #36,!133Fix: Governance expiry warning should have proper year at all times,!132Witnesses page fixes
......@@ -7,8 +7,14 @@ function fractional_part_len(value) {
// FIXME this should be unit tested.. here is one bug: 501,695,.505
export function formatDecimal(value, decPlaces = 2, truncate0s = true) {
let decSeparator, fl, i, j, sign, thouSeparator, abs_value;
if (value === null || value === void 0 || isNaN(value)) {
let fl;
if (
value === null ||
// eslint-disable-next-line no-void
value === void 0 ||
// eslint-disable-next-line no-restricted-globals
isNaN(value)
) {
return ['N', 'a', 'N'];
}
if (truncate0s) {
......@@ -16,12 +22,12 @@ export function formatDecimal(value, decPlaces = 2, truncate0s = true) {
if (fl < 2) fl = 2;
if (fl < decPlaces) decPlaces = fl;
}
decSeparator = '.';
thouSeparator = ',';
sign = value < 0 ? '-' : '';
abs_value = Math.abs(value);
i = parseInt(abs_value.toFixed(decPlaces), 10) + '';
j = i.length;
const decSeparator = '.';
const thouSeparator = ',';
const sign = value < 0 ? '-' : '';
const abs_value = Math.abs(value);
const i = parseInt(abs_value.toFixed(decPlaces), 10) + '';
let j = i.length;
j = i.length > 3 ? j % 3 : 0;
const decPart = decPlaces
? decSeparator +
......@@ -60,8 +66,10 @@ export const repLog10 = (rep2) => {
rep = neg ? rep.substring(1) : rep;
let out = log10(rep);
// eslint-disable-next-line no-restricted-globals
if (isNaN(out)) out = 0;
out = Math.max(out - 9, 0); // @ -9, $0.50 earned is approx magnitude 1
// eslint-disable-next-line operator-assignment
out = (neg ? -1 : 1) * out;
out = out * 9 + 25; // 9 points per magnitude. center at 25
// base-line 0 to darken and < 0 to auto hide (grep rephide)
......@@ -72,7 +80,7 @@ export const repLog10 = (rep2) => {
export function countDecimals(amount) {
if (amount == null) return amount;
amount = String(amount)
.match(/[\d\.]+/g)
.match(/[\d.]+/g)
.join(''); // just dots and digits
const parts = amount.split('.');
return parts.length > 2
......@@ -94,7 +102,7 @@ export function formatLargeNumber(number, decimals) {
];
const regexp = /\.0+$|(\.[0-9]*[1-9])0+$/;
for (let i = symbols.length - 1; i > 0; i--) {
for (let i = symbols.length - 1; i > 0; i -= 1) {
if (number >= symbols[i].value) {
return (
(number / symbols[i].value)
......@@ -103,6 +111,8 @@ export function formatLargeNumber(number, decimals) {
);
}
}
return number;
}
// this function searches for right translation of provided error (usually from back-end)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment