dip/static/js/main.js

27 lines
856 B
JavaScript
Raw Normal View History

2023-07-13 22:25:21 +02:00
function main() {
2023-07-17 21:12:44 +02:00
let ip = "";
2023-07-13 22:25:21 +02:00
let dip_ip = document.getElementById("dip_ip");
let dip_hostname = document.getElementById("dip_hostname");
let dip_city = document.getElementById("dip_city");
let dip_country = document.getElementById("dip_country");
2023-07-13 22:25:21 +02:00
let dip_as_number = document.getElementById("dip_as_number");
let dip_as_org = document.getElementById("dip_as_org");
2023-07-17 21:12:44 +02:00
if (window.location.pathname.length > 4) {
ip = window.location.pathname.split("/")[1];
}
2023-07-13 22:25:21 +02:00
fetch(`/json/${ip}`).then((response) => {
response.json().then((res) => {
dip_ip.innerHTML = res["ip"];
dip_hostname.innerHTML = res["hostname"];
dip_city.innerHTML = res["city"];
dip_country.innerHTML = res["country"];
2023-07-13 22:25:21 +02:00
dip_as_number.innerHTML = res["as"]["number"];
dip_as_org.innerHTML = res["as"]["org"];
});
});
}
main();