[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.
这个提交包含在:
Andreas 2021-02-26 10:37:43 +01:00
父节点 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;
/*
|--------------------------------------------------------------------------

查看文件

@ -13,21 +13,21 @@ class QSO extends CI_Controller {
{
parent::__construct();
$this->lang->load('qso');
$this->load->model('user_model');
if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); }
}
public function index()
{
$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();
@ -36,7 +36,7 @@ class QSO extends CI_Controller {
$data['dxcc'] = $this->logbook_model->fetchDxcc();
$data['iota'] = $this->logbook_model->fetchIota();
$data['modes'] = $this->modes->active();
$this->load->library('form_validation');
@ -58,7 +58,7 @@ class QSO extends CI_Controller {
// $this->logbook_model->add();
//change to create_qso function as add and create_qso duplicate functionality
$this->logbook_model->create_qso();
// Store Basic QSO Info for reuse
// Put data in an array first, then call set_userdata once.
// This solves the problem of CI dumping out the session
@ -83,7 +83,7 @@ class QSO extends CI_Controller {
'transmit_power' => $this->input->post('transmit_power')
);
// ];
setcookie("radio", $qso_data['radio'], time()+3600*24*99);
setcookie("station_profile_id", $qso_data['station_profile_id'], time()+3600*24*99);
@ -93,13 +93,13 @@ class QSO extends CI_Controller {
if($this->input->post('sat_name')) {
$this->session->set_userdata('prop_mode', 'SAT');
}
// Get last 5 qsos
$data['query'] = $this->logbook_model->last_custom('5');
// Set Any Notice Messages
$data['notice'] = "QSO Added";
// Load view to create another contact
$data['page_title'] = "Add QSO";
@ -116,15 +116,15 @@ class QSO extends CI_Controller {
$this->load->model('logbook_model');
$this->logbook_model->create_qso();
}
function edit() {
$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'); }
$query = $this->logbook_model->qso_info($this->uri->segment(3));
$this->load->library('form_validation');
$this->form_validation->set_rules('time_on', 'Start Date', 'required');
@ -135,7 +135,7 @@ class QSO extends CI_Controller {
$data['dxcc'] = $this->logbook_model->fetchDxcc();
$data['iota'] = $this->logbook_model->fetchIota();
$data['modes'] = $this->modes->all();
if ($this->form_validation->run() == FALSE)
{
$this->load->view('qso/edit', $data);
@ -180,7 +180,7 @@ class QSO extends CI_Controller {
$this->logbook_model->edit();
}
function qsl_rcvd($id, $method) {
$this->load->model('logbook_model');
$this->load->model('user_model');
@ -215,13 +215,13 @@ class QSO extends CI_Controller {
echo json_encode(array('message' => 'OK'));
}
}
/* Delete QSO */
function delete($id) {
$this->load->model('logbook_model');
$this->logbook_model->delete($id);
$this->session->set_flashdata('notice', 'QSO Deleted Successfully');
$data['message_title'] = "Deleted";
$data['message_contents'] = "QSO Deleted Successfully";
@ -245,12 +245,12 @@ class QSO extends CI_Controller {
echo json_encode(array('message' => 'OK'));
return;
}
function band_to_freq($band, $mode) {
$this->load->library('frequency');
echo $this->frequency->convent_band($band, $mode);
}
@ -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;
}
}

查看文件

