diff --git a/application/controllers/Qso.php b/application/controllers/Qso.php index 21498327d..b8376d4ef 100755 --- a/application/controllers/Qso.php +++ b/application/controllers/Qso.php @@ -253,4 +253,68 @@ class QSO extends CI_Controller { echo $this->frequency->convent_band($band, $mode); } + + /* + * Function is used for autocompletion of SOTA in the QSO entry form + */ + public function get_sota() { + $json = []; + + if(!empty($this->input->get("query"))) { + $query = isset($_GET['query']) ? $_GET['query'] : FALSE; + $sota = strtoupper($query); + + $file = 'assets/json/sota.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); + } + + /* + * 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); + } } diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index 9d3056c32..71718b46c 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -34,6 +34,7 @@ + uri->segment(1) == "search" && $this->uri->segment(2) == "filter") { ?> @@ -318,9 +319,66 @@ $(document).on('keypress',function(e) { uri->segment(1) == "qso") { ?> -