Merge pull request #1222 from AndreasK79/contest_serial_logic_fix

[Contesting] Pushed fix so that serial is not set when serial is not …
这个提交包含在:
Andreas Kristiansen 2021-10-11 18:55:55 +02:00 提交者 GitHub
当前提交 9548386868
找不到此签名对应的密钥
GPG 密钥 ID: 4AEE18F83AFDEB23

查看文件

@ -1,10 +1,7 @@
// Callsign always has focus on load // Callsign always has focus on load
$("#callsign").focus(); $("#callsign").focus();
// Init serial sent as 1 when loading page $(document).ready(function () {
$("#exch_serial_s").val(1);
$( document ).ready(function() {
restoreContestSession(); restoreContestSession();
setRst($("#mode").val()); setRst($("#mode").val());
}); });
@ -26,6 +23,7 @@ function reset_contest_session() {
$("#callsign").focus(); $("#callsign").focus();
setRst($("#mode").val()); setRst($("#mode").val());
$("#exchangetype").val("None"); $("#exchangetype").val("None");
setExchangetype("None");
$("#contestname").val("Other").change(); $("#contestname").val("Other").change();
$(".contest_qso_table_contents").empty(); $(".contest_qso_table_contents").empty();
@ -41,17 +39,17 @@ function reset_contest_session() {
} }
// Storing the contestid in contest session // Storing the contestid in contest session
$('#contestname').change(function() { $('#contestname').change(function () {
localStorage.setItem("contestid", $("#contestname").val()); localStorage.setItem("contestid", $("#contestname").val());
}); });
// Storing the exchange type in contest session // Storing the exchange type in contest session
$('#exchangetype').change(function() { $('#exchangetype').change(function () {
localStorage.setItem("exchangetype", $('#exchangetype').val()); localStorage.setItem("exchangetype", $('#exchangetype').val());
}); });
// realtime clock // realtime clock
$(function($) { $(function ($) {
var options = { var options = {
utc: true, utc: true,
format: '%H:%M:%S' format: '%H:%M:%S'
@ -59,7 +57,7 @@ $(function($) {
$('.input_time').jclock(options); $('.input_time').jclock(options);
}); });
$(function($) { $(function ($) {
var options = { var options = {
utc: true, utc: true,
format: '%d-%m-%Y' format: '%d-%m-%Y'
@ -68,25 +66,25 @@ $(function($) {
}); });
// We don't want spaces to be written in callsign // We don't want spaces to be written in callsign
$(function() { $(function () {
$('#callsign').on('keypress', function(e) { $('#callsign').on('keypress', function (e) {
if (e.which == 32){ if (e.which == 32) {
return false; return false;
} }
}); });
}); });
// We don't want spaces to be written in exchange // We don't want spaces to be written in exchange
$(function() { $(function () {
$('#exch_recv').on('keypress', function(e) { $('#exch_recv').on('keypress', function (e) {
if (e.which == 32){ if (e.which == 32) {
return false; return false;
} }
}); });
}); });
// Here we capture keystrokes to execute functions // Here we capture keystrokes to execute functions
document.onkeyup = function(e) { document.onkeyup = function (e) {
// ALT-W wipe // ALT-W wipe
if (e.altKey && e.which == 87) { if (e.altKey && e.which == 87) {
reset_log_fields(); reset_log_fields();
@ -94,7 +92,7 @@ document.onkeyup = function(e) {
} else if ((e.keyCode == 10 || e.keyCode == 13) && (e.ctrlKey || e.metaKey)) { } else if ((e.keyCode == 10 || e.keyCode == 13) && (e.ctrlKey || e.metaKey)) {
logQso(); logQso();
// Enter in sent exchange logs QSO // Enter in sent exchange logs QSO
} else if((e.which == 13) && ($(document.activeElement).attr("id") == "exch_recv")) { } else if ((e.which == 13) && ($(document.activeElement).attr("id") == "exch_recv")) {
logQso(); logQso();
} else if (e.which == 27) { } else if (e.which == 27) {
reset_log_fields(); reset_log_fields();
@ -158,10 +156,10 @@ document.onkeyup = function(e) {
}; };
// On Key up check and suggest callsigns // On Key up check and suggest callsigns
$("#callsign").keyup(function() { $("#callsign").keyup(function () {
var call = $(this).val(); var call = $(this).val();
if (call.length >= 3) { if (call.length >= 3) {
$.get('lookup/scp/' + call.toUpperCase(), function(result) { $.get('lookup/scp/' + call.toUpperCase(), function (result) {
$('.callsign-suggestions').text(result); $('.callsign-suggestions').text(result);
highlight(call.toUpperCase()); highlight(call.toUpperCase());
}); });
@ -183,7 +181,7 @@ function reset_log_fields() {
setRst($("#mode").val()); setRst($("#mode").val());
} }
RegExp.escape = function(text) { RegExp.escape = function (text) {
return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"); return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
} }
@ -192,7 +190,7 @@ function highlight(term, base) {
base = base || document.body; base = base || document.body;
var re = new RegExp("(" + RegExp.escape(term) + ")", "gi"); var re = new RegExp("(" + RegExp.escape(term) + ")", "gi");
var replacement = "<span class=\"text-primary\">" + term + "</span>"; var replacement = "<span class=\"text-primary\">" + term + "</span>";
$(".callsign-suggestions", base).contents().each( function(i, el) { $(".callsign-suggestions", base).contents().each(function (i, el) {
if (el.nodeType === 3) { if (el.nodeType === 3) {
var data = el.data; var data = el.data;
if (data = data.replace(re, replacement)) { if (data = data.replace(re, replacement)) {
@ -204,17 +202,16 @@ function highlight(term, base) {
} }
// Only set the frequency when not set by userdata/PHP. // Only set the frequency when not set by userdata/PHP.
if ($('#frequency').val() == "") if ($('#frequency').val() == "") {
{ $.get('qso/band_to_freq/' + $('#band').val() + '/' + $('.mode').val(), function (result) {
$.get('qso/band_to_freq/' + $('#band').val() + '/' + $('.mode').val(), function(result) {
$('#frequency').val(result); $('#frequency').val(result);
$('#frequency_rx').val(""); $('#frequency_rx').val("");
}); });
} }
/* on mode change */ /* on mode change */
$('#mode').change(function() { $('#mode').change(function () {
$.get('qso/band_to_freq/' + $('#band').val() + '/' + $('.mode').val(), function(result) { $.get('qso/band_to_freq/' + $('#band').val() + '/' + $('.mode').val(), function (result) {
$('#frequency').val(result); $('#frequency').val(result);
$('#frequency_rx').val(""); $('#frequency_rx').val("");
}); });
@ -223,20 +220,21 @@ $('#mode').change(function() {
/* Calculate Frequency */ /* Calculate Frequency */
/* on band change */ /* on band change */
$('#band').change(function() { $('#band').change(function () {
$.get('qso/band_to_freq/' + $(this).val() + '/' + $('.mode').val(), function(result) { $.get('qso/band_to_freq/' + $(this).val() + '/' + $('.mode').val(), function (result) {
$('#frequency').val(result); $('#frequency').val(result);
$('#frequency_rx').val(""); $('#frequency_rx').val("");
}); });
}); });
$('#exchangetype').change(function(){ $('#exchangetype').change(function () {
var exchangetype = $("#exchangetype").val(); var exchangetype = $("#exchangetype").val();
setExchangetype(exchangetype); setExchangetype(exchangetype);
}); });
function setExchangetype(exchangetype) { function setExchangetype(exchangetype) {
if (exchangetype == 'None') { if (exchangetype == 'None') {
$("#exch_serial_s").val("");
$(".exchanger").hide(); $(".exchanger").hide();
$(".exchanges").hide(); $(".exchanges").hide();
$(".serials").hide(); $(".serials").hide();
@ -245,6 +243,7 @@ function setExchangetype(exchangetype) {
$(".gridsquares").hide(); $(".gridsquares").hide();
} }
else if (exchangetype == 'Exchange') { else if (exchangetype == 'Exchange') {
$("#exch_serial_s").val("");
$(".exchanger").show(); $(".exchanger").show();
$(".exchanges").show(); $(".exchanges").show();
$(".serials").hide(); $(".serials").hide();
@ -253,6 +252,12 @@ function setExchangetype(exchangetype) {
$(".gridsquares").hide(); $(".gridsquares").hide();
} }
else if (exchangetype == 'Serial') { else if (exchangetype == 'Serial') {
var serialsent = localStorage.getItem("serialsent");
if (serialsent != null) {
$("#exch_serial_s").val(serialsent);
} else {
$("#exch_serial_s").val(1);
}
$(".exchanger").hide(); $(".exchanger").hide();
$(".exchanges").hide(); $(".exchanges").hide();
$(".serials").show(); $(".serials").show();
@ -261,6 +266,12 @@ function setExchangetype(exchangetype) {
$(".gridsquares").hide(); $(".gridsquares").hide();
} }
else if (exchangetype == 'Serialexchange') { else if (exchangetype == 'Serialexchange') {
var serialsent = localStorage.getItem("serialsent");
if (serialsent != null) {
$("#exch_serial_s").val(serialsent);
} else {
$("#exch_serial_s").val(1);
}
$(".exchanger").show(); $(".exchanger").show();
$(".exchanges").show(); $(".exchanges").show();
$(".serials").show(); $(".serials").show();
@ -269,6 +280,12 @@ function setExchangetype(exchangetype) {
$(".gridsquares").hide(); $(".gridsquares").hide();
} }
else if (exchangetype == 'Serialgridsquare') { else if (exchangetype == 'Serialgridsquare') {
var serialsent = localStorage.getItem("serialsent");
if (serialsent != null) {
$("#exch_serial_s").val(serialsent);
} else {
$("#exch_serial_s").val(1);
}
$(".exchanger").hide(); $(".exchanger").hide();
$(".exchanges").hide(); $(".exchanges").hide();
$(".serials").show(); $(".serials").show();
@ -277,6 +294,7 @@ function setExchangetype(exchangetype) {
$(".gridsquares").show(); $(".gridsquares").show();
} }
else if (exchangetype == 'Gridsquare') { else if (exchangetype == 'Gridsquare') {
$("#exch_serial_s").val("");
$(".exchanger").hide(); $(".exchanger").hide();
$(".exchanges").hide(); $(".exchanges").hide();
$(".serials").hide(); $(".serials").hide();
@ -305,7 +323,7 @@ function logQso() {
} }
var data = [[ var data = [[
$("#start_date").val()+ ' ' + $("#start_time").val(), $("#start_date").val() + ' ' + $("#start_time").val(),
$("#callsign").val().toUpperCase(), $("#callsign").val().toUpperCase(),
$("#band").val(), $("#band").val(),
$("#mode").val(), $("#mode").val(),
@ -331,7 +349,7 @@ function logQso() {
enctype: 'multipart/form-data', enctype: 'multipart/form-data',
success: function (html) { success: function (html) {
if (localStorage.getItem("qso") == null) { if (localStorage.getItem("qso") == null) {
localStorage.setItem("qso", $("#start_date").val()+ ' ' + $("#start_time").val() + ',' + $("#callsign").val().toUpperCase() + ',' + $("#contestname").val()); localStorage.setItem("qso", $("#start_date").val() + ' ' + $("#start_time").val() + ',' + $("#callsign").val().toUpperCase() + ',' + $("#contestname").val());
} }
$('#name').val(""); $('#name').val("");
@ -411,11 +429,11 @@ function restoreContestSession() {
$.ajax({ $.ajax({
url: base_url + 'index.php/contesting/getSessionQsos', url: base_url + 'index.php/contesting/getSessionQsos',
type: 'post', type: 'post',
data: {'qso': qsodata,}, data: { 'qso': qsodata, },
success: function (html) { success: function (html) {
var mode = ''; var mode = '';
$.each(html, function(){ $.each(html, function () {
if (this.col_submode == null || this.col_submode == '') { if (this.col_submode == null || this.col_submode == '') {
mode = this.col_mode; mode = this.col_mode;
} else { } else {
@ -423,18 +441,18 @@ function restoreContestSession() {
} }
$(".qsotable tbody").prepend('<tr>' + $(".qsotable tbody").prepend('<tr>' +
'<td>'+ this.col_time_on + '</td>' + '<td>' + this.col_time_on + '</td>' +
'<td>'+ this.col_call + '</td>' + '<td>' + this.col_call + '</td>' +
'<td>'+ this.col_band + '</td>' + '<td>' + this.col_band + '</td>' +
'<td>'+ mode + '</td>' + '<td>' + mode + '</td>' +
'<td>'+ this.col_rst_sent + '</td>' + '<td>' + this.col_rst_sent + '</td>' +
'<td>'+ this.col_rst_rcvd + '</td>' + '<td>' + this.col_rst_rcvd + '</td>' +
'<td>'+ this.col_stx_string + '</td>' + '<td>' + this.col_stx_string + '</td>' +
'<td>'+ this.col_srx_string + '</td>' + '<td>' + this.col_srx_string + '</td>' +
'<td>'+ this.col_stx + '</td>' + '<td>' + this.col_stx + '</td>' +
'<td>'+ this.col_srx + '</td>' + '<td>' + this.col_srx + '</td>' +
'<td>'+ this.col_gridsquare + '</td>' + '<td>' + this.col_gridsquare + '</td>' +
'<td>'+ this.col_vucc_grids + '</td>' + '<td>' + this.col_vucc_grids + '</td>' +
'</tr>'); '</tr>');
}); });
if (!$.fn.DataTable.isDataTable('.qsotable')) { if (!$.fn.DataTable.isDataTable('.qsotable')) {
@ -445,7 +463,7 @@ function restoreContestSession() {
"scrollCollapse": true, "scrollCollapse": true,
"paging": false, "paging": false,
"scrollX": true, "scrollX": true,
"order": [[ 0, "desc" ]] "order": [[0, "desc"]]
}); });
} }
} }