-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
35 lines (26 loc) · 975 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
//elemnt seçimi
const amountElement = document.getElementById("amount");
const firstSelect = document.getElementById("firstCurrency");
const secondSelect = document.getElementById("secondCurrency");
const ui = new Ui(firstSelect, secondSelect);
const currency = new Currency("USD", "TRY");
eventListeners();
function eventListeners() {
amountElement.addEventListener("input", exchangeCurrency);
firstSelect.onchange = function () {
currency.changeFirstSelect(firstSelect.options[firstSelect.selectedIndex].textContent);
ui.changeFirst();
};
secondSelect.onchange = function () {
currency.changeSecondSelect(secondSelect.options[secondSelect.selectedIndex].textContent);
ui.changeSecond();
};
}
function exchangeCurrency() {
currency.changeAmount(amountElement.value);
currency.exchange()
.then(result => {
ui.changeResult(result);
})
.catch(err => console.log(err));
}