You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.1 KiB
45 lines
1.1 KiB
4 years ago
|
{% extends 'base.html' %}
|
||
|
|
||
|
{% block app_content %}
|
||
|
<meta name="csrf-token" content="{{ csrf_token() }}">
|
||
|
{% block player_app_content %}{% endblock %}
|
||
|
{% endblock %}
|
||
|
|
||
|
{% block scripts %}
|
||
|
{{ super() }}
|
||
|
<script>
|
||
|
var csrftoken = $('meta[name=csrf-token]').attr('content')
|
||
|
$.ajaxSetup({
|
||
|
beforeSend: function(xhr, settings) {
|
||
|
if (!/^(GET|HEAD|OPTIONS|TRACE)$/i.test(settings.type) && !this.crossDomain) {
|
||
|
xhr.setRequestHeader("X-CSRFToken", csrftoken)
|
||
|
}
|
||
|
}
|
||
|
})
|
||
|
|
||
|
function sendLocation(position) {
|
||
|
$.ajax({
|
||
|
type: "POST",
|
||
|
url: "{{ url_for('main.send_location', username=current_user.name) }}",
|
||
|
data:{
|
||
|
lat: position.coords.latitude,
|
||
|
long: position.coords.longitude
|
||
|
},
|
||
|
|
||
|
error: function(error) {
|
||
|
console.log(error);
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
|
||
|
$(document).ready(function(){
|
||
|
if (navigator.geolocation) {
|
||
|
navigator.geolocation.getCurrentPosition(sendLocation);
|
||
|
|
||
|
} else {
|
||
|
console.log('Geolocation is not supported by this browser.')
|
||
|
}
|
||
|
})
|
||
|
|
||
|
</script>
|
||
|
{% endblock %}
|