From 71a2d1c291ac08ebd27c238e80f5fb3ff842227f Mon Sep 17 00:00:00 2001
From: Andreas <6977712+AndreasK79@users.noreply.github.com>
Date: Sun, 4 Feb 2024 10:28:20 +0100
Subject: [PATCH 1/5] [Contesting] Fix for table qso count
---
assets/js/sections/contesting.js | 63 +++++++++++++-------------------
1 file changed, 26 insertions(+), 37 deletions(-)
diff --git a/assets/js/sections/contesting.js b/assets/js/sections/contesting.js
index 4eea49de1..3cf6d79ed 100644
--- a/assets/js/sections/contesting.js
+++ b/assets/js/sections/contesting.js
@@ -400,14 +400,14 @@ function logQso() {
serials = $("#exch_serial_s").val();
serialr = $("#exch_serial_r").val();
break;
-
+
case 'Serialexchange':
exchsent = $("#exch_sent").val();
exchrcvd = $("#exch_rcvd").val();
serials = $("#exch_serial_s").val();
serialr = $("#exch_serial_r").val();
break;
-
+
case 'Serialgridsquare':
gridr = gridsquare;
vuccr = vucc;
@@ -416,21 +416,6 @@ function logQso() {
break;
}
- var data = [[
- $("#start_date").val() + ' ' + $("#start_time").val(),
- $("#callsign").val().toUpperCase(),
- $("#band").val(),
- $("#mode").val(),
- $("#rst_sent").val(),
- $("#rst_rcvd").val(),
- exchsent,
- exchrcvd,
- serials,
- serialr,
- gridr,
- vuccr,
- ]];
-
var formdata = new FormData(document.getElementById("qso_input"));
$.ajax({
url: base_url + 'index.php/qso/saveqso',
@@ -447,7 +432,7 @@ function logQso() {
}
$('#name').val("");
-
+
$('#callsign').val("");
$('#comment').val("");
$('#exch_rcvd').val("");
@@ -455,7 +440,7 @@ function logQso() {
$('#exch_serial_r').val("");
$("#callsign").focus();
await setSession(formdata);
-
+
await refresh_qso_table(sessiondata);
var qTable = $('.qsotable').DataTable();
qTable.search('').order([0, 'desc']).draw();
@@ -471,23 +456,23 @@ async function getSession() {
type: 'post',
});
}
-
+
async function restoreContestSession(data) {
if (data) {
if (data.copytodok == "1") {
$('#copyexchangetodok').prop('checked', true);
}
-
+
if (data.contestid != "") {
$("#contestname").val(data.contestid);
}
-
+
if (data.exchangetype != "") {
$("#exchangetype").val(data.exchangetype);
setExchangetype(data.exchangetype);
setSerial(data);
}
-
+
if (data.exchangesent != "") {
$("#exch_sent").val(data.exchangesent);
}
@@ -508,6 +493,7 @@ async function refresh_qso_table(data) {
data: { 'qso': data.qso, },
success: function (html) {
var mode = '';
+ var data;
$(".contest_qso_table_contents").empty();
$.each(html, function () {
if (this.col_submode == null || this.col_submode == '') {
@@ -516,20 +502,21 @@ async function refresh_qso_table(data) {
mode = this.col_submode;
}
- $(".qsotable tbody").prepend('
' +
- '| ' + this.col_time_on + ' | ' +
- '' + this.col_call + ' | ' +
- '' + this.col_band + ' | ' +
- '' + mode + ' | ' +
- '' + this.col_rst_sent + ' | ' +
- '' + this.col_rst_rcvd + ' | ' +
- '' + this.col_stx_string + ' | ' +
- '' + this.col_srx_string + ' | ' +
- '' + this.col_stx + ' | ' +
- '' + this.col_srx + ' | ' +
- '' + this.col_gridsquare + ' | ' +
- '' + this.col_vucc_grids + ' | ' +
- '
');
+ data = [[
+ this.col_time_on,
+ this.col_call,
+ this.col_band,
+ mode,
+ this.col_rst_sent,
+ this.col_rst_rcvd,
+ this.col_stx_string,
+ this.col_srx_string,
+ this.col_stx,
+ this.col_srx,
+ this.col_gridsquare,
+ this.col_vucc_grids
+ ]];
+
});
if (!$.fn.DataTable.isDataTable('.qsotable')) {
$.fn.dataTable.moment('DD-MM-YYYY HH:mm:ss');
@@ -561,6 +548,8 @@ async function refresh_qso_table(data) {
]
});
}
+ var table = $('.qsotable').DataTable();
+ table.rows.add(data).draw();
}
});
}
From 457a572257a96fd63aa3ed9d7f3484f0656cf095 Mon Sep 17 00:00:00 2001
From: Andreas <6977712+AndreasK79@users.noreply.github.com>
Date: Sun, 4 Feb 2024 10:44:07 +0100
Subject: [PATCH 2/5] Fixed error when data was empty. Also clear table before
inserting again.
---
assets/js/sections/contesting.js | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/assets/js/sections/contesting.js b/assets/js/sections/contesting.js
index 3cf6d79ed..6a77edbce 100644
--- a/assets/js/sections/contesting.js
+++ b/assets/js/sections/contesting.js
@@ -493,7 +493,7 @@ async function refresh_qso_table(data) {
data: { 'qso': data.qso, },
success: function (html) {
var mode = '';
- var data;
+ var data = [];
$(".contest_qso_table_contents").empty();
$.each(html, function () {
if (this.col_submode == null || this.col_submode == '') {
@@ -549,7 +549,10 @@ async function refresh_qso_table(data) {
});
}
var table = $('.qsotable').DataTable();
- table.rows.add(data).draw();
+ if (data.length > 0) {
+ table.clear();
+ table.rows.add(data).draw();
+ }
}
});
}
From fc43f9b02e8c874df5743cbd451ee6145b3736db Mon Sep 17 00:00:00 2001
From: Andreas <6977712+AndreasK79@users.noreply.github.com>
Date: Sun, 4 Feb 2024 10:56:38 +0100
Subject: [PATCH 3/5] Refactor to get the table to load
---
assets/js/sections/contesting.js | 62 ++++++++++++++++----------------
1 file changed, 32 insertions(+), 30 deletions(-)
diff --git a/assets/js/sections/contesting.js b/assets/js/sections/contesting.js
index 6a77edbce..4b98c8229 100644
--- a/assets/js/sections/contesting.js
+++ b/assets/js/sections/contesting.js
@@ -492,32 +492,6 @@ async function refresh_qso_table(data) {
type: 'post',
data: { 'qso': data.qso, },
success: function (html) {
- var mode = '';
- var data = [];
- $(".contest_qso_table_contents").empty();
- $.each(html, function () {
- if (this.col_submode == null || this.col_submode == '') {
- mode = this.col_mode;
- } else {
- mode = this.col_submode;
- }
-
- data = [[
- this.col_time_on,
- this.col_call,
- this.col_band,
- mode,
- this.col_rst_sent,
- this.col_rst_rcvd,
- this.col_stx_string,
- this.col_srx_string,
- this.col_stx,
- this.col_srx,
- this.col_gridsquare,
- this.col_vucc_grids
- ]];
-
- });
if (!$.fn.DataTable.isDataTable('.qsotable')) {
$.fn.dataTable.moment('DD-MM-YYYY HH:mm:ss');
$('.qsotable').DataTable({
@@ -549,10 +523,38 @@ async function refresh_qso_table(data) {
});
}
var table = $('.qsotable').DataTable();
- if (data.length > 0) {
- table.clear();
- table.rows.add(data).draw();
- }
+ table.clear();
+
+ var mode = '';
+ var data;
+ $.each(html, function () {
+ if (this.col_submode == null || this.col_submode == '') {
+ mode = this.col_mode;
+ } else {
+ mode = this.col_submode;
+ }
+
+ data = [[
+ this.col_time_on,
+ this.col_call,
+ this.col_band,
+ mode,
+ this.col_rst_sent,
+ this.col_rst_rcvd,
+ this.col_stx_string,
+ this.col_srx_string,
+ this.col_stx,
+ this.col_srx,
+ this.col_gridsquare,
+ this.col_vucc_grids
+ ]];
+
+ if (data.length > 0) {
+ table.rows.add(data).draw();
+ }
+
+ });
+
}
});
}
From ed37f6596d6efe5aaabfdad55c347d1fc9026ec1 Mon Sep 17 00:00:00 2001
From: Andreas <6977712+AndreasK79@users.noreply.github.com>
Date: Sun, 4 Feb 2024 11:01:14 +0100
Subject: [PATCH 4/5] Need to clear datatable when session is deleted
---
assets/js/sections/contesting.js | 33 ++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/assets/js/sections/contesting.js b/assets/js/sections/contesting.js
index 4b98c8229..32a994f61 100644
--- a/assets/js/sections/contesting.js
+++ b/assets/js/sections/contesting.js
@@ -36,6 +36,39 @@ async function reset_contest_session() {
$(".contest_qso_table_contents").empty();
$('#copyexchangetodok').prop('checked', false);
+ if (!$.fn.DataTable.isDataTable('.qsotable')) {
+ $.fn.dataTable.moment('DD-MM-YYYY HH:mm:ss');
+ $('.qsotable').DataTable({
+ "stateSave": true,
+ "pageLength": 25,
+ responsive: false,
+ "scrollY": "400px",
+ "scrollCollapse": true,
+ "paging": false,
+ "scrollX": true,
+ "language": {
+ url: getDataTablesLanguageUrl(),
+ },
+ order: [0, 'desc'],
+ "columnDefs": [
+ {
+ "render": function ( data, type, row ) {
+ return pad(row[8],3);
+ },
+ "targets" : 8
+ },
+ {
+ "render": function ( data, type, row ) {
+ return pad(row[9],3);
+ },
+ "targets" : 9
+ }
+ ]
+ });
+ }
+ var table = $('.qsotable').DataTable();
+ table.clear();
+
}
// Storing the contestid in contest session
From b4562e203dfcff03e4328e4fb67b813ea9b20e0d Mon Sep 17 00:00:00 2001
From: int2001
Date: Sun, 4 Feb 2024 10:34:32 +0000
Subject: [PATCH 5/5] Prevent Racecondition
---
assets/js/sections/contesting.js | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/assets/js/sections/contesting.js b/assets/js/sections/contesting.js
index 4b98c8229..3e2eb9198 100644
--- a/assets/js/sections/contesting.js
+++ b/assets/js/sections/contesting.js
@@ -111,6 +111,7 @@ document.onkeyup = function (e) {
reset_log_fields();
// CTRL-Enter logs QSO
} else if ((e.keyCode == 10 || e.keyCode == 13) && (e.ctrlKey || e.metaKey)) {
+ $("#callsign").blur();
logQso();
// Enter in received exchange logs QSO
} else if ((e.which == 13) && (
@@ -203,9 +204,9 @@ $('#start_date').change(function() {
});
// On Key up check and suggest callsigns
-$("#callsign").keyup(function () {
+$("#callsign").keyup(async function (e) {
var call = $(this).val();
- if (call.length >= 3) {
+ if ((!((e.keyCode == 10 || e.keyCode == 13) && (e.ctrlKey || e.metaKey))) && (call.length >= 3)) { // prevent checking again when pressing CTRL-Enter
$.ajax({
url: 'lookup/scp',
@@ -219,7 +220,7 @@ $("#callsign").keyup(function () {
}
});
- checkIfWorkedBefore();
+ await checkIfWorkedBefore();
var qTable = $('.qsotable').DataTable();
qTable.search(call).draw();
}
@@ -228,7 +229,7 @@ $("#callsign").keyup(function () {
}
});
-function checkIfWorkedBefore() {
+async function checkIfWorkedBefore() {
var call = $("#callsign").val();
if (call.length >= 3) {
$('#callsign_info').text("");