-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
47 lines (40 loc) · 1.55 KB
/
Copy pathscript.js
File metadata and controls
47 lines (40 loc) · 1.55 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
const countdownEl = document.getElementById('countdown');
const targetDate = new Date(Date.now() + 24 * 60 * 60 * 1000); // 24 hours from now
function updateCountdown() {
const now = new Date();
const diff = targetDate - now;
if (diff <= 0) {
countdownEl.textContent = 'Airdrop ended';
clearInterval(interval);
return;
}
const hours = Math.floor(diff / (1000 * 60 * 60));
const minutes = Math.floor((diff % (1000 * 60 * 60)) / (1000 * 60));
const seconds = Math.floor((diff % (1000 * 60)) / 1000);
countdownEl.textContent = `${hours}h ${minutes}m ${seconds}s`;
}
const interval = setInterval(updateCountdown, 1000);
updateCountdown();
const connectButton = document.getElementById('connectButton');
const statusEl = document.getElementById('status');
connectButton.addEventListener('click', async () => {
if (window.ethereum) {
try {
await window.ethereum.request({ method: 'eth_requestAccounts' });
const web3 = new Web3(window.ethereum);
const accounts = await web3.eth.getAccounts();
statusEl.textContent = `Connected: ${accounts[0]}`;
} catch (err) {
statusEl.textContent = `Connection failed: ${err.message}`;
}
} else {
statusEl.textContent = 'MetaMask not detected';
}
});
const claimForm = document.getElementById('claimForm');
claimForm.addEventListener('submit', (e) => {
e.preventDefault();
const name = document.getElementById('username').value;
const email = document.getElementById('email').value;
statusEl.textContent = `Thank you, ${name}! Claim submitted for ${email}.`;
});