From 43a78f499ca910c5d820e63cbd304b02bf0d51ff Mon Sep 17 00:00:00 2001 From: Andreas Date: Sun, 24 Jan 2021 15:29:29 +0100 Subject: [PATCH] [Station profile] US Counties dropdown added --- application/controllers/Station.php | 33 +++++++++++++ application/views/interface_assets/footer.php | 49 +++++++++++++++++++ application/views/station_profile/create.php | 8 +-- application/views/station_profile/edit.php | 8 +-- 4 files changed, 92 insertions(+), 6 deletions(-) diff --git a/application/controllers/Station.php b/application/controllers/Station.php index 85804481..8183aa8e 100644 --- a/application/controllers/Station.php +++ b/application/controllers/Station.php @@ -135,4 +135,37 @@ class Station extends CI_Controller { redirect('station'); } + /* + * 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"); + + $file = 'assets/json/US_counties.csv'; + + if (is_readable($file)) { + $lines = file($file, FILE_IGNORE_NEW_LINES); + $input = preg_quote($county, '~'); + $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); + } + } \ No newline at end of file diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index 91c4f6ca..bbbe3473 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -2785,6 +2785,55 @@ function deleteQsl(id) { } + + +uri->segment(1) == "station") { ?> + + diff --git a/application/views/station_profile/create.php b/application/views/station_profile/create.php index d790ebb2..d82cedd7 100644 --- a/application/views/station_profile/create.php +++ b/application/views/station_profile/create.php @@ -59,7 +59,8 @@ Station city. For example: Inverness -
+
+
+ Station County (Only used for USA/Alaska/Hawaii)
+
diff --git a/application/views/station_profile/edit.php b/application/views/station_profile/edit.php index 18a4b99d..d90dcc76 100644 --- a/application/views/station_profile/edit.php +++ b/application/views/station_profile/edit.php @@ -60,7 +60,8 @@ Station city. For example: Inverness
-
+
+
station_cnty; } ?>"> + station_cnty; } ?>"> Station County (Only used for USA/Alaska/Hawaii)
+