updated main.js

This commit is contained in:
Paul 2020-02-09 10:43:22 +01:00
parent 01c49de4fc
commit bfedf05f7d

View File

@ -3,14 +3,24 @@
function main() { function main() {
var jqxhr = var jqxhr =
$.ajax({ $.ajax({
type: "GET",
url: "https://ip.paulbsd.com", url: "https://ip.paulbsd.com",
headers: { headers: {
'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Origin': '*',
'Accept': 'application/json', 'Accept': 'application/json',
}, },
dataType: 'json', dataType: 'json',
}).done(function(){ console.log(data.ip) }); }).done(function(data){ console.log(transformIPInfo(data)) });
return jqxhr; return jqxhr;
}
function transformIPInfo(data) {
if (data.hostname != '') {
return data.ip + '/' + data.hostname;
}
else {
return data.ip;
}
} }
$(document).ready(function() { $(document).ready(function() {