Repository navigation
Expand file tree
/
Copy pathscript.js
More file actions
134 lines (122 loc) · 5.61 KB
/
Copy pathscript.js
File metadata and controls
134 lines (122 loc) · 5.61 KB
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
let clicked = false
let livePrice = document.querySelector(".p-text")
fetch("https://api.coingecko.com/api/v3/coins/bitcoin")
.then(response => response.json())
.then(data => leftButton.innerHTML = data.name)
let logo = document.querySelector(".logo1")
let logo2 = document.querySelector(".logo2")
let btc = document.querySelector(".bitcoin")
let btcDesc = document.querySelector(".btcDesc")
let leftButton = document.querySelector(".leftButton")
leftButton.addEventListener("click", function (e) {
fetch("https://api.coingecko.com/api/v3/coins/bitcoin")
.then(response => response.json())
.then(data => btc.innerHTML = data.name)
fetch("https://api.coingecko.com/api/v3/coins/bitcoin")
.then(response => response.json())
.then(data => btcDesc.innerHTML = data.description.en)
fetch("https://api.coingecko.com/api/v3/coins/bitcoin")
.then(response => response.json())
.then(data => logo.src = data.image.small)
fetch("https://api.coingecko.com/api/v3/coins/bitcoin")
.then(response => response.json())
.then(data => logo2.src = data.image.small)
fetch("https://api.coingecko.com/api/v3/coins/bitcoin")
.then(response => response.json())
.then(data => livePrice.innerHTML ="Last Bitcoin Price: $" + data.market_data.current_price.usd)
leftButton.style.backgroundColor = "black";
leftButton.style.color = "white"
rightButton.style.backgroundColor = "lightgray"
rightButton.style.color = "black"
button3.style.backgroundColor = "lightgray"
button3.style.color = "black"
button4.style.backgroundColor = "lightgray"
button4.style.color = "black"
})
fetch("https://api.coingecko.com/api/v3/coins/ethereum")
.then(response => response.json())
.then(data => rightButton.innerHTML = data.name)
let rightButton = document.querySelector(".buttonRight")
rightButton.addEventListener("click", function (e) {
fetch("https://api.coingecko.com/api/v3/coins/ethereum")
.then(response => response.json())
.then(data => btc.innerHTML = data.name)
fetch("https://api.coingecko.com/api/v3/coins/ethereum")
.then(response => response.json())
.then(data => btcDesc.innerHTML = data.description.en)
fetch("https://api.coingecko.com/api/v3/coins/ethereum")
.then(response => response.json())
.then(data => logo.src = data.image.small)
fetch("https://api.coingecko.com/api/v3/coins/ethereum")
.then(response => response.json())
.then(data => logo2.src = data.image.small)
fetch("https://api.coingecko.com/api/v3/coins/ethereum")
.then(response => response.json())
.then(data => livePrice.innerHTML ="Last Eth Price: $" + data.market_data.current_price.usd)
rightButton.style.backgroundColor = "black";
rightButton.style.color = "white"
leftButton.style.backgroundColor = "lightgray"
leftButton.style.color = "black"
button3.style.backgroundColor = "lightgray"
button3.style.color = "black"
button4.style.backgroundColor = "lightgray"
button4.style.color = "black"
})
let button3 = document.querySelector(".button3")
fetch("https://api.coingecko.com/api/v3/coins/polkadot")
.then(response => response.json())
.then(data => button3.innerHTML = data.name)
button3.addEventListener("click", function (e) {
fetch("https://api.coingecko.com/api/v3/coins/polkadot")
.then(response => response.json())
.then(data => btc.innerHTML = data.name)
fetch("https://api.coingecko.com/api/v3/coins/polkadot")
.then(response => response.json())
.then(data => btcDesc.innerHTML = data.description.en)
fetch("https://api.coingecko.com/api/v3/coins/polkadot")
.then(response => response.json())
.then(data => logo.src = data.image.small)
fetch("https://api.coingecko.com/api/v3/coins/polkadot")
.then(response => response.json())
.then(data => logo2.src = data.image.small)
fetch("https://api.coingecko.com/api/v3/coins/polkadot")
.then(response => response.json())
.then(data => livePrice.innerHTML ="Last Polkadot Price: $" + data.market_data.current_price.usd)
button3.style.backgroundColor = "black";
button3.style.color = "white"
leftButton.style.backgroundColor = "lightgray"
leftButton.style.color = "black"
rightButton.style.backgroundColor = "lightgray"
rightButton.style.color = "black"
button4.style.backgroundColor = "lightgray"
button4.style.color = "black"
})
let button4 = document.querySelector(".button4")
fetch("https://api.coingecko.com/api/v3/coins/dogecoin")
.then(response => response.json())
.then(data => button4.innerHTML = data.name)
button4.addEventListener("click", function (e) {
fetch("https://api.coingecko.com/api/v3/coins/dogecoin")
.then(response => response.json())
.then(data => btc.innerHTML = data.name)
fetch("https://api.coingecko.com/api/v3/coins/dogecoin")
.then(response => response.json())
.then(data => btcDesc.innerHTML = data.description.en)
fetch("https://api.coingecko.com/api/v3/coins/dogecoin")
.then(response => response.json())
.then(data => logo.src = data.image.small)
fetch("https://api.coingecko.com/api/v3/coins/dogecoin")
.then(response => response.json())
.then(data => logo2.src = data.image.small)
fetch("https://api.coingecko.com/api/v3/coins/dogecoin")
.then(response => response.json())
.then(data => livePrice.innerHTML ="Last Dogecoin Price: $" + data.market_data.current_price.usd)
button4.style.backgroundColor = "black";
button4.style.color = "white"
leftButton.style.backgroundColor = "lightgray"
leftButton.style.color = "black"
button3.style.backgroundColor = "lightgray"
button3.style.color = "black"
rightButton.style.backgroundColor = "lightgray"
rightButton.style.color = "black"
})