@ -20,7 +20,7 @@ class User extends CI_Controller {
function add() {
$this->load->model('user_model');
if(!$this->user_model->authorize(99)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); }
$this->load->library('form_validation');
$this->form_validation->set_rules('user_name', 'Username', 'required');
@ -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');
}
@ -102,7 +104,7 @@ class User extends CI_Controller {
$this->load->model('user_model');
if((!$this->user_model->authorize(99)) && ($this->session->userdata('user_id') != $this->uri->segment(3))) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); }
$query = $this->user_model->get_by_id($this->uri->segment(3));
$this->load->library('form_validation');
$this->form_validation->set_rules('user_name', 'Username', 'required|xss_clean');
@ -206,7 +208,7 @@ class User extends CI_Controller {
} else {
$data['user_clublog_name'] = $q->user_clublog_name;
}
if($this->input->post('user_clublog_password')) {
$data['user_clublog_password'] = $this->input->post('user_clublog_password', true);
} else {
@ -218,13 +220,13 @@ class User extends CI_Controller {
} else {
$data['user_lotw_password'] = $q->user_lotw_password;
}
if($this->input->post('user_eqsl_name')) {
$data['user_eqsl_name'] = $this->input->post('user_eqsl_name', true);
} else {
$data['user_eqsl_name'] = $q->user_eqsl_name;
}
if($this->input->post('user_eqsl_password')) {
$data['user_eqsl_password'] = $this->input->post('user_eqsl_password', true);
} else {
@ -248,7 +250,13 @@ class User extends CI_Controller {
} else {
$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');
}
@ -347,8 +356,8 @@ class User extends CI_Controller {
function login() {
// Check our version and run any migrations
$this->load->library('Migration');
$this->migration->current();
$this->migration->current();
$this->load->model('user_model');
$query = $this->user_model->get($this->input->post('user_name', true));

查看文件

@ -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');
}
}

查看文件

@ -5,7 +5,7 @@
* This model implements user authentication and authorization
*
*/
// Uses 'phpass' from http://www.openwall.com/phpass/ to implement password hashing
// TODO migration away from this?
@ -28,7 +28,7 @@ class User_Model extends CI_Model {
$this->db->where('user_name', $clean_username);
$r = $this->db->get($this->config->item('auth_table'));
return $r;
}
}
// FUNCTION: object get_by_id($id)
// Retrieve a user by user ID
@ -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,13 +154,14 @@ 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
if($this->session->userdata('user_type') == 99) {
$data['user_type'] = $fields['user_type'];
}
// Check to see if username is used already
if($this->exists($fields['user_name']) && $this->get($fields['user_name'])->row()->user_id != $fields['id']) {
return EUSERNAMEEXISTS;
@ -168,7 +170,7 @@ class User_Model extends CI_Model {
if($this->exists_by_email($fields['user_email']) && $this->get_by_email($fields['user_email'])->row()->user_id != $fields['id']) {
return EEMAILEXISTS;
}
// Hash password
if($fields['user_password'] != NULL)
{
@ -187,12 +189,12 @@ class User_Model extends CI_Model {
{
$data['user_clublog_password'] = $fields['user_clublog_password'];
}
if($fields['user_eqsl_password'] != NULL)
{
$data['user_eqsl_password'] = $fields['user_eqsl_password'];
}
// Update the user
$this->db->where('user_id', $fields['id']);
$this->db->update($this->config->item('auth_table'), $data);
@ -202,7 +204,7 @@ class User_Model extends CI_Model {
}
} else {
return EFORBIDDEN;
}
}
}
// FUNCTION: bool delete()
@ -234,15 +236,15 @@ class User_Model extends CI_Model {
// Nothing is returned - it can be assumed that if this is called, the user's
// login session *will* be cleared, no matter what state it is in
function clear_session() {
$this->session->sess_destroy();
}
// FUNCTION: void update_session()
// Updates a user's login session after they've logged in
// TODO: This should return bool TRUE/FALSE or 0/1
function update_session($id) {
$u = $this->get_by_id($id);
$userdata = array(
@ -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);
@ -362,7 +365,7 @@ class User_Model extends CI_Model {
// Will return '0' in the event of problems with the
// hashing function
private function _hash($password) {
$hash = password_hash($password, PASSWORD_DEFAULT);
$hash = password_hash($password, PASSWORD_DEFAULT);
if(strlen($hash) < 20) {
return EPASSWORDINVALID;
@ -370,7 +373,7 @@ class User_Model extends CI_Model {
return $hash;
}
}
}
?>

查看文件

@ -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');
@ -645,104 +422,30 @@ $(document).on('change', 'input', function(){
$('#callsign').val("");
$("#callsign").focus();
}
});
});
});
//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
}
});
<?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 } ?>
// 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);
});
}
});
$('#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 } ?>

查看文件

@ -28,7 +28,7 @@
<div class="form-group">
<label>User Role</label>
<select class="custom-select" name="user_type">
<?php
<?php
$levels = $this->config->item('auth_level');
while (list($key, $val) = each($levels)) {
?>
@ -66,7 +66,7 @@
<input class="form-control" type="text" name="user_callsign" value="<?php if(isset($user_callsign)) { echo $user_callsign; } ?>" />
<?php if(isset($callsign_error)) { echo "<div class=\"small error\">".$callsign_error."</div>"; } ?>
</div>
<div class="form-group">
<label>Locator</label>
<input class="form-control" type="text" name="user_locator" value="<?php if(isset($user_locator)) { echo $user_locator; } ?>" />
@ -75,9 +75,9 @@
<div class="form-group">
<label>Timezone</label>
<?php
<?php
if(!isset($user_timezone)) { $user_timezone = 0; }
echo form_dropdown('user_timezone', $timezones, $user_timezone);
echo form_dropdown('user_timezone', $timezones, $user_timezone);
?>
</div>
@ -92,7 +92,7 @@
<option value="d.m.Y"><?php echo date('d.m.Y'); ?></option>
<option value="Y-m-d"><?php echo date('Y-m-d'); ?></option>
</select>
<small id="SelectDateFormatHelp" class="form-text text-muted">Select how you would like dates shown when logged into your account.</small>
</div>
@ -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>

查看文件

@ -26,7 +26,7 @@
<?php } ?>
<?php $this->load->helper('form'); ?>
<form method="post" action="<?php echo site_url('user/edit')."/".$this->uri->segment(3); ?>" name="users" autocomplete="off">
<div class="row">
<div class="col-md">
@ -66,7 +66,7 @@
<div class="card-body">
<div class="form-group">
<label>Level</label>
<?php if($this->session->userdata('user_type') == 99) { ?>
<select class="custom-select" name="user_type">
<?php
@ -76,7 +76,7 @@
<option value="<?php echo $key; ?>" <?php if($user_type == $key) { echo "selected=\"selected\""; } ?>><?php echo $val; ?></option>
<?php } ?>
</select>
<?php } else {
<?php } else {
$l = $this->config->item('auth_level');
echo $l[$user_type];
}?>
@ -234,9 +234,9 @@
<?php if(isset($eqslpassword_error)) { echo "<div class=\"small error\">".$eqslpassword_error."</div>"; } else { ?>
<div class="small form-text text-muted">Leave blank to keep existing password</div></td>
<?php } ?>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
@ -267,7 +267,31 @@
</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); ?>" />
<br>

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);
});
}
});