From a313d261a700f44d7b67f15bc34f83099be0a623 Mon Sep 17 00:00:00 2001 From: Andreas Kristiansen <6977712+AndreasK79@users.noreply.github.com> Date: Mon, 24 Mar 2025 10:01:41 +0100 Subject: [PATCH] [QSO Entry] Add summary for more awards --- application/controllers/Qso.php | 8 +- application/views/lookup/result.php | 64 +++++---- application/views/qso/award_tabs.php | 49 +++++++ assets/js/sections/common.js | 8 +- assets/js/sections/qso.js | 196 ++++++++++++++++++++++++++- 5 files changed, 279 insertions(+), 46 deletions(-) create mode 100644 application/views/qso/award_tabs.php diff --git a/application/controllers/Qso.php b/application/controllers/Qso.php index d4cf3a345..c72882ea4 100644 --- a/application/controllers/Qso.php +++ b/application/controllers/Qso.php @@ -668,7 +668,7 @@ class QSO extends CI_Controller { /** * Open the API url which causes the browser to open the QSO live logging and populate the callsign with the data from the API - * + * * Usage example: * https:///index.php/qso/log_qso?callsign=4W7EST */ @@ -697,7 +697,7 @@ class QSO extends CI_Controller { } /** - * Easy modal Loader + * Easy modal Loader * Used for Share Modal in QSO Details view */ function getShareModal() { @@ -711,4 +711,8 @@ class QSO extends CI_Controller { $this->load->view('qso/components/share_modal', $data, false); } + + function getAwardTabs() { + $this->load->view('qso/award_tabs'); + } } diff --git a/application/views/lookup/result.php b/application/views/lookup/result.php index 25346881b..1dc872338 100644 --- a/application/views/lookup/result.php +++ b/application/views/lookup/result.php @@ -24,44 +24,42 @@ foreach ($result as $mode => $value) { } if ($showRow) { - echo ' - '. strtoupper($mode) .''; + echo '' . strtoupper($mode) . ''; + + $typeMapping = [ + 'dxcc' => $dxcc, + 'iota' => $iota, + 'vucc' => substr(trim($grid), 0, 4), + 'cq' => $cqz, + 'was' => $was, + 'sota' => $sota, + 'wwff' => $wwff, + 'itu' => $ituz, + 'continent' => $continent, + 'pota' => $pota, + ]; + foreach ($value as $key => $val) { - switch($type) { - // function displayContacts(searchphrase, band, sat, orbit, mode, type, qsl) { + $searchPhrase = isset($typeMapping[$type]) ? str_replace("&", "%26", $typeMapping[$type]) : ''; - case 'dxcc': $linkinfo = '' . $val . ''; break; - case 'iota': $linkinfo = '' . $val . ''; break; - case 'vucc': $linkinfo = '' . $val . ''; break; - case 'cq': $linkinfo = '' . $val . ''; break; - case 'was': $linkinfo = '' . $val . ''; break; - case 'sota': $linkinfo = '' . $val . ''; break; - case 'pota': $linkinfo = '' . $val . ''; break; - case 'wwff': $linkinfo = '' . $val . ''; break; - case 'itu': $linkinfo = '' . $val . ''; break; - case 'continent': $linkinfo = '' . $val . ''; break; + $linkinfo = $searchPhrase + ? "$val" + : $val; + + $tdClass = ($current_band == $key && strtoupper($current_mode) == strtoupper($mode)) + ? "class='border-3 border-danger'" + : ''; + + $content = $val; + if ($val === 'W') { + $content = "
$linkinfo
"; + } elseif ($val === 'C') { + $content = "
$linkinfo
"; } - if ($current_band == $key && strtoupper($current_mode )== strtoupper($mode)) { - $info = ''; - } else { - $info = ''; - } - - if ($val == 'W') { - $info .= '
' . $linkinfo . '
'; - } - else if ($val == 'C') { - $info .= '
' . $linkinfo . '
'; - } - else { - $info .= $val; - } - - $info .= ''; - - echo $info; + echo "$content"; } + echo ''; } } diff --git a/application/views/qso/award_tabs.php b/application/views/qso/award_tabs.php new file mode 100644 index 000000000..70273ab38 --- /dev/null +++ b/application/views/qso/award_tabs.php @@ -0,0 +1,49 @@ +
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/assets/js/sections/common.js b/assets/js/sections/common.js index 65b2c591a..8cb61d0fa 100644 --- a/assets/js/sections/common.js +++ b/assets/js/sections/common.js @@ -842,12 +842,8 @@ function getDxccResult(dxcc, name) { current_mode: $('#mode').val(), }, success: function (html) { - $('.dxccsummary').remove(); - $('.qsopane').append('

' + lang_dxccsummary_for + name + '
'); - $('.dxccsummarybody').append(html); - $('.dxccsummaryheader').click(function(){ - $('.dxccsummaryheader').toggleClass('dxccsummaryheaderopened'); - }); + $('#dxcc-summary').empty(); + $('#dxcc-summary').append(html); } }); } diff --git a/assets/js/sections/qso.js b/assets/js/sections/qso.js index 7d5559efd..ede423464 100644 --- a/assets/js/sections/qso.js +++ b/assets/js/sections/qso.js @@ -697,7 +697,7 @@ $("#callsign").on("focusout", function () { $('#lotw_link').attr('href', "https://lotw.arrl.org/lotwuser/act?act=" + callsign.replace('Ø', '0')); $('#lotw_link').attr('target', "_blank"); $('#lotw_info').attr('data-bs-toggle', "tooltip"); - if (result.lotw_days == 1) { + if (result.lotw_days == 1) { $('#lotw_info').attr('data-bs-original-title', lang_lotw_upload_day_ago); } else { $('#lotw_info').attr('data-bs-original-title', lang_lotw_upload_days_ago.replace('%x', result.lotw_days)); @@ -853,9 +853,11 @@ $("#callsign").on("focusout", function () { /* display past QSOs */ $('#partial_view').html(result.partial); - // Get DXX Summary - getDxccResult(result.dxcc.adif, convert_case(result.dxcc.entity)); - } + // Get DXCC Summary + loadAwardTabs(function() { + getDxccResult(result.dxcc.adif, convert_case(result.dxcc.entity)); + }); + } // else { // console.log("Callsigns do not match, skipping lookup"); // console.log("Typed Callsign: " + $('#callsign').val()); @@ -868,6 +870,190 @@ $("#callsign").on("focusout", function () { } }) +// This function executes the call to the backend for fetching cq summary and inserted table below qso entry +function getCqResult() { + $.ajax({ + url: base_url + 'index.php/lookup/search', + type: 'post', + data: { + type: 'cq', + cqz: $('#cqz').val(), + reduced_mode: true, + current_band: $('#band').val(), + current_mode: $('#mode').val(), + }, + success: function (html) { + $('#cq-summary').empty(); + $('#cq-summary').append(html); + } + }); +} + +// This function executes the call to the backend for fetching was summary and inserted table below qso entry +function getWasResult() { + if ($('#stateDropdown').val() === '') return; + $.ajax({ + url: base_url + 'index.php/lookup/search', + type: 'post', + data: { + type: 'was', + was: $('#stateDropdown').val(), + reduced_mode: true, + current_band: $('#band').val(), + current_mode: $('#mode').val(), + }, + success: function (html) { + $('#state-summary').empty(); + $('#state-summary').append(html); + } + }); +} + +// This function executes the call to the backend for fetching sota summary and inserted table below qso entry +function getSotaResult() { + if ($('#sota_ref').val() === '') return; + $.ajax({ + url: base_url + 'index.php/lookup/search', + type: 'post', + data: { + type: 'sota', + sota: $('#sota_ref').val(), + reduced_mode: true, + current_band: $('#band').val(), + current_mode: $('#mode').val(), + }, + success: function (html) { + $('#sota-summary').empty(); + $('#sota-summary').append(html); + } + }); +} + +// This function executes the call to the backend for fetching pota summary and inserted table below qso entry +function getPotaResult() { + if ($('#pota_ref').val() === '') return; + $.ajax({ + url: base_url + 'index.php/lookup/search', + type: 'post', + data: { + type: 'pota', + pota: $('#pota_ref').val(), + reduced_mode: true, + current_band: $('#band').val(), + current_mode: $('#mode').val(), + }, + success: function (html) { + $('#pota-summary').empty(); + $('#pota-summary').append(html); + } + }); +} + +// This function executes the call to the backend for fetching continent summary and inserted table below qso entry +function getContinentResult() { + $.ajax({ + url: base_url + 'index.php/lookup/search', + type: 'post', + data: { + type: 'continent', + continent: $('#continent').val(), + reduced_mode: true, + current_band: $('#band').val(), + current_mode: $('#mode').val(), + }, + success: function (html) { + $('#continent-summary').empty(); + $('#continent-summary').append(html); + } + }); +} + +// This function executes the call to the backend for fetching wwff summary and inserted table below qso entry +function getWwffResult() { + if ($('#wwff_ref').val() === '') return; + $.ajax({ + url: base_url + 'index.php/lookup/search', + type: 'post', + data: { + type: 'wwff', + wwff: $('#wwff_ref').val(), + reduced_mode: true, + current_band: $('#band').val(), + current_mode: $('#mode').val(), + }, + success: function (html) { + $('#wwff-summary').empty(); + $('#wwff-summary').append(html); + } + }); +} + +// This function executes the call to the backend for fetching gridsquare summary and inserted table below qso entry +function getGridsquareResult() { + if ($('#locator').val() === '') return; + $.ajax({ + url: base_url + 'index.php/lookup/search', + type: 'post', + data: { + type: 'vucc', + grid: $('#locator').val(), + reduced_mode: true, + current_band: $('#band').val(), + current_mode: $('#mode').val(), + }, + success: function (html) { + $('#gridsquare-summary').empty(); + $('#gridsquare-summary').append(html); + } + }); +} + +function loadAwardTabs(callback) { + $.ajax({ + url: base_url + 'index.php/qso/getAwardTabs', + type: 'post', + data: {}, + success: function (html) { + $('.awardpane').remove(); + $('.qsopane').append('
'); + $('.awardpane').append(html); + + // Execute callback if provided + if (typeof callback === "function") { + callback(); + } + + $("a[href='#cq-summary']").on('shown.bs.tab', function(e) { + getCqResult(); + }); + + $("a[href='#state-summary']").on('shown.bs.tab', function(e) { + getWasResult(); + }); + + $("a[href='#pota-summary']").on('shown.bs.tab', function(e) { + getPotaResult(); + }); + + $("a[href='#continent-summary']").on('shown.bs.tab', function(e) { + getContinentResult(); + }); + + $("a[href='#sota-summary']").on('shown.bs.tab', function(e) { + getSotaResult(); + }); + + $("a[href='#gridsquare-summary']").on('shown.bs.tab', function(e) { + getGridsquareResult(); + }); + + $("a[href='#wwff-summary']").on('shown.bs.tab', function(e) { + getWwffResult(); + }); + } + }); +} + /* time input shortcut */ $('#start_time').on('change', function () { var raw_time = $(this).val(); @@ -1219,7 +1405,7 @@ function resetDefaultQSOFields() { $('#stateDropdown').val(""); $('#callsign-image').attr('style', 'display: none;'); $('#callsign-image-content').text(""); - $('.dxccsummary').remove(); + $('.awardpane').remove(); $('#timesWorked').html(lang_qso_title_previous_contacts); }