function into method
This commit is contained in:
parent
4bd7dfc7ff
commit
5d21258634
1 changed files with 11 additions and 11 deletions
|
|
@ -31,15 +31,6 @@ function validateAndFormatEurAmountInput(eurAmountInput) {
|
|||
eurAmountInput.classList.add('input-is-invalid');
|
||||
}
|
||||
|
||||
function updateBtcInput(eurInput, btcAmountInput) {
|
||||
const eurToSatRate = 1021;
|
||||
const cleanEurAmount = readIntFromEurAmountInput(eurInput);
|
||||
|
||||
const satsAmount = cleanEurAmount * eurToSatRate;
|
||||
const formattedSatsAmount = formatNumberWithSpaces(satsAmount);
|
||||
btcAmountInput.value = formattedSatsAmount;
|
||||
}
|
||||
|
||||
class AmountInput {
|
||||
constructor({ parentElement, id }) {
|
||||
this.element = null;
|
||||
|
|
@ -103,17 +94,26 @@ class AmountInput {
|
|||
|
||||
eurInput.addEventListener('blur', () => {
|
||||
validateAndFormatEurAmountInput(eurInput);
|
||||
updateBtcInput(eurInput, btcInput);
|
||||
this.updateBtcInput(eurInput, btcInput);
|
||||
});
|
||||
|
||||
eurInput.addEventListener('input', () => {
|
||||
eurInput.value = eurInput.value.replace(/[^0-9]/g, '');
|
||||
updateBtcInput(eurInput, btcInput);
|
||||
this.updateBtcInput(eurInput, btcInput);
|
||||
});
|
||||
|
||||
this.element = amountArea;
|
||||
this.parentElement.appendChild(this.element);
|
||||
}
|
||||
|
||||
updateBtcInput(eurInput, btcAmountInput) {
|
||||
const eurToSatRate = 1021;
|
||||
const cleanEurAmount = readIntFromEurAmountInput(eurInput);
|
||||
|
||||
const satsAmount = cleanEurAmount * eurToSatRate;
|
||||
const formattedSatsAmount = formatNumberWithSpaces(satsAmount);
|
||||
btcAmountInput.value = formattedSatsAmount;
|
||||
}
|
||||
}
|
||||
|
||||
function offersPage() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue