Created
August 21, 2013 14:03
-
-
Save mchristie/6294868 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function timeout_warning() | |
{ | |
$('#location_feedback').html('<p>Hmmm, this is taking a while, maybe your browser doesn\'t support geolocation?<br /><br /><a href="/browse" class="button">Browse towns</a> <a href="/" class="button">Search</a></p>'); | |
$('#location_feedback').attr('class', 'warning'); | |
} | |
var timer = setTimeout("timeout_warning()", 10000); | |
if (navigator.geolocation) { | |
navigator.geolocation.getCurrentPosition(function(position) { | |
if (position.coords.accuracy > 25000) { | |
$('#location_feedback').html('<p>We can\'t get a very accurate fix on your location, sorry.<br />Try <a href="/browse">browsing towns instead</a>.'); | |
$('#location_feedback').html('<br /><a href="/browse" class="button medium">browsing towns</a>.</p>'); | |
$('#radar').remove(); | |
<!-- $('#location_feedback').addClass('alert-box alert'); --> | |
clearTimeout(timer); | |
} else { | |
$('#location_feedback').text('Hazzah! Your location is '+position.coords.latitude+","+position.coords.longitude+', finding takeaways...'); | |
<!-- $('#location_feedback').addClass('alert-box success'); --> | |
window.location = '/takeaways/near-me/'+position.coords.latitude+"/"+position.coords.longitude; | |
} | |
}); | |
} else { | |
$('#location_feedback').text('Sorry, but geolocation services are not supported by your browser.'); | |
$('#location_feedback').attr('class', 'error'); | |
clearTimeout(timer); | |
} | |
// Find a town link just incase | |
$.getJSON('/browse/town_link', function(data) { | |
$('#town_link'). | |
html('It looks like your in <strong>'+data.name+'</strong>, would you like to <a href="'+data.url+'">look for Takeaways in '+data.name+'</a>?'). | |
show(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment