-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
102 lines (76 loc) · 4.22 KB
/
script.js
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
var ip, domain;
var api_key = "at_bivtbhWLWWqSq3eNGiSeOzLDAWwM7";
var myicon = L.icon({
iconUrl: 'images/icon-location.svg'
});
var mymap;
function mapload(){
var ip, domain;
if (/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(document.getElementById("search").value )){
ip = document.getElementById("search").value;
console.log("ip");
}
else if(/^[a-zA-Z0-9][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]\.[a-zA-Z]{2,}$/.test(document.getElementById("search").value)){
domain = document.getElementById("search").value;
console.log("domain");
}
else if(/^[a-zA-Z0-9][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]\.[a-zA-Z]{2,}\.[a-zA-Z]{2,}$/.test(document.getElementById("search").value)){
domain = document.getElementById("search").value;
console.log("domain");
}
else{
alert("Invalid IP or Domain");
}
$(function () {
$.ajax({
url: "https://geo.ipify.org/api/v1",
data: {apiKey: api_key, ipAddress: ip, domain: domain},
success: function(data) {
// $("body").append("<pre>"+ JSON.stringify(data,"",2)+"</pre>");
// const mapdata = JSON.stringify(data,"",2);
console.log(data);
document.getElementById("ip-stats").innerHTML = data.ip;
document.getElementById("location-stats").innerHTML = data.location.city + ", " + data.location.country + "<br>" + data.location.postalCode;
document.getElementById("timezone-stats").innerHTML = data.location.timezone;
document.getElementById("isp-stats").innerHTML = data.isp;
mymap.remove();
mymap = new L.map('mapid', { zoomControl: false}).setView([data.location.lat, data.location.lng], 13);
L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}', {
attribution: 'Map data © <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
maxZoom: 18,
id: 'mapbox/streets-v11',
tileSize: 512,
zoomOffset: -1,
accessToken: 'pk.eyJ1Ijoic2Vpa2hjaGlsbGkiLCJhIjoiY2tyNmExcTZjM2RtNTMxbzZ3MjI0dWVnZCJ9.-t-twYtKEmBa3skJ0YUHnA'
}).addTo(mymap);
L.marker([data.location.lat, data.location.lng], {icon: myicon}).addTo(mymap);
}
});
});
}
$(function () {
$.ajax({
url: "https://geo.ipify.org/api/v1",
data: {apiKey: api_key, ipAddress: ip},
success: function(data) {
// $("body").append("<pre>"+ JSON.stringify(data,"",2)+"</pre>");
// const mapdata = JSON.stringify(data,"",2);
console.log(data);
document.getElementById("ip-stats").innerHTML = data.ip;
document.getElementById("location-stats").innerHTML = data.location.city + ", " + data.location.country + "<br>" + data.location.postalCode;
document.getElementById("timezone-stats").innerHTML = data.location.timezone;
document.getElementById("isp-stats").innerHTML = data.isp;
mymap = new L.map('mapid',{ zoomControl: false}).setView([data.location.lat, data.location.lng], 13);
L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}', {
attribution: 'Map data © <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
maxZoom: 18,
id: 'mapbox/streets-v11',
tileSize: 512,
zoomOffset: -1,
accessToken: 'pk.eyJ1Ijoic2Vpa2hjaGlsbGkiLCJhIjoiY2tyNmExcTZjM2RtNTMxbzZ3MjI0dWVnZCJ9.-t-twYtKEmBa3skJ0YUHnA'
}).addTo(mymap);
L.marker([data.location.lat, data.location.lng], {icon: myicon}).addTo(mymap);
}
});
});
//at_bivtbhWLWWqSq3eNGiSeOzLDAWwM7