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