diff --git a/application/controllers/Satellite.php b/application/controllers/Satellite.php index 129669559..cdf285253 100644 --- a/application/controllers/Satellite.php +++ b/application/controllers/Satellite.php @@ -237,6 +237,15 @@ class Satellite extends CI_Controller { echo json_encode($satellite_data, JSON_FORCE_OBJECT); } + public function lotw_support() { + $sat = $this->security->xss_clean($this->input->post('sat')); + $this->load->model('satellite_model'); + $lotw_data = $this->satellite_model->lotw_support($sat); + + header('Content-Type: application/json'); + echo json_encode($lotw_data); + } + public function pass() { $this->load->model('satellite_model'); diff --git a/application/models/Satellite_model.php b/application/models/Satellite_model.php index 46a7d0784..4e435ed5e 100644 --- a/application/models/Satellite_model.php +++ b/application/models/Satellite_model.php @@ -197,6 +197,13 @@ class Satellite_model extends CI_Model { return $query->row(); } + function lotw_support($sat) { + $this->db->select('satellite.lotw AS lotw_support'); + $this->db->where('name', $sat); + $query = $this->db->get('satellite'); + return $query->row(); + } + } ?> diff --git a/application/views/qso/index.php b/application/views/qso/index.php index bd657926b..b2d5ec4a3 100644 --- a/application/views/qso/index.php +++ b/application/views/qso/index.php @@ -38,6 +38,9 @@ switch ($date_format) { var lang_qso_wait_before_saving = ""; var latlng=[]; var user_date_format = ""; // Pass the user's date format to JavaScript + var lang_qso_sat_lotw_support_not_found = ""; + var lang_qso_sat_lotw_supported = ""; + var lang_qso_sat_lotw_not_supported = ""; @@ -668,7 +671,9 @@ if (typeof window.DX_WATERFALL_FIELD_MAP === 'undefined') { - +
+   +
diff --git a/assets/js/sections/qso.js b/assets/js/sections/qso.js index 8b8e61e86..83578e432 100644 --- a/assets/js/sections/qso.js +++ b/assets/js/sections/qso.js @@ -933,10 +933,19 @@ $("#sat_name").on('change', function () { $("#selectPropagation").val(""); stop_az_ele_ticker(); } else { + $('#lotw_support').text(""); + $('#lotw_support').removeClass(); get_tles(); + get_lotw_support(); } }); +$("#sat_name").on('focusout', function () { + if ($(this).val().length == 0) { + $('#lotw_support').text(""); + $('#lotw_support').removeClass(); + } +}); var satupdater; @@ -1016,6 +1025,37 @@ function get_tles() { }); } +function get_lotw_support() { + $.ajax({ + url: base_url + 'index.php/satellite/lotw_support', + type: 'post', + data: { + sat: $("#sat_name").val(), + }, + success: function (data) { + if (data == null) { + $('#lotw_support').html(lang_qso_sat_lotw_support_not_found).fadeIn("slow"); + $('#lotw_support').addClass('badge bg-warning'); + //} else if (typeof data === 'string') { + } else { + console.log("TEST "+data.lotw_support); + if (data) { + if (data.lotw_support == 'Y') { + $('#lotw_support').html(lang_qso_sat_lotw_supported).fadeIn("slow"); + $('#lotw_support').addClass('badge bg-success'); + } else if (data.lotw_support == 'N') { + $('#lotw_support').html(lang_qso_sat_lotw_not_supported).fadeIn("slow"); + $('#lotw_support').addClass('badge bg-danger'); + } + } + } + }, + error: function (data) { + console.log('Something went wrong while trying to determine LoTW support for sat: '+$("#sat_name")); + }, + }); +} + if ($("#sat_name").val() !== '') { get_tles(); } @@ -1214,6 +1254,8 @@ function reset_fields() { pendingReferencesMap.clear(); $('#locator_info').text(""); + $('#lotw_support').text(""); + $('#lotw_support').removeClass(); $('#comment').val(""); $('#country').val(""); $('#continent').val(""); @@ -2846,6 +2888,8 @@ function highlightSCP(term, base) { function resetDefaultQSOFields() { $('#callsign_info').text(""); $('#locator_info').text(""); + $('#lotw_support').text(""); + $('#lotw_support').removeClass(); $('#country').val(""); $('#continent').val(""); $("#distance").val("");