aboutsummaryrefslogtreecommitdiffstats
path: root/www/js
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2013-03-07 17:12:34 +0000
committerStruan Donald <struan@exo.org.uk>2013-03-07 17:12:34 +0000
commitcfa7f124c0e91027164e9f56985153db8662bcf0 (patch)
tree1043a054f8aa1e0053344798562c913dad48bec0 /www/js
parentb0fbfebd42eb9d3377bd22d6c31ac6a991355c58 (diff)
show a countdown bar on the locating screen
Diffstat (limited to 'www/js')
-rw-r--r--www/js/views/around.js32
1 files changed, 31 insertions, 1 deletions
diff --git a/www/js/views/around.js b/www/js/views/around.js
index 2c9b418..59a01e1 100644
--- a/www/js/views/around.js
+++ b/www/js/views/around.js
@@ -24,13 +24,42 @@
l.on('locating', this.locationUpdate, this);
l.geolocate(100);
+ this.startLocateProgress();
},
locationUpdate: function( accuracy ) {
- $('#accuracy').text(parseInt(myLocation.coords.accuracy, 10) + 'm');
+ if ( accuracy && accuracy < 500 ) {
+ $('#progress-bar').css( 'background-color', 'orange' );
+ } else if ( accuracy && accuracy < 250 ) {
+ $('#progress-bar').css( 'background-color', 'yellow' );
+ } else {
+ $('#progress-bar').css( 'background-color', 'grey' );
+ }
+
+ $('#accuracy').text(parseInt(accuracy, 10) + 'm');
+ console.log('accuracy is ' + accuracy);
+ },
+
+ startLocateProgress: function() {
+ this.locateCount = 1;
+ var that = this;
+ window.setTimeout( function() {that.showLocateProgress();}, 1000);
+ },
+
+ showLocateProgress: function() {
+ if ( this.locateCount > 20 ) {
+ return;
+ }
+ var percent = ( ( 20 - this.locateCount ) / 20 ) * 100;
+ $('#progress-bar').css( 'width', percent + '%' );
+ this.locateCount++;
+ var that = this;
+ window.setTimeout( function() {that.showLocateProgress();}, 1000);
},
showMap: function( info ) {
+ this.locateCount = 21;
+ $('#progress-bar').css( 'background-color', 'green' );
$('#locating').hide();
var coords = info.coordinates;
fixmystreet.latitude = coords.latitude;
@@ -48,6 +77,7 @@
},
noMap: function( details ) {
+ this.locateCount = 21;
$('#locating').hide();
$('#ajaxOverlay').hide();
if ( details.msg ) {