[Contest logging] CAT added. Split some of the JS into it's own file. Frequency is also saved.

pull/708/head
Andreas 2020-12-07 21:26:16 +01:00
rodzic 2229a1579b
commit f784507435
3 zmienionych plików z 210 dodań i 167 usunięć

Wyświetl plik

@ -90,6 +90,21 @@
</select>
</div>
<div class="form-group col-md-2">
<label for="frequency">Frequency</label>
<input type="text" class="form-control form-control-sm" id="frequency" name="freq_display" value="<?php echo $this->session->userdata('freq'); ?>" />
</div>
<div class="form-group col-md-2">
<label for="inputRadio">Radio</label>
<select class="form-control form-control-sm radios" id="radio" name="radio">
<option value="0" selected="selected">None</option>
<?php foreach ($radios->result() as $row) { ?>
<option value="<?php echo $row->id; ?>" <?php if($this->session->userdata('radio') == $row->id) { echo "selected=\"selected\""; } ?>><?php echo $row->radio; ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="form-row">

Wyświetl plik

@ -918,6 +918,20 @@ $(document).on('change', 'input', function(){
setRst($('.mode') .val());
});
function convert_case(str) {
var lower = str.toLowerCase();
return lower.replace(/(^| )(\w)/g, function(x) {
return x.toUpperCase();
});
}
</script>
<?php } ?>
<?php if ( ($this->uri->segment(1) == "qso" && $_GET['manual'] == 0) || $this->uri->segment(1) == "contesting") { ?>
<script>
function setRst(mode) {
if(mode == 'JT65' || mode == 'JT65B' || mode == 'JT6C' || mode == 'JTMS' || mode == 'ISCAT' || mode == 'MSK144' || mode == 'JTMSK' || mode == 'QRA64' || mode == 'FT8' || mode == 'FT4' || mode == 'JS8' || mode == 'JT9' || mode == 'JT9-1' || mode == 'ROS'){
$('#rst_sent').val('-5');
@ -933,13 +947,14 @@ $(document).on('change', 'input', function(){
$('#rst_recv').val('59');
}
}
/* Javascript for controlling rig frequency. */
<?php if ( $_GET['manual'] == 0 ) { ?>
</script>
<?php } ?>
<?php if ( ($this->uri->segment(1) == "qso" && $_GET['manual'] == 0) || $this->uri->segment(1) == "contesting") { ?>
<script>
// Javascript for controlling rig frequency.
var updateFromCAT = function() {
if($('select.radios option:selected').val() != '0') {
radioID = $('select.radios option:selected').val();
radioID = $('select.radios option:selected').val();
$.getJSON( "radio/json/" + radioID, function( data ) {
/* {
"uplink_freq": "2400210000",
@ -962,24 +977,24 @@ $(document).on('change', 'input', function(){
if (data.mode == "LSB" || data.mode == "USB" || data.mode == "SSB") {
$(".mode").val('SSB');
} else {
$(".mode").val(data.mode);
$(".mode").val(data.mode);
}
if (old_mode !== $(".mode").val()) {
// Update RST on mode change via CAT
setRst($(".mode").val());
}
$("#sat_name").val(data.satname);
$("#sat_mode").val(data.satmode);
$("#sat_name").val(data.satname);
$("#sat_mode").val(data.satmode);
// Display CAT Timeout warnng based on the figure given in the config file
var minutes = Math.floor(<?php echo $this->config->item('cat_timeout_interval'); ?> / 60);
if(data.updated_minutes_ago > minutes) {
if($('.radio_timeout_error').length == 0) {
$('.qso_panel').prepend('<div class="alert alert-danger radio_timeout_error" role="alert">Radio connection timed-out: ' + $('select.radios option:selected').text() + ' data is ' + data.updated_minutes_ago + ' minutes old.</div>');
$('.qso_panel').prepend('<div class="alert alert-danger radio_timeout_error" role="alert">Radio connection timed-out: ' + $('select.radios option:selected').text() + ' data is ' + data.updated_minutes_ago + ' minutes old.</div>');
} else {
$('.radio_timeout_error').text('Radio connection timed-out: ' + $('select.radios option:selected').text() + ' data is ' + data.updated_minutes_ago + ' minutes old.');
$('.radio_timeout_error').text('Radio connection timed-out: ' + $('select.radios option:selected').text() + ' data is ' + data.updated_minutes_ago + ' minutes old.');
}
} else {
$(".radio_timeout_error" ).remove();
@ -998,10 +1013,10 @@ $(document).on('change', 'input', function(){
// If radio isn't SatPC32 clear sat_name and sat_mode
$( ".radios" ).change(function() {
if ($(".radios option:selected").text() != "SatPC32") {
$("#sat_name").val("");
$("#sat_mode").val("");
$("#frequency").val("");
$("#frequency_rx").val("");
$("#sat_name").val("");
$("#sat_mode").val("");
$("#frequency").val("");
$("#frequency_rx").val("");
$("#selectPropagation").val($("#selectPropagation option:first").val());
}
@ -1010,16 +1025,6 @@ $(document).on('change', 'input', function(){
}
});
<?php } ?>
function convert_case(str) {
var lower = str.toLowerCase();
return lower.replace(/(^| )(\w)/g, function(x) {
return x.toUpperCase();
});
}
</script>
<?php } ?>
@ -2437,156 +2442,48 @@ function deleteQsl(id) {
}
</script>
<?php if ($this->uri->segment(1) == "contesting") { ?>
<script src="<?php echo base_url() ;?>assets/js/sections/contesting.js"></script>
<script>
function logQso() {
if ($("#callsign").val().length > 0) {
// Callsign always has focus on load
$("#callsign").focus();
$('.callsign-suggestions').text("");
$(".qsotable tbody").prepend('<tr>' +
'<td>'+$("#start_date").val()+ ' ' + $("#start_time").val() + '</td>' +
'<td>'+$("#callsign").val().toUpperCase()+'</td>' +
'<td>'+$("#band").val()+'</td>' +
'<td>'+$("#mode").val()+'</td>' +
'<td>'+$("#rst_sent").val()+'</td>' +
'<td>'+$("#rst_recv").val()+'</td>' +
'<td>'+$("#exch_sent").val()+'</td>' +
'<td>'+$("#exch_recv").val()+'</td>' +
'</tr>');
// Init serial sent as 1 when lading page
$("#exch_sent").val(1);
var baseURL= "<?php echo base_url();?>";
var formdata = new FormData(document.getElementById("qso_input"));
$.ajax({
url: baseURL + 'index.php/qso/saveqso',
type: 'post',
data: formdata,
processData: false,
contentType: false,
enctype: 'multipart/form-data',
success: function (html) {
$('#name').val("");
// realtime clock
$(function($) {
var options = {
utc: true,
format: '%H:%M:%S'
}
$('.input_time').jclock(options);
});
$(function($) {
var options = {
utc: true,
format: '%d-%m-%Y'
}
$('.input_date').jclock(options);
});
// We don't want spaces to be written in callsign
$(function() {
$('#callsign').on('keypress', function(e) {
if (e.which == 32){
//console.log('Space Detected');
return false;
}
});
});
// We don't want spaces to be written in exchange
$(function() {
$('#exch_recv').on('keypress', function(e) {
if (e.which == 32){
//console.log('Space Detected');
return false;
}
});
});
// Here we capture keystrokes fo execute functions
document.onkeyup = function(e) {
// ALT-W wipe
if (e.altKey && e.which == 87) {
reset_log_fields();
} else if ((e.keyCode == 10 || e.keyCode == 13) && (e.ctrlKey || e.metaKey)) {
logQso();
} else if (e.which == 27) {
reset_log_fields();
// Space to jump to either callsign or sent exchange
} else if (e.which == 32) {
if ($(document.activeElement).attr("id") == "callsign") {
$("#exch_recv").focus();
return false;
} else if ($(document.activeElement).attr("id") == "exch_recv") {
$("#callsign").focus();
return false;
}
}
};
// On Key up check and suggest callsigns
$("#callsign").keyup(function() {
var call = $(this).val();
if (call.length >= 3) {
$.get('lookup/scp/' + call.toUpperCase(), function(result) {
$('.callsign-suggestions').text(result);
highlight(call.toUpperCase());
});
}
else if (call.length <= 2) {
$('.callsign-suggestions').text("");
}
});
function reset_log_fields() {
$('#name').val("");
$('.callsign-suggestions').text("");
$('#callsign').val("");
$('#comment').val("");
$('#exch_recv').val("");
$("#callsign").focus();
}
function logQso() {
if ($("#callsign").val().length > 0) {
$('.callsign-suggestions').text("");
$(".qsotable tbody").prepend('<tr>' +
'<td>'+$("#start_date").val()+ ' ' + $("#start_time").val() + '</td>' +
'<td>'+$("#callsign").val().toUpperCase()+'</td>' +
'<td>'+$("#band").val()+'</td>' +
'<td>'+$("#mode").val()+'</td>' +
'<td>'+$("#rst_sent").val()+'</td>' +
'<td>'+$("#rst_recv").val()+'</td>' +
'<td>'+$("#exch_sent").val()+'</td>' +
'<td>'+$("#exch_recv").val()+'</td>' +
'</tr>');
var baseURL= "<?php echo base_url();?>";
var formdata = new FormData(document.getElementById("qso_input"));
$.ajax({
url: baseURL + 'index.php/qso/saveqso',
type: 'post',
data: formdata,
processData: false,
contentType: false,
enctype: 'multipart/form-data',
success: function (html) {
$('#name').val("");
$('#callsign').val("");
$('#comment').val("");
$('#exch_recv').val("");
if ($('input[name=exchangeradio]:checked', '#qso_input').val() == "serial") {
$("#exch_sent").val(+$("#exch_sent").val() + 1);
$('#callsign').val("");
$('#comment').val("");
$('#exch_recv').val("");
if ($('input[name=exchangeradio]:checked', '#qso_input').val() == "serial") {
$("#exch_sent").val(+$("#exch_sent").val() + 1);
}
$("#callsign").focus();
}
$("#callsign").focus();
}
});
}
}
RegExp.escape = function(text) {
return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
}
function highlight(term, base) {
if (!term) return;
base = base || document.body;
var re = new RegExp("(" + RegExp.escape(term) + ")", "gi");
var replacement = "<span class=\"text-primary\">" + term + "</span>";
$(".callsign-suggestions", base).contents().each( function(i, el) {
if (el.nodeType === 3) {
var data = el.data;
if (data = data.replace(re, replacement)) {
var wrapper = $("<span>").html(data);
$(el).before(wrapper.contents()).remove();
}
});
}
});
}
}
</script>
<?php } ?>
</body>
</html>

Wyświetl plik

@ -0,0 +1,131 @@
// Callsign always has focus on load
$("#callsign").focus();
// Init serial sent as 1 when loading page
$("#exch_sent").val(1);
// realtime clock
$(function($) {
var options = {
utc: true,
format: '%H:%M:%S'
}
$('.input_time').jclock(options);
});
$(function($) {
var options = {
utc: true,
format: '%d-%m-%Y'
}
$('.input_date').jclock(options);
});
// We don't want spaces to be written in callsign
$(function() {
$('#callsign').on('keypress', function(e) {
if (e.which == 32){
return false;
}
});
});
// We don't want spaces to be written in exchange
$(function() {
$('#exch_recv').on('keypress', function(e) {
if (e.which == 32){
return false;
}
});
});
// Here we capture keystrokes fo execute functions
document.onkeyup = function(e) {
// ALT-W wipe
if (e.altKey && e.which == 87) {
reset_log_fields();
} else if ((e.keyCode == 10 || e.keyCode == 13) && (e.ctrlKey || e.metaKey)) {
logQso();
} else if (e.which == 27) {
reset_log_fields();
// Space to jump to either callsign or sent exchange
} else if (e.which == 32) {
if ($(document.activeElement).attr("id") == "callsign") {
$("#exch_recv").focus();
return false;
} else if ($(document.activeElement).attr("id") == "exch_recv") {
$("#callsign").focus();
return false;
}
}
};
// On Key up check and suggest callsigns
$("#callsign").keyup(function() {
var call = $(this).val();
if (call.length >= 3) {
$.get('lookup/scp/' + call.toUpperCase(), function(result) {
$('.callsign-suggestions').text(result);
highlight(call.toUpperCase());
});
}
else if (call.length <= 2) {
$('.callsign-suggestions').text("");
}
});
function reset_log_fields() {
$('#name').val("");
$('.callsign-suggestions').text("");
$('#callsign').val("");
$('#comment').val("");
$('#exch_recv').val("");
$("#callsign").focus();
}
RegExp.escape = function(text) {
return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
}
function highlight(term, base) {
if (!term) return;
base = base || document.body;
var re = new RegExp("(" + RegExp.escape(term) + ")", "gi");
var replacement = "<span class=\"text-primary\">" + term + "</span>";
$(".callsign-suggestions", base).contents().each( function(i, el) {
if (el.nodeType === 3) {
var data = el.data;
if (data = data.replace(re, replacement)) {
var wrapper = $("<span>").html(data);
$(el).before(wrapper.contents()).remove();
}
}
});
}
// Only set the frequency when not set by userdata/PHP.
if ($('#frequency').val() == "")
{
$.get('qso/band_to_freq/' + $('#band').val() + '/' + $('.mode').val(), function(result) {
$('#frequency').val(result);
$('#frequency_rx').val("");
});
}
/* on mode change */
$('.mode').change(function() {
$.get('qso/band_to_freq/' + $('#band').val() + '/' + $('.mode').val(), function(result) {
$('#frequency').val(result);
$('#frequency_rx').val("");
});
});
/* Calculate Frequency */
/* on band change */
$('#band').change(function() {
$.get('qso/band_to_freq/' + $(this).val() + '/' + $('.mode').val(), function(result) {
$('#frequency').val(result);
$('#frequency_rx').val("");
});
});