-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
149 lines (127 loc) · 7.59 KB
/
index.html
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
<title>CrytpoConverter</title>
</head>
<body>
<header><img class="logo" src="img/LogoHeader.jpeg" alt="cryptoconverter"></header>
<div class="container">
<div class="row">
<div class="col-md-6">
<div class="card">
<div class="card-header">
<h3>Convertir</h3>
</div>
<div class="card-body">
<form method="post">
<div class="form-group">
<label for="crypto">Crypto</label>
<select name="crypto" id="crypto" class="form-control">
<option value="BTC">Bitcoin</option>
<option value="ETH">Ethereum</option>
<option value="XRP">Ripple</option>
<option value="BCH">Bitcoin Cash</option>
<option value="LTC">Litecoin</option>
<option value="XLM">Stellar</option>
<option value="ADA">Cardano</option>
<option value="XMR">Monero</option>
<option value="DASH">Dash</option>
<option value="EOS">EOS</option>
<option value="NEO">NEO</option>
<option value="XEM">NEM</option>
<option value="MIOTA">IOTA</option>
<option value="TRX">TRON</option>
<option value="ETC">Ethereum Classic</option>
<option value="LSK">Lisk</option>
<option value="XVG">Verge</option>
<option value="OMG">OmiseGO</option>
<option value="BTG">Bitcoin Gold</option>
<option value="ZEC">Zcash</option>
<option value="QTUM">Qtum</option>
<option value="DOGE">Dogecoin</option>
<option value="BCN">Bytecoin</option>
<option value="ZRX">0x</option>
</select>
</div>
<div class="form-group">
<label for="devise">Devise</label>
<select name="devise" id="devise" class="form-control">
<option value="EUR">Euro</option>
<option value="USD">Dollar</option>
<option value="GBP">Livre sterling</option>
<option value="AUD">Dollar australien</option>
<option value="CAD">Dollar canadien</option>
<option value="CHF">Franc suisse</option>
<option value="JPY">Yen</option>
<option value="CNY">Yuan renminbi</option>
<option value="NZD">Dollar néo-zélandais</option>
<option value="SGD">Dollar de Singapour</option>
<option value="SEK">Couronne suédoise</option>
<option value="PLN">Zloty</option>
<option value="NOK">Couronne norvégienne</option>
<option value="KRW">Won</option>
<option value="TRY">Lira turque</option>
<option value="RUB">Rouble</option>
<option value="INR">Roupie indienne</option>
<option value="BRL">Real</option>
<option value="ZAR">Rand</option>
<option value="MYR">Ringgit</option>
<option value="PHP">Peso philippin</option>
<option value="IDR">Rupiah</option>
<option value="THB">Baht</option>
<option value="VND">Dong</option>
<option value="MXN">Peso mexicain</option>
<option value="CZK">Couronne tchèque</option>
<option value="HUF">Forint</option>
</select>
</div>
<div class="form-group">
<label for="montant">Montant</label>
<input type="text" name="montant" id="montant" class="form-control">
</div>
<button type="submit" id="submit" class="btn btn-primary">Convertir</button>
</form>
</div>
</div>
</div>
<div class="col-md-6">
<div class="card">
<div class="card-header">
<h3>Résultat</h3>
</div>
<div class="card-body">
<p id="montants"> </p> <p id="cryptos"> </p> <p> = </p> <p id="resultat"> </p> <p id="devises"> </p>
</div>
<script>
document.getElementById('submit').onclick = async (e) => {
e.preventDefault();
var crypto = document.getElementById('crypto').value;
var devise = document.getElementById('devise').value;
var montant = document.getElementById('montant').value;
var url = 'https://min-api.cryptocompare.com/data/price?fsym=' + crypto + '&tsyms=' + devise;
var response = await fetch(url);
var data = await response.json();
console.log(data)
var resultat = data[devise] * montant;
console.log(resultat);
document.getElementById('resultat').innerHTML = resultat;
console.log(montant);
document.getElementById('montants').innerHTML = montant;
console.log(crypto);
document.getElementById('cryptos').innerHTML = crypto;
console.log(devise);
document.getElementById('devises').innerHTML = devise;
}
</script>
</div>
</div>
</div>
</div>
</div>
</body>
</html>