Update distance on change of locator

pull/2215/head
phl0 2023-06-15 18:15:29 +02:00
rodzic 11efa6b03a
commit 386e0977e9
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 48EA1E640798CA9A
2 zmienionych plików z 33 dodań i 0 usunięć

Wyświetl plik

@ -952,6 +952,36 @@ class Logbook extends CI_Controller {
return "";
}
/* return distance */
function searchdistance($locator, $station_id = null) {
$this->load->library('Qra');
if($locator != null) {
if (isset($station_id)) {
// be sure that station belongs to user
$this->load->model('Stations');
if (!$this->Stations->check_station_is_accessible($station_id)) {
return 0;
}
// get station profile
$station_profile = $this->Stations->profile_clean($station_id);
// get locator
$mylocator = $station_profile->station_gridsquare;
} else if($this->session->userdata('user_locator') != null){
$mylocator = $this->session->userdata('user_locator');
} else {
$mylocator = $this->config->item('locator');
}
$distance = $this->qra->distance($mylocator, $locator, 'K');
echo round($distance, 0);
}
return 0;
}
/* return station bearing */
function bearing($locator, $unit = 'M', $station_id = null) {
$this->load->library('Qra');

Wyświetl plik

@ -711,6 +711,9 @@ $("#locator").keyup(function(){
})
$('#locator_info').load("logbook/searchbearing/" + $(this).val() + "/" + $('#stationProfile').val()).fadeIn("slow");
$.get('logbook/searchdistance/' + $(this).val() + "/" + $('#stationProfile').val(), function(result) {
document.getElementById("distance").value = result;
});
}
}
});