mirror of
https://github.com/magicbug/Cloudlog
synced 2024-11-23 10:08:38 +00:00
[Contesting] New beta contesting features PR by AndreasK79
New feature: Contest logging
This commit is contained in:
commit
b40b3a2834
@ -9,8 +9,46 @@ if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class Contesting extends CI_Controller {
|
||||
|
||||
public function index()
|
||||
public function index()
|
||||
{
|
||||
echo 'Functions to come';
|
||||
}
|
||||
|
||||
$this->load->model('cat');
|
||||
$this->load->model('stations');
|
||||
$this->load->model('logbook_model');
|
||||
$this->load->model('user_model');
|
||||
$this->load->model('modes');
|
||||
if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); }
|
||||
|
||||
$data['active_station_profile'] = $this->stations->find_active();
|
||||
$data['notice'] = false;
|
||||
$data['stations'] = $this->stations->all();
|
||||
$data['radios'] = $this->cat->radios();
|
||||
$data['dxcc'] = $this->logbook_model->fetchDxcc();
|
||||
$data['modes'] = $this->modes->active();
|
||||
|
||||
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$this->form_validation->set_rules('start_date', 'Date', 'required');
|
||||
$this->form_validation->set_rules('start_time', 'Time', 'required');
|
||||
$this->form_validation->set_rules('callsign', 'Callsign', 'required');
|
||||
|
||||
$data['page_title'] = "Contest logging";
|
||||
|
||||
$this->load->view('interface_assets/header', $data);
|
||||
$this->load->view('contesting/index');
|
||||
$this->load->view('interface_assets/footer');
|
||||
|
||||
|
||||
//setcookie("radio", $qso_data['radio'], time()+3600*24*99);
|
||||
//setcookie("station_profile_id", $qso_data['station_profile_id'], time()+3600*24*99);
|
||||
|
||||
//$this->session->set_userdata($qso_data);
|
||||
|
||||
// If SAT name is set make it session set to sat
|
||||
if($this->input->post('sat_name')) {
|
||||
$this->session->set_userdata('prop_mode', 'SAT');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -98,6 +98,14 @@ class QSO extends CI_Controller {
|
||||
$this->load->view('interface_assets/footer');
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* This is used for contest-logging and the ajax-call
|
||||
*/
|
||||
public function saveqso() {
|
||||
$this->load->model('logbook_model');
|
||||
$this->logbook_model->create_qso();
|
||||
}
|
||||
|
||||
function edit() {
|
||||
|
||||
|
9
application/models/Contesting_model.php
Normal file
9
application/models/Contesting_model.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
class Contesting_model extends CI_Model {
|
||||
function __construct()
|
||||
{
|
||||
// Call the Model constructor
|
||||
parent::__construct();
|
||||
|
||||
}
|
||||
}
|
@ -20,7 +20,27 @@ class Logbook_model extends CI_Model {
|
||||
|
||||
if($this->input->post('sat_name')) {
|
||||
$prop_mode = "SAT";
|
||||
}
|
||||
}
|
||||
|
||||
// Contest exchange, need to separate between serial and other type of exchange
|
||||
if($this->input->post('exchangeradio')) {
|
||||
if($this->input->post('exchangeradio') == "serial") {
|
||||
$srx = $this->input->post('exch_recv');
|
||||
$stx = $this->input->post('exch_sent');
|
||||
$srx_string = null;
|
||||
$stx_string = null;
|
||||
} else {
|
||||
$srx = null;
|
||||
$stx = null;
|
||||
$srx_string = $this->input->post('exch_recv');
|
||||
$stx_string = $this->input->post('exch_sent');
|
||||
}
|
||||
} else {
|
||||
$srx_string = null;
|
||||
$stx_string = null;
|
||||
$srx = null;
|
||||
$stx = null;
|
||||
}
|
||||
|
||||
if($this->session->userdata('user_locator')){
|
||||
$locator = $this->session->userdata('user_locator');
|
||||
@ -108,8 +128,10 @@ class Logbook_model extends CI_Model {
|
||||
'COL_AGE' => null,
|
||||
'COL_TEN_TEN' => null,
|
||||
'COL_TX_PWR' => $tx_power,
|
||||
'COL_STX' => null,
|
||||
'COL_SRX' => null,
|
||||
'COL_STX' => $stx,
|
||||
'COL_SRX' => $srx,
|
||||
'COL_STX_STRING' => $stx_string,
|
||||
'COL_SRX_STRING' => $srx_string,
|
||||
'COL_NR_BURSTS' => null,
|
||||
'COL_NR_PINGS' => null,
|
||||
'COL_MAX_BURSTS' => null,
|
||||
|
193
application/views/contesting/index.php
Normal file
193
application/views/contesting/index.php
Normal file
@ -0,0 +1,193 @@
|
||||
<div class="container qso_panel">
|
||||
<h2><?php echo $page_title; ?></h2>
|
||||
<div class="row">
|
||||
|
||||
<div class="col-sm-12 col-md-12">
|
||||
<div class="card">
|
||||
<div class="card-header"><h5 class="card-title">Logging form</h5></div>
|
||||
<div class="card-body">
|
||||
<form id="qso_input" name="qsos">
|
||||
|
||||
<div class="form-group row">
|
||||
|
||||
<label class="col-md-2 control-label" for="radio">Exchange type</label>
|
||||
<div class="col-md-9">
|
||||
<div class="form-check form-check-inline">
|
||||
<input class="form-check-input" type="radio" name="exchangeradio" id="serial" value="serial" checked>
|
||||
<label class="form-check-label" for="serial">
|
||||
Serial
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-check form-check-inline">
|
||||
<input class="form-check-input" type="radio" name="exchangeradio" id="other" value="other">
|
||||
<label class="form-check-label" for="other">
|
||||
Other
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-2">
|
||||
<label for="start_date">Date</label>
|
||||
<input type="text" class="form-control form-control-sm input_date" name="start_date" id="start_date" value="<?php if (($this->session->userdata('start_date') != NULL && ((time() - $this->session->userdata('time_stamp')) < 24 * 60 * 60))) { echo $this->session->userdata('start_date'); } else { echo date('d-m-Y');}?>">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-1">
|
||||
<label for="start_time">Time</label>
|
||||
<input type="text" class="form-control form-control-sm input_time" name="start_time" id="start_time" value="<?php if (($this->session->userdata('start_time') != NULL && ((time() - $this->session->userdata('time_stamp')) < 24 * 60 * 60))) { echo $this->session->userdata('start_time'); } else {echo date('H:i'); } ?>" size="7">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-2">
|
||||
<label for="mode">Mode</label>
|
||||
<select id="mode" class="form-control mode form-control-sm" name="mode">
|
||||
<?php
|
||||
foreach($modes->result() as $mode){
|
||||
if ($mode->submode == null) {
|
||||
printf("<option value=\"%s\" %s>%s</option>", $mode->mode, $this->session->userdata('mode')==$mode->mode?"selected=\"selected\"":"",$mode->mode);
|
||||
} else {
|
||||
printf("<option value=\"%s\" %s>⇒ %s</option>", $mode->submode, $this->session->userdata('mode')==$mode->submode?"selected=\"selected\"":"",$mode->submode);
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-2">
|
||||
<label for="band">Band</label>
|
||||
|
||||
<select id="band" class="form-control form-control-sm" name="band">
|
||||
<optgroup label="HF">
|
||||
<option value="160m" <?php if($this->session->userdata('band') == "160m") { echo "selected=\"selected\""; } ?>>160m</option>
|
||||
<option value="80m" <?php if($this->session->userdata('band') == "80m") { echo "selected=\"selected\""; } ?>>80m</option>
|
||||
<option value="60m" <?php if($this->session->userdata('band') == "60m") { echo "selected=\"selected\""; } ?>>60m</option>
|
||||
<option value="40m" <?php if($this->session->userdata('band') == "40m") { echo "selected=\"selected\""; } ?>>40m</option>
|
||||
<option value="30m" <?php if($this->session->userdata('band') == "30m") { echo "selected=\"selected\""; } ?>>30m</option>
|
||||
<option value="20m" <?php if($this->session->userdata('band') == "20m") { echo "selected=\"selected\""; } ?>>20m</option>
|
||||
<option value="17m" <?php if($this->session->userdata('band') == "17m") { echo "selected=\"selected\""; } ?>>17m</option>
|
||||
<option value="15m" <?php if($this->session->userdata('band') == "15m") { echo "selected=\"selected\""; } ?>>15m</option>
|
||||
<option value="12m" <?php if($this->session->userdata('band') == "12m") { echo "selected=\"selected\""; } ?>>12m</option>
|
||||
<option value="10m" <?php if($this->session->userdata('band') == "10m") { echo "selected=\"selected\""; } ?>>10m</option>
|
||||
</optgroup>
|
||||
|
||||
<optgroup label="VHF">
|
||||
<option value="6m" <?php if($this->session->userdata('band') == "6m") { echo "selected=\"selected\""; } ?>>6m</option>
|
||||
<option value="4m" <?php if($this->session->userdata('band') == "4m") { echo "selected=\"selected\""; } ?>>4m</option>
|
||||
<option value="2m" <?php if($this->session->userdata('band') == "2m") { echo "selected=\"selected\""; } ?>>2m</option>
|
||||
</optgroup>
|
||||
|
||||
<optgroup label="UHF">
|
||||
<option value="70cm" <?php if($this->session->userdata('band') == "70cm") { echo "selected=\"selected\""; } ?>>70cm</option>
|
||||
<option value="23cm" <?php if($this->session->userdata('band') == "23cm") { echo "selected=\"selected\""; } ?>>23cm</option>
|
||||
<option value="13cm" <?php if($this->session->userdata('band') == "13cm") { echo "selected=\"selected\""; } ?>>13cm</option>
|
||||
<option value="9cm" <?php if($this->session->userdata('band') == "9cm") { echo "selected=\"selected\""; } ?>>9cm</option>
|
||||
</optgroup>
|
||||
|
||||
<optgroup label="Microwave">
|
||||
<option value="6cm" <?php if($this->session->userdata('band') == "6cm") { echo "selected=\"selected\""; } ?>>6cm</option>
|
||||
<option value="3cm" <?php if($this->session->userdata('band') == "3cm") { echo "selected=\"selected\""; } ?>>3cm</option>
|
||||
</optgroup>
|
||||
</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">
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="callsign">Callsign</label>
|
||||
<input type="text" class="form-control form-control-sm" id="callsign" name="callsign" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group 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>
|
||||
|
||||
<div class="form-group col-md-1">
|
||||
<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 class="form-group col-md-1">
|
||||
<label for="rst_recv">RST (R)</label>
|
||||
<input type="text" class="form-control form-control-sm" name="rst_recv" id="rst_recv" value="59">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-1">
|
||||
<label for="exch_recv">Exch (R)</label>
|
||||
<input type="text" class="form-control form-control-sm" name="exch_recv" id="exch_recv" value="">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-5">
|
||||
<label for="name">Name</label>
|
||||
<input type="text" class="form-control form-control-sm" name="name" id="name" value="">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-5">
|
||||
<label for="comment">Comment</label>
|
||||
<input type="text" class="form-control form-control-sm" name="comment" id="comment" value="">
|
||||
</div>
|
||||
</div>
|
||||
<button type="reset" class="btn btn-sm btn-warning" onclick="reset_log_fields()">Reset</button>
|
||||
<button type="button" class="btn btn-sm btn-primary" onclick="logQso();"><i class="fas fa-save"></i> Log QSO</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<br/>
|
||||
<div class="card callsign-suggest">
|
||||
<div class="card-header"><h5 class="card-title">Callsign Suggestions</h5></div>
|
||||
|
||||
<div class="card-body callsign-suggestions"></div>
|
||||
</div>
|
||||
|
||||
<div class="card log">
|
||||
<div class="card-header"><h5 class="card-title">Logbook (for this logging session)</h5></div>
|
||||
|
||||
<table class="table-sm table qsotable table-bordered table-hover table-striped table-condensed text-center">
|
||||
<thead>
|
||||
<tr class="log_title titles">
|
||||
<th>Date/Time</th>
|
||||
<th>Call</th>
|
||||
<th>Band</th>
|
||||
<th>Mode</th>
|
||||
<th>RST (S)</th>
|
||||
<th>RST (R)</th>
|
||||
<th>Exch S</th>
|
||||
<th>Exch R</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
@ -984,6 +984,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');
|
||||
@ -999,13 +1013,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",
|
||||
@ -1028,24 +1043,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();
|
||||
@ -1064,10 +1079,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());
|
||||
}
|
||||
|
||||
@ -1076,16 +1091,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 } ?>
|
||||
@ -2528,5 +2533,49 @@ 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-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").focus();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<?php } ?>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -71,6 +71,8 @@
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item" href="<?php echo site_url('qso?manual=1');?>" title="Log QSO made in the past">Post QSO</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item" href="<?php echo site_url('contesting');?>" title="Log contest QSOs">Contest logging</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item" href="<?php echo site_url('qsl');?>" title="QSL"> View QSL</a>
|
||||
</div>
|
||||
</li>
|
||||
|
131
assets/js/sections/contesting.js
Normal file
131
assets/js/sections/contesting.js
Normal file
@ -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("");
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user