Merge pull request #2432 from phl0/ajaxToPost

这个提交包含在:
Andreas Kristiansen 2023-09-05 12:56:04 +02:00 提交者 GitHub
当前提交 e74a949b07
找不到此签名对应的密钥
GPG 密钥 ID: 4AEE18F83AFDEB23
共有 5 个文件被更改,包括 124 次插入40 次删除

查看文件

@ -863,7 +863,9 @@ class Logbook extends CI_Controller {
/* return station bearing */ /* return station bearing */
function searchbearing($locator, $station_id = null) { function searchbearing() {
$locator = xss_clean($this->input->post('grid'));
$station_id = xss_clean($this->input->post('stationProfile'));
$this->load->library('Qra'); $this->load->library('Qra');
if($locator != null) { if($locator != null) {
@ -900,7 +902,9 @@ class Logbook extends CI_Controller {
} }
/* return distance */ /* return distance */
function searchdistance($locator, $station_id = null) { function searchdistance() {
$locator = xss_clean($this->input->post('grid'));
$station_id = xss_clean($this->input->post('stationProfile'));
$this->load->library('Qra'); $this->load->library('Qra');
if($locator != null) { if($locator != null) {
@ -995,7 +999,8 @@ class Logbook extends CI_Controller {
return $latlng; return $latlng;
} }
function qralatlngjson($qra) { function qralatlngjson() {
$qra = xss_clean($this->input->post('qra'));
$this->load->library('Qra'); $this->load->library('Qra');
$latlng = $this->qra->qra2latlong($qra); $latlng = $this->qra->qra2latlong($qra);
print json_encode($latlng); print json_encode($latlng);

查看文件

@ -26,9 +26,12 @@ class Qra {
$my = qra2latlong($tx); $my = qra2latlong($tx);
$stn = qra2latlong($rx); $stn = qra2latlong($rx);
$bearing = bearing($my[0], $my[1], $stn[0], $stn[1], $unit); if ($my !== false && $stn !== false ) {
$bearing = bearing($my[0], $my[1], $stn[0], $stn[1], $unit);
return $bearing; return $bearing;
} else {
return false;
}
} }
/* /*
@ -168,6 +171,11 @@ function qra2latlong($strQRA) {
if (substr_count($strQRA, ',') == 3) { if (substr_count($strQRA, ',') == 3) {
// Handle grid corners // Handle grid corners
$grids = explode(',', $strQRA); $grids = explode(',', $strQRA);
$gridlengths = array(strlen($grids[0]), strlen($grids[1]), strlen($grids[2]), strlen($grids[3]));
$same = array_count_values($gridlengths);
if (count($same) != 1) {
return false;
}
$coords = array(0, 0); $coords = array(0, 0);
for($i=0; $i<4; $i++) { for($i=0; $i<4; $i++) {
$cornercoords[$i] = qra2latlong($grids[$i]); $cornercoords[$i] = qra2latlong($grids[$i]);
@ -178,6 +186,9 @@ function qra2latlong($strQRA) {
} else if (substr_count($strQRA, ',') == 1) { } else if (substr_count($strQRA, ',') == 1) {
// Handle grid lines // Handle grid lines
$grids = explode(',', $strQRA); $grids = explode(',', $strQRA);
if (strlen($grids[0]) != strlen($grids[1])) {
return false;
}
$coords = array(0, 0); $coords = array(0, 0);
for($i=0; $i<2; $i++) { for($i=0; $i<2; $i++) {
$linecoords[$i] = qra2latlong($grids[$i]); $linecoords[$i] = qra2latlong($grids[$i]);

查看文件

@ -981,18 +981,29 @@ $(document).on('keypress',function(e) {
var markers = L.layerGroup(); var markers = L.layerGroup();
var pos = [51.505, -0.09]; var pos = [51.505, -0.09];
var mymap = L.map('qsomap').setView(pos, 12); var mymap = L.map('qsomap').setView(pos, 12);
<?php $.ajax({
if ($active_station_info->station_gridsquare != "") { ?> url: base_url + 'index.php/logbook/qralatlngjson',
$.getJSON('logbook/qralatlngjson/<?php echo $user_gridsquare; ?>', function(result) { type: 'post',
mymap.panTo([result[0], result[1]]); data: {
pos = result; <?php if ($active_station_info->station_gridsquare != "") { ?>
}) qra: '<?php echo $user_gridsquare; ?>',
<?php } else if (null !== $this->config->item('locator')) { ?> <?php } else if (null !== $this->config->item('locator')) { ?>
$.getJSON('logbook/qralatlngjson/<?php echo $this->config->item('locator'); ?>', function(result) { qra: '<?php echo $this->config->item('locator'); ?>',
mymap.panTo([result[0], result[1]]); <?php } else { ?>
pos = result; // Fallback to London in case all else fails
}) qra: 'IO91WM',
<?php } ?> <?php } ?>
},
success: function(data) {
result = JSON.parse(data);
if (typeof result[0] !== "undefined" && typeof result[1] !== "undefined") {
mymap.panTo([result[0], result[1]]);
pos = result;
}
},
error: function() {
},
});
L.tileLayer('<?php echo $this->optionslib->get_option('option_map_tile_server');?>', { L.tileLayer('<?php echo $this->optionslib->get_option('option_map_tile_server');?>', {
maxZoom: 18, maxZoom: 18,

查看文件

@ -152,9 +152,33 @@ function qso_edit(id) {
$('#locator').change(function(){ $('#locator').change(function(){
if ($(this).val().length >= 4) { if ($(this).val().length >= 4) {
$('#locator_info').load(base_url + "index.php/logbook/searchbearing/" + $(this).val() + "/" + $('#stationProfile').val()).fadeIn("slow"); $.ajax({
$.get(base_url + 'index.php/logbook/searchdistance/' + $(this).val() + "/" + $('#stationProfile').val(), function(result) { url: base_url + 'index.php/logbook/searchbearing',
document.getElementById("distance").value = result; type: 'post',
data: {
grid: $(this).val(),
stationProfile: $('#stationProfile').val()
},
success: function(data) {
$('#locator_info').html(data).fadeIn("slow");
},
error: function() {
$('#locator_info').text("Error loading bearing!").fadeIn("slow");
},
});
$.ajax({
url: base_url + 'index.php/logbook/searchdistance',
type: 'post',
data: {
grid: $(this).val(),
stationProfile: $('#stationProfile').val()
},
success: function(data) {
document.getElementById("distance").value = data;
},
error: function() {
document.getElementById("distance").value = null;
},
}); });
} }
}); });

查看文件

@ -811,27 +811,60 @@ $("#locator").keyup(function(){
} }
if(qra_input.length >= 4 && $(this).val().length > 0) { if(qra_input.length >= 4 && $(this).val().length > 0) {
$.getJSON(base_url + 'index.php/logbook/qralatlngjson/' + $(this).val(), function(result) $.ajax({
{ url: base_url + 'index.php/logbook/qralatlngjson',
// Set Map to Lat/Long type: 'post',
markers.clearLayers(); data: {
if (typeof result !== "undefined") { qra: $(this).val(),
var redIcon = L.icon({ },
iconUrl: icon_dot_url, success: function(data) {
iconSize: [18, 18], // size of the icon // Set Map to Lat/Long
}); result = JSON.parse(data);
markers.clearLayers();
if (typeof result[0] !== "undefined" && typeof result[1] !== "undefined") {
var redIcon = L.icon({
iconUrl: icon_dot_url,
iconSize: [18, 18], // size of the icon
});
var marker = L.marker([result[0], result[1]], {icon: redIcon}); var marker = L.marker([result[0], result[1]], {icon: redIcon});
mymap.setZoom(8); mymap.setZoom(8);
mymap.panTo([result[0], result[1]]); mymap.panTo([result[0], result[1]]);
mymap.setView([result[0], result[1]], 8); mymap.setView([result[0], result[1]], 8);
} markers.addLayer(marker).addTo(mymap);
markers.addLayer(marker).addTo(mymap); }
}) },
error: function() {
},
});
$('#locator_info').load(base_url +"index.php/logbook/searchbearing/" + $(this).val() + "/" + $('#stationProfile').val()).fadeIn("slow"); $.ajax({
$.get(base_url + 'index.php/logbook/searchdistance/' + $(this).val() + "/" + $('#stationProfile').val(), function(result) { url: base_url + 'index.php/logbook/searchbearing',
document.getElementById("distance").value = result; type: 'post',
data: {
grid: $(this).val(),
stationProfile: $('#stationProfile').val()
},
success: function(data) {
$('#locator_info').html(data).fadeIn("slow");
},
error: function() {
$('#locator_info').text("Error loading bearing!").fadeIn("slow");
},
});
$.ajax({
url: base_url + 'index.php/logbook/searchdistance',
type: 'post',
data: {
grid: $(this).val(),
stationProfile: $('#stationProfile').val()
},
success: function(data) {
document.getElementById("distance").value = data;
},
error: function() {
document.getElementById("distance").value = null;
},
}); });
} }
} }