author | Clipperz <info@clipperz.com> | 2013-01-09 09:03:53 (UTC) |
---|---|---|
committer | Clipperz <info@clipperz.com> | 2013-01-09 09:03:53 (UTC) |
commit | 644891059e1f37d0748bc34b9ca78c05fa748214 (patch) (unidiff) | |
tree | a746ee125d503088dc53dac823474e4295560947 /frontend/gamma/js/JQTouch/extensions/jqt.location.js | |
parent | a9974c63bdcef65f009420dce095d1e39da7e3b8 (diff) | |
download | clipperz-644891059e1f37d0748bc34b9ca78c05fa748214.zip clipperz-644891059e1f37d0748bc34b9ca78c05fa748214.tar.gz clipperz-644891059e1f37d0748bc34b9ca78c05fa748214.tar.bz2 |
Added JQTouch and Zepto libraries
JQTouch and Zepto are tentatively used for the mobile version of Clipperz.
No final commitment has been made, though.
Diffstat (limited to 'frontend/gamma/js/JQTouch/extensions/jqt.location.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/gamma/js/JQTouch/extensions/jqt.location.js | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/frontend/gamma/js/JQTouch/extensions/jqt.location.js b/frontend/gamma/js/JQTouch/extensions/jqt.location.js new file mode 100644 index 0000000..9d53a1a --- a/dev/null +++ b/frontend/gamma/js/JQTouch/extensions/jqt.location.js | |||
@@ -0,0 +1,51 @@ | |||
1 | (function($) { | ||
2 | if ($.jQTouch) | ||
3 | { | ||
4 | $.jQTouch.addExtension(function Location(){ | ||
5 | |||
6 | var latitude, longitude, callback, callback2; | ||
7 | |||
8 | function updateLocation(fn, fn2) { | ||
9 | if (navigator.geolocation) | ||
10 | { | ||
11 | callback = fn; | ||
12 | callback2 = fn2; | ||
13 | navigator.geolocation.getCurrentPosition(savePosition, failResponse); | ||
14 | return true; | ||
15 | } else { | ||
16 | console.log('Device not capable of geo-location.'); | ||
17 | fn(false); | ||
18 | return false; | ||
19 | } | ||
20 | } | ||
21 | function failResponse(error){ | ||
22 | if (callback2) { | ||
23 | callback2(error); | ||
24 | } | ||
25 | } | ||
26 | function savePosition(position) { | ||
27 | latitude = position.coords.latitude; | ||
28 | longitude = position.coords.longitude; | ||
29 | if (callback) { | ||
30 | callback(getLocation()); | ||
31 | } | ||
32 | } | ||
33 | function getLocation() { | ||
34 | if (latitude && longitude) { | ||
35 | return { | ||
36 | latitude: latitude, | ||
37 | longitude: longitude | ||
38 | }; | ||
39 | |||
40 | } else { | ||
41 | console.log('No location available. Try calling updateLocation() first.'); | ||
42 | return false; | ||
43 | } | ||
44 | } | ||
45 | return { | ||
46 | updateLocation: updateLocation, | ||
47 | getLocation: getLocation | ||
48 | }; | ||
49 | }); | ||
50 | } | ||
51 | })($); \ No newline at end of file | ||