-
Notifications
You must be signed in to change notification settings - Fork 3
/
compass.html
58 lines (44 loc) · 1.38 KB
/
compass.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
<html>
<head>
<meta name = "viewport" content = "initial-scale = 1.0, user-scalable = no" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<script type="text/javascript" src="NKit.js"></script>
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body>
<script>
NKSetPageOpaque('compass.html', 'NO');
var navController = new NKNavigationController();
navController.setTitle("Compass");
navController.setTintColor(0, 0, 0);
NKRegisterClass("CompassObject");
function start() //Starts Listening Heading Update
{
CallNKitAction('startlistening?className=CompassObject');
get(); //triggers for the first time
}
function stop() //Stops Listening to Heading. When changing page stop listening.
{
CallNKitAction('stoplistening?className=CompassObject');
clearTimeout(a);
NKLog("Stop");
}
function get() //This requests heading every 100ms
{
CallNKitAction('sendback?className=CompassObject');
var a = window.setTimeout('get()', 100); //loop
}
function compasstext(heading) //Receives heading data from Objective C
{
document.getElementById('compass').innerHTML = "Heading: " + heading;
}
function onPageHidden()
{
// Add code to stop listening if running
}
</script>
<div class="greybutton" onClick="start()">Start</div>
<div class="greybutton" onClick="stop()">Stop</div>
<div id="compass" class="infobox"></div>
</body>
</html>