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