working
This commit is contained in:
parent
37b9722643
commit
4bd7dfc7ff
1 changed files with 9 additions and 11 deletions
|
|
@ -4,7 +4,7 @@ const BuyOrSellButtonGroup = require('../components/BuyOrSellButtonGroup');
|
|||
const PremiumSelector = require('../components/PremiumSelector');
|
||||
const PriceDisplay = require('../components/PriceDisplay');
|
||||
|
||||
function readIntFromEurAmountInput() {
|
||||
function readIntFromEurAmountInput(eurAmountInput) {
|
||||
const eurAmountFieldValue = eurAmountInput.value;
|
||||
const regularExpression = /([\d\s]+)/;
|
||||
const matchResult = eurAmountFieldValue.match(regularExpression);
|
||||
|
|
@ -19,8 +19,8 @@ function readIntFromEurAmountInput() {
|
|||
return cleanInputNumber;
|
||||
}
|
||||
|
||||
function validateAndFormatEurAmountInput() {
|
||||
const cleanInputNumber = readIntFromEurAmountInput();
|
||||
function validateAndFormatEurAmountInput(eurAmountInput) {
|
||||
const cleanInputNumber = readIntFromEurAmountInput(eurAmountInput);
|
||||
eurAmountInput.classList.remove('input-is-valid', 'input-is-invalid');
|
||||
if (cleanInputNumber) {
|
||||
eurAmountInput.value = formatNumberWithSpaces(cleanInputNumber);
|
||||
|
|
@ -31,9 +31,9 @@ function validateAndFormatEurAmountInput() {
|
|||
eurAmountInput.classList.add('input-is-invalid');
|
||||
}
|
||||
|
||||
function updateBtcInput() {
|
||||
function updateBtcInput(eurInput, btcAmountInput) {
|
||||
const eurToSatRate = 1021;
|
||||
const cleanEurAmount = readIntFromEurAmountInput();
|
||||
const cleanEurAmount = readIntFromEurAmountInput(eurInput);
|
||||
|
||||
const satsAmount = cleanEurAmount * eurToSatRate;
|
||||
const formattedSatsAmount = formatNumberWithSpaces(satsAmount);
|
||||
|
|
@ -102,13 +102,13 @@ class AmountInput {
|
|||
amountArea.appendChild(btcAmount);
|
||||
|
||||
eurInput.addEventListener('blur', () => {
|
||||
validateAndFormatEurAmountInput();
|
||||
updateBtcInput();
|
||||
validateAndFormatEurAmountInput(eurInput);
|
||||
updateBtcInput(eurInput, btcInput);
|
||||
});
|
||||
|
||||
eurInput.addEventListener('input', () => {
|
||||
eurAmountInput.value = eurAmountInput.value.replace(/[^0-9]/g, '');
|
||||
updateBtcInput();
|
||||
eurInput.value = eurInput.value.replace(/[^0-9]/g, '');
|
||||
updateBtcInput(eurInput, btcInput);
|
||||
});
|
||||
|
||||
this.element = amountArea;
|
||||
|
|
@ -760,8 +760,6 @@ function offersPage() {
|
|||
applyTrustCheckboxConstraints(allMembersCheckbox);
|
||||
});
|
||||
|
||||
updateBtcInput();
|
||||
|
||||
const myOffers = new MyOffers(ownOffersContainer);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue