| OLD | NEW |
| 1 <html> | 1 <html> |
| 2 <head> | 2 <head> |
| 3 <script> | 3 <script> |
| 4 var last_position = 0; | 4 var last_position = 0; |
| 5 var last_error = 0; | 5 var last_error = 0; |
| 6 var watch_id = 0; | 6 var watch_id = 0; |
| 7 var navigation_count = 0; | 7 var navigation_count = 0; |
| 8 var max_navigation_count = undefined; | 8 var max_navigation_count = undefined; |
| 9 var iteration = 0; | 9 var iteration = 0; |
| 10 function geoNavigateIfNeeded(msg) { | 10 function geoNavigateIfNeeded(msg) { |
| 11 if (max_navigation_count == undefined || | 11 if (max_navigation_count == undefined || |
| 12 navigation_count++ < max_navigation_count) { | 12 navigation_count++ < max_navigation_count) { |
| 13 ++iteration; | 13 ++iteration; |
| 14 document.location.hash = '#' + iteration + ':' + msg; | 14 document.location.hash = '#' + iteration + ':' + msg; |
| 15 } | 15 } |
| 16 } | 16 } |
| 17 function geoSuccessCallback(position) { | 17 function geoSuccessCallback(position) { |
| 18 last_position = position; | 18 last_position = position; |
| 19 geoNavigateIfNeeded('geoSuccessCallback'); | 19 geoNavigateIfNeeded('geoSuccessCallback'); |
| 20 } | 20 } |
| 21 function geoErrorCallback(error) { | 21 function geoErrorCallback(error) { |
| 22 console.log('error = ' + error); |
| 22 last_error = error; | 23 last_error = error; |
| 23 geoNavigateIfNeeded('geoErrorCallback'); | 24 geoNavigateIfNeeded('geoErrorCallback'); |
| 24 } | 25 } |
| 25 function geoStart() { | 26 function geoStart() { |
| 26 watch_id = navigator.geolocation.watchPosition( | 27 watch_id = navigator.geolocation.watchPosition( |
| 27 geoSuccessCallback, geoErrorCallback, | 28 geoSuccessCallback, geoErrorCallback, |
| 28 {maximumAge:600000, timeout:100000, enableHighAccuracy:true}); | 29 {maximumAge:600000, timeout:100000, enableHighAccuracy:true}); |
| 29 return watch_id; | 30 return watch_id; |
| 30 } | 31 } |
| 31 function geoGetLastPositionLatitude() { | 32 function geoGetLastPositionLatitude() { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 45 function geoAccessNavigatorGeolocation() { | 46 function geoAccessNavigatorGeolocation() { |
| 46 return "" + typeof(navigator.geolocation); | 47 return "" + typeof(navigator.geolocation); |
| 47 } | 48 } |
| 48 </script> | 49 </script> |
| 49 </head> | 50 </head> |
| 50 <body> | 51 <body> |
| 51 <input type="button" value="manual" onclick="geoStart()"/> | 52 <input type="button" value="manual" onclick="geoStart()"/> |
| 52 </body> | 53 </body> |
| 53 </html> | 54 </html> |
| 54 | 55 |
| OLD | NEW |