[QSO Entry] Added county with autocomplete to the form.
这个提交包含在:
父节点
59616f1f5c
当前提交
7892846e8a
共有 4 个文件被更改,包括 84 次插入 和 0 次删除
|
|
@ -317,4 +317,39 @@ class QSO extends CI_Controller {
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
echo json_encode($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_cq_zone'] = 'CQ Zone';
|
||||||
$lang['gen_hamradio_dxcc'] = 'DXCC';
|
$lang['gen_hamradio_dxcc'] = 'DXCC';
|
||||||
$lang['gen_hamradio_usa_state'] = 'USA State';
|
$lang['gen_hamradio_usa_state'] = 'USA State';
|
||||||
|
$lang['gen_hamradio_county_reference'] = 'USA County';
|
||||||
$lang['gen_hamradio_iota_reference'] = 'IOTA Reference';
|
$lang['gen_hamradio_iota_reference'] = 'IOTA Reference';
|
||||||
$lang['gen_hamradio_sota_reference'] = 'SOTA Reference';
|
$lang['gen_hamradio_sota_reference'] = 'SOTA Reference';
|
||||||
$lang['gen_hamradio_dok'] = 'DOK';
|
$lang['gen_hamradio_dok'] = 'DOK';
|
||||||
|
|
|
||||||
|
|
@ -323,6 +323,49 @@ $(document).on('keypress',function(e) {
|
||||||
$( document ).ready(function() {
|
$( document ).ready(function() {
|
||||||
var baseURL= "<?php echo base_url();?>";
|
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({
|
$('#sota_ref').selectize({
|
||||||
maxItems: 1,
|
maxItems: 1,
|
||||||
closeAfterSelect: true,
|
closeAfterSelect: true,
|
||||||
|
|
|
||||||
|
|
@ -347,6 +347,11 @@
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</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">
|
<div class="form-group">
|
||||||
<label for="iota_ref"><?php echo $this->lang->line('gen_hamradio_iota_reference'); ?></label>
|
<label for="iota_ref"><?php echo $this->lang->line('gen_hamradio_iota_reference'); ?></label>
|
||||||
<select class="custom-select" id="iota_ref" name="iota_ref">
|
<select class="custom-select" id="iota_ref" name="iota_ref">
|
||||||
|
|
|
||||||
正在加载…
在新工单中引用