dip/static/js/main.js
Paul Lecuq f79bc57d83
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
fixed bug in js stuff
2023-07-17 21:12:44 +02:00

27 lines
856 B
JavaScript

function main() {
let ip = "";
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");
let dip_as_number = document.getElementById("dip_as_number");
let dip_as_org = document.getElementById("dip_as_org");
if (window.location.pathname.length > 4) {
ip = window.location.pathname.split("/")[1];
}
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"];
dip_as_number.innerHTML = res["as"]["number"];
dip_as_org.innerHTML = res["as"]["org"];
});
});
}
main();