add new options button and the ability to choose the sequence of the exchanges

This commit is contained in:
HB9HIL
2024-08-26 16:03:28 +02:00
parent d13c59548c
commit 03946e87c0
2 changed files with 185 additions and 85 deletions

View File

@@ -36,6 +36,56 @@
<div class="col-auto">
<input type="text" class="form-control form-control-sm" id="operator_callsign" name="operator_callsign" value='<?php echo $this->session->userdata('operator_callsign'); ?>' required>
</div>
<div class="col-auto">
<a class="btn btn-sm btn-primary" id="moreSettingsButton"><i class="fas fa-wrench"></i> <?= __("More Settings"); ?></a>
<div class="modal fade" id="moreSettingsModal" tabindex="-1" aria-labelledby="moreSettingsModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="moreSettingsModalLabel"><?= __("More Settings"); ?></h5>
</div>
<div class="modal-body">
<div class="row mb-3">
<label class="col-auto control-label"><?= __("Copy received exchange to"); ?></label>
<div class="form-check-inline col-auto">
<select class="form-select form-select-sm" id="copyexchangeto" name="copyexchangeto" title="<?= __("Exchange is only copied if it is matching rules for the selected field!"); ?>">
<option value='None'><?= __("None"); ?></option>
<option value='dok'><?= __("DOK"); ?></option>
<option value='name'><?= __("Name"); ?></option>
<option value='age'><?= __("Age"); ?></option>
<option value='state'><?= __("State"); ?></option>
<option value='power'><?= __("RX Power (W)"); ?></option>
<option value='locator'><?= __("Locator"); ?></option>
<option value='qth'><?= __("QTH"); ?></option>
</select>
</div>
</div>
<div class="row mb-3">
<label class="col-auto control-label me-1"><?= __("Sequence of Exchanges"); ?>
<i class="fas fa-question-circle" id="exchangesequence"
data-bs-toggle="tooltip" data-bs-html="true" data-bs-placement="top"
title="<?= sprintf(__("%s = Serial, %s = Gridsquare, %s = Exchange."), "S", "<br>G", "<br>E"); ?><br><?= __("Choose in which order you want to type in the different reports. However, only the elements contained in the selected exchange type are displayed."); ?>">
</i>
</label>
<div class="form-check-inline col-auto">
<select class="form-select form-select-sm" id="exchangesequence_select" name="exchangesequence_select">
<option value='s-g-e'>S - G - E</option>
<option value='s-e-g'>S - E - G</option>
<option value='g-s-e'>G - S - E</option>
<option value='g-e-s'>G - E - S</option>
<option value='e-s-g'>E - S - G</option>
<option value='e-g-s'>E - G - S</option>
</select>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal"><?= __("Close"); ?></button>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row">
@@ -100,53 +150,63 @@
</div>
</div>
<div class="row">
<div class="mb-3 col-md-3">
<label for="callsign"><?= __("Callsign"); ?></label>
<input type="text" class="form-control form-control-sm" id="callsign" name="callsign" required>
<small id="callsign_info" class="badge text-bg-danger"></small><br/>
<small id="bearing_info" class="form-text text-muted"></small>
<div class="row mb-4">
<div class="col-md-2">
<div>
<label for="callsign"><?= __("Callsign"); ?></label>
<input type="text" class="form-control form-control-sm" id="callsign" name="callsign" required>
<small id="callsign_info" class="badge text-bg-danger"></small><br/>
<small id="bearing_info" class="form-text text-muted"></small>
</div>
</div>
<div class="mb-3 col-md-1">
<label for="rst_sent"><?= __("RST (S)"); ?></label>
<input type="text" class="form-control form-control-sm" name="rst_sent" id="rst_sent" value="59">
<div class="col-md-1">
<div>
<label for="rst_sent"><?= __("RST (S)"); ?></label>
<input type="text" class="form-control form-control-sm" name="rst_sent" id="rst_sent" value="59">
</div>
</div>
<div style="display:none" class="mb-3 col-md-1 serials">
<label for="exch_serial_s"><?= __("Serial (S)"); ?></label>
<input type="number" class="form-control form-control-sm" name="exch_serial_s" id="exch_serial_s" min="0" value="">
</div>
<div id="sent_exchange" class="d-flex gap-2">
<div style="display:none" class="serials">
<label for="exch_serial_s"><?= __("Serial (S)"); ?></label>
<input type="number" class="form-control form-control-sm" name="exch_serial_s" id="exch_serial_s" min="0" value="">
</div>
<div style="display:none" class="mb-3 col-md-1 gridsquares">
<label for="exch_gridsquare_s"><?= __("Gridsquare (S)"); ?></label>
<input disabled type="text" class="form-control form-control-sm" name="exch_gridsquare_s" id="exch_gridsquare_s" value="<?php echo $my_gridsquare;?>">
<div style="display:none" class="gridsquares">
<label for="exch_gridsquare_s"><?= __("Gridsquare (S)"); ?></label>
<input disabled type="text" class="form-control form-control-sm" name="exch_gridsquare_s" id="exch_gridsquare_s" value="<?php echo $my_gridsquare;?>">
</div>
<div style="display:none" class="exchanges">
<label for="exch_sent"><?= __("Exch (S)"); ?></label>
<input type="text" class="form-control form-control-sm" name="exch_sent" id="exch_sent" value="">
</div>
</div>
<div style="display:none" class="mb-3 col-md-1 exchanges">
<label for="exch_sent"><?= __("Exch (S)"); ?></label>
<input type="text" class="form-control form-control-sm" name="exch_sent" id="exch_sent" value="">
<div class="col-md-1">
<div>
<label for="rst_rcvd"><?= __("RST (R)"); ?></label>
<input type="text" class="form-control form-control-sm" name="rst_rcvd" id="rst_rcvd" value="59">
</div>
</div>
<div id="rcvd_exchange" class="d-flex gap-2">
<div style="display:none" class="serialr">
<label for="exch_serial_r"><?= __("Serial (R)"); ?></label>
<input type="number" class="form-control form-control-sm" name="exch_serial_r" id="exch_serial_r" min="0" value="">
</div>
<div class="mb-3 col-md-1">
<label for="rst_rcvd"><?= __("RST (R)"); ?></label>
<input type="text" class="form-control form-control-sm" name="rst_rcvd" id="rst_rcvd" value="59">
<div style="display:none" class="gridsquarer">
<label for="exch_gridsquare_r"><?= __("Gridsquare (R)"); ?></label>
<input type="text" class="form-control form-control-sm" name="locator" id="exch_gridsquare_r" value="">
</div>
<div style="display:none" class="exchanger">
<label for="exch_rcvd"><?= __("Exch (R)"); ?></label>
<input type="text" class="form-control form-control-sm" name="exch_rcvd" id="exch_rcvd" value="">
</div>
</div>
<div style="display:none" class="mb-3 col-md-1 serialr">
<label for="exch_serial_r"><?= __("Serial (R)"); ?></label>
<input type="number" class="form-control form-control-sm" name="exch_serial_r" id="exch_serial_r" min="0" value="">
</div>
<div style="display:none" class="mb-3 col-md-1 gridsquarer">
<label for="exch_gridsquare_r"><?= __("Gridsquare (R)"); ?></label>
<input type="text" class="form-control form-control-sm" name="locator" id="exch_gridsquare_r" value="">
</div>
<div style="display:none" class="mb-3 col-md-1 exchanger">
<label for="exch_rcvd"><?= __("Exch (R)"); ?></label>
<input type="text" class="form-control form-control-sm" name="exch_rcvd" id="exch_rcvd" value="">
</div>
</div>
<div class="row">
@@ -163,21 +223,6 @@
<button type="button" class="mb-3 btn btn-sm btn-secondary" onclick="reset_log_fields()"><i class="fas fa-sync-alt"></i> <?= __("Reset QSO"); ?></button>
<button type="button" class="mb-3 btn btn-sm btn-primary" onclick="logQso();"><i class="fas fa-save"></i> <?= __("Save QSO"); ?></button>
<div class="row">
<label class="col-auto control-label" for="radio"><?= __("Copy received exchange to"); ?></label>
<div class="form-check-inline col-auto">
<select class="form-select form-select-sm" id="copyexchangeto" name="copyexchangeto" title="<?= __("Exchange is only copied if it is matching rules for the selected field!"); ?>">
<option value='None'><?= __("None"); ?></option>
<option value='dok'><?= __("DOK"); ?></option>
<option value='name'><?= __("Name"); ?></option>
<option value='age'><?= __("Age"); ?></option>
<option value='state'><?= __("State"); ?></option>
<option value='power'><?= __("RX Power (W)"); ?></option>
<option value='locator'><?= __("Locator"); ?></option>
<option value='qth'><?= __("QTH"); ?></option>
</select>
</div>
</div>
</form>
</div>
</div>

