This repository has been archived by the owner on Nov 29, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
spottag.js
64 lines (45 loc) · 1.89 KB
/
spottag.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
/* Bridget Lane, Bradford Webb, Bryon Bacon
HackNC 3-2-14
Pebble SpotTag Project */
simply.title("\n Spot\n Tag");
var savedLat = null;
var savedLon = null;
var savedLat2 = null;
var savedLon2 = null;
function opts() {
simply.title("\n Make Tag\n\n Find Tag\n\n");
}
simply.on('singleClick', function(e) {
var makeTag = "Tag Made";
var trackTag = "Your Tags";
if (e.button === "up") {
navigator.geolocation.getCurrentPosition(function(pos) {
var coords = pos.coords;
var weatherUrl = 'http://api.openweathermap.org/data/2.5/weather?' +
'lat=' + coords.latitude + '&lon=' + coords.longitude + '&units=metric';
ajax({ url: weatherUrl, type: 'json' }, function(data) {
savedLat = coords.latitude.toFixed(4);
savedLon = coords.longitude.toFixed(4);
savedLat2 = coords.latitude.toFixed(2);
savedLon2 = coords.longitude.toFixed(2);
var sub = data.name + ":\nLat: " + savedLat + "\nLon: " + savedLon;
simply.text({ title: makeTag, subtitle: sub });
});
});
simply.vibe('short');
}
if (e.button === "down") {
navigator.geolocation.getCurrentPosition(function(pos) {
var coords = pos.coords;
var weatherUrl = 'http://api.openweathermap.org/data/2.5/weather?' +
'lat=' + coords.latitude + '&lon=' + coords.longitude + '&units=metric';
ajax({ url: weatherUrl, type: 'json' }, function(data) {
var sub = "Last: \n" + savedLat2 + ", " + savedLon2 + "\n" + "Current: \n " + coords.latitude.toFixed(2) + ", " + coords.longitude.toFixed(2);
simply.text({title: trackTag, subtitle: sub})
});
});
}
if (e.button === "select") {
opts();
}
});