aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2012-10-12 13:57:00 +0100
committerMatthew Somerville <matthew@mysociety.org>2012-10-12 13:57:00 +0100
commit2d6757a8032db76859f6cdb5178879b3e9b719cc (patch)
treef9c33a307f375667e37897ebd76f33d644b11228
parent6133310264e6539a91be9ef8e60ece4839dcb4dd (diff)
Add auto-location to alert page (fixes #23).
-rw-r--r--perllib/FixMyStreet/Cobrand/UK.pm1
-rw-r--r--web/js/fixmystreet.js9
2 files changed, 6 insertions, 4 deletions
diff --git a/perllib/FixMyStreet/Cobrand/UK.pm b/perllib/FixMyStreet/Cobrand/UK.pm
index 75f6ba061..dfdce641e 100644
--- a/perllib/FixMyStreet/Cobrand/UK.pm
+++ b/perllib/FixMyStreet/Cobrand/UK.pm
@@ -144,7 +144,6 @@ sub find_closest {
my $str = $self->SUPER::find_closest( $latitude, $longitude, $problem );
- # Get nearest postcode from Matthew's random gazetteer (put in MaPit? Or elsewhere?)
my $url = "http://mapit.mysociety.org/nearest/4326/$longitude,$latitude";
my $j = LWP::Simple::get($url);
if ($j) {
diff --git a/web/js/fixmystreet.js b/web/js/fixmystreet.js
index b689d501c..6ae4ed92d 100644
--- a/web/js/fixmystreet.js
+++ b/web/js/fixmystreet.js
@@ -134,10 +134,12 @@ $(function(){
// Geolocation
if (geo_position_js.init()) {
+ var link = '<a href="#LINK" id="geolocate_link">&hellip; or locate me automatically</a>';
+ $('form[action="/alert/list"]').append(link.replace('LINK','alert/list'));
if ($('body.frontpage').length) {
- $('#postcodeForm').after('<a href="#" id="geolocate_link">&hellip; or locate me automatically</a>');
+ $('#postcodeForm').after(link.replace('LINK','around'));
} else{
- $('#postcodeForm').append('<a href="#" id="geolocate_link">&hellip; or locate me automatically</a>');
+ $('#postcodeForm').append(link.replace('LINK','around'));
}
$('#geolocate_link').click(function(e) {
var $link = $(this);
@@ -152,7 +154,8 @@ $(function(){
$link.find('img').remove();
var latitude = pos.coords.latitude;
var longitude = pos.coords.longitude;
- location.href = '/around?latitude=' + latitude + ';longitude=' + longitude;
+ var page = $link.attr('href').substr(1);
+ location.href = '/' + page + '?latitude=' + latitude + ';longitude=' + longitude;
}, function(err) {
$link.find('img').remove();
if (err.code == 1) { // User said no