const lookupElem = document.getElementById('lookupElem'); const yourIp = document.getElementById('your-ip'); function getFlagEmoji(countryCode) { return countryCode .toUpperCase() .replace(/./g, char => String.fromCodePoint(127397 + char.charCodeAt())); } function fetchIp() { const ip = document.getElementById("ipInput").value; fetch(`https://ipapi.co/${ip}/json/`) .then(response => response.json()) .then(data => { const flag = getFlagEmoji(data.country_code || ''); const table = `
IP | ${data.ip} |
---|---|
City | ${data.city} |
Postal Code | ${data.postal} |
Region | ${data.region} |
Country | ${flag} ${data.country_name} (${data.country_code}) |
Timezone | ${data.timezone} |
Organization | ${data.org} |
Coordinates | ${data.latitude}, ${data.longitude} |