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');
|
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 {
|
class AmountInput {
|
||||||
constructor({ parentElement, id }) {
|
constructor({ parentElement, id }) {
|
||||||
this.element = null;
|
this.element = null;
|
||||||
|
|
@ -103,17 +94,26 @@ class AmountInput {
|
||||||
|
|
||||||
eurInput.addEventListener('blur', () => {
|
eurInput.addEventListener('blur', () => {
|
||||||
validateAndFormatEurAmountInput(eurInput);
|
validateAndFormatEurAmountInput(eurInput);
|
||||||
updateBtcInput(eurInput, btcInput);
|
this.updateBtcInput(eurInput, btcInput);
|
||||||
});
|
});
|
||||||
|
|
||||||
eurInput.addEventListener('input', () => {
|
eurInput.addEventListener('input', () => {
|
||||||
eurInput.value = eurInput.value.replace(/[^0-9]/g, '');
|
eurInput.value = eurInput.value.replace(/[^0-9]/g, '');
|
||||||
updateBtcInput(eurInput, btcInput);
|
this.updateBtcInput(eurInput, btcInput);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.element = amountArea;
|
this.element = amountArea;
|
||||||
this.parentElement.appendChild(this.element);
|
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() {
|
function offersPage() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue