mirror of
https://git.dn42.dev/lare/myip.dn42.git
synced 2024-10-24 03:11:33 +02:00
In general, JS and CSS resources should be in separate files. This improves clarity and security (for example, when using CSP).
45 lines
1.2 KiB
JavaScript
45 lines
1.2 KiB
JavaScript
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://v4.myip.dn42/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://v6.myip.dn42/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();
|
|
}
|