-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpopup.js
More file actions
67 lines (43 loc) · 1.48 KB
/
popup.js
File metadata and controls
67 lines (43 loc) · 1.48 KB
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
/*globals $, chrome, console, Uint8Array */
function filterData(data) {
'use strict';
var interestingKeys, filteredData;
interestingKeys = ["city", "country", "countryCode", "isp", "org", "lat", "lon", "query", "regionName", "timezone", "zip"];
filteredData = {};
$.each(data, function (k, v) {
if (interestingKeys.indexOf(k) !== -1) {
if (k === 'query') {
k = 'IP';
} else if (k === 'org') {
k = 'organization';
}
filteredData[k] = v;
}
});
return filteredData;
}
/**
* creates the table data and updates the extension icon
*/
function createPopUpPage() {
'use strict';
$().fadeIn(2000);
callWebService(function (dataBlob, data) {
var img, table_body;
// https://www.whatismyip.com/images/flags/se.png
img = "<img id=\"flagImg\" src=\"https://www.whatismyip.com/images/flags/" + data.countryCode.toLowerCase() + ".png\"/>";
data = filterData(data);
table_body = img;
$.each(data, function (k, v) {
table_body += "<tr><td>" + k + "</td><td><b>" + v + "</b></td></tr>";
});
$("#GeoResults").html(table_body);
updateExtensionIcon(dataBlob);
initMapInternal(data.lat, data.lon);
});
}
document.addEventListener('DOMContentLoaded', function () {
'use strict';
console.log("getting started");
createPopUpPage();
});