From a84aa06965837b8f2e9e9a2c1707db44558a2502 Mon Sep 17 00:00:00 2001 From: phl0 Date: Tue, 29 Aug 2023 23:38:24 +0200 Subject: [PATCH] Move searchdistance to POST parameters --- application/controllers/Logbook.php | 4 +++- assets/js/sections/common.js | 15 +++++++++++++-- assets/js/sections/qso.js | 17 ++++++++++++++--- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/application/controllers/Logbook.php b/application/controllers/Logbook.php index 7c198db7..6efb85f5 100644 --- a/application/controllers/Logbook.php +++ b/application/controllers/Logbook.php @@ -917,7 +917,9 @@ class Logbook extends CI_Controller { } /* 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'); if($locator != null) { diff --git a/assets/js/sections/common.js b/assets/js/sections/common.js index 158b1228..a5d1298a 100644 --- a/assets/js/sections/common.js +++ b/assets/js/sections/common.js @@ -153,8 +153,19 @@ function qso_edit(id) { $('#locator').change(function(){ if ($(this).val().length >= 4) { $('#locator_info').load(base_url + "index.php/logbook/searchbearing/" + $(this).val() + "/" + $('#stationProfile').val()).fadeIn("slow"); - $.get(base_url + 'index.php/logbook/searchdistance/' + $(this).val() + "/" + $('#stationProfile').val(), function(result) { - document.getElementById("distance").value = result; + $.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 = 'Error calculating distance!'; + }, }); } }); diff --git a/assets/js/sections/qso.js b/assets/js/sections/qso.js index 777a82db..1d1e6a2e 100644 --- a/assets/js/sections/qso.js +++ b/assets/js/sections/qso.js @@ -849,11 +849,22 @@ $("#locator").keyup(function(){ $('#locator_info').html(data).fadeIn("slow"); }, error: function() { - $('#locator_info').text("Error loading bearing and distance").fadeIn("slow"); + $('#locator_info').text("Error loading bearing!").fadeIn("slow"); }, }); - $.get(base_url + 'index.php/logbook/searchdistance/' + $(this).val() + "/" + $('#stationProfile').val(), function(result) { - document.getElementById("distance").value = result; + $.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 = 'Error calculating distance!'; + }, }); } }