From 9ad9e7c0f002cb34893fc99dd8fb43525c51b50e Mon Sep 17 00:00:00 2001 From: DJ3CE Date: Sat, 11 Jan 2025 02:30:23 +0100 Subject: [PATCH] Further improvements to SimpleFle * show contest-exchange beneath RSTr/-s, as usual * implement non-numeric contest-exchange * warn, if xor contest-select / contest-data present * introduce increment-mode, to be set by user * add documentation --- application/views/simplefle/index.php | 3 +- application/views/simplefle/syntax_help.php | 36 ++++++ assets/js/sections/simplefle.js | 121 +++++++++++++++++--- 3 files changed, 140 insertions(+), 20 deletions(-) diff --git a/application/views/simplefle/index.php b/application/views/simplefle/index.php index 0ef87a99e..1929c89aa 100644 --- a/application/views/simplefle/index.php +++ b/application/views/simplefle/index.php @@ -32,6 +32,7 @@ var lang_qso_simplefle_warning_missing_band_mode = ""; var lang_qso_simplefle_warning_missing_time = ""; var lang_qso_simplefle_warning_example_data = ""; + var lang_qso_simplefle_warning_missing_contestid = ""; var lang_qso_simplefle_confirm_save_to_log = ""; var lang_qso_simplefle_success_save_to_log_header = ""; var lang_qso_simplefle_success_save_to_log = ""; @@ -187,4 +188,4 @@ - \ No newline at end of file + diff --git a/application/views/simplefle/syntax_help.php b/application/views/simplefle/syntax_help.php index 62e770a3c..c1969e5dd 100644 --- a/application/views/simplefle/syntax_help.php +++ b/application/views/simplefle/syntax_help.php @@ -25,5 +25,41 @@ day ++ df3et +

+

+
+    2112 dj3ce < comment >
+
+

+
+  2112 dj3ce @Cedric
+
+

+
+  2112 dj3ce [tnx qso]
+
+

+
+    2112 dj3ce ,1.12
+    2113 dj3ce ,LA.DL
+    2114 dj3ce ,12,LA.14.DL
+    2114 dj3ce .14 ,12 .DL ,LA
+
+

+
+    ,++
+    2112 dj3ce ,1.12
+    2113 dk0mm .105
+
+

+
+    2115 dj3ce ,15,D23.1.F39
+    2116 dk0mm ,-,16.1015
+
+

+

+
+    2119 dj3ce      <...>
+

', ''); ?>

