diff options
| author | Adam Soltys <[email protected]> | 2024-04-18 15:20:33 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2024-04-18 15:20:33 -0700 |
| commit | 53d7f4705ec6bdb5252914530447f6a3b9656c0b (patch) | |
| tree | a6275db236dac014beb38048884012c970e2c60f /src/components | |
| parent | 0bc5b95562d0c527d3ced3ab66fbb66ba651d67a (diff) | |
| download | coinos-ui-numpad.tar.gz coinos-ui-numpad.zip | |
wipnumpad
Diffstat (limited to 'src/components')
| -rw-r--r-- | src/components/Numpad.svelte | 47 |
1 files changed, 17 insertions, 30 deletions
diff --git a/src/components/Numpad.svelte b/src/components/Numpad.svelte index 9119999f..efd3fc9a 100644 --- a/src/components/Numpad.svelte +++ b/src/components/Numpad.svelte @@ -43,43 +43,29 @@ KRW: "₩", }[currency] || ""; - const numPad = ["1", "2", "3", "4", "5", "6", "7", "8", "9", ".", "0", "<"]; + const numPad = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "C", "0", "<"]; + let n = ""; const handleInput = (value) => { + console.log("N", n); + console.log("value", value); if (selecting) amount = 0; - selecting = false; if (fiat) { - if (amountFiat === 0 && value !== "." && value !== "<" && value !== "0") { - amountFiat = value; - } else if ((amountFiat === 0 || amountFiat === "0") && value === "0") { - return; - } else if (amountFiat === 0 && value === ".") { - amountFiat = "0."; - } else if ( - amountFiat !== 0 && - amountFiat.includes(".") && - value === "." - ) { - return; + if (value === "C") { + n = ""; } else if (value === "<") { - if (amountFiat !== 0) { - amountFiat = amountFiat.slice(0, amountFiat.length - 1); - if (amountFiat.length === 0) { - amountFiat = 0; - amount = 0; - } - } - } else if ( - value !== "." && - value !== "<" && - parseInt(amountFiat + value) > rate - ) { - warning($t("user.receive.lessThan1BTCWarning")); - } else if (amountFiat !== 0 && amountFiat.match(/\.../)) { - return; + n = n.slice(0, -1); + } else { + n += value; + } + + if (!n) { + amountFiat = "0"; } else { - amountFiat = amountFiat + value; + console.log("BF", amountFiat); + amountFiat = (parseInt(n, 10) / 100).toFixed(2); + console.log("AF", amountFiat); } } else { if (value === ".") { @@ -136,6 +122,7 @@ if (fiat) { amountFiat = html; + n = parseFloat(html).toFixed(2) } else { amount = parseInt(html.replace(/,/g, "")); } |
