summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2020-12-13 21:17:56 +0100
committerDaniel Friesel <derf@finalrewind.org>2020-12-13 21:17:56 +0100
commitedc03d0f97cb75de09bbb9366a9d82346f32d5e1 (patch)
treebfcf827fee86dd38b536c5bef7c39a2f8c0082cb /scripts
parentb48dd6f41bc4715af7dcd02ac4268fd43214b4c3 (diff)
update autocomplete list of station names (and add update script)
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/update-autocomplete26
1 files changed, 26 insertions, 0 deletions
diff --git a/scripts/update-autocomplete b/scripts/update-autocomplete
new file mode 100755
index 0000000..9797cd7
--- /dev/null
+++ b/scripts/update-autocomplete
@@ -0,0 +1,26 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+use 5.020;
+
+use JSON;
+use File::Slurp qw(write_file);
+use Travel::Status::DE::IRIS::Stations;
+
+my @station_names = map { $_->[1] } Travel::Status::DE::IRIS::Stations::get_stations();
+
+my $station_json = JSON->new->utf8->encode([@station_names]);
+
+my $autocomplete = <<"EOF";
+\$(function() {
+ var stations = $station_json;
+ \$('input.station').autocomplete({
+ delay: 0,
+ minLength: 3,
+ source: stations
+ });
+});
+EOF
+
+write_file("public/static/js/autocomplete.js", $autocomplete);