diff --git a/assets/js/sections/simplefle.js b/assets/js/sections/simplefle.js index 3ca4b26c3..7ae2a891d 100644 --- a/assets/js/sections/simplefle.js +++ b/assets/js/sections/simplefle.js @@ -226,6 +226,9 @@ function handleInput() { var sotaWwff = ""; var srx = ""; var stx = ""; + var stx_incr_mode = 0; + var prev_stx = ""; + var prev_stx_string = ""; qsoList = []; $("#qsoTable tbody").empty(); errors = []; @@ -238,10 +241,11 @@ function handleInput() { var rst_r = null; var gridsquare = ""; var srx = ""; + var stx = ""; var call_rec = false; var add_info = {}; - // First, search for <...>-Patterns, which may contain comments (... or additional fields) + // First, search for <...>- and [...]-Patterns, which may contain comments (... or additional fields) / qsl-notes let addInfoMatches = row.matchAll(/<([^>]*)>|\[([^\]]*)\]/g); addInfoMatches.forEach((item) => { row = row.replace(item[0], ""); @@ -326,21 +330,60 @@ function handleInput() { } else { rst_r = item; } - } else if (itemNumber > 0 && (parts = item.match(/^([\.,])(\d*)(,|([\.,])(\d+))?$/))) { // Contest ,*** .*** - if (parts[1] == ',') { - stx = parts[2]; - } else { - srx = parts[2]; - } - if (parts.length > 3 && parts[3] !== undefined && parts[3] == ',') { // With ',' only increment stx - stx++; - } else if (parts.length > 4 && parts[4] !== undefined) { - if (parts[4] == ',') { - stx = parts[5]; - } else { - srx = parts[5]; + } else if (itemNumber > 0 && (parts = item.match(/^(([\.,])((\d*|\+[\+0]|-)|([A-Za-z0-9\/]+)))+$/))) { // Contest ,*** .*** + // Caution! May be entered multiple times, and may contain empty tokens + // Iterate over all parts -- take care to behave exactly like entered with spaces + item.matchAll(/([\.,])((\d*|\+[\+0]|-)|([A-Za-z0-9\/]+))(?=$|[\.,])/g).forEach((exch) => { + var pre_stx = stx; + var pre_srx = srx; + + switch (exch[1]+((exch[3]===undefined)?'s':'n')) { // [.,][sn] + case ".n": // Received serial + srx = exch[2]; + break; + case ",n": // Sent serial + stx = exch[2]; + break; + case ".s": // Received exchange + add_info.srx_string = exch[2]; + break; + case ",s": // Sent exchange + add_info.stx_string = exch[2]; } - } + + // Mode swith + if (stx == "++") { + stx = pre_stx; + stx_incr_mode = 1; + return; // no further processing of this (sub-)token here jumps to next pattern, if available + } else if (stx == "+0") { + stx = pre_stx; + stx_incr_mode = 0; + return; // no further processing of this (sub-)token here jumps to next pattern, if available + } + + if (stx == '-') { // Wipe all sent exchange if '-' + stx = ''; + prev_stx = ''; + delete add_info.stx_string; + prev_stx_string = ''; + } + + // FLE paradima: Previous if not set - we have some sort of contest exchange, so + // re-apply previously set stx / stx_string if not already populated + if (prev_stx != '' && stx == '') { + stx = (prev_stx*1) + stx_incr_mode; + } + + if (prev_stx_string != '' && add_info.stx_string === undefined) { + add_info.stx_string = prev_stx_string; + } + + // Sanity check + if (srx == "++" || srx == "+0" || srx == '-') srx = pre_srx; + }); + + } else if (itemNumber > 0 && (parts = item.match(/(?<=^@)[A-Za-z]+/))) { add_info.name = parts[0]; } @@ -403,17 +446,34 @@ function handleInput() { sotaWwffText = `W: ${sotaWwff}`; } - const refs = [sotaWwffText,stx,srx].filter( (x) => x.length>0 || x>0 ).join(','); + // Contest exchange info: sent + let stx_info = ""; + if (stx != '') { + stx_info += `${stx}`; + } + if (add_info.stx_string !== undefined && add_info.stx_string.length > 0) { + stx_info += `${add_info.stx_string}`; + } + + // Contest exchange info: received + let srx_info = ""; + if (srx != '') { + srx_info += `${srx}`; + } + if (add_info.srx_string !== undefined && add_info.srx_string.length > 0) { + srx_info += `${add_info.srx_string}`; + } + const tableRow = $(` ${extraQsoDate} ${qsotime} ${callsign} ${band} ${mode} - ${rst_s} - ${rst_r} + ${rst_s}${stx_info} + ${rst_r}${srx_info} ${gridsquare} - ${refs} + ${sotaWwffText} `); $("#qsoTable > tbody:last-child").append(tableRow); @@ -456,6 +516,8 @@ function handleInput() { } prevMode = mode; + prev_stx = stx; + prev_stx_string = add_info.stx_string ?? ''; }); // Scroll to the bototm of #qsoTableBody (scroll by the value of its scrollheight property) @@ -761,6 +823,16 @@ function isExampleDataEntered() { return isExampleData; } +function isAllContestDataWithContestId() { + // true = allfine, false = something wrong + let hasContestId = $("#contest").val() != ''; + let hasContestData = false; + qsoList.forEach((item) => { + hasContestData = hasContestData || (item[10] != '' || item[12].stx_string !== undefined || item[11] != '' || item[12].stx_string !== undefined); + }); + return hasContestData == hasContestId; +} + function getAdifTag(tagName, value) { return "<" + tagName + ":" + value.length + ">" + value + " "; } @@ -932,6 +1004,17 @@ $(".js-save-to-log").click(function () { }); return false; } + if (false === isAllContestDataWithContestId()) { + BootstrapDialog.alert({ + title: lang_general_word_warning, + message: lang_qso_simplefle_warning_missing_contestid, + type: BootstrapDialog.TYPE_DANGER, + btnCancelLabel: lang_general_word_cancel, + btnOKLabel: lang_general_word_ok, + btnOKClass: "btn-warning", + }); + return false; + } if (true === isExampleDataEntered()) { BootstrapDialog.alert({ title: lang_general_word_warning,