NDOJ/templates/timezone/media-js.html
cuom1999 d7cc620a0a Add markdown utils
- External links open in a new tab
- Clicking on image open an image modal
2024-06-06 21:17:11 -05:00

44 lines
No EOL
1.6 KiB
HTML

{% compress js %}
<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 %}