-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtinyphone_map.html
72 lines (72 loc) · 2.61 KB
/
tinyphone_map.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
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0; padding: 0 }
#map_canvas { height: 100% }
</style>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=REPLACE_ME_WITH_YOUR_API_KEY&sensor=false"></script>
<script type="text/javascript" src="tinyphone_client.js"></script>
<script>
//GET API KEY FOR GOOGLE MAPS AT https://code.google.com/apis/console/
var phoneNumber = "1 (360) 989-1290";
var map;
var mapJump = 100; //number of pixels to move
function initMap(){
var mapOptions = {
center: new google.maps.LatLng(40.74, -73.96),
zoom: 8,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
}
tinyphone.init("ast1.itp-redial.com",12003,phoneNumber);
tinyphone.on('connect', function(){
var d = document.getElementById("connected");
d.innerHTML="connected to server";
});
tinyphone.on('disconnect', function(){
var d = document.getElementById("connected");
d.innerHTML="disconnected";
});
tinyphone.on('new_call', function(caller){
var parent = document.getElementById("call_list");
var newdiv = document.createElement('div');
var divIdName = caller.id;
newdiv.setAttribute('id',divIdName);
//you could use caller.callerNumber if you're not concerned about privacy
newdiv.innerHTML = 'Caller '+caller.callerLabel;
parent.appendChild(newdiv);
});
tinyphone.on('keypress', function(caller){
var keypress = caller.keypress;
switch(keypress){
case '2': map.panBy(0, mapJump*-1);break; //up
case '8': map.panBy(0, mapJump);break; //down
case '4': map.panBy(mapJump*-1, 0);break; //left
case '8': map.panBy(mapJump, 0);break; //right
case '1': map.panBy(mapJump*-1, mapJump*-1);break; //diag up left
case '3': map.panBy(mapJump, mapJump*-1);break; //diag up right
case '7': map.panBy(mapJump*-1, mapJump);break; //diag down left
case '9': map.panBy(mapJump, mapJump);break; //diag down right
case '*': var z = map.getZoom(); map.setZoom(z-1);break; //zoom out
case '#': var z = map.getZoom(); map.setZoom(z+1);break; //zoom in
}
});
tinyphone.on('hangup', function(caller){
var d = document.getElementById("call_list");
var olddiv = document.getElementById(caller.id);
d.removeChild(olddiv);
});
</script>
</head>
<body onLoad='initMap()'>
<h3>
<div id="phone_number">call <script>document.write(phoneNumber)</script></div>
</h3>
<div id="connected">disconnected</div>
<div id="call_list"></div>
<div id="map_canvas" style="width:100%; height:100%"></div>
</body>
</html>