-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
91 lines (67 loc) · 2.29 KB
/
index.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
const input = document.querySelector("input.amount")
const container = document.querySelector(".master-container")
const button = document.querySelector(".button")
const currencySwitcher = document.querySelector(".dropdown-button")
const currencyContainer = document.querySelector(".currency-container")
const confirmationContainer = document.querySelector(".confirmation")
const close = document.querySelector(".close")
const exit = document.querySelector(".exit")
const beka = document.querySelector(".amount-to-pay-container:before")
const clickCopy = document.querySelector("#click-to-copy")
const copied = document.querySelector(".copied-to-clipboard")
const convertedAmount = document.querySelector(".chosen-currency-amount")
const usdValue = document.querySelector(".usd-value")
let value = "0"
shrink = function () {
container.classList.add("shrink")
}
enlarge = function () {
container.classList.remove("shrink")
}
input.addEventListener("focus", function () {
shrink()
})
input.addEventListener("blur", function () {
enlarge()
})
currencySwitcher.addEventListener("click", function() {
currencyContainer.classList.add("visible")
})
close.addEventListener("click", function() {
currencyContainer.classList.remove("visible")
})
exit.addEventListener("click", function() {
window.location.reload(false)
})
clickCopy.addEventListener("click", function() {
copied.classList.add("copied")
})
input.addEventListener("keyup", function(event) {
if (input.value > 0) {
button.classList.remove("disabled")
}
if (input.value <= 0) {
button.classList.add("disabled")
}
roundtoThree = function(num) {
return +(Math.round(num + "e+3") + "e-3");
}
convertedAmount.innerHTML = input.value
usdValue.innerHTML = input.value
return value = input.value
})
button.addEventListener("click", function(event){
console.log('hehe')
event.preventDefault()
if (value > 0) {
console.log('it works!')
confirmationContainer.classList.add("visible")
confirmationContainer.classList.add("ontop")
}
if (value <= 0) {
shrink()
input.focus()
container.classList.remove("animate-disabled")
setTimeout(() => container.classList.add("animate-disabled"), 0)
}
})