-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
35 lines (31 loc) · 1.4 KB
/
script.js
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
function performSearch() {
var domain = document.getElementById('search-bar').value;
var resultsDiv = document.getElementById('results');
if (!domain) {
resultsDiv.innerHTML = 'Please enter a domain to search for.';
return;
}
resultsDiv.innerHTML = 'Loading...';
fetch('https://api1.astechnetwork.eu.org/info?domain=' + encodeURIComponent(domain))
.then(function(response) {
if (!response.ok) {
throw new Error('Network response was not ok. Status: ' + response.status);
}
return response.json(); // Parse the JSON from the response
})
.then(function(data) {
// Format and display the results
var formattedResults = 'Domain: ' + domain + '\n' +
'IP Address: ' + (data.ip || 'Not available') + '\n' +
'Country: ' + (data.geo.country || 'Not available') + '\n' +
'Timezone: ' + (data.geo.timezone || 'Not available') + '\n' +
// ... include other fields as needed
'WHOIS Info: ' + (data.whois || 'Not available').replace(/\n/g, '<br>') + '\n';
resultsDiv.innerHTML = '<pre>' + formattedResults + '</pre>';
})
.catch(function(error) {
// More detailed error message
console.error('Fetch Error:', error);
resultsDiv.innerHTML = 'Failed to load information: ' + error.toString();
});
}