From f4d71b4d9fb4191c07a9c200d32626175568b4fa Mon Sep 17 00:00:00 2001 From: Birte Kristina Friesel Date: Sat, 26 Aug 2023 09:17:28 +0200 Subject: obtain autocompletion from database --- scripts/update-autocomplete | 43 ------------------------------------------- 1 file changed, 43 deletions(-) delete mode 100755 scripts/update-autocomplete (limited to 'scripts/update-autocomplete') diff --git a/scripts/update-autocomplete b/scripts/update-autocomplete deleted file mode 100755 index bfb6914..0000000 --- a/scripts/update-autocomplete +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env perl - -use strict; -use warnings; -use 5.020; - -use JSON; -use File::Slurp qw(write_file); -use List::Util qw(uniq); -use Travel::Status::DE::IRIS::Stations; - -my @station_names - = uniq map { $_->[1] } Travel::Status::DE::IRIS::Stations::get_stations(); -my $station_list = q{}; - -for my $station (@station_names) { - $station_list .= sprintf( "\t\t\t\"%s\": null,\n", $station ); -} - -my $autocomplete = <<"EOF"; -/* - * Copyright (C) 2020 DB Station&Service AG, Europaplatz 1, 10557 Berlin - * Copyright (C) 2020 Birte Kristina Friesel - * - * SPDX-License-Identifier: CC-BY-4.0 - */ -document.addEventListener('DOMContentLoaded', function() { - var elems = document.querySelectorAll('.autocomplete'); - M.Autocomplete.init(elems, { - minLength: 3, - limit: 50, - data: { -$station_list - } - }); -}); -EOF - -write_file( - "public/static/js/autocomplete.js", - { binmode => ':encoding(utf-8)' }, - $autocomplete -); -- cgit v1.2.3