-
Notifications
You must be signed in to change notification settings - Fork 1
/
popup.js
29 lines (23 loc) · 914 Bytes
/
popup.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
function converter(numero) {
var request = new XMLHttpRequest();
request.open("GET", "https://api.coingecko.com/api/v3/simple/price?ids=lbry-credits&vs_currencies=usd");
request.send();
request.onload = () => {
if (request.status == 200) {
var response = JSON.parse(request.responseText);
}
}
request.onload = () => {
if (request.status == 200) {
var response = JSON.parse(request.responseText);
var result_tofix = response['lbry-credits'].usd * numero
document.querySelector('#result').textContent = result_tofix.toFixed(4) + " USD";
}
}
}
document.addEventListener("DOMContentLoaded", function() {
document.querySelector('#btn').addEventListener('click', function() {
let numero = document.querySelector('#numero').value;
converter(numero);
})
})