Cloned DMOJ
This commit is contained in:
parent
f623974b58
commit
49dc9ff10c
513 changed files with 132349 additions and 39 deletions
45
templates/timezone/media-js.html
Normal file
45
templates/timezone/media-js.html
Normal file
|
@ -0,0 +1,45 @@
|
|||
{% compress js %}
|
||||
<script src="{{ static('libs/featherlight/featherlight.min.js') }}" type="text/javascript"></script>
|
||||
<script type="text/javascript" src="{{ static('libs/timezone-map/timezone-picker.js') }}"></script>
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
$('#open-map').featherlight({
|
||||
afterOpen: function () {
|
||||
timezone_picker($('.featherlight-inner .map-inset'), $('#id_timezone'),
|
||||
'{{ static('libs/timezone-map/timezone-picker.json') }}');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
if ('geolocation' in navigator) {
|
||||
$(function () {
|
||||
$('<span>, <a href="#" id="detect-tz">detect</a></span>').insertAfter('#open-map');
|
||||
$('#detect-tz').click(function (event) {
|
||||
var button = $(this).html('detecting...');
|
||||
navigator.geolocation.getCurrentPosition(function (position) {
|
||||
$.ajax({
|
||||
url: 'https://maps.googleapis.com/maps/api/timezone/json',
|
||||
data: {
|
||||
location: position.coords.latitude + ',' + position.coords.longitude,
|
||||
timestamp: Math.floor(Date.now() / 1000)
|
||||
}
|
||||
}).done(function (data) {
|
||||
if (data['timeZoneId'])
|
||||
$('#id_timezone').val(data.timeZoneId).change();
|
||||
else
|
||||
alert('Invalid response from Google: ' + data);
|
||||
}).fail(function (jqXHR, status) {
|
||||
alert(status);
|
||||
}).always(function () {
|
||||
button.html('detect');
|
||||
});
|
||||
}, function () {
|
||||
button.html('detect');
|
||||
alert('Unable to detect');
|
||||
});
|
||||
event.preventDefault();
|
||||
});
|
||||
});
|
||||
}
|
||||
</script>
|
||||
{% endcompress %}
|
Loading…
Add table
Add a link
Reference in a new issue