Take sats as whole numbers in the browser too
This commit is contained in:
1 parent
d12df91acc
commit
2bc257004d
1 file changed
+8
-9
+8
-9
@@ -85,18 +85,17 @@
|
|||||||
return parts[2] + "." + parts[1] + "." + parts[0];
|
return parts[2] + "." + parts[1] + "." + parts[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Whole sats, with spaces allowed as thousands separators. Anything carrying
|
||||||
|
a decimal separator gives null, like the server does. */
|
||||||
function parseSats(text) {
|
function parseSats(text) {
|
||||||
var cleaned = String(text === null || text === undefined ? "" : text)
|
var cleaned = String(text === null || text === undefined ? "" : text);
|
||||||
.split(NARROW_SPACE).join("")
|
THOUSANDS_SEPARATORS.forEach(function (separator) {
|
||||||
.split(" ").join("")
|
cleaned = cleaned.split(separator).join("");
|
||||||
.replace(",", ".");
|
});
|
||||||
if (!/^\d*(\.\d{0,8})?$/.test(cleaned) || cleaned === "" || cleaned === ".") {
|
if (!/^-?\d+$/.test(cleaned)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
var parts = cleaned.split(".");
|
return Number(cleaned);
|
||||||
var whole = parts[0] === "" ? "0" : parts[0];
|
|
||||||
var fraction = (parts[1] || "").padEnd(8, "0");
|
|
||||||
return Number(whole) * 100000000 + Number(fraction);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The stored type names and what the owner sees, docs/spec.md section 7.3. */
|
/* The stored type names and what the owner sees, docs/spec.md section 7.3. */
|
||||||
|
|||||||
Reference in new issue
Block a user