[QSO Dialog] Auto-fill location and locator when SOTA is chosen. This is fetched from the API. This can be turned on/off in the user settings.
Did a refactor at the same time and moved a lot of javascript from footer.php to qso.js.
这个提交包含在:
父节点
29581e9f70
当前提交
7c04327268
共有 9 个文件被更改,包括 783 次插入 和 671 次删除
|
|
@ -21,7 +21,7 @@ $config['migration_enabled'] = TRUE;
|
|||
| be upgraded / downgraded to.
|
||||
|
|
||||
*/
|
||||
$config['migration_version'] = 63;
|
||||
$config['migration_version'] = 64;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -352,4 +352,29 @@ class QSO extends CI_Controller {
|
|||
header('Content-Type: application/json');
|
||||
echo json_encode($json);
|
||||
}
|
||||
|
||||
public function get_sota_info() {
|
||||
$sota = xss_clean($this->input->post('sota'));
|
||||
$url = 'https://api2.sota.org.uk/api/summits/' . $sota;
|
||||
|
||||
// Let's use cURL instead of file_get_contents
|
||||
// begin script
|
||||
$ch = curl_init();
|
||||
|
||||
// basic curl options for all requests
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_HEADER, 0);
|
||||
|
||||
// use the URL we built
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
|
||||
$input = curl_exec($ch);
|
||||
$chi = curl_getinfo($ch);
|
||||
|
||||
// Close cURL handle
|
||||
curl_close($ch);
|
||||
|
||||
header('Content-Type: application/json');
|
||||
echo $input;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ class User extends CI_Controller {
|
|||
$data['user_timezone'] = $this->input->post('user_timezone');
|
||||
$data['user_measurement_base'] = $this->input->post('user_measurement_base');
|
||||
$data['user_stylesheet'] = $this->input->post('user_stylesheet');
|
||||
$data['user_sota_lookup'] = $this->input->post('user_sota_lookup');
|
||||
$this->load->view('user/add', $data);
|
||||
} else {
|
||||
$this->load->view('user/add', $data);
|
||||
|
|
@ -63,7 +64,7 @@ class User extends CI_Controller {
|
|||
}
|
||||
else
|
||||
{
|
||||
switch($this->user_model->add($this->input->post('user_name'), $this->input->post('user_password'), $this->input->post('user_email'), $this->input->post('user_type'), $this->input->post('user_firstname'), $this->input->post('user_lastname'), $this->input->post('user_callsign'), $this->input->post('user_locator'), $this->input->post('user_timezone'), $this->input->post('user_measurement_base'), $this->input->post('user_date_format'), $this->input->post('user_stylesheet'))) {
|
||||
switch($this->user_model->add($this->input->post('user_name'), $this->input->post('user_password'), $this->input->post('user_email'), $this->input->post('user_type'), $this->input->post('user_firstname'), $this->input->post('user_lastname'), $this->input->post('user_callsign'), $this->input->post('user_locator'), $this->input->post('user_timezone'), $this->input->post('user_measurement_base'), $this->input->post('user_date_format'), $this->input->post('user_stylesheet'), $this->input->post('user_sota_lookup'))) {
|
||||
// Check for errors
|
||||
case EUSERNAMEEXISTS:
|
||||
$data['username_error'] = 'Username <b>'.$this->input->post('user_name').'</b> already in use!';
|
||||
|
|
@ -93,6 +94,7 @@ class User extends CI_Controller {
|
|||
$data['user_locator'] = $this->input->post('user_locator');
|
||||
$data['user_measurement_base'] = $this->input->post('user_measurement_base');
|
||||
$data['user_stylesheet'] = $this->input->post('user_stylesheet');
|
||||
$data['user_sota_lookup'] = $this->input->post('user_sota_lookup');
|
||||
$this->load->view('user/add', $data);
|
||||
$this->load->view('interface_assets/footer');
|
||||
}
|
||||
|
|
@ -249,6 +251,12 @@ class User extends CI_Controller {
|
|||
$data['user_stylesheet'] = $q->user_stylesheet;
|
||||
}
|
||||
|
||||
if($this->input->post('user_sota_lookup')) {
|
||||
$data['user_sota_lookup'] = $this->input->post('user_sota_lookup', true);
|
||||
} else {
|
||||
$data['user_sota_lookup'] = $q->user_sota_lookup;
|
||||
}
|
||||
|
||||
$this->load->view('user/edit', $data);
|
||||
$this->load->view('interface_assets/footer');
|
||||
}
|
||||
|
|
@ -290,6 +298,7 @@ class User extends CI_Controller {
|
|||
$data['user_locator'] = $this->input->post('user_locator', true);
|
||||
$data['user_timezone'] = $this->input->post('user_timezone', true);
|
||||
$data['user_stylesheet'] = $this->input->post('user_stylesheet');
|
||||
$data['user_sota_lookup'] = $this->input->post('user_sota_lookup');
|
||||
$this->load->view('user/edit');
|
||||
$this->load->view('interface_assets/footer');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/*
|
||||
* This migration creates a table called options which will hold global options needed within cloudlog
|
||||
* removing the need for lots of configuration files.
|
||||
*/
|
||||
|
||||
class Migration_add_user_sota_lookup extends CI_Migration {
|
||||
|
||||
public function up()
|
||||
{
|
||||
$fields = array(
|
||||
'user_sota_lookup integer DEFAULT 0',
|
||||
);
|
||||
|
||||
$this->dbforge->add_column('users', $fields);
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
$this->dbforge->drop_column('users', 'user_sota_lookup');
|
||||
}
|
||||
}
|
||||
|
|
@ -96,7 +96,7 @@ class User_Model extends CI_Model {
|
|||
|
||||
// FUNCTION: bool add($username, $password, $email, $type)
|
||||
// Add a user
|
||||
function add($username, $password, $email, $type, $firstname, $lastname, $callsign, $locator, $timezone, $measurement, $user_date_format, $user_stylesheet) {
|
||||
function add($username, $password, $email, $type, $firstname, $lastname, $callsign, $locator, $timezone, $measurement, $user_date_format, $user_stylesheet, $user_sota_lookup) {
|
||||
// Check that the user isn't already used
|
||||
if(!$this->exists($username)) {
|
||||
$data = array(
|
||||
|
|
@ -112,6 +112,7 @@ class User_Model extends CI_Model {
|
|||
'user_measurement_base' => xss_clean($measurement),
|
||||
'user_date_format' => xss_clean($user_date_format),
|
||||
'user_stylesheet' => xss_clean($user_stylesheet),
|
||||
'user_sota_lookup' => xss_clean($user_sota_lookup),
|
||||
);
|
||||
|
||||
// Check the password is valid
|
||||
|
|
@ -153,6 +154,7 @@ class User_Model extends CI_Model {
|
|||
'user_measurement_base' => xss_clean($fields['user_measurement_base']),
|
||||
'user_date_format' => xss_clean($fields['user_date_format']),
|
||||
'user_stylesheet' => xss_clean($fields['user_stylesheet']),
|
||||
'user_sota_lookup' => xss_clean($fields['user_sota_lookup']),
|
||||
);
|
||||
|
||||
// Check to see if the user is allowed to change user levels
|
||||
|
|
@ -260,6 +262,7 @@ class User_Model extends CI_Model {
|
|||
'user_measurement_base' => $u->row()->user_measurement_base,
|
||||
'user_date_format' => $u->row()->user_date_format,
|
||||
'user_stylesheet' => $u->row()->user_stylesheet,
|
||||
'user_sota_lookup' => $u->row()->user_sota_lookup,
|
||||
);
|
||||
|
||||
$this->session->set_userdata($userdata);
|
||||
|
|
|
|||
|
|
@ -319,201 +319,7 @@ $(document).on('keypress',function(e) {
|
|||
<?php } ?>
|
||||
|
||||
<?php if ($this->uri->segment(1) == "qso") { ?>
|
||||
<script type="text/javascript">
|
||||
$( document ).ready(function() {
|
||||
var baseURL= "<?php echo base_url();?>";
|
||||
|
||||
$('#input_usa_state').change(function(){
|
||||
var state = $("#input_usa_state option:selected").text();
|
||||
if (state != "") {
|
||||
$("#stationCntyInput").prop('disabled', false);
|
||||
|
||||
$('#stationCntyInput').selectize({
|
||||
maxItems: 1,
|
||||
closeAfterSelect: true,
|
||||
loadThrottle: 250,
|
||||
valueField: 'name',
|
||||
labelField: 'name',
|
||||
searchField: 'name',
|
||||
options: [],
|
||||
create: false,
|
||||
load: function(query, callback) {
|
||||
var state = $("#input_usa_state option:selected").text();
|
||||
|
||||
if (!query || state == "") return callback();
|
||||
$.ajax({
|
||||
url: baseURL+'index.php/qso/get_county',
|
||||
type: 'GET',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
query: query,
|
||||
state: state,
|
||||
},
|
||||
error: function() {
|
||||
callback();
|
||||
},
|
||||
success: function(res) {
|
||||
callback(res);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
$("#stationCntyInput").prop('disabled', true);
|
||||
//$('#stationCntyInput')[0].selectize.destroy();
|
||||
$("#stationCntyInput").val("");
|
||||
}
|
||||
});
|
||||
|
||||
$('#sota_ref').selectize({
|
||||
maxItems: 1,
|
||||
closeAfterSelect: true,
|
||||
loadThrottle: 250,
|
||||
valueField: 'name',
|
||||
labelField: 'name',
|
||||
searchField: 'name',
|
||||
options: [],
|
||||
create: false,
|
||||
load: function(query, callback) {
|
||||
if (!query || query.length < 3) return callback(); // Only trigger if 3 or more characters are entered
|
||||
$.ajax({
|
||||
url: baseURL+'index.php/qso/get_sota',
|
||||
type: 'GET',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
query: query,
|
||||
},
|
||||
error: function() {
|
||||
callback();
|
||||
},
|
||||
success: function(res) {
|
||||
callback(res);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$('#darc_dok').selectize({
|
||||
maxItems: 1,
|
||||
closeAfterSelect: true,
|
||||
loadThrottle: 250,
|
||||
valueField: 'name',
|
||||
labelField: 'name',
|
||||
searchField: 'name',
|
||||
options: [],
|
||||
create: false,
|
||||
load: function(query, callback) {
|
||||
if (!query) return callback(); // Only trigger if at least 1 character is entered
|
||||
$.ajax({
|
||||
url: baseURL+'index.php/qso/get_dok',
|
||||
type: 'GET',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
query: query,
|
||||
},
|
||||
error: function() {
|
||||
callback();
|
||||
},
|
||||
success: function(res) {
|
||||
callback(res);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
Populate the Satellite Names Field on the QSO Panel
|
||||
*/
|
||||
$.getJSON( "<?php echo base_url();?>assets/json/satellite_data.json", function( data ) {
|
||||
|
||||
// Build the options array
|
||||
var items = [];
|
||||
$.each( data, function( key, val ) {
|
||||
items.push(
|
||||
'<option value="' + key + '">' + key + '</option>'
|
||||
);
|
||||
});
|
||||
|
||||
// Add to the datalist
|
||||
$('.satellite_names_list').append(items.join( "" ));
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
var selected_sat;
|
||||
var selected_sat_mode;
|
||||
|
||||
$(document).on('change', 'input', function(){
|
||||
var optionslist = $('.satellite_names_list')[0].options;
|
||||
var value = $(this).val();
|
||||
for (var x=0;x<optionslist.length;x++){
|
||||
if (optionslist[x].value === value) {
|
||||
$("#sat_mode").val("");
|
||||
$('.satellite_modes_list').find('option').remove().end();
|
||||
selected_sat = value;
|
||||
// get Json file
|
||||
$.getJSON( "<?php echo base_url();?>assets/json/satellite_data.json", function( data ) {
|
||||
|
||||
// Build the options array
|
||||
var sat_modes = [];
|
||||
$.each( data, function( key, val ) {
|
||||
if (key == value) {
|
||||
$.each( val.Modes, function( key1, val2 ) {
|
||||
//console.log (key1);
|
||||
sat_modes.push('<option value="' + key1 + '">' + key1 + '</option>');
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Add to the datalist
|
||||
$('.satellite_modes_list').append(sat_modes.join( "" ));
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('change', 'input', function(){
|
||||
var optionslist = $('.satellite_modes_list')[0].options;
|
||||
var value = $(this).val();
|
||||
for (var x=0;x<optionslist.length;x++){
|
||||
if (optionslist[x].value === value) {
|
||||
|
||||
// Store selected sat mode
|
||||
selected_sat_mode = value;
|
||||
|
||||
// get Json file
|
||||
$.getJSON( "<?php echo base_url();?>assets/json/satellite_data.json", function( data ) {
|
||||
|
||||
// Build the options array
|
||||
var sat_modes = [];
|
||||
$.each( data, function( key, val ) {
|
||||
if (key == selected_sat) {
|
||||
$.each( val.Modes, function( key1, val2 ) {
|
||||
if(key1 == selected_sat_mode) {
|
||||
|
||||
if (val2[0].Uplink_Mode == "LSB" || val2[0].Uplink_Mode == "USB") {
|
||||
$("#mode").val("SSB");
|
||||
} else {
|
||||
$("#mode").val(val2[0].Uplink_Mode);
|
||||
}
|
||||
$("#band").val(frequencyToBand(val2[0].Uplink_Freq));
|
||||
$("#band_rx").val(frequencyToBand(val2[0].Downlink_Freq));
|
||||
$("#frequency").val(val2[0].Uplink_Freq);
|
||||
$("#frequency_rx").val(val2[0].Downlink_Freq);
|
||||
$("#selectPropagation").val('SAT');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
||||
<script src="<?php echo base_url() ;?>assets/js/sections/qso.js"></script>
|
||||
|
||||
<script>
|
||||
var markers = L.layerGroup();
|
||||
|
|
@ -527,7 +333,6 @@ $(document).on('change', 'input', function(){
|
|||
|
||||
</script>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
var manual = <?php echo $_GET['manual']; ?>;
|
||||
|
|
@ -599,35 +404,7 @@ $(document).on('change', 'input', function(){
|
|||
}
|
||||
});
|
||||
|
||||
/* Function: reset_fields is used to reset the fields on the QSO page */
|
||||
function reset_fields() {
|
||||
|
||||
$('#locator_info').text("");
|
||||
$('#country').val("");
|
||||
$('#lotw_info').text("");
|
||||
$('#dxcc_id').val("");
|
||||
$('#cqz').val("");
|
||||
$('#name').val("");
|
||||
$('#qth').val("");
|
||||
$('#locator').val("");
|
||||
$('#iota_ref').val("");
|
||||
$("#locator").removeClass("workedGrid");
|
||||
$("#locator").removeClass("newGrid");
|
||||
$("#callsign").removeClass("workedGrid");
|
||||
$("#callsign").removeClass("newGrid");
|
||||
$('#callsign_info').removeClass("badge-secondary");
|
||||
$('#callsign_info').removeClass("badge-success");
|
||||
$('#callsign_info').removeClass("badge-danger");
|
||||
$('#qsl_via').val("");
|
||||
$('#callsign_info').text("");
|
||||
$('#input_usa_state').val("");
|
||||
$('#qso-last-table').show();
|
||||
$('#partial_view').hide();
|
||||
|
||||
mymap.setView([51.505, -0.09], 13);
|
||||
mymap.removeLayer(markers);
|
||||
$('.callsign-suggest').hide();
|
||||
}
|
||||
|
||||
jQuery(function($) {
|
||||
var input = $('#callsign');
|
||||
|
|
@ -648,101 +425,27 @@ $(document).on('change', 'input', function(){
|
|||
});
|
||||
});
|
||||
|
||||
//Spacebar moves to the name field when you're entering a callsign
|
||||
//Similar to contesting ux, good for pileups.
|
||||
$("#callsign").on("keypress", function(e) {
|
||||
if (e.which == 32){
|
||||
$("#name").focus();
|
||||
return false; //Eliminate space char
|
||||
}
|
||||
});
|
||||
|
||||
// On Key up check and suggest callsigns
|
||||
$("#callsign").keyup(function() {
|
||||
if ($(this).val().length >= 3) {
|
||||
$('.callsign-suggest').show();
|
||||
$.get('lookup/scp/' + $(this).val().toUpperCase(), function(result) {
|
||||
|
||||
$('.callsign-suggestions').text(result);
|
||||
<?php if ($this->session->userdata('user_sota_lookup') == 1) { ?>
|
||||
$('#sota_ref').change(function() {
|
||||
var sota = $('#sota_ref').val();
|
||||
if (sota.length > 0) {
|
||||
$.ajax({
|
||||
url: base_url+'index.php/qso/get_sota_info',
|
||||
type: 'post',
|
||||
data: {'sota': sota},
|
||||
success: function(res) {
|
||||
$('#qth').val(res.name);
|
||||
$('#locator').val(res.locator);
|
||||
},
|
||||
error: function() {
|
||||
$('#qth').val('');
|
||||
$('#locator').val('');
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
<?php } ?>
|
||||
|
||||
$('#dxcc_id').on('change', function() {
|
||||
$.getJSON('logbook/jsonentity/' + $(this).val(), function (result) {
|
||||
if (result.dxcc.name != undefined) {
|
||||
|
||||
$('#country').val(convert_case(result.dxcc.name));
|
||||
$('#cqz').val(convert_case(result.dxcc.cqz));
|
||||
|
||||
$('#callsign_info').removeClass("badge-secondary");
|
||||
$('#callsign_info').removeClass("badge-success");
|
||||
$('#callsign_info').removeClass("badge-danger");
|
||||
$('#callsign_info').attr('title', '');
|
||||
$('#callsign_info').text(convert_case(result.dxcc.name));
|
||||
|
||||
changebadge(result.dxcc.name);
|
||||
|
||||
// Set Map to Lat/Long it locator is not empty
|
||||
if($('#locator').val() == "") {
|
||||
var redIcon = L.icon({
|
||||
iconUrl: icon_dot_url,
|
||||
iconSize: [18, 18], // size of the icon
|
||||
});
|
||||
|
||||
markers.clearLayers();
|
||||
var marker = L.marker([result.dxcc.lat, result.dxcc.long], {icon: redIcon});
|
||||
mymap.setZoom(8);
|
||||
mymap.panTo([result.dxcc.lat, result.dxcc.long]);
|
||||
markers.addLayer(marker).addTo(mymap);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function changebadge(entityname) {
|
||||
if($("#sat_name" ).val() != "") {
|
||||
$.getJSON('logbook/jsonlookupdxcc/' + convert_case(entityname) + '/SAT/0/0', function(result)
|
||||
{
|
||||
|
||||
$('#callsign_info').removeClass("badge-secondary");
|
||||
$('#callsign_info').removeClass("badge-success");
|
||||
$('#callsign_info').removeClass("badge-danger");
|
||||
$('#callsign_info').attr('title', '');
|
||||
|
||||
if (result.workedBefore)
|
||||
{
|
||||
$('#callsign_info').addClass("badge-success");
|
||||
$('#callsign_info').attr('title', 'DXCC was already worked in the past on this band and mode!');
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#callsign_info').addClass("badge-danger");
|
||||
$('#callsign_info').attr('title', 'New DXCC, not worked on this band and mode!');
|
||||
}
|
||||
})
|
||||
} else {
|
||||
$.getJSON('logbook/jsonlookupdxcc/' + convert_case(entityname) + '/0/' + $("#band").val() +'/' + $("#mode").val(), function(result)
|
||||
{
|
||||
// Reset CSS values before updating
|
||||
$('#callsign_info').removeClass("badge-secondary");
|
||||
$('#callsign_info').removeClass("badge-success");
|
||||
$('#callsign_info').removeClass("badge-danger");
|
||||
$('#callsign_info').attr('title', '');
|
||||
|
||||
if (result.workedBefore)
|
||||
{
|
||||
$('#callsign_info').addClass("badge-success");
|
||||
$('#callsign_info').attr('title', 'DXCC was already worked in the past on this band and mode!');
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#callsign_info').addClass("badge-danger");
|
||||
$('#callsign_info').attr('title', 'New DXCC, not worked on this band and mode!');
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
<?php if ($this->config->item('qso_auto_qth')) { ?>
|
||||
$('#qth').focusout(function() {
|
||||
if ($('#locator').val() === '') {
|
||||
|
|
@ -808,303 +511,6 @@ $(document).on('change', 'input', function(){
|
|||
}
|
||||
<?php } ?>
|
||||
|
||||
$("#callsign").focusout(function() {
|
||||
|
||||
if ($(this).val().length >= 3) {
|
||||
/* Find and populate DXCC */
|
||||
$('.callsign-suggest').hide();
|
||||
|
||||
if($("#sat_name").val() != ""){
|
||||
var sat_type = "SAT";
|
||||
var json_band = "0";
|
||||
var json_mode = "0";
|
||||
} else {
|
||||
var sat_type = "0";
|
||||
var json_band = $("#band").val();
|
||||
var json_mode = $("#mode").val();
|
||||
}
|
||||
|
||||
var find_callsign = $(this).val().toUpperCase();
|
||||
|
||||
find_callsign.replace(/\//g, "-");
|
||||
|
||||
// Replace / in a callsign with - to stop urls breaking
|
||||
$.getJSON('logbook/json/' + find_callsign.replace(/\//g, "-") + '/' + sat_type + '/' + json_band + '/' + json_mode, function(result)
|
||||
{
|
||||
//$('#country').val(result); lotw_info
|
||||
if(result.dxcc.entity != undefined) {
|
||||
$('#country').val(convert_case(result.dxcc.entity));
|
||||
$('#callsign_info').text(convert_case(result.dxcc.entity));
|
||||
|
||||
if($("#sat_name" ).val() != "") {
|
||||
//logbook/jsonlookupgrid/io77/SAT/0/0
|
||||
$.getJSON('logbook/jsonlookupcallsign/' + find_callsign.replace(/\//g, "-") + '/SAT/0/0', function(result)
|
||||
{
|
||||
// Reset CSS values before updating
|
||||
$('#callsign').removeClass("workedGrid");
|
||||
$('#callsign').removeClass("newGrid");
|
||||
$('#callsign').attr('title', '');
|
||||
|
||||
if (result.workedBefore)
|
||||
{
|
||||
$('#callsign').addClass("workedGrid");
|
||||
$('#callsign').attr('title', 'Callsign was already worked in the past on this band and mode!');
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#callsign').addClass("newGrid");
|
||||
$('#callsign').attr('title', 'New Callsign!');
|
||||
}
|
||||
})
|
||||
} else {
|
||||
$.getJSON('logbook/jsonlookupcallsign/' + find_callsign.replace(/\//g, "-") + '/0/' + $("#band").val() +'/' + $("#mode").val(), function(result)
|
||||
{
|
||||
// Reset CSS values before updating
|
||||
$('#callsign').removeClass("workedGrid");
|
||||
$('#callsign').removeClass("newGrid");
|
||||
$('#callsign').attr('title', '');
|
||||
|
||||
if (result.workedBefore)
|
||||
{
|
||||
$('#callsign').addClass("workedGrid");
|
||||
$('#callsign').attr('title', 'Callsign was already worked in the past on this band and mode!');
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#callsign').addClass("newGrid");
|
||||
$('#callsign').attr('title', 'New Callsign!');
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
changebadge(result.dxcc.entity);
|
||||
}
|
||||
|
||||
if(result.lotw_member == "active") {
|
||||
$('#lotw_info').text("LoTW");
|
||||
}
|
||||
|
||||
$('#dxcc_id').val(result.dxcc.adif);
|
||||
$('#cqz').val(result.dxcc.cqz);
|
||||
$('#ituz').val(result.dxcc.ituz);
|
||||
|
||||
|
||||
var redIcon = L.icon({
|
||||
iconUrl: icon_dot_url,
|
||||
iconSize: [18, 18], // size of the icon
|
||||
});
|
||||
|
||||
// Set Map to Lat/Long
|
||||
markers.clearLayers();
|
||||
mymap.setZoom(8);
|
||||
if (typeof result.latlng !== "undefined" && result.latlng !== false) {
|
||||
var marker = L.marker([result.latlng[0], result.latlng[1]], {icon: redIcon});
|
||||
mymap.panTo([result.latlng[0], result.latlng[1]]);
|
||||
} else {
|
||||
var marker = L.marker([result.dxcc.lat, result.dxcc.long], {icon: redIcon});
|
||||
mymap.panTo([result.dxcc.lat, result.dxcc.long]);
|
||||
}
|
||||
|
||||
markers.addLayer(marker).addTo(mymap);
|
||||
|
||||
|
||||
/* Find Locator if the field is empty */
|
||||
if($('#locator').val() == "") {
|
||||
$('#locator').val(result.callsign_qra);
|
||||
$('#locator_info').html(result.bearing);
|
||||
|
||||
if (result.callsign_qra != "")
|
||||
{
|
||||
if (result.workedBefore)
|
||||
{
|
||||
$('#locator').addClass("workedGrid");
|
||||
$('#locator').attr('title', 'Grid was already worked in the past');
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#locator').addClass("newGrid");
|
||||
$('#locator').attr('title', 'New grid!');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#locator').removeClass("workedGrid");
|
||||
$('#locator').removeClass("newGrid");
|
||||
$('#locator').attr('title', '');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Find Operators Name */
|
||||
if($('#qsl_via').val() == "") {
|
||||
$('#qsl_via').val(result.qsl_manager);
|
||||
}
|
||||
|
||||
/* Find Operators Name */
|
||||
if($('#name').val() == "") {
|
||||
$('#name').val(result.callsign_name);
|
||||
}
|
||||
|
||||
if($('#qth').val() == "") {
|
||||
$('#qth').val(result.callsign_qth);
|
||||
}
|
||||
|
||||
/*
|
||||
* Update state with returned value
|
||||
*/
|
||||
if($("#input_usa_state").val() == "") {
|
||||
$("#input_usa_state").val(result.callsign_state).trigger('change');
|
||||
}
|
||||
|
||||
|
||||
if($('#iota_ref').val() == "") {
|
||||
$('#iota_ref').val(result.callsign_iota);
|
||||
}
|
||||
// Hide the last QSO table
|
||||
$('#qso-last-table').hide();
|
||||
$('#partial_view').show();
|
||||
/* display past QSOs */
|
||||
$('#partial_view').html(result.partial);
|
||||
});
|
||||
} else {
|
||||
/* Reset fields ... */
|
||||
$('#callsign_info').text("");
|
||||
$('#locator_info').text("");
|
||||
$('#country').val("");
|
||||
$('#dxcc_id').val("");
|
||||
$('#cqz').val("");
|
||||
$('#name').val("");
|
||||
$('#qth').val("");
|
||||
$('#locator').val("");
|
||||
$('#iota_ref').val("");
|
||||
$("#locator").removeClass("workedGrid");
|
||||
$("#locator").removeClass("newGrid");
|
||||
$("#callsign").removeClass("workedGrid");
|
||||
$("#callsign").removeClass("newGrid");
|
||||
$('#callsign_info').removeClass("badge-secondary");
|
||||
$('#callsign_info').removeClass("badge-success");
|
||||
$('#callsign_info').removeClass("badge-danger");
|
||||
$('#input_usa_state').val("");
|
||||
}
|
||||
})
|
||||
|
||||
// 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("");
|
||||
});
|
||||
});
|
||||
|
||||
/* On Key up Calculate Bearing and Distance */
|
||||
$("#locator").keyup(function(){
|
||||
if ($(this).val()) {
|
||||
var qra_input = $(this).val();
|
||||
|
||||
var qra_lookup = qra_input.substring(0, 4);
|
||||
|
||||
if(qra_lookup.length >= 4) {
|
||||
|
||||
// Check Log if satname is provided
|
||||
if($("#sat_name" ).val() != "") {
|
||||
|
||||
//logbook/jsonlookupgrid/io77/SAT/0/0
|
||||
|
||||
$.getJSON('logbook/jsonlookupgrid/' + qra_lookup.toUpperCase() + '/SAT/0/0', function(result)
|
||||
{
|
||||
// Reset CSS values before updating
|
||||
$('#locator').removeClass("workedGrid");
|
||||
$('#locator').removeClass("newGrid");
|
||||
$('#locator').attr('title', '');
|
||||
|
||||
if (result.workedBefore)
|
||||
{
|
||||
$('#locator').addClass("workedGrid");
|
||||
$('#locator').attr('title', 'Grid was already worked in the past');
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#locator').addClass("newGrid");
|
||||
$('#locator').attr('title', 'New grid!');
|
||||
}
|
||||
})
|
||||
} else {
|
||||
$.getJSON('logbook/jsonlookupgrid/' + qra_lookup.toUpperCase() + '/0/' + $("#band").val() +'/' + $("#mode").val(), function(result)
|
||||
{
|
||||
// Reset CSS values before updating
|
||||
$('#locator').removeClass("workedGrid");
|
||||
$('#locator').removeClass("newGrid");
|
||||
$('#locator').attr('title', '');
|
||||
|
||||
if (result.workedBefore)
|
||||
{
|
||||
$('#locator').addClass("workedGrid");
|
||||
$('#locator').attr('title', 'Grid was already worked in the past');
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#locator').addClass("newGrid");
|
||||
$('#locator').attr('title', 'New grid!');
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if(qra_input.length >= 4 && $(this).val().length > 0) {
|
||||
$.getJSON('logbook/qralatlngjson/' + $(this).val(), function(result)
|
||||
{
|
||||
// Set Map to Lat/Long
|
||||
markers.clearLayers();
|
||||
if (typeof result !== "undefined") {
|
||||
var redIcon = L.icon({
|
||||
iconUrl: icon_dot_url,
|
||||
iconSize: [18, 18], // size of the icon
|
||||
});
|
||||
|
||||
var marker = L.marker([result[0], result[1]], {icon: redIcon});
|
||||
mymap.setZoom(8);
|
||||
mymap.panTo([result[0], result[1]]);
|
||||
}
|
||||
markers.addLayer(marker).addTo(mymap);
|
||||
})
|
||||
|
||||
$('#locator_info').load("logbook/searchbearing/" + $(this).val()).fadeIn("slow");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Change report based on mode
|
||||
$('.mode').change(function(){
|
||||
setRst($('.mode') .val());
|
||||
});
|
||||
|
||||
|
||||
|
||||
function convert_case(str) {
|
||||
var lower = str.toLowerCase();
|
||||
return lower.replace(/(^| )(\w)/g, function(x) {
|
||||
return x.toUpperCase();
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<?php } ?>
|
||||
|
|
|
|||
|
|
@ -120,6 +120,15 @@
|
|||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="sotalookup">SOTA auto lookup gridsquare and name for summit.</label>
|
||||
<select class="custom-select" id="sotalookup" name="user_sota_lookup">
|
||||
<option value="0">No</option>
|
||||
<option value="1">Yes</option>
|
||||
</select>
|
||||
<div class="small form-text text-muted">If this is set, name and gridsquare is fetched from the API and filled in location and locator.</div></td>
|
||||
</div>
|
||||
|
||||
<input type="hidden" name="id" value="<?php echo $this->uri->segment(3); ?>" />
|
||||
<button type="submit" class="btn btn-primary">Create Account</button>
|
||||
</form>
|
||||
|
|
|
|||
|
|
@ -267,6 +267,30 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<br>
|
||||
<div class="row">
|
||||
<!-- Club Log -->
|
||||
<div class="col-md">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
Summits On The Air
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="form-group">
|
||||
<label for="sotalookup">SOTA auto lookup gridsquare and name for summit.</label>
|
||||
<select class="custom-select" id="sotalookup" name="user_sota_lookup">
|
||||
<option value="1" <?php if ($user_sota_lookup == 1) { echo " selected =\"selected\""; } ?>>Yes</option>
|
||||
<option value="0" <?php if ($user_sota_lookup == 0) { echo " selected =\"selected\""; } ?>>No</option>
|
||||
</select>
|
||||
<div class="small form-text text-muted">If this is set, name and gridsquare is fetched from the API and filled in location and locator.</div></td>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<input type="hidden" name="id" value="<?php echo $this->uri->segment(3); ?>" />
|
||||
|
|
|
|||
611
assets/js/sections/qso.js
普通文件
611
assets/js/sections/qso.js
普通文件
|
|
@ -0,0 +1,611 @@
|
|||
$( document ).ready(function() {
|
||||
|
||||
$('#input_usa_state').change(function(){
|
||||
var state = $("#input_usa_state option:selected").text();
|
||||
if (state != "") {
|
||||
$("#stationCntyInput").prop('disabled', false);
|
||||
|
||||
$('#stationCntyInput').selectize({
|
||||
maxItems: 1,
|
||||
closeAfterSelect: true,
|
||||
loadThrottle: 250,
|
||||
valueField: 'name',
|
||||
labelField: 'name',
|
||||
searchField: 'name',
|
||||
options: [],
|
||||
create: false,
|
||||
load: function(query, callback) {
|
||||
var state = $("#input_usa_state option:selected").text();
|
||||
|
||||
if (!query || state == "") return callback();
|
||||
$.ajax({
|
||||
url: base_url+'index.php/qso/get_county',
|
||||
type: 'GET',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
query: query,
|
||||
state: state,
|
||||
},
|
||||
error: function() {
|
||||
callback();
|
||||
},
|
||||
success: function(res) {
|
||||
callback(res);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
$("#stationCntyInput").prop('disabled', true);
|
||||
//$('#stationCntyInput')[0].selectize.destroy();
|
||||
$("#stationCntyInput").val("");
|
||||
}
|
||||
});
|
||||
|
||||
$('#sota_ref').selectize({
|
||||
maxItems: 1,
|
||||
closeAfterSelect: true,
|
||||
loadThrottle: 250,
|
||||
valueField: 'name',
|
||||
labelField: 'name',
|
||||
searchField: 'name',
|
||||
options: [],
|
||||
create: false,
|
||||
load: function(query, callback) {
|
||||
if (!query || query.length < 3) return callback(); // Only trigger if 3 or more characters are entered
|
||||
$.ajax({
|
||||
url: base_url+'index.php/qso/get_sota',
|
||||
type: 'GET',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
query: query,
|
||||
},
|
||||
error: function() {
|
||||
callback();
|
||||
},
|
||||
success: function(res) {
|
||||
callback(res);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$('#darc_dok').selectize({
|
||||
maxItems: 1,
|
||||
closeAfterSelect: true,
|
||||
loadThrottle: 250,
|
||||
valueField: 'name',
|
||||
labelField: 'name',
|
||||
searchField: 'name',
|
||||
options: [],
|
||||
create: false,
|
||||
load: function(query, callback) {
|
||||
if (!query) return callback(); // Only trigger if at least 1 character is entered
|
||||
$.ajax({
|
||||
url: base_url+'index.php/qso/get_dok',
|
||||
type: 'GET',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
query: query,
|
||||
},
|
||||
error: function() {
|
||||
callback();
|
||||
},
|
||||
success: function(res) {
|
||||
callback(res);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
Populate the Satellite Names Field on the QSO Panel
|
||||
*/
|
||||
$.getJSON(base_url+"assets/json/satellite_data.json", function( data ) {
|
||||
|
||||
// Build the options array
|
||||
var items = [];
|
||||
$.each( data, function( key, val ) {
|
||||
items.push(
|
||||
'<option value="' + key + '">' + key + '</option>'
|
||||
);
|
||||
});
|
||||
|
||||
// Add to the datalist
|
||||
$('.satellite_names_list').append(items.join( "" ));
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
var selected_sat;
|
||||
var selected_sat_mode;
|
||||
|
||||
$(document).on('change', 'input', function(){
|
||||
var optionslist = $('.satellite_modes_list')[0].options;
|
||||
var value = $(this).val();
|
||||
for (var x=0;x<optionslist.length;x++){
|
||||
if (optionslist[x].value === value) {
|
||||
|
||||
// Store selected sat mode
|
||||
selected_sat_mode = value;
|
||||
|
||||
// get Json file
|
||||
$.getJSON(base_url + "assets/json/satellite_data.json", function( data ) {
|
||||
|
||||
// Build the options array
|
||||
var sat_modes = [];
|
||||
$.each( data, function( key, val ) {
|
||||
if (key == selected_sat) {
|
||||
$.each( val.Modes, function( key1, val2 ) {
|
||||
if(key1 == selected_sat_mode) {
|
||||
|
||||
if (val2[0].Uplink_Mode == "LSB" || val2[0].Uplink_Mode == "USB") {
|
||||
$("#mode").val("SSB");
|
||||
} else {
|
||||
$("#mode").val(val2[0].Uplink_Mode);
|
||||
}
|
||||
$("#band").val(frequencyToBand(val2[0].Uplink_Freq));
|
||||
$("#band_rx").val(frequencyToBand(val2[0].Downlink_Freq));
|
||||
$("#frequency").val(val2[0].Uplink_Freq);
|
||||
$("#frequency_rx").val(val2[0].Downlink_Freq);
|
||||
$("#selectPropagation").val('SAT');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('change', 'input', function(){
|
||||
var optionslist = $('.satellite_names_list')[0].options;
|
||||
var value = $(this).val();
|
||||
for (var x=0;x<optionslist.length;x++){
|
||||
if (optionslist[x].value === value) {
|
||||
$("#sat_mode").val("");
|
||||
$('.satellite_modes_list').find('option').remove().end();
|
||||
selected_sat = value;
|
||||
// get Json file
|
||||
$.getJSON( base_url+"assets/json/satellite_data.json", function( data ) {
|
||||
|
||||
// Build the options array
|
||||
var sat_modes = [];
|
||||
$.each( data, function( key, val ) {
|
||||
if (key == value) {
|
||||
$.each( val.Modes, function( key1, val2 ) {
|
||||
//console.log (key1);
|
||||
sat_modes.push('<option value="' + key1 + '">' + key1 + '</option>');
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Add to the datalist
|
||||
$('.satellite_modes_list').append(sat_modes.join( "" ));
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function changebadge(entityname) {
|
||||
if($("#sat_name" ).val() != "") {
|
||||
$.getJSON('logbook/jsonlookupdxcc/' + convert_case(entityname) + '/SAT/0/0', function(result)
|
||||
{
|
||||
|
||||
$('#callsign_info').removeClass("badge-secondary");
|
||||
$('#callsign_info').removeClass("badge-success");
|
||||
$('#callsign_info').removeClass("badge-danger");
|
||||
$('#callsign_info').attr('title', '');
|
||||
|
||||
if (result.workedBefore)
|
||||
{
|
||||
$('#callsign_info').addClass("badge-success");
|
||||
$('#callsign_info').attr('title', 'DXCC was already worked in the past on this band and mode!');
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#callsign_info').addClass("badge-danger");
|
||||
$('#callsign_info').attr('title', 'New DXCC, not worked on this band and mode!');
|
||||
}
|
||||
})
|
||||
} else {
|
||||
$.getJSON('logbook/jsonlookupdxcc/' + convert_case(entityname) + '/0/' + $("#band").val() +'/' + $("#mode").val(), function(result)
|
||||
{
|
||||
// Reset CSS values before updating
|
||||
$('#callsign_info').removeClass("badge-secondary");
|
||||
$('#callsign_info').removeClass("badge-success");
|
||||
$('#callsign_info').removeClass("badge-danger");
|
||||
$('#callsign_info').attr('title', '');
|
||||
|
||||
if (result.workedBefore)
|
||||
{
|
||||
$('#callsign_info').addClass("badge-success");
|
||||
$('#callsign_info').attr('title', 'DXCC was already worked in the past on this band and mode!');
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#callsign_info').addClass("badge-danger");
|
||||
$('#callsign_info').attr('title', 'New DXCC, not worked on this band and mode!');
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/* Function: reset_fields is used to reset the fields on the QSO page */
|
||||
function reset_fields() {
|
||||
|
||||
$('#locator_info').text("");
|
||||
$('#country').val("");
|
||||
$('#lotw_info').text("");
|
||||
$('#dxcc_id').val("");
|
||||
$('#cqz').val("");
|
||||
$('#name').val("");
|
||||
$('#qth').val("");
|
||||
$('#locator').val("");
|
||||
$('#iota_ref').val("");
|
||||
$("#locator").removeClass("workedGrid");
|
||||
$("#locator").removeClass("newGrid");
|
||||
$("#callsign").removeClass("workedGrid");
|
||||
$("#callsign").removeClass("newGrid");
|
||||
$('#callsign_info').removeClass("badge-secondary");
|
||||
$('#callsign_info').removeClass("badge-success");
|
||||
$('#callsign_info').removeClass("badge-danger");
|
||||
$('#qsl_via').val("");
|
||||
$('#callsign_info').text("");
|
||||
$('#input_usa_state').val("");
|
||||
$('#qso-last-table').show();
|
||||
$('#partial_view').hide();
|
||||
|
||||
mymap.setView([51.505, -0.09], 13);
|
||||
mymap.removeLayer(markers);
|
||||
$('.callsign-suggest').hide();
|
||||
}
|
||||
|
||||
$("#callsign").focusout(function() {
|
||||
|
||||
if ($(this).val().length >= 3) {
|
||||
/* Find and populate DXCC */
|
||||
$('.callsign-suggest').hide();
|
||||
|
||||
if($("#sat_name").val() != ""){
|
||||
var sat_type = "SAT";
|
||||
var json_band = "0";
|
||||
var json_mode = "0";
|
||||
} else {
|
||||
var sat_type = "0";
|
||||
var json_band = $("#band").val();
|
||||
var json_mode = $("#mode").val();
|
||||
}
|
||||
|
||||
var find_callsign = $(this).val().toUpperCase();
|
||||
|
||||
find_callsign.replace(/\//g, "-");
|
||||
|
||||
// Replace / in a callsign with - to stop urls breaking
|
||||
$.getJSON('logbook/json/' + find_callsign.replace(/\//g, "-") + '/' + sat_type + '/' + json_band + '/' + json_mode, function(result)
|
||||
{
|
||||
//$('#country').val(result); lotw_info
|
||||
if(result.dxcc.entity != undefined) {
|
||||
$('#country').val(convert_case(result.dxcc.entity));
|
||||
$('#callsign_info').text(convert_case(result.dxcc.entity));
|
||||
|
||||
if($("#sat_name" ).val() != "") {
|
||||
//logbook/jsonlookupgrid/io77/SAT/0/0
|
||||
$.getJSON('logbook/jsonlookupcallsign/' + find_callsign.replace(/\//g, "-") + '/SAT/0/0', function(result)
|
||||
{
|
||||
// Reset CSS values before updating
|
||||
$('#callsign').removeClass("workedGrid");
|
||||
$('#callsign').removeClass("newGrid");
|
||||
$('#callsign').attr('title', '');
|
||||
|
||||
if (result.workedBefore)
|
||||
{
|
||||
$('#callsign').addClass("workedGrid");
|
||||
$('#callsign').attr('title', 'Callsign was already worked in the past on this band and mode!');
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#callsign').addClass("newGrid");
|
||||
$('#callsign').attr('title', 'New Callsign!');
|
||||
}
|
||||
})
|
||||
} else {
|
||||
$.getJSON('logbook/jsonlookupcallsign/' + find_callsign.replace(/\//g, "-") + '/0/' + $("#band").val() +'/' + $("#mode").val(), function(result)
|
||||
{
|
||||
// Reset CSS values before updating
|
||||
$('#callsign').removeClass("workedGrid");
|
||||
$('#callsign').removeClass("newGrid");
|
||||
$('#callsign').attr('title', '');
|
||||
|
||||
if (result.workedBefore)
|
||||
{
|
||||
$('#callsign').addClass("workedGrid");
|
||||
$('#callsign').attr('title', 'Callsign was already worked in the past on this band and mode!');
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#callsign').addClass("newGrid");
|
||||
$('#callsign').attr('title', 'New Callsign!');
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
changebadge(result.dxcc.entity);
|
||||
}
|
||||
|
||||
if(result.lotw_member == "active") {
|
||||
$('#lotw_info').text("LoTW");
|
||||
}
|
||||
|
||||
$('#dxcc_id').val(result.dxcc.adif);
|
||||
$('#cqz').val(result.dxcc.cqz);
|
||||
$('#ituz').val(result.dxcc.ituz);
|
||||
|
||||
|
||||
var redIcon = L.icon({
|
||||
iconUrl: icon_dot_url,
|
||||
iconSize: [18, 18], // size of the icon
|
||||
});
|
||||
|
||||
// Set Map to Lat/Long
|
||||
markers.clearLayers();
|
||||
mymap.setZoom(8);
|
||||
if (typeof result.latlng !== "undefined" && result.latlng !== false) {
|
||||
var marker = L.marker([result.latlng[0], result.latlng[1]], {icon: redIcon});
|
||||
mymap.panTo([result.latlng[0], result.latlng[1]]);
|
||||
} else {
|
||||
var marker = L.marker([result.dxcc.lat, result.dxcc.long], {icon: redIcon});
|
||||
mymap.panTo([result.dxcc.lat, result.dxcc.long]);
|
||||
}
|
||||
|
||||
markers.addLayer(marker).addTo(mymap);
|
||||
|
||||
|
||||
/* Find Locator if the field is empty */
|
||||
if($('#locator').val() == "") {
|
||||
$('#locator').val(result.callsign_qra);
|
||||
$('#locator_info').html(result.bearing);
|
||||
|
||||
if (result.callsign_qra != "")
|
||||
{
|
||||
if (result.workedBefore)
|
||||
{
|
||||
$('#locator').addClass("workedGrid");
|
||||
$('#locator').attr('title', 'Grid was already worked in the past');
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#locator').addClass("newGrid");
|
||||
$('#locator').attr('title', 'New grid!');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#locator').removeClass("workedGrid");
|
||||
$('#locator').removeClass("newGrid");
|
||||
$('#locator').attr('title', '');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Find Operators Name */
|
||||
if($('#qsl_via').val() == "") {
|
||||
$('#qsl_via').val(result.qsl_manager);
|
||||
}
|
||||
|
||||
/* Find Operators Name */
|
||||
if($('#name').val() == "") {
|
||||
$('#name').val(result.callsign_name);
|
||||
}
|
||||
|
||||
if($('#qth').val() == "") {
|
||||
$('#qth').val(result.callsign_qth);
|
||||
}
|
||||
|
||||
/*
|
||||
* Update state with returned value
|
||||
*/
|
||||
if($("#input_usa_state").val() == "") {
|
||||
$("#input_usa_state").val(result.callsign_state).trigger('change');
|
||||
}
|
||||
|
||||
|
||||
if($('#iota_ref').val() == "") {
|
||||
$('#iota_ref').val(result.callsign_iota);
|
||||
}
|
||||
// Hide the last QSO table
|
||||
$('#qso-last-table').hide();
|
||||
$('#partial_view').show();
|
||||
/* display past QSOs */
|
||||
$('#partial_view').html(result.partial);
|
||||
});
|
||||
} else {
|
||||
/* Reset fields ... */
|
||||
$('#callsign_info').text("");
|
||||
$('#locator_info').text("");
|
||||
$('#country').val("");
|
||||
$('#dxcc_id').val("");
|
||||
$('#cqz').val("");
|
||||
$('#name').val("");
|
||||
$('#qth').val("");
|
||||
$('#locator').val("");
|
||||
$('#iota_ref').val("");
|
||||
$("#locator").removeClass("workedGrid");
|
||||
$("#locator").removeClass("newGrid");
|
||||
$("#callsign").removeClass("workedGrid");
|
||||
$("#callsign").removeClass("newGrid");
|
||||
$('#callsign_info').removeClass("badge-secondary");
|
||||
$('#callsign_info').removeClass("badge-success");
|
||||
$('#callsign_info').removeClass("badge-danger");
|
||||
$('#input_usa_state').val("");
|
||||
}
|
||||
})
|
||||
|
||||
// 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("");
|
||||
});
|
||||
});
|
||||
|
||||
/* On Key up Calculate Bearing and Distance */
|
||||
$("#locator").keyup(function(){
|
||||
if ($(this).val()) {
|
||||
var qra_input = $(this).val();
|
||||
|
||||
var qra_lookup = qra_input.substring(0, 4);
|
||||
|
||||
if(qra_lookup.length >= 4) {
|
||||
|
||||
// Check Log if satname is provided
|
||||
if($("#sat_name" ).val() != "") {
|
||||
|
||||
//logbook/jsonlookupgrid/io77/SAT/0/0
|
||||
|
||||
$.getJSON('logbook/jsonlookupgrid/' + qra_lookup.toUpperCase() + '/SAT/0/0', function(result)
|
||||
{
|
||||
// Reset CSS values before updating
|
||||
$('#locator').removeClass("workedGrid");
|
||||
$('#locator').removeClass("newGrid");
|
||||
$('#locator').attr('title', '');
|
||||
|
||||
if (result.workedBefore)
|
||||
{
|
||||
$('#locator').addClass("workedGrid");
|
||||
$('#locator').attr('title', 'Grid was already worked in the past');
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#locator').addClass("newGrid");
|
||||
$('#locator').attr('title', 'New grid!');
|
||||
}
|
||||
})
|
||||
} else {
|
||||
$.getJSON('logbook/jsonlookupgrid/' + qra_lookup.toUpperCase() + '/0/' + $("#band").val() +'/' + $("#mode").val(), function(result)
|
||||
{
|
||||
// Reset CSS values before updating
|
||||
$('#locator').removeClass("workedGrid");
|
||||
$('#locator').removeClass("newGrid");
|
||||
$('#locator').attr('title', '');
|
||||
|
||||
if (result.workedBefore)
|
||||
{
|
||||
$('#locator').addClass("workedGrid");
|
||||
$('#locator').attr('title', 'Grid was already worked in the past');
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#locator').addClass("newGrid");
|
||||
$('#locator').attr('title', 'New grid!');
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if(qra_input.length >= 4 && $(this).val().length > 0) {
|
||||
$.getJSON('logbook/qralatlngjson/' + $(this).val(), function(result)
|
||||
{
|
||||
// Set Map to Lat/Long
|
||||
markers.clearLayers();
|
||||
if (typeof result !== "undefined") {
|
||||
var redIcon = L.icon({
|
||||
iconUrl: icon_dot_url,
|
||||
iconSize: [18, 18], // size of the icon
|
||||
});
|
||||
|
||||
var marker = L.marker([result[0], result[1]], {icon: redIcon});
|
||||
mymap.setZoom(8);
|
||||
mymap.panTo([result[0], result[1]]);
|
||||
}
|
||||
markers.addLayer(marker).addTo(mymap);
|
||||
})
|
||||
|
||||
$('#locator_info').load("logbook/searchbearing/" + $(this).val()).fadeIn("slow");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Change report based on mode
|
||||
$('.mode').change(function(){
|
||||
setRst($('.mode') .val());
|
||||
});
|
||||
|
||||
function convert_case(str) {
|
||||
var lower = str.toLowerCase();
|
||||
return lower.replace(/(^| )(\w)/g, function(x) {
|
||||
return x.toUpperCase();
|
||||
});
|
||||
}
|
||||
|
||||
$('#dxcc_id').on('change', function() {
|
||||
$.getJSON('logbook/jsonentity/' + $(this).val(), function (result) {
|
||||
if (result.dxcc.name != undefined) {
|
||||
|
||||
$('#country').val(convert_case(result.dxcc.name));
|
||||
$('#cqz').val(convert_case(result.dxcc.cqz));
|
||||
|
||||
$('#callsign_info').removeClass("badge-secondary");
|
||||
$('#callsign_info').removeClass("badge-success");
|
||||
$('#callsign_info').removeClass("badge-danger");
|
||||
$('#callsign_info').attr('title', '');
|
||||
$('#callsign_info').text(convert_case(result.dxcc.name));
|
||||
|
||||
changebadge(result.dxcc.name);
|
||||
|
||||
// Set Map to Lat/Long it locator is not empty
|
||||
if($('#locator').val() == "") {
|
||||
var redIcon = L.icon({
|
||||
iconUrl: icon_dot_url,
|
||||
iconSize: [18, 18], // size of the icon
|
||||
});
|
||||
|
||||
markers.clearLayers();
|
||||
var marker = L.marker([result.dxcc.lat, result.dxcc.long], {icon: redIcon});
|
||||
mymap.setZoom(8);
|
||||
mymap.panTo([result.dxcc.lat, result.dxcc.long]);
|
||||
markers.addLayer(marker).addTo(mymap);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
//Spacebar moves to the name field when you're entering a callsign
|
||||
//Similar to contesting ux, good for pileups.
|
||||
$("#callsign").on("keypress", function(e) {
|
||||
if (e.which == 32){
|
||||
$("#name").focus();
|
||||
return false; //Eliminate space char
|
||||
}
|
||||
});
|
||||
|
||||
// On Key up check and suggest callsigns
|
||||
$("#callsign").keyup(function() {
|
||||
if ($(this).val().length >= 3) {
|
||||
$('.callsign-suggest').show();
|
||||
$.get('lookup/scp/' + $(this).val().toUpperCase(), function(result) {
|
||||
$('.callsign-suggestions').text(result);
|
||||
});
|
||||
}
|
||||
});
|
||||
正在加载…
在新工单中引用