View File

@@ -71,6 +71,45 @@ async function reset_contest_session() {
}
function sort_exchange() {
// Split the squence into an array
var selectedOrder = $('#exchangesequence_select').val().split('-');
// Map sequence to corresponding SENT elements
let mapping = {
"g": ".gridsquares",
"s": ".serials",
"e": ".exchanges",
};
// Reorder the elements in the DOM
selectedOrder.forEach(function(item) {
$('#sent_exchange').append($(mapping[item]));
});
// Map sequence to corresponding RECEIVED elements
mapping = {
"g": ".gridsquarer",
"s": ".serialr",
"e": ".exchanger",
};
// Reorder the elements in the DOM
selectedOrder.forEach(function(item) {
$('#rcvd_exchange').append($(mapping[item]));
});
}
// Change the sequence of the exchange fields
$('#exchangesequence_select').change(function () {
sort_exchange();
});
// Show Settings modal on click
$('#moreSettingsButton').click(function () {
$('#moreSettingsModal').modal('show');
});
// Storing the contestid in contest session
$('#contestname, #copyexchangeto').change(function () {
var formdata = new FormData(document.getElementById("qso_input"));
@@ -423,6 +462,8 @@ function setSerial(data) {
function setExchangetype(exchangetype) {
// Perhaps a better approach is to hide everything, then just enable the things you need
$('#sent_exchange').hide().removeClass();
$('#rcvd_exchange').hide().removeClass();
$(".exchanger").hide();
$(".exchanges").hide();
$(".serials").hide();
@@ -430,46 +471,35 @@ function setExchangetype(exchangetype) {
$(".gridsquarer").hide();
$(".gridsquares").hide();
if (exchangetype == 'Exchange') {
$(".exchanger").show();
$(".exchanges").show();
}
else if (exchangetype == 'Serial') {
$(".serials").show();
$(".serialr").show();
}
else if (exchangetype == 'Serialexchange') {
$(".exchanger").show();
$(".exchanges").show();
$(".serials").show();
$(".serialr").show();
}
else if (exchangetype == 'Serialgridsquare') {
$(".serials").show();
$(".serialr").show();
$(".gridsquarer").show();
$(".gridsquares").show();
}
else if (exchangetype == 'SerialGridExchange') {
$(".serials").show();
$(".serialr").show();
$(".gridsquarer").show();
$(".gridsquares").show();
$(".exchanger").show();
$(".exchanges").show();
}
else if (exchangetype == 'Gridsquare') {
$(".gridsquarer").show();
$(".gridsquares").show();
}
// To track the transition, the code for the exchangecopy is kept
// separate.
switch(exchangetype) {
case 'None':
$('#sent_exchange').hide().removeClass();
$('#rcvd_exchange').hide().removeClass();
break;
case 'Serial':
$('#sent_exchange').show().addClass('d-flex gap-2 col-md-2');
$('#rcvd_exchange').show().addClass('d-flex gap-2 col-md-2');
$(".serials").show();
$(".serialr").show();
break;
case 'Serialgridsquare':
$('#sent_exchange').show().addClass('d-flex gap-2 col-md-3');
$('#rcvd_exchange').show().addClass('d-flex gap-2 col-md-3');
$(".serials").show();
$(".serialr").show();
$(".gridsquarer").show();
$(".gridsquares").show();
break;
case 'Gridsquare':
$('#sent_exchange').show().addClass('d-flex gap-2 col-md-2');
$('#rcvd_exchange').show().addClass('d-flex gap-2 col-md-2');
$(".gridsquarer").show();
$(".gridsquares").show();
if ($("#copyexchangeto").prop('disabled') == false) {
$("#copyexchangeto").prop('disabled','disabled');
$("#copyexchangeto").data('oldValue',$("#copyexchangeto").val());
@@ -478,8 +508,21 @@ function setExchangetype(exchangetype) {
// Do nothing
}
break;
case 'Exchange':
$('#sent_exchange').show().addClass('d-flex gap-2 col-md-2');
$('#rcvd_exchange').show().addClass('d-flex gap-2 col-md-2');
$(".exchanger").show();
$(".exchanges").show();
break;
case 'Serialexchange':
$('#sent_exchange').show().addClass('d-flex gap-2 col-md-3');
$('#rcvd_exchange').show().addClass('d-flex gap-2 col-md-3');
$(".exchanger").show();
$(".exchanges").show();
$(".serials").show();
$(".serialr").show();
if ($("#copyexchangeto").prop('disabled') == false) {
// Do nothing
} else {
@@ -487,13 +530,24 @@ function setExchangetype(exchangetype) {
$("#copyexchangeto").prop('disabled',false);
}
break;
case 'SerialGridExchange':
$('#sent_exchange').show().addClass('d-flex gap-2 col-md-4');
$('#rcvd_exchange').show().addClass('d-flex gap-2 col-md-4');
$(".serials").show();
$(".serialr").show();
$(".gridsquarer").show();
$(".gridsquares").show();
$(".exchanger").show();
$(".exchanges").show();
if ($("#copyexchangeto").prop('disabled') == false) {
// Do nothing
} else {
$("#copyexchangeto").val($("#copyexchangeto").data('oldValue') ?? 'None');
$("#copyexchangeto").prop('disabled',false);
}
break;
default:
}
}
@@ -637,6 +691,7 @@ async function restoreContestSession(data) {
} else {
$("#exch_serial_s").val("1");
}
// sort_exchange();
}
async function refresh_qso_table(data) {