[QSO Dialog] County has been added.

Adds USA County
这个提交包含在:
Peter Goodhall 2021-01-31 16:49:54 +00:00 提交者 GitHub
当前提交 89d579489a
找不到此签名对应的密钥
GPG 密钥 ID: 4AEE18F83AFDEB23
共有 7 个文件被更改,包括 152 次插入1 次删除

查看文件

@ -317,4 +317,39 @@ class QSO extends CI_Controller {
header('Content-Type: application/json');
echo json_encode($json);
}
/*
* Function is used for autocompletion of Counties in the station profile form
*/
public function get_county() {
$json = [];
if(!empty($this->input->get("query"))) {
//$query = isset($_GET['query']) ? $_GET['query'] : FALSE;
$county = $this->input->get("state");
$cleanedcounty = explode('(', $county);
$cleanedcounty = trim($cleanedcounty[0]);
$file = 'assets/json/US_counties.csv';
if (is_readable($file)) {
$lines = file($file, FILE_IGNORE_NEW_LINES);
$input = preg_quote($cleanedcounty, '~');
$reg = '~^'. $input .'(.*)$~';
$result = preg_grep($reg, $lines);
$json = [];
$i = 0;
foreach ($result as &$value) {
$county = explode(',', $value);
// Limit to 100 as to not slowdown browser too much
if (count($json) <= 100) {
$json[] = ["name"=>$county[1]];
}
}
}
}
header('Content-Type: application/json');
echo json_encode($json);
}
}

查看文件

@ -83,6 +83,7 @@ $lang['gen_hamradio_logbook'] = 'Logbook';
$lang['gen_hamradio_cq_zone'] = 'CQ Zone';
$lang['gen_hamradio_dxcc'] = 'DXCC';
$lang['gen_hamradio_usa_state'] = 'USA State';
$lang['gen_hamradio_county_reference'] = 'USA County';
$lang['gen_hamradio_iota_reference'] = 'IOTA Reference';
$lang['gen_hamradio_sota_reference'] = 'SOTA Reference';
$lang['gen_hamradio_dok'] = 'DOK';

查看文件

@ -150,6 +150,7 @@ class Logbook_model extends CI_Model {
'COL_DXCC' => $dxcc_id,
'COL_CQZ' => $cqz,
'COL_STATE' => trim($this->input->post('usa_state')),
'COL_USACA_COUNTIES' => trim($this->input->post('county')),
'COL_SOTA_REF' => trim($this->input->post('sota_ref')),
'COL_SIG' => trim($this->input->post('sig')),
'COL_SIG_INFO' => trim($this->input->post('sig_info')),
@ -529,7 +530,8 @@ class Logbook_model extends CI_Model {
'COL_QSL_VIA' => $this->input->post('qsl_via_callsign'),
'station_id' => $this->input->post('station_profile'),
'COL_OPERATOR' => $this->input->post('operator_callsign'),
'COL_STATE' =>$this->input->post('usa_state')
'COL_STATE' =>$this->input->post('usa_state'),
'COL_USACA_COUNTIES' =>$this->input->post('usa_county'),
);
if ($this->exists_qrz_api_key($data['station_id'])) {

查看文件

@ -323,6 +323,49 @@ $(document).on('keypress',function(e) {
$( 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,
@ -1991,6 +2034,26 @@ $(document).ready(function(){
nl2br: false,
message: html,
onshown: function(dialog) {
var state = $("#input_usa_state option:selected").text();
if (state != "") {
$("#stationCntyInput").prop('disabled', false);
selectize_usa_county();
}
$('#input_usa_state').change(function(){
var state = $("#input_usa_state option:selected").text();
if (state != "") {
$("#stationCntyInput").prop('disabled', false);
selectize_usa_county();
} else {
$("#stationCntyInput").prop('disabled', true);
$('#stationCntyInput')[0].selectize.destroy();
$("#stationCntyInput").val("");
}
});
$('#sota_ref').selectize({
maxItems: 1,
closeAfterSelect: true,
@ -2052,6 +2115,40 @@ $(document).ready(function(){
});
}
function selectize_usa_county() {
var baseURL= "<?php echo base_url();?>";
$('#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);
}
});
}
});
}
function qso_save() {
var baseURL= "<?php echo base_url();?>";
var myform = document.getElementById("qsoform");

查看文件

@ -371,6 +371,11 @@
</select>
</div>
<div class="form-group">
<label for="stationCntyInput">USA County</label>
<input disabled="disabled" class="form-control" id="stationCntyInput" type="text" name="usa_county" value="<?php echo $qso->COL_USACA_COUNTIES; ?>" />
</div>
<div class="form-group">
<label for="iota_ref">IOTA</label>
<select class="custom-select" id="iota_ref" name="iota_ref">

查看文件

@ -347,6 +347,11 @@
</select>
</div>
<div class="form-group">
<label for="stationCntyInput"><?php echo $this->lang->line('gen_hamradio_county_reference'); ?></label>
<input disabled="disabled" class="form-control" id="stationCntyInput" type="text" name="county" value="" />
</div>
<div class="form-group">
<label for="iota_ref"><?php echo $this->lang->line('gen_hamradio_iota_reference'); ?></label>
<select class="custom-select" id="iota_ref" name="iota_ref">

查看文件

@ -144,6 +144,12 @@
</tr>
<?php } ?>
<?php if($row->COL_USACA_COUNTIES != null) { ?>
<tr>
<td>USA County:</td>
<td><?php echo $row->COL_USACA_COUNTIES; ?></td>
</tr>
<?php } ?>
<?php if($row->COL_NAME != null) { ?>
<tr>