Repository navigation
Expand file tree
/
Copy pathgcoin.html
More file actions
89 lines (77 loc) · 2.33 KB
/
Copy pathgcoin.html
File metadata and controls
89 lines (77 loc) · 2.33 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>gcoins to usd converter</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
padding: 20px;
max-width: 400px;
margin: auto;
}
.converter {
background: #fff;
padding: 20px;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
input[type="number"] {
width: 100%;
padding: 10px;
margin: 10px 0;
border-radius: 5px;
border: 1px solid #ccc;
}
button {
width: 100%;
padding: 10px;
background-color: #007bff;
color: #fff;
border: none;
border-radius: 5px;
cursor: pointer;
}
button:hover {
background-color: #0056b3;
}
.result {
margin: 10px 0;
font-weight: bold;
}
</style>
</head>
<body>
<div class="converter">
<h2>gcoins to usd converter</h2>
<label for="gcoins">enter gcoins:</label>
<input type="number" id="gcoins" placeholder="enter gcoins">
<div class="result" id="usdResult"></div>
<button onclick="gcoinsToUsd()">convert to usd</button>
<hr>
<label for="usd">enter usd:</label>
<input type="number" id="usd" placeholder="enter usd">
<div class="result" id="gcoinsResult"></div>
<button onclick="usdToGcoins()">convert to gcoins</button>
</div>
<script>
function gcoinsToUsd() {
const gcoins = document.getElementById('gcoins').value;
const usd = gcoins / 50000;
document.getElementById('usdResult').textContent = `usd: $${formatWithCommas(usd.toFixed(2))}`;
}
function usdToGcoins() {
const usd = document.getElementById('usd').value;
const gcoins = usd * 50000;
document.getElementById('gcoinsResult').textContent = `gcoins: ${formatWithCommas(gcoins.toFixed(0))}`;
}
function formatWithCommas(x) {
const parts = x.toString().split(".");
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
return parts.join(".");
}
</script>
</body>
</html>