-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
65 lines (61 loc) · 2.7 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<!DOCTYPE html>
<html>
<head>
<script async src="https://cloud.51degrees.com/api/v4/AQRPh2TeZOxotqLs3Eg.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<h1>51Degrees Cloud Example</h1>
<h2>Ip</h2>
<div id="htmlIp"></div>
<h2>Network</h2>
<div id="htmlNetwork"></div>
<h2>Location</h2>
<div id="htmlLocation"></div>
<hr/>
<div>
<button type="button" onclick="buttonClicked()">Use my location</button>
</div>
</body>
<script type="text/javascript">
function addLocation(data) {
document.getElementById("htmlLocation").innerHTML = "";
addTextLocation("Town (by lat/lon): " + data.location["town"]);
addTextLocation("Country (by lat/lon): " + data.location["country"]);
addTextLocation("CountryCode (by lat/lon): " + data.location["countrycode"]);
addTextLocation("CountryCode3 (by lat/lon): " + data.location["countrycode3"]);
addTextLocation("TimeZoneOffset (by lat/lon): " + data.location["timezoneoffset"]);
}
window.onload = function() {
fod.complete(function (data) {
// Fetch the properties from the JSON response and write to the page.
addTextIp("Ipv6 (by IP): " + data.ip["ipv6"]);
addTextIp("Ip (by IP): " + data.ip["ip"]);
addTextIp("Latitude (by IP): " + data.ip["latitude"]);
addTextIp("AccuracyRadius (by IP): " + data.ip["accuracyradius"]);
addTextIp("Longitude (by IP): " + data.ip["longitude"]);
addTextIp("Shapes (by IP): " + data.ip["shapes"]);
addTextNetwork("Name: " + data.network["name"]);
addTextNetwork("Country: " + data.network["country"]);
addTextNetwork("Owner: " + data.network["owner"]);
addTextNetwork("IpRangeEnd: " + data.network["iprangeend"]);
addTextNetwork("IpRangeStart: " + data.network["iprangestart"]);
addLocation(data);
});
}
buttonClicked = function() {
fod.complete(function (data) {
addLocation(data);
}, 'location');
}
addTextIp = function(text) {
document.getElementById("htmlIp").innerHTML+="<p>" + text + "</p>";
}
addTextNetwork = function(text) {
document.getElementById("htmlNetwork").innerHTML+="<p>" + text + "</p>";
}
addTextLocation = function(text) {
document.getElementById("htmlLocation").innerHTML+="<p>" + text + "</p>";
}
</script>
</html>