kopia lustrzana https://github.com/magicbug/Cloudlog
[DOK autocomplete] Added DOK autocomplete in the QSO entry area
rodzic
dc7545729f
commit
7f80984db0
|
@ -276,4 +276,36 @@ class QSO extends CI_Controller {
|
|||
header('Content-Type: application/json');
|
||||
echo json_encode($json);
|
||||
}
|
||||
|
||||
/*
|
||||
* Function is used for autocompletion of DOK in the QSO entry form
|
||||
*/
|
||||
public function get_dok() {
|
||||
$json = [];
|
||||
|
||||
if(!empty($this->input->get("query"))) {
|
||||
$query = isset($_GET['query']) ? $_GET['query'] : FALSE;
|
||||
$sota = strtoupper($query);
|
||||
|
||||
$file = 'assets/json/dok.txt';
|
||||
|
||||
if (is_readable($file)) {
|
||||
$lines = file($file, FILE_IGNORE_NEW_LINES);
|
||||
$input = preg_quote($sota, '~');
|
||||
$reg = '~^'. $input .'(.*)$~';
|
||||
$result = preg_grep($reg, $lines);
|
||||
$json = [];
|
||||
$i = 0;
|
||||
foreach ($result as &$value) {
|
||||
// Limit to 100 as to not slowdown browser too much
|
||||
if (count($json) <= 100) {
|
||||
$json[] = ["name"=>$value];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode($json);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -351,6 +351,34 @@ $( document ).ready(function() {
|
|||
}
|
||||
});
|
||||
|
||||
$('#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 3 or more characters are 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
|
||||
*/
|
||||
|
|
Plik diff jest za duży
Load Diff
Ładowanie…
Reference in New Issue