-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathjavascript.js
More file actions
53 lines (50 loc) · 1.95 KB
/
javascript.js
File metadata and controls
53 lines (50 loc) · 1.95 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
document.addEventListener('DOMContentLoaded', function() {
fetch('https://ipapi.co/json/')
.then(response => response.json())
.then(data => {
displayUserInfo(data.ip, data.country_name, data.city);
});
const emailForm = document.getElementById('email-form');
emailForm.addEventListener('submit', function(event) {
event.preventDefault();
const email = document.getElementById('email').value;
if (email) {
const ip = document.getElementById('ip').textContent;
const country = document.getElementById('country').textContent;
const city = document.getElementById('city').textContent;
fetch('process.php', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
body: new URLSearchParams({
email: email,
ip: ip,
country: country,
city: city
})
})
.then(response => response.text())
.then(result => {
alert(result);
navigator.clipboard.writeText(`User: ${ip}, Country: ${country}, City: ${city}`)
.then(() => {
alert('Data copied to clipboard');
})
.catch(err => {
alert('Error copying data to clipboard');
});
})
.catch(error => {
alert('Error saving data');
});
} else {
alert('Please enter a valid email');
}
});
});
function displayUserInfo(ip, country, city) {
document.getElementById('ip').textContent = ip;
document.getElementById('country').textContent = country;
document.getElementById('city').textContent = city;
}