-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathScreenPop.html
343 lines (286 loc) · 9.59 KB
/
ScreenPop.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
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
<!DOCTYPE html>
<html dir="ltr" lang="en">
<head>
<meta charset="utf-8">
<title>Whitepages PRO Screen Pop</title>
<script>
if (!window.console) {
window.console = {
log: function() {},
warn: function() {},
error: function() {}
};
}
</script>
<link rel="stylesheet" type="text/css" href="ScreenPop.css"></link>
<script src="jquery-1.9.1.min.js"></script>
<!-- React -->
<script type="text/javascript" src="react-0.13.3/build/react.js"></script>
<script type="text/javascript" src="react-0.13.3/build/JSXTransformer.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAGEYK30LIBhct6fXDUBRjunTLZjpRk7-4" async defer></script>
<!-- Finesse JS Convenience library -->
<script src="finn-all-10.5.1-ES3.js"></script>
<script type="text/javascript">
var wpProApiKey = "";
var devMode = false;
var finn = {};
var currentCallInfo = null;
function handleWhitepagesResponse(rsp) {
if (!rsp || rsp.rc > 299) {
console.error("Error retrieving caller info: " + rsp.text);
return;
}
var data = JSON.parse(rsp.text);
console.log(data);
currentCallInfo = data;
render();
}
function testPop () {
var number = $("#test-number").val();
pop(number);
}
function pop(number) {
finn.log("POP! POP!");
var url = "http://proapi.whitepages.com/2.1/phone.json?api_key=" + wpProApiKey + "&response_type=callerid&phone_number=";
url += number;
//document.getElementById("whitepages").src = "https://pro.lookup.whitepages.com/phones?number=" + value;
//popWrapper();
var params = {};
params[gadgets.io.RequestParameters.METHOD] = 'GET';
gadgets.io.makeRequest(url, handleWhitepagesResponse, params);
/*
$.support.cors = true;
$.ajax({
type: "GET",
url: url,
dataType: 'json',
contentType: 'application/json'
})
.done(function(data) {
console.log(data)
})
.fail(function(err) {
console.error(JSON.stringify(err));
}) */
}
$(document).ready(function() {
$("#test-tools").hide();
$(parent.document.getElementById(window.name).parentNode.parentNode).css("padding", "0px");
finn = new Finn("Whitepages PRO ScreenPop");
finn.load(function(agent) {
wpProApiKey = finn.container.getParameter("apiKey");
devMode = (finn.container.getParameter("devMode").toLowerCase() == "true");
if (devMode) {
finn.container.addDevToolsToGadget();
$("#test-tools").show();
}
render();
finn.log("Finesse loaded.");
finn.on('call started', handleCallStarted);
});
});
function handleCallStarted(call) {
if (call.fromAddress) {
pop(call.fromAddress);
}
}
</script>
</head>
<body>
<div id="test-tools">
<input type="text" id="test-number" value=""></input>
<button id="pop-button" onclick="testPop();">Pop</button>
</div>
<div id="pop-container"/>
<!-- iframe src="https://pro.lookup.whitepages.com/phones" id="whitepages"></iframe -->
<script type="text/jsx">
function render() {
React.render(
<Whitepages callInfo={currentCallInfo} />,
document.getElementById("pop-container")
);
}
var Whitepages = React.createClass({
componentDidUpdate: function() {
if (!this.props.callInfo)
return;
var lat = this.props.callInfo.results[0].best_location.lat_long.latitude;
var long = this.props.callInfo.results[0].best_location.lat_long.longitude;
map = new google.maps.Map(document.getElementById("location-map"), {
scrollwheel: false,
// Adjust latitude slightly since we scroll the map down a bit.
center: {lat: lat + 0.14, lng: long},
zoom: 10
});
var marker = new google.maps.Marker({
position: {lat: lat, lng: long},
map: map,
title: "Location"
});
$("#details").scrollTop(259);
},
render: function() {
if (!this.props.callInfo)
return <div id="summary"></div>
var name = "Unknown";
var gender = null;
var ageStart = null;
var ageEnd = null;
var demographics = "Unknown";
if (this.props.callInfo.results[0].belongs_to[0]) {
name = this.props.callInfo.results[0].belongs_to[0].best_name ||
this.props.callInfo.results[0].belongs_to[0].name;
gender = this.props.callInfo.results[0].belongs_to[0].gender;
ageStart = this.props.callInfo.results[0].belongs_to[0].age_range.start;
ageEnd = this.props.callInfo.results[0].belongs_to[0].age_range.end;
demographics = gender + ", " + ageStart + "-" + ageEnd;
}
var city = this.props.callInfo.results[0].best_location.city;
var address = this.props.callInfo.results[0].best_location.address;
address = address.replace(/,/g, ',<br/>');
var receivingMailText = "No";
if (this.props.callInfo.results[0].best_location.is_receiving_mail) {
receivingMailText = "Yes";
}
var usage = this.props.callInfo.results[0].best_location.usage;
var deliveryPoint = this.props.callInfo.results[0].best_location.delivery_point;
var stateCode = this.props.callInfo.results[0].best_location.state_code;
var spamLevel = this.props.callInfo.results[0].reputation.level;
var spamLevelText = "Not Spam";
var lineType = this.props.callInfo.results[0].line_type;
var carrier = this.props.callInfo.results[0].carrier;
var doNotCallText = "Not Registered";
if (this.props.callInfo.results[0].do_not_call) {
doNotCallText = "Registered";
}
switch(spamLevel) {
case 1:
spamLevelText = "Not Spam";
break;
case 2:
spamLevelText = "Low";
break;
case 3:
spamLevelText = "Mid";
break;
case 4:
spamLevelText = "High";
break;
}
return <div id="content">
<div id="powered-by">
<div id="powered-by-text">Powered by</div>
<img alt="Whitepages Pro" width="90"
data-svg-fallback="https://cdnproweb.global.ssl.fastly.net/assets/pro_logo-ae5b793f453a989ca8bdb633ed7c41a9.png"
src="https://cdnproweb.global.ssl.fastly.net/assets/pro_logo-06126de9a4c3cd95e053c78cf56d3232.svg"
></img>
</div>
<div id="summary">
<div id="summary-header">
<div id="summary-name">{name}</div>
<div id="summary-location">
<span className="icon pin-filled" id="summary-location-icon"></span>
<span>{city}, {stateCode}</span>
</div>
</div>
<div id="summary-content">
<div className="summary-info-section">
<div className="summary-info">
<div className="summary-info-heading">Spam Score</div>
<div className="summary-info-text">{spamLevel} ({spamLevelText})</div>
</div>
<div className="summary-info-image">
<span className={"spam-gauge level-" + spamLevel}></span>
</div>
</div>
<div className="summary-info-section">
<div className="summary-info">
<div className="summary-info-heading">Phone</div>
<div className="summary-info-text">{lineType} ({carrier})</div>
</div>
</div>
<div className="summary-info-section">
<div className="summary-info">
<div className="summary-info-heading">Demographic</div>
<div className="summary-info-text">{demographics}</div>
</div>
</div>
</div>
</div>
<div id="details">
<div id="location-map">
</div>
<div className="detail-section">
<div className="detail-heading">
<span className="icon pin detail-icon" id="detail-location-icon"></span>
<div className="detail-heading-label">Location</div>
</div>
<div className="detail-info">
<div className="detail-label">
Address
</div>
<div className="detail-value" dangerouslySetInnerHTML={{__html: address}}>
</div>
</div>
<div className="detail-info">
<div className="detail-label">
Receiving Mail
</div>
<div className="detail-value">
{receivingMailText}
</div>
</div>
<div className="detail-info">
<div className="detail-label">
Usage
</div>
<div className="detail-value">
{usage}
</div>
</div>
<div className="detail-info">
<div className="detail-label">
Delivery Point
</div>
<div className="detail-value">
{deliveryPoint}
</div>
</div>
</div>
<div className="detail-section">
<div className="detail-heading">
<span className="icon phone detail-icon" id="detail-phone-icon"></span>
<div className="detail-heading-label">Phone</div>
</div>
<div className="detail-info">
<div className="detail-label">
Type
</div>
<div className="detail-value">
{lineType}
</div>
</div>
<div className="detail-info">
<div className="detail-label">
Carrier
</div>
<div className="detail-value">
{carrier}
</div>
</div>
<div className="detail-info">
<div className="detail-label">
Do Not Call Registry
</div>
<div className="detail-value">
{doNotCallText}
</div>
</div>
</div>
</div>
</div>
}
});
</script>
</body>
</html>