myip.dn42/wwwroot/assets/js/myip.js

46 lines
1.2 KiB
JavaScript
Raw Permalink Normal View History

function getdefault() {
fetch('/api')
.then(function (response) {
return response.json();
})
.then(function (data) {
document.getElementById("defaultip").innerHTML=data.ip;
document.getElementById("serverdefault").innerHTML=data.server;
document.getElementById("node_as").innerHTML=data.node_as;
document.getElementById("node_location").innerHTML=data.node_location;
document.getElementById("node_id").innerHTML=data.node_id;
})
}
function getipv4() {
fetch('http://172.20.0.81/api')
.then(function (response) {
return response.json();
})
.then(function (data) {
document.getElementById("ipv4").innerHTML=data.ip;
document.getElementById("serveripv4").innerHTML=data.server;
})
}
function getipv6() {
fetch('http://[fd42:d42:d42:81::1]/api')
.then(function (response) {
return response.json();
})
.then(function (data) {
document.getElementById("ipv6").innerHTML=data.ip;
document.getElementById("serveripv6").innerHTML=data.server;
})
}
window.onload = function () {
getdefault();
getipv4();
getipv6();
}