-
Notifications
You must be signed in to change notification settings - Fork 1
/
swap.html
340 lines (290 loc) · 10.6 KB
/
swap.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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Purchase VL1</title>
<style>
/* Reset styles */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Arial', sans-serif;
}
body {
background-color: #121212;
color: #fff;
padding: 20px;
font-size: 16px;
}
/* Container */
.swp-container {
max-width: 500px;
margin: 0 auto;
background-color: #1f1f1f;
padding: 20px;
border-radius: 8px;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}
/* Connection Status */
#chainId {
font-size: 14px;
text-align: center;
margin-bottom: 10px;
}
/* Main Title */
h1 {
font-size: 24px;
text-align: center;
margin-bottom: 20px;
}
/* Ratio Info */
.swp-ratio {
text-align: center;
margin-bottom: 20px;
}
.swp-ratio p {
margin: 5px 0;
font-size: 14px;
color: #aaa;
}
/* Input Section */
.swp-input-container {
display: flex;
align-items: center;
margin-bottom: 20px;
}
.swp-input-wrapper {
flex-grow: 1;
position: relative;
}
input[type="text"] {
width: 100%;
padding: 12px 15px;
border-radius: 6px;
border: 1px solid #333;
background-color: #252525;
color: #fff;
font-size: 16px;
transition: border-color 0.3s;
}
input[type="text"]:focus {
border-color: #00ff87;
outline: none;
}
/* Custom Dropdown */
.swp-custom-dropdown {
position: absolute;
right: 0;
top: 0;
z-index: 10;
}
.swp-dropdown-btn {
display: flex;
align-items: center;
background-color: #333;
padding: 10px;
border-radius: 6px;
cursor: pointer;
transition: background-color 0.3s;
}
.swp-dropdown-btn:hover {
background-color: #444;
}
.swp-dropdown-btn img {
width: 20px;
margin-right: 10px;
}
.swp-dropdown-menu {
position: absolute;
top: 100%;
right: 0;
background-color: #333;
border-radius: 6px;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
width: 150px;
display: none;
z-index: 20;
}
.swp-dropdown-item {
padding: 10px;
display: flex;
align-items: center;
cursor: pointer;
transition: background-color 0.3s;
}
.swp-dropdown-item:hover {
background-color: #444;
}
.swp-dropdown-item img {
width: 18px;
margin-right: 10px;
}
/* Show the dropdown when clicked */
.swp-dropdown-menu.active {
display: block;
}
/* Button to purchase */
.swp-btn {
display: inline-flex; /* Align text and logo inline */
align-items: center; /* Center align the text and image */
justify-content: center; /* Center content horizontally */
width: 100%;
padding: 12px;
background-color: #00ff87;
border-radius: 6px;
border: none;
font-size: 18px;
color: #121212;
cursor: pointer;
transition: background-color 0.3s;
gap: 8px; /* Space between the text and the logo */
}
.swp-btn img.logo {
width: 20px; /* Logo width */
height: 20px; /* Logo height */
}
/* Hover effect for enabled button */
.swp-btn:hover {
background-color: #00e77a;
}
/* Disabled button styles */
.swp-btn:disabled {
background-color: #333; /* Darker color when disabled */
color: #888; /* Dimmed text color for disabled state */
cursor: not-allowed; /* Disable cursor */
}
.swp-btn:disabled:hover {
background-color: #333; /* Maintain the same color on hover when disabled */
}
/* Countdown Timer */
.swp-countdown {
font-size: 18px;
text-align: center;
margin-bottom: 20px;
}
</style>
</head>
<body>
<div class="swp-container">
<!-- Connection Status -->
<div id="chainId">Not connected</div>
<!-- Title -->
<h1>Purchase Your VL1</h1>
<!-- Countdown Timer -->
<div class="swp-countdown" id="countdown"></div>
<!-- Exchange Ratio Information -->
<div class="swp-ratio">
<p>1 USD = 5 VL1 Ratio</p>
</div>
<!-- Max Buy Limit and ETH Price -->
<div class="swp-ratio">
<p>Your Max Buy Limit in USD: <span id="maxBuyLimit">0.00</span></p>
<p>ETH price for this IDO is set at 2000</p>
</div>
<!-- Input Field for Purchase -->
<div class="swp-input-container">
<div class="swp-input-wrapper">
<!-- Input Field -->
<input type="text"
id="swp-inputAmount"
placeholder="Enter $ value"
autocomplete="off"
oninput="updateButtonText()" />
<!-- Custom Dropdown -->
<div class="swp-custom-dropdown">
<!-- Selected Token -->
<div class="swp-dropdown-btn" id="swp-dropdownBtn">
<img id="swp-selectedLogo"
src="https://tether.to/images/logoMarkGreen.svg"
alt="Token Logo" />
<span id="swp-selectedOption">USDT</span>
</div>
<!-- Dropdown Menu -->
<div class="swp-dropdown-menu" id="swp-dropdownMenu">
<!-- USDT Option -->
<div class="swp-dropdown-item" data-value="usdt">
<img src="https://tether.to/images/logoMarkGreen.svg" alt="USDT Logo" />
USDT
</div>
<!-- ETH Option -->
<div class="swp-dropdown-item" data-value="eth">
<img src="https://raw.githubusercontent.com/parzivalishan/newsuper/e878707eac174405c16eab4f9b455cbb08952248/assets/eth-logo.svg" alt="ETH Logo" />
ETH
</div>
</div>
</div>
</div>
</div>
<!-- Purchase Button -->
<button class="swp-btn" id="purchaseBtn" disabled>
Purchase VL1
<img src="https://coin-images.coingecko.com/coins/images/24383/large/apecoin.jpg?1696523566" alt="Logo" class="logo">
</button>
</div>
<script>
// Countdown Timer Logic
const countdownElement = document.getElementById('countdown');
const saleStartTime = new Date("2024-11-25T00:00:00Z").getTime(); // Set your sale start time here
function updateCountdown() {
const now = new Date().getTime();
const timeRemaining = saleStartTime - now;
if (timeRemaining <= 0) {
countdownElement.textContent = "Sale has started!";
document.getElementById('purchaseBtn').disabled = false; // Enable purchase button after countdown
} else {
const hours = Math.floor(timeRemaining / (1000 * 60 * 60));
const minutes = Math.floor((timeRemaining % (1000 * 60 * 60)) / (1000 * 60));
const seconds = Math.floor((timeRemaining % (1000 * 60)) / 1000);
countdownElement.textContent = `Time left: ${hours}h ${minutes}m ${seconds}s`;
document.getElementById('purchaseBtn').disabled = true; // Disable purchase button until sale starts
}
}
setInterval(updateCountdown, 1000); // Update the countdown every second
updateCountdown(); // Initial call to display the countdown immediately
// Update the button text dynamically
function updateButtonText() {
const inputAmount = document.getElementById('swp-inputAmount').value;
const purchaseBtn = document.getElementById('purchaseBtn');
const convertedValue = inputAmount * 5; // 1 USD = 5 VL1
if (inputAmount && !isNaN(inputAmount) && inputAmount > 0) {
// Update the purchase button text with calculated VL1 and logo
purchaseBtn.innerHTML = `
Purchase ${convertedValue} VL1
<img src="https://coin-images.coingecko.com/coins/images/24383/large/apecoin.jpg?1696523566" alt="Logo" class="logo">
`;
} else {
// Set the default button text with the logo when input is invalid or empty
purchaseBtn.innerHTML = `
Purchase VL1
<img src="https://coin-images.coingecko.com/coins/images/24383/large/apecoin.jpg?1696523566" alt="Logo" class="logo">
`;
}
}
// Dropdown Toggle
document.getElementById('swp-dropdownBtn').addEventListener('click', function() {
document.getElementById('swp-dropdownMenu').classList.toggle('active');
});
// Dropdown Item Selection
const dropdownItems = document.querySelectorAll('.swp-dropdown-item');
dropdownItems.forEach(item => {
item.addEventListener('click', function() {
const selectedValue = item.getAttribute('data-value');
const selectedLogo = selectedValue === 'usdt'
? 'https://tether.to/images/logoMarkGreen.svg'
: 'https://raw.githubusercontent.com/parzivalishan/newsuper/e878707eac174405c16eab4f9b455cbb08952248/assets/eth-logo.svg';
const selectedText = selectedValue === 'usdt' ? 'USDT' : 'ETH';
// Change the selected option text and logo
document.getElementById('swp-selectedOption').textContent = selectedText;
document.getElementById('swp-selectedLogo').src = selectedLogo;
// Close the dropdown
document.getElementById('swp-dropdownMenu').classList.remove('active');
// Update button text based on selection
updateButtonText();
});
});
</script>
</body>
</html>