/* * fixmystreet.js * FixMyStreet JavaScript */ function form_category_onchange() { if ( category_extras ) { if ( $('#category_meta').size() ) { $('#category_meta').empty(); } else { $('#form_category_row').after( '
' ); } if ( category_extras[this.options[ this.selectedIndex ].text] ) { var fields = category_extras[this.options[ this.selectedIndex ].text]; $('Or locate me automatically').css({ "padding-bottom": "0.5em" });
$('#geolocate_link').click(function(e) {
e.preventDefault();
// Spinny thing!
$('#geolocate_para').append(' ');
geo_position_js.getCurrentPosition(function(pos) {
$('#geolocate_para img').remove();
var latitude = pos.coords.latitude;
var longitude = pos.coords.longitude;
location.href = '/around?latitude=' + latitude + ';longitude=' + longitude;
}, function(err) {
$('#geolocate_para img').remove();
if (err.code == 1) { // User said no
} else if (err.code == 2) { // No position
$('#geolocate_para').html("Could not look up location");
} else if (err.code == 3) { // Too long
$('#geolocate_para').html("No result returned");
} else { // Unknown
$('#geolocate_para').html("Unknown error");
}
}, {
timeout: 10000
});
});
}
});