From f784507435947ce0e5a3b74e5ee84461e390dc1a Mon Sep 17 00:00:00 2001 From: Andreas Date: Mon, 7 Dec 2020 21:26:16 +0100 Subject: [PATCH] [Contest logging] CAT added. Split some of the JS into it's own file. Frequency is also saved. --- application/views/contesting/index.php | 15 ++ application/views/interface_assets/footer.php | 231 +++++------------- assets/js/sections/contesting.js | 131 ++++++++++ 3 files changed, 210 insertions(+), 167 deletions(-) create mode 100644 assets/js/sections/contesting.js diff --git a/application/views/contesting/index.php b/application/views/contesting/index.php index 0cbb5622..174489dc 100644 --- a/application/views/contesting/index.php +++ b/application/views/contesting/index.php @@ -90,6 +90,21 @@ +
+ + +
+ +
+ + +
+
diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index 9f4e0ece..2727c03a 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -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(); + }); + } + + + + +uri->segment(1) == "qso" && $_GET['manual'] == 0) || $this->uri->segment(1) == "contesting") { ?> + + +uri->segment(1) == "qso" && $_GET['manual'] == 0) || $this->uri->segment(1) == "contesting") { ?> + @@ -2437,156 +2442,48 @@ function deleteQsl(id) { } uri->segment(1) == "contesting") { ?> + + diff --git a/assets/js/sections/contesting.js b/assets/js/sections/contesting.js new file mode 100644 index 00000000..05c23680 --- /dev/null +++ b/assets/js/sections/contesting.js @@ -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 = "" + term + ""; + $(".callsign-suggestions", base).contents().each( function(i, el) { + if (el.nodeType === 3) { + var data = el.data; + if (data = data.replace(re, replacement)) { + var wrapper = $("").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(""); + }); +}); \ No newline at end of file