Fixed a bug: show map image alternative when offline

Former-commit-id: f800226594a46447c031e2e9273d33a04f86a810
This commit is contained in:
Tatiana Llorente 2019-03-21 18:13:21 +01:00
parent b8f1b5f6a1
commit 151fe6ac78
2 changed files with 39 additions and 16 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View File

@ -681,22 +681,45 @@ if (!defined('METACONSOLE')) {
</style> </style>
<script language="javascript" type="text/javascript"> <script language="javascript" type="text/javascript">
var optionText = $("#timezone option:selected").val(); // Get the map
$(function() { var map_url = "http://a.tile.openstreetmap.org";
$("#zonepicker").timezonePicker({ // 1. Create a new XMLHttpRequest object
initialLat: 20, var xhr = new XMLHttpRequest();
initialLng: 0, // 2. Configure it: GET-request for the map_url
initialZoom: 2, xhr.open('GET', map_url);
onReady: function() { // 3. Send the request over the network
$("#zonepicker").timezonePicker('selectZone', optionText); xhr.send();
}, // 4. This will be called after the response is received
mapOptions: { xhr.onload = function() {
maxZoom: 6, // analyze HTTP status of the response
minZoom: 2 if (xhr.status != 200) {
}, var map_unavailable = false;
useOpenLayers: true } else {
}); var map_unavailable = true;
}); }
var img_src = "<?php echo ui_get_full_url('images/edit_user_map_not_available.jpg', false, false, false, false); ?>";
if(map_unavailable === false){
$("#zonepicker").append('<img src="'+img_src+'" alt="This map is not available" title="This map is not available" style="max-width:100%"/>').css('text-align','center');
}else{
var optionText = $("#timezone option:selected").val();
$(function() {
$("#zonepicker").timezonePicker({
initialLat: 20,
initialLng: 0,
initialZoom: 2,
onReady: function() {
$("#zonepicker").timezonePicker('selectZone', optionText);
},
mapOptions: {
maxZoom: 6,
minZoom: 2
},
useOpenLayers: true
});
});
}
};
</script> </script>
<?php <?php