aboutsummaryrefslogtreecommitdiffstats
path: root/www/js
diff options
context:
space:
mode:
Diffstat (limited to 'www/js')
-rw-r--r--www/js/locate.js2
-rw-r--r--www/js/views/search.js19
2 files changed, 18 insertions, 3 deletions
diff --git a/www/js/locate.js b/www/js/locate.js
index 02d47bc..3912a32 100644
--- a/www/js/locate.js
+++ b/www/js/locate.js
@@ -22,7 +22,7 @@
if ( data.latitude ) {
that.trigger('search_located', { coordinates: { latitude: data.latitude, longitude: data.longitude } } );
} else if ( data.suggestions ) {
- that.trigger( 'search_failed', { locs: data.suggestions } );
+ that.trigger( 'search_failed', { suggestions: data.suggestions, locations: data.locations } );
} else {
that.trigger( 'search_failed', { msg: data.error } );
}
diff --git a/www/js/views/search.js b/www/js/views/search.js
index 8e2bfd2..6f26e02 100644
--- a/www/js/views/search.js
+++ b/www/js/views/search.js
@@ -5,6 +5,7 @@
id: 'search-page',
events: {
+ 'click a.address': 'goAddress',
'click #submit': 'search',
'pagehide': 'destroy',
'pageshow': 'afterDisplay'
@@ -26,13 +27,27 @@
this.navigate('around');
},
+ goAddress: function(e) {
+ var t = $(e.target);
+ var lat = t.attr('data-lat');
+ var long = t.attr('data-long');
+
+ FMS.currentLocation = { latitude: lat, longitude: long };
+ this.navigate('around');
+ },
searchFail: function( details ) {
$('#ajaxOverlay').hide();
if ( details.msg ) {
this.displayError( details.msg );
- } else if ( details.locs ) {
- this.displayError( FMS.strings.multiple_locations );
+ } else if ( details.locations ) {
+ var multiple = '';
+ for ( var i = 0; i < details.locations.length; i++ ) {
+ var loc = details.locations[i];
+ var li = '<li><a class="address" id="location_' + i + '" data-lat="' + loc.lat + '" data-long="' + loc.long + '">' + loc.address + '</a></li>';
+ multiple = multiple + li;
+ }
+ $('#front-howto').html('<ul>' + multiple + '</ul>');
} else {
this.displayError( FMS.strings.location_problem );
}