[DOK autocomplete] Added DOK autocomplete in the QSO entry area

pull/831/head
Andreas 2021-01-20 12:56:53 +01:00
rodzic dc7545729f
commit 7f80984db0
3 zmienionych plików z 1149 dodań i 0 usunięć

Wyświetl plik

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

Wyświetl plik

@ -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
*/

1089
assets/json/dok.txt 100644

Plik diff jest za duży Load Diff