Burathar
4 years ago
7 changed files with 84 additions and 10 deletions
@ -0,0 +1,45 @@
@@ -0,0 +1,45 @@
|
||||
{% 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 %} |
Loading…
Reference in new issue