2020-12-08 04:26:16 +08:00
|
|
|
// Callsign always has focus on load
|
|
|
|
|
$("#callsign").focus();
|
|
|
|
|
|
|
|
|
|
// Init serial sent as 1 when loading page
|
|
|
|
|
$("#exch_sent").val(1);
|
|
|
|
|
|
2020-12-27 16:37:48 +08:00
|
|
|
$( document ).ready(function() {
|
|
|
|
|
restoreContestSession();
|
2020-12-29 21:51:12 +08:00
|
|
|
setRst($("#mode").val());
|
2021-03-14 19:44:42 +08:00
|
|
|
|
|
|
|
|
// Check to see what serial type is selected and set validation
|
2021-08-07 16:13:38 +08:00
|
|
|
if($('#serial').is(':checked')) {
|
2021-03-14 19:44:42 +08:00
|
|
|
set_serial_number_input_validation();
|
|
|
|
|
}
|
2021-08-07 16:13:38 +08:00
|
|
|
if($('#other').is(':checked')) {
|
2021-03-14 19:44:42 +08:00
|
|
|
set_other_input_validation();
|
|
|
|
|
}
|
2020-12-27 16:37:48 +08:00
|
|
|
});
|
|
|
|
|
|
2020-12-29 02:55:51 +08:00
|
|
|
// This erases the contest logging session which is stored in localStorage
|
|
|
|
|
function reset_contest_session() {
|
2020-12-30 00:26:52 +08:00
|
|
|
$('#name').val("");
|
|
|
|
|
$('.callsign-suggestions').text("");
|
|
|
|
|
$('#callsign').val("");
|
|
|
|
|
$('#comment').val("");
|
|
|
|
|
$('#exch_sent').val("1");
|
|
|
|
|
$('#exch_recv').val("");
|
|
|
|
|
$("#callsign").focus();
|
|
|
|
|
setRst($("#mode").val());
|
2020-12-30 00:29:43 +08:00
|
|
|
$("#serial").prop("checked", true);
|
2020-12-30 00:33:16 +08:00
|
|
|
$("#contestname").val("Other").change();
|
2020-12-30 00:37:23 +08:00
|
|
|
$(".contest_qso_table_contents").empty();
|
2020-12-30 00:29:43 +08:00
|
|
|
|
2020-12-29 02:55:51 +08:00
|
|
|
localStorage.removeItem("contestid");
|
|
|
|
|
localStorage.removeItem("exchangetype");
|
|
|
|
|
localStorage.removeItem("exchangesent");
|
|
|
|
|
localStorage.removeItem("qso");
|
2020-12-27 16:37:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Storing the contestid in contest session
|
|
|
|
|
$('#contestname').change(function() {
|
|
|
|
|
localStorage.setItem("contestid", $("#contestname").val());
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Storing the exchange type in contest session
|
|
|
|
|
$('input[type=radio][name=exchangeradio]').change(function() {
|
|
|
|
|
localStorage.setItem("exchangetype", $('input[name=exchangeradio]:checked', '#qso_input').val());
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
2020-12-08 04:26:16 +08:00
|
|
|
// 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();
|
2020-12-25 23:57:04 +08:00
|
|
|
// CTRL-Enter logs QSO
|
2020-12-08 04:26:16 +08:00
|
|
|
} else if ((e.keyCode == 10 || e.keyCode == 13) && (e.ctrlKey || e.metaKey)) {
|
|
|
|
|
logQso();
|
2020-12-25 23:57:04 +08:00
|
|
|
// Enter in sent exchange logs QSO
|
|
|
|
|
} else if((e.which == 13) && ($(document.activeElement).attr("id") == "exch_recv")) {
|
|
|
|
|
logQso();
|
2020-12-08 04:26:16 +08:00
|
|
|
} 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();
|
2020-12-29 21:51:12 +08:00
|
|
|
setRst($("#mode").val());
|
2020-12-08 04:26:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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("");
|
|
|
|
|
});
|
2021-03-14 19:44:42 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Change Serial Validation when selected
|
|
|
|
|
$('#serial').change(function() {
|
2021-08-07 16:13:38 +08:00
|
|
|
if($('#serial').is(':checked')) {
|
2021-03-14 19:44:42 +08:00
|
|
|
set_serial_number_input_validation();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Change other serial type when selected
|
|
|
|
|
$('#other').change(function() {
|
2021-08-07 16:13:38 +08:00
|
|
|
if($('#other').is(':checked')) {
|
2021-03-14 19:44:42 +08:00
|
|
|
set_other_input_validation();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2021-08-07 16:13:38 +08:00
|
|
|
$('#exchangetype').change(function(){
|
2021-08-11 04:32:15 +08:00
|
|
|
var exchangetype = $("#exchangetype").val();
|
2021-08-12 17:52:36 +08:00
|
|
|
setExchangetype(exchangetype);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
function setExchangetype(exchangetype) {
|
2021-08-07 16:13:38 +08:00
|
|
|
if (exchangetype == 'None') {
|
2021-08-11 04:32:15 +08:00
|
|
|
$(".exchanger").hide();
|
|
|
|
|
$(".exchanges").hide();
|
|
|
|
|
$(".serials").hide();
|
|
|
|
|
$(".serialr").hide();
|
|
|
|
|
$(".gridsquarer").hide();
|
|
|
|
|
$(".gridsquares").hide();
|
2021-08-07 16:13:38 +08:00
|
|
|
}
|
2021-08-12 17:56:38 +08:00
|
|
|
else if (exchangetype == 'Exchange') {
|
2021-08-12 17:52:36 +08:00
|
|
|
$(".exchanger").show();
|
|
|
|
|
$(".exchanges").show();
|
|
|
|
|
$(".serials").hide();
|
|
|
|
|
$(".serialr").hide();
|
|
|
|
|
$(".gridsquarer").hide();
|
|
|
|
|
$(".gridsquares").hide();
|
|
|
|
|
}
|
|
|
|
|
else if (exchangetype == 'Serial') {
|
2021-08-11 04:32:15 +08:00
|
|
|
$(".exchanger").hide();
|
|
|
|
|
$(".exchanges").hide();
|
|
|
|
|
$(".serials").show();
|
|
|
|
|
$(".serialr").show();
|
|
|
|
|
$(".gridsquarer").hide();
|
|
|
|
|
$(".gridsquares").hide();
|
2021-08-07 16:13:38 +08:00
|
|
|
}
|
2021-08-12 17:52:36 +08:00
|
|
|
else if (exchangetype == 'Serialexchange') {
|
2021-08-11 04:32:15 +08:00
|
|
|
$(".exchanger").show();
|
|
|
|
|
$(".exchanges").show();
|
|
|
|
|
$(".serials").show();
|
|
|
|
|
$(".serialr").show();
|
|
|
|
|
$(".gridsquarer").hide();
|
|
|
|
|
$(".gridsquares").hide();
|
2021-08-07 16:13:38 +08:00
|
|
|
}
|
2021-08-12 17:52:36 +08:00
|
|
|
else if (exchangetype == 'Serialgridsquare') {
|
2021-08-11 04:32:15 +08:00
|
|
|
$(".exchanger").hide();
|
|
|
|
|
$(".exchanges").hide();
|
|
|
|
|
$(".serials").show();
|
|
|
|
|
$(".serialr").show();
|
|
|
|
|
$(".gridsquarer").show();
|
|
|
|
|
$(".gridsquares").show();
|
2021-08-07 16:13:38 +08:00
|
|
|
}
|
2021-08-12 17:52:36 +08:00
|
|
|
else if (exchangetype == 'Gridsquare') {
|
2021-08-11 04:32:15 +08:00
|
|
|
$(".exchanger").hide();
|
|
|
|
|
$(".exchanges").hide();
|
|
|
|
|
$(".serials").hide();
|
|
|
|
|
$(".serialr").hide();
|
|
|
|
|
$(".gridsquarer").show();
|
|
|
|
|
$(".gridsquares").show();
|
2021-08-07 16:13:38 +08:00
|
|
|
}
|
2021-08-12 17:52:36 +08:00
|
|
|
}
|
2021-08-07 16:13:38 +08:00
|
|
|
|
2021-03-14 19:44:42 +08:00
|
|
|
/*
|
|
|
|
|
Function: set_serial_number_input_validation
|
|
|
|
|
Job: This sets the field input to number for validation
|
|
|
|
|
*/
|
|
|
|
|
function set_serial_number_input_validation() {
|
|
|
|
|
$('#exch_sent').attr('type', 'number');
|
|
|
|
|
$('#exch_recv').attr('type', 'number');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
Function: set_other_input_validation
|
|
|
|
|
Job: This sets the field input to text for validation
|
|
|
|
|
*/
|
|
|
|
|
function set_other_input_validation() {
|
|
|
|
|
$('#exch_sent').attr('type', 'text');
|
|
|
|
|
$('#exch_recv').attr('type', 'text');
|
2021-08-07 16:13:38 +08:00
|
|
|
}
|
2021-08-11 14:54:24 +08:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
Function: logQso
|
|
|
|
|
Job: this handles the logging done in the contesting module.
|
|
|
|
|
*/
|
|
|
|
|
function logQso() {
|
|
|
|
|
if ($("#callsign").val().length > 0) {
|
|
|
|
|
|
|
|
|
|
$('.callsign-suggestions').text("");
|
|
|
|
|
|
|
|
|
|
var table = $('.qsotable').DataTable();
|
|
|
|
|
|
|
|
|
|
var data = [[$("#start_date").val()+ ' ' + $("#start_time").val(),
|
|
|
|
|
$("#callsign").val().toUpperCase(),
|
|
|
|
|
$("#band").val(),
|
|
|
|
|
$("#mode").val(),
|
|
|
|
|
$("#rst_sent").val(),
|
|
|
|
|
$("#rst_recv").val(),
|
|
|
|
|
$("#exch_sent").val(),
|
|
|
|
|
$("#exch_recv").val()]];
|
|
|
|
|
|
|
|
|
|
table.rows.add(data).draw();
|
|
|
|
|
|
|
|
|
|
var formdata = new FormData(document.getElementById("qso_input"));
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: base_url + 'index.php/qso/saveqso',
|
|
|
|
|
type: 'post',
|
|
|
|
|
data: formdata,
|
|
|
|
|
processData: false,
|
|
|
|
|
contentType: false,
|
|
|
|
|
enctype: 'multipart/form-data',
|
|
|
|
|
success: function (html) {
|
|
|
|
|
if (localStorage.getItem("qso") == null) {
|
|
|
|
|
localStorage.setItem("qso", $("#start_date").val()+ ' ' + $("#start_time").val() + ',' + $("#callsign").val().toUpperCase() + ',' + $("#contestname").val());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$('#name').val("");
|
|
|
|
|
|
|
|
|
|
$('#callsign').val("");
|
|
|
|
|
$('#comment').val("");
|
|
|
|
|
$('#exch_recv').val("");
|
2021-08-12 17:52:36 +08:00
|
|
|
var exchangetype = $("#exchangetype").val();
|
|
|
|
|
if (exchangetype == "Serial" || exchangetype == 'Serialexchange' || exchangetype == 'Serialgridsquare') {
|
|
|
|
|
$(".serials").val(+$(".serials").val() + 1);
|
2021-08-11 14:54:24 +08:00
|
|
|
}
|
|
|
|
|
$("#callsign").focus();
|
|
|
|
|
|
|
|
|
|
// Store contest session
|
|
|
|
|
localStorage.setItem("contestid", $("#contestname").val());
|
2021-08-12 17:52:36 +08:00
|
|
|
localStorage.setItem("exchangetype", $("#exchangetype").val());
|
|
|
|
|
localStorage.setItem("exchangereceived", $(".exchanger").val());
|
|
|
|
|
localStorage.setItem("exchangesent", $(".exchanges").val());
|
|
|
|
|
localStorage.setItem("serialreceived", $(".serialr").val());
|
|
|
|
|
localStorage.setItem("serialsent", $(".serials").val());
|
|
|
|
|
localStorage.setItem("gridsquarereceived", $(".gridsquarer").val());
|
|
|
|
|
localStorage.setItem("gridsquaresent", $(".gridsquares").val());
|
2021-08-11 14:54:24 +08:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// We are restoring the settings in the contest logging form here
|
|
|
|
|
function restoreContestSession() {
|
|
|
|
|
var contestname = localStorage.getItem("contestid");
|
|
|
|
|
|
|
|
|
|
if (contestname != null) {
|
|
|
|
|
$("#contestname").val(contestname);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var exchangetype = localStorage.getItem("exchangetype");
|
2021-08-12 17:52:36 +08:00
|
|
|
$("#exchangetype").val(exchangetype);
|
|
|
|
|
setExchangetype(exchangetype);
|
2021-08-11 14:54:24 +08:00
|
|
|
|
2021-08-12 17:52:36 +08:00
|
|
|
$(".exchanger").val(localStorage.getItem("exchangereceived"));
|
|
|
|
|
$(".exchanges").val(localStorage.getItem("exchangesent"));
|
|
|
|
|
$(".serialr").val(localStorage.getItem("serialreceived"));
|
|
|
|
|
$(".serials").val(localStorage.getItem("serialsent"));
|
|
|
|
|
$(".gridsquarer").val(localStorage.getItem("gridsquarereceived"));
|
|
|
|
|
$(".gridsquares").val(localStorage.getItem("gridsquaresent"));
|
2021-08-11 14:54:24 +08:00
|
|
|
|
|
|
|
|
if (localStorage.getItem("qso") != null) {
|
|
|
|
|
var qsodata = localStorage.getItem("qso");
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: base_url + 'index.php/contesting/getSessionQsos',
|
|
|
|
|
type: 'post',
|
|
|
|
|
data: {'qso': qsodata,},
|
|
|
|
|
success: function (html) {
|
|
|
|
|
var mode = '';
|
|
|
|
|
var sentexchange = '';
|
|
|
|
|
var receivedexchange = '';
|
|
|
|
|
$.each(html, function(){
|
|
|
|
|
if (this.col_submode == null || this.col_submode == '') {
|
|
|
|
|
mode = this.col_mode;
|
|
|
|
|
} else {
|
|
|
|
|
mode = this.col_submode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (this.col_srx == null || this.col_srx == '') {
|
|
|
|
|
receivedexchange = this.col_srx_string;
|
|
|
|
|
} else {
|
|
|
|
|
receivedexchange = this.col_srx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (this.col_stx == null || this.col_stx == '') {
|
|
|
|
|
sentexchange = this.col_stx_string;
|
|
|
|
|
} else {
|
|
|
|
|
sentexchange = this.col_stx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$(".qsotable tbody").prepend('<tr>' +
|
|
|
|
|
'<td>'+ this.col_time_on + '</td>' +
|
|
|
|
|
'<td>'+ this.col_call + '</td>' +
|
|
|
|
|
'<td>'+ this.col_band + '</td>' +
|
|
|
|
|
'<td>'+ mode + '</td>' +
|
|
|
|
|
'<td>'+ this.col_rst_sent + '</td>' +
|
|
|
|
|
'<td>'+ this.col_rst_rcvd + '</td>' +
|
|
|
|
|
'<td>'+ sentexchange + '</td>' +
|
|
|
|
|
'<td>'+ receivedexchange + '</td>' +
|
|
|
|
|
'</tr>');
|
|
|
|
|
});
|
|
|
|
|
if (!$.fn.DataTable.isDataTable('.qsotable')) {
|
|
|
|
|
$('.qsotable').DataTable({
|
|
|
|
|
"pageLength": 25,
|
|
|
|
|
responsive: false,
|
|
|
|
|
"scrollY": "400px",
|
|
|
|
|
"scrollCollapse": true,
|
|
|
|
|
"paging": false,
|
|
|
|
|
"scrollX": true,
|
|
|
|
|
"order": [[ 0, "desc" ]]
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|