PageSourceSearch

https://bodo-hausen.de/wp-content/plugins/smg-theme-extension/public/js/searchform.js?ver=7.1

js bodo-hausen.de collected 2026-10-07 05:30:11 UTC 75,364 bytes, 1,582 lines download raw bytes

1(function ($) {
2        /* GLOBALS */
3        var active = 1;
4        var ibePackage = 0;
5        var ibeHotel = 0;
6        var ibeFlight = 0;
7        var airportMapping = [
8            {
9                code: '',
10                name: 'Deutschland',
11                children: [
12                    {code: 'BER', name: 'Berlin Brandenburg'},
13                    {code: 'SXF', name: 'Berlin Schönefeld'},
14                    {code: 'TXL', name: 'Berlin Tegel'},
15                    {code: 'BRE', name: 'Bremen'},
16                    {code: 'DTM', name: 'Dortmund'},
17                    {code: 'DRS', name: 'Dresden'},
18                    {code: 'DUS', name: 'Düsseldorf'},
19                    {code: 'ERF', name: 'Erfurt Weimar'},
20                    {code: 'FRA', name: 'Frankfurt am Main'},
21                    {code: 'HHN', name: 'Frankfurt Hahn'},
22                    {code: 'FDH', name: 'Friedrichshafen'},
23                    {code: 'HAM', name: 'Hamburg'},
24                    {code: 'HAJ', name: 'Hannover-Langenhagen'},
25                    {code: 'HDF', name: 'Heringsdorf'},
26                    {code: 'FKB', name: 'Karlsruhe/Baden-Baden'},
27                    {code: 'KSF', name: 'Kassel-Calden'},
28                    {code: 'CGN', name: 'Köln/Bonn'},
29                    {code: 'LEJ', name: 'Leipzig/Halle'},
30                    {code: 'LBC', name: 'Lübeck-Blankensee'},
31                    {code: 'FMM', name: 'Memmingen'},
32                    {code: 'MUC', name: 'München'},
33                    {code: 'FMO', name: 'Münster/Osnabrück'},
34                    {code: 'NUE', name: 'Nürnberg'},
35                    {code: 'PAD', name: 'Paderborn/Lippstadt'},
36                    {code: 'RLG', name: 'Rostock-Laage'},
37                    {code: 'SCN', name: 'Saarbrücken'},
38                    {code: 'STR', name: 'Stuttgart'},
39                    {code: 'GWT', name: 'Sylt'},
40                    {code: 'NRN', name: 'Weeze/Niederreihn'},
41                    {code: 'ZQW', name: 'Zweibrücken'},
42                ]
43            },
44            {
45                code: '',
46                name: 'Schweiz',
47                children: [
48                    {code: 'BSL', name: 'Basel'},
49                    {code: 'MLH', name: 'Basel/Mulhouse'},
50                    {code: 'BRN', name: 'Bern/Belp'},
51                    {code: 'GVA', name: 'Genf'},
52                    {code: 'LUG', name: 'Lugano-Agno'},
53                    {code: 'ACH', name: 'St. Gallen/Altenrhein'},
54                    {code: 'ZRH', name: 'Zürich'},
55                ]
56            },
57            {
58                code: '',
59                name: 'Österreich',
60                children: [
61                    {code: 'GRZ', name: 'Graz-Thalerhof'},
62                    {code: 'INN', name: 'Innsbruck'},
63                    {code: 'KLU', name: 'Klagenfurt'},
64                    {code: 'LNZ', name: 'Linz'},
65                    {code: 'SZG', name: 'Salzburg'},
66                    {code: 'VIE', name: 'Wien'},
67                ]
68            },
69            {
70                code: '',
71                name: 'Niederlande',
72                children: [
73                    {code: 'AMS', name: 'Amsterdam'},
74                    {code: 'WIN', name: 'Eindhofen'},
75                    {code: 'GRQ', name: 'Groningen Elde'},
76                    {code: 'MST', name: 'Maastrich'},
77                ]
78            },
79            {
80                code: '',
81                name: 'Sonstige Flughäfen',
82                children: [
83                    {code: 'CRL', name: 'Chaleroi (BE)'},
84                    {code: 'BLL', name: 'Billund (DK)'},
85                    {code: 'BTS', name: 'Bratislava (SK)'},
86                    {code: 'BRU', name: 'Brüssel (BE)'},
87                    {code: 'LJU', name: 'Ljubljana (SI)'},
88                    {code: 'LGG', name: 'Lüttich/Liege (BE)'},
89                    {code: 'LUX', name: 'Luxembourg (LU)'},
90                    {code: 'MXP', name: 'Mailand-Malpensa (IT)'},
91                    {code: 'LIN', name: 'Mailand-Linate (IT)'},
92                    {code: 'PRG', name: 'Prag (CZ)'},
93                    {code: 'SXB', name: 'Strasbourgh (FR)'},
94                ]
95            },
96        ];
97
98        var durationMapping = {
99            "beliebig": "0",
100            "exakt wie angegeben": "exact",
101            "1 Woche": "7",
102            "2 Wochen": "14",
103            "3 Wochen": "21",
104            "4 Wochen": "28",
105            "5 - 8 Tage": "5|6|7|8",
106            "9 - 12 Tage": "9|10|11|12",
107            "13 - 16 Tage": "13|14|15|16",
108            "17 - 22 Tage": "17|18|19|20|21|22",
109            "1 Tag": "1",
110            "2 Tage": "2",
111            "3 Tage": "3",
112            "4 Tage": "4",
113            "5 Tage": "5",
114            "6 Tage": "6",
115            "7 Tage": "7",
116            "8 Tage": "8",
117            "9 Tage": "9",
118            "10 Tage": "10",
119            "11 Tage": "11",
120            "12 Tage": "12",
121            "13 Tage": "13",
122            "14 Tage": "14",
123            "15 Tage": "15",
124            "16 Tage": "16",
125            "17 Tage": "17",
126            "18 Tage": "18",
127            "19 Tage": "19",
128            "20 Tage": "20",
129            "21 Tage": "21",
130            "22 Tage": "22",
131            "> 22 Tage": "23",
132        };
133
134        var lastChildrenCount = null;
135
136        var iconHotel =
137            '<svg id="Ebene_1" data-name="Ebene 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 181.05 185.58">\n' +
138            '  <path d="m177.05,80.19c-2.21,0-4,1.79-4,4v4.59h-50.79c-2.21-.08-31.83-.79-48.58,16.35-7.25,7.42-10.96,17-11.07,28.5H8V53.44L91.07,8.55l84.06,46.01c1.94,1.06,4.37.35,5.43-1.59,1.06-1.94.35-4.37-1.59-5.43L93,.49c-1.19-.65-2.63-.65-3.82-.01L2.1,47.53c-1.29.7-2.1,2.05-2.1,3.52v130.52c0,2.21,1.79,4,4,4s4-1.79,4-4v-39.93h165.05v39.93c0,2.21,1.79,4,4,4s4-1.79,4-4v-97.38c0-2.21-1.79-4-4-4Zm-106.44,53.45c.12-9.34,3.05-17.03,8.77-22.89,14.52-14.88,42.37-13.98,42.64-13.97.05,0,.11,0,.16,0h50.87v36.85h-102.44Z" fill="currentColor" stroke-width="0"/>\n' +
139            '  <path d="m18.42,98.55c0,12.18,9.91,22.09,22.09,22.09s22.09-9.91,22.09-22.09-9.91-22.09-22.09-22.09-22.09,9.91-22.09,22.09Zm36.18,0c0,7.77-6.32,14.09-14.09,14.09s-14.09-6.32-14.09-14.09,6.32-14.09,14.09-14.09,14.09,6.32,14.09,14.09Z" fill="currentColor" stroke-width="0"/>\n' +
140            '</svg>';
141
142        var iconRegion =
143            '<svg id="Ebene_1" data-name="Ebene 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 146.99 193.34">\n' +
144            '  <path d="m118.89,51.71c0-12.69-10.33-23.02-23.02-23.02s-23.02,10.33-23.02,23.02,10.33,23.02,23.02,23.02,23.02-10.33,23.02-23.02Zm-23.02,15.02c-8.28,0-15.02-6.74-15.02-15.02s6.74-15.02,15.02-15.02,15.02,6.74,15.02,15.02-6.74,15.02-15.02,15.02Z" fill="currentColor" stroke-width="0"/>\n' +
145            '  <path d="m138.22,98.46l-.04-.12s-.04-.1-.04-.1c-.74-2.08-3.02-3.11-5.09-2.37-2.08.74-3.15,3.07-2.41,5.15l.06.17c.59,1.63,2.12,2.64,3.76,2.64.45,0,.91-.08,1.36-.24,2.08-.75,3.15-3.05,2.4-5.12Z" fill="currentColor" stroke-width="0"/>\n' +
146            '  <path d="m20.99,160.61c-1.35-1.75-3.86-2.08-5.61-.73-1.75,1.35-2.08,3.86-.73,5.61l.32.41c.79,1.02,1.97,1.55,3.16,1.55.86,0,1.72-.27,2.45-.84,1.75-1.35,2.06-3.87.71-5.61l-.3-.38Z" fill="currentColor" stroke-width="0"/>\n' +
147            '  <path d="m14.08,149.33l-.21-.43c-.94-2-3.32-2.87-5.32-1.93-2,.94-2.86,3.32-1.93,5.32l.22.47c.68,1.44,2.12,2.29,3.62,2.29.57,0,1.16-.12,1.71-.39,2-.95,2.85-3.33,1.9-5.33Z" fill="currentColor" stroke-width="0"/>\n' +
148            '  <path d="m27.48,75.24c.92,0,1.85-.32,2.6-.96l.35-.3c1.69-1.42,1.91-3.94.49-5.64-1.42-1.69-3.94-1.91-5.64-.49l-.42.35c-1.68,1.44-1.87,3.96-.43,5.64.79.92,1.91,1.4,3.04,1.4Z" fill="currentColor" stroke-width="0"/>\n' +
149            '  <path d="m42.27,178.42l-.42-.22c-1.96-1.03-4.38-.27-5.4,1.68-1.03,1.96-.27,4.37,1.68,5.4l.48.25c.59.3,1.21.44,1.83.44,1.45,0,2.85-.79,3.56-2.17,1.01-1.96.24-4.38-1.73-5.39Z" fill="currentColor" stroke-width="0"/>\n' +
150            '  <path d="m30.47,170.55c-1.69-1.43-4.21-1.22-5.64.47-1.43,1.69-1.22,4.21.47,5.64l.42.35c.75.62,1.65.92,2.55.92,1.15,0,2.29-.49,3.08
150-1.45,1.41-1.7,1.18-4.22-.52-5.63l-.36-.3Z" fill="currentColor" stroke-width="0"/>\n' +
151            '  <path d="m9.58,136.37l-.1-.46c-.47-2.16-2.61-3.52-4.77-3.05-2.16.47-3.52,2.61-3.05,4.77l.12.53c.42,1.85,2.07,3.11,3.9,3.11.3,0,.6-.03.9-.1,2.15-.49,3.5-2.64,3.01-4.79Z" fill="currentColor" stroke-width="0"/>\n' +
152            '  <path d="m8.37,98.05c.54.25,1.1.36,1.66.36,1.52,0,2.97-.87,3.64-2.34l.2-.43c.93-2,.06-4.38-1.94-5.31-2.01-.93-4.38-.06-5.31,1.94l-.22.49c-.92,2.01-.03,4.38,1.98,5.3Z" fill="currentColor" stroke-width="0"/>\n' +
153            '  <path d="m15.08,85.07c.72.54,1.56.8,2.4.8,1.21,0,2.41-.55,3.2-1.59l.28-.37c1.34-1.75,1.01-4.26-.74-5.61s-4.26-1.01-5.61.74l-.33.43c-1.33,1.77-.97,4.27.79,5.6Z" fill="currentColor" stroke-width="0"/>\n' +
154            '  <path d="m4.62,112.18c.28.06.56.09.84.09,1.85,0,3.51-1.29,3.91-3.17l.1-.47c.48-2.16-.89-4.29-3.05-4.77-2.16-.48-4.29.89-4.77,3.05l-.11.52c-.46,2.16.92,4.29,3.08,4.75Z" fill="currentColor" stroke-width="0"/>\n' +
155            '  <path d="m4.04,126.78c2.21-.02,3.98-1.83,3.97-4.04v-.47c0-2.21-1.79-4-4-4s-4,1.79-4,4v.54c.02,2.2,1.81,3.96,4,3.96h.04Z" fill="currentColor" stroke-width="0"/>\n' +
156            '  <path d="m117.76,164.84l-.33.36c-1.5,1.62-1.38,4.14.25,5.64.77.71,1.73,1.05,2.7,1.05,1.09,0,2.17-.44,2.96-1.3l.33-.36c1.49-1.63,1.38-4.16-.26-5.65-1.63-1.49-4.16-1.38-5.65.26Z" fill="currentColor" stroke-width="0"/>\n' +
157            '  <path d="m68.64,185.34l-.48-.02c-2.2-.11-4.08,1.6-4.18,3.81-.1,2.21,1.6,4.08,3.81,4.18l.53.02c.06,0,.11,0,.17,0,2.13,0,3.91-1.69,3.99-3.84.09-2.21-1.63-4.07-3.83-4.16Z" fill="currentColor" stroke-width="0"/>\n' +
158            '  <path d="m82.33,184.41l-.47.08c-2.18.37-3.64,2.43-3.27,4.61.33,1.95,2.02,3.33,3.94,3.33.22,0,.45-.02.67-.06l.53-.09c2.17-.39,3.62-2.46,3.24-4.64s-2.46-3.62-4.64-3.24Z" fill="currentColor" stroke-width="0"/>\n' +
159            '  <path d="m55.07,183.33l-.47-.12c-2.13-.58-4.33.68-4.9,2.82-.58,2.13.69,4.33,2.82,4.91l.51.14c.34.09.69.13,1.02.13,1.77,0,3.39-1.19,3.86-2.98.56-2.14-.71-4.33-2.85-4.89Z" fill="currentColor" stroke-width="0"/>\n' +
160            '  <path d="m95.47,180.54l-.44.18c-2.04.84-3.02,3.17-2.19,5.22.63,1.55,2.13,2.49,3.7,2.49.5,0,1.02-.1,1.51-.3l.49-.2c2.04-.85,3-3.19,2.15-5.23-.85-2.04-3.19-3-5.23-2.15Z" fill="currentColor" stroke-width="0"/>\n' +
161            '  <path d="m131.34,152.31c-1.91-1.11-4.36-.45-5.46,1.46l-.23.4c-1.12,1.9-.49,4.35,1.41,5.48.64.38,1.34.56,2.03.56,1.37,0,2.7-.7,3.45-1.97l.27-.47c1.1-1.91.45-4.36-1.46-5.46Z" fill="currentColor" stroke-width="0"/>\n' +
162            '  <path d="m136.41,138.6c-2.11-.66-4.35.51-5.02,2.61l-.14.43c-.69,2.1.45,4.36,2.55,5.05.42.14.84.2,1.25.2,1.68,0,3.24-1.07,3.8-2.75l.17-.53c.66-2.11-.51-4.35-2.61-5.02Z" fill="currentColor" stroke-width="0"/>\n' +
163            '  <path d="m133.82,114.51c.25,2.03,1.97,3.51,3.96,3.51.16,0,.33,0,.49-.03,2.19-.27,3.75-2.26,3.48-4.46l-.07-.53c-.28-2.19-2.28-3.73-4.48-3.45-2.19.28-3.74,2.29-3.45,4.48l.06.47Z" fill="currentColor" stroke-width="0"/>\n' +
164            '  <path d="m138.39,124.12c-2.19-.18-4.14,1.44-4.33,3.64l-.04.48c-.21,2.2,1.41,4.15,3.61,4.36.13.01.25.02.38.02,2.04,0,3.78-1.55,3.98-3.63l.05-.53c.19-2.2-1.44-4.14-3.64-4.33Z" fill="currentColor" stroke-width="0"/>\n' +
165            '  <path d="m107.46,173.91l-.39.27c-1.81,1.26-2.26,3.75-1,5.57.78,1.12,2.02,1.72,3.29,1.72.79,0,1.58-.23,2.28-.72l.44-.31c1.8-1.28,2.23-3.77.96-5.58s-3.77-2.23-5.58-.96Z" fill="currentColor" stroke-width="0"/>\n' +
166            '  <path d="m39.61,66.95c.63,0,1.27-.15,1.86-.46l.24-.13c1.95-1.04,2.69-3.46,1.65-5.41-1.04-1.95-3.46-2.69-5.41-1.65l-.2.11c-1.95,1.03-2.7,3.45-1.68,5.4.72,1.36,2.1,2.14,3.54,2.14Z" fill="currentColor" stroke-width="0"/>\n' +
167            '  <path d="m96.23,134.54h.03c1.13,0,2.21-.5,2.96-1.34,1.92-2.17,47.04-53.34,47.75-82.35.32-13.21-4.66-25.78-14.04-35.38C123.35,5.63,109.97,0,96.23,0c-27.94,0-50.68,22.71-50.74,50.64-.12,2.85.04,30.44,47.79,82.6.76.83,1.83,1.3,2.95,1.3ZM53.48,51.06c0-.1.01-.21.01-.31,0-23.57,19.17-42.74,42.74-42.74,11.6,0,22.89,4.75,30.98,13.04,7.86,8.05,12.03,18.56,11.76,29.6h0c-.54,22.17-32.82,62.02-42.82,73.85C52.7,75.9,53.47,51.25,53.48,51.06Z" fill="currentColor" stroke-width="0"/>\n' +
168            '</svg>';
169
170        var iconCity =
171            '<svg id="Ebene_1" data-name="Ebene 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 123.27 189.58">\n' +
172            '  <path d="m88.98,62.48c0-15.17-12.34-27.51-27.51-27.51s-27.51,12.34-27.51,27.51,12.34,27.51,27.51,27.51,27.51-12.34,27.51-27.51Zm-27.51,19.51c-10.76,0-19.51-8.75-19.51-19.51s8.75-19.51,19.51-19.51,19.51,8.75,19.51,19.51-8.75,19.51-19.51,19.51Z" fill="currentColor" stroke-width="0"/>\n' +
173            '  <path d="m94.14,131.75c-1.57,1.55-1.59,4.08-.04,5.66,4.7,4.76,7.19,10.36,7.19,16.18,0,15.44-17.4,28-38.78,28s-38.78-12.56-38.78-28c0-5.15,1.98-10.19,5.73-14.58,1.43-1.68,1.23-4.21-.45-5.64-1.68-1.43-4.21-1.23-5.64.45-5,5.86-7.64,12.7-7.64,19.77,0,19.85,20.99,36,46.78,36s46.78-16.15,46.78-36c0-7.97-3.28-15.5-9.5-21.8-1.55-1.57-4.08-1.59-5.66-.04Z" fill="currentColor" stroke-width="0"/>\n' +
174            '  <path d="m61.63,163.98h.03c1.13,0,2.21-.5,2.96-1.34,2.36-2.66,57.76-65.49,58.62-100.92.39-16.03-5.66-31.28-17.04-42.94C94.57,6.84,78.32,0,61.63,0,27.7,0,.08,27.58.02,61.5c-.15,3.14-.27,36.8,58.67,101.18.76.83,1.83,1.3,2.95,1.3ZM8,61.93c0-.1.01-.21.01-.31,0-29.56,24.05-53.62,53.62-53.62,14.54,0,28.71,5.96,38.85,16.36,9.86,10.1,15.1,23.3,14.77,37.16h0c-.69,28.15-42.2,78.9-53.69,92.42C6.88,93.07,7.99,62.2,8,61.93Z" fill="currentColor" stroke-width="0"/>\n' +
175            '</svg>';
176
177        let travelType = document.getElementById('travel_type').value;
178        let  is_travel_type_pa_active = document.getElementById('is_travel_type_pa_active').value;
179        let  is_travel_type_nh_active = document.getElementById('is_travel_type_nh_active').value;
180
181        if (is_travel_type_nh_active && !is_travel_type_pa_active) {
182            travelType = 'nh';
183        }
184
185        if (typeof travelType !== 'undefined' && travelType !== null) {
186            switch (travelType) {
187                case "nh":
188                    showHotel();
189                    break;
190
191                case "nf":
192                    showFlies();
193                    break;
194
195                case "pa":
196                default:
197                    showPackage();
198                    break;
199            }
200        }
201
202        $('#input-departure-modal-wrapper').append(`<div class="form-check"><input  type="checkbox" class="form-check-input" id="input-departure-all-input" name="ALLAIR" value="ALLAIR"><label  for="ALLAIR" class="form-check-label input-departure-all-lable">Alle Flughäfen</label></div>`);
203
204        $('#input-departure').append(`<option class="input-departure-all-option" value="ALLAIR">alle Flughäfen</option>`);
205
206        Object.keys(airportMapping).forEach((group) => {
207            $('#input-departure').append(`<optgroup  label="${airportMapping[group]['name']}">`);
208
209            airportMapping[group]['children'].forEach((child) => {
210                $('#input-departure').append(`<option value="${child['code']}">${child['name']}</option>`);
211            });
212
213            $('#input-departure').append(`</optgroup>`);
214
215            $('#input-departure-modal-wrapper').append(`<div><strong>${airportMapping[group]['name']}</strong></div>`);
216
217            airportMapping[group]['children'].forEach((child) => {
218                $('#input-departure-modal-wrapper').append(`<div class="form-check"><input type="checkbox" class="form-check-input" id="${child['code']}" name="${child['code']}" value="${child['code']}"><label  for="${child['code']}" class="form-check-label">${child['name']}</label></div>`);
219            });
220        });
221
222        $("#input-departure-modal-search").keyup(function () {
223
224            let filter = $(this).val(), count = 0;
225
226            $('#input-departure-modal-wrapper div').each(function () {
227                if ($(this).text().search(new RegExp(filter, "i")) < 0) {
228                    $(this).hide();  // MY CHANGE
229                } else {
230                    $(this).show(); // MY CHANGE
231                    count++;
232                }
233            });
234        });
235
236        $("#input-departure-all-input").click(function () {
237            if ($('#input-departure-all-input').is(':checked')) {
238                $('#input-departure-modal-wrapper input').each(function () {
239                    $(this).prop('checked', true);
240                });
241            } else {
242                $('#input-departure-modal-wrapper input').each(function () {
243                    $(this).prop('checked', false);
244                });
245            }
246        });
247
248        $("#input-departure-modal-save-button").click(function () {
249
250            let departures = [];
251
252            $('#input-departure-modal-wrapper input').each(function () {
253                if ($(this).is(':checked')) {
254                    departures.push($(this).val());
255                }
256            });
257
258            $('#input-departure').val(departures);
259
260            $('#input-departure').trigger('change');
261
262            const selected = $('#input-departure').select2("data");
263
264            let departure = "";
265
266            for (let i = 0; i <= selected.length - 1; i++) {
267                if (departure !== "") {
268                    departure += "|";
269                }
270
271                departure += selected[i].id;
272
273                document.getElementById('departure_value').value = departure;
274            }
275
276            $('#input-departure-modal').appendTo("body").modal('hide');
277        });
278
279        $("#input-travellers-submit-btn").click(function () {
280            document.getElementById('travellers-counter').style.display = "none";
281        });
282
283        $.fn.select2.amd.define("SelectionAdapter",
284            [
285                'select2/selection/single',
286                'select2/selection/placeholder',
287                'select2/selection/allowClear',
288                'select2/selection/eventRelay',
289                'select2/utils'
290            ],
291            function (SingleSelection, Placeholder, AllowClear, EventRelay, Utils) {
292                var SelectionAdapter = Utils.Decorate(
293                    SingleSelection,
294                    Placeholder
295                );
296
297                SelectionAdapter = Utils.Decorate(
298                    SelectionAdapter,
299                    AllowClear
300                );
301
302                SelectionAdapter = Utils.Decorate(
303                    SelectionAdapter,
304                    EventRelay
305                );
306
307                return SelectionAdapter;
308            }
309        );
310
311        $.fn.select2.amd.define("DropdownAdapter",
312            [
313                'select2/selection/single',
314                'select2/selection/placeholder',
315                'select2/selection/allowClear',
316                'select2/dropdown',
317                'select2/dropdown/search',
318                'select2/dropdown/attachBody',
319                'select2/utils'
320            ],
321            function (SingleSelection, Placeholder, AllowClear, Dropdown, DropdownSearch, AttachBody, Utils) {
322                var DropdownAdapter = Utils.Decorate(
323                    Utils.Decorate(
324                        Dropdown,
325                        DropdownSearch
326                    ),
327                    AttachBody
328                );
329
330                return DropdownAdapter;
331            }
332        );
333
334        var base_element = $('#input-departure');
335
336        if (document.documentElement.clientWidth > 1250) {
337            $(base_element)
338                .select2({
339                    placeholder: "Welcher Abflughafen?",
340                    allowClear: true,
341                    selectionAdapter: $.fn.select2.amd.require("SelectionAdapter"),
342                    dropdownAdapter: $.fn.select2.amd.require("DropdownAdapter"),
343                    templateResult: function (data) {
344                        if (!data.id) {
345                            return data.text;
346                        }
347
348                        var $res = $('<div></div>');
349
350                        $res.text(data.text);
351                        $res.addClass('wrap');
352
353                        return $res;
354                    },
355                    templateSelection: function (data) {
356                        if (!data.id) {
357                            return data.text;
358                        }
359
360                        var selected = ($(base_element).val() || []).length;
361                        var total = $('option', $(base_element)).length;
362
363                        return selected + " von " + total + " gewählt";
364                    }
365                })
366                .on('select2:open', function (e) {
367                    $("#input-departure").select2("close");
368
369                    $('#input-departure-modal-wrapper input').each(function () {
370                        if ($.inArray($(this).val(), $("#input-departure").val()) !== -1) {
371                            $(this).prop('checked', true);
372                        } else {
373                            $(this).prop('checked', false);
374                        }
375                    });
376
377                    $('#input-departure-modal').appendTo("body").modal('show');
378                });
379        } else {
380            $(base_element)
381                .select2({
382                    placeholder: "Welcher Abflughafen?",
383                    allowClear: true,
384                    closeOnSelect: false,
385                    selectionAdapter: $.fn.select2.amd.require("SelectionAdapter"),
386                    dropdownAdapter: $.fn.select2.amd.require("DropdownAdapter"),
387                    templateResult: function (data) {
388                        if (!data.id) {
389                            return data.text;
390                        }
391
392                        var $res = $('<div></div>');
393
394                        $res.text(data.text);
395                        $res.addClass('wrap');
396
397                        if (data.id === "ALLAIR") {
398                            $res.addClass('input-departure-all-option-wrap');
399                        }
400
401                        return $res;
402                    },
403                    templateSelection: function (data) {
404                        if (!data.id) {
405                            return data.text;
406                        }
407
408                        var selected = ($(base_element).val() || []).length;
409                        var total = $('option', $(base_element)).length;
410
411                        return selected + " von " + total + " gewählt";
412                    }
413                }).on('select2:select', function (e) {
414                if (e.params.data.id === 'ALLAIR') {
415                    const options = $('#input-departure option');
416
417                    for (let i = 0; i < options.length; i++) {
418                        options[i].selected = true;
419                    }
420
421                    $('#input-departure').trigger("change");
422
423                    $('#input-departure').select2("close");
424                }
425            }).on('select2:unselect', function (e) {
426                if (e.params.data.id === 'ALLAIR') {
427                    const options = $('#input-departure option');
428
429                    for (let i = 0; i < options.length; i++) {
430                        options[i].selected = false;
431                    }
432
433                    $('#input-departure').trigger("change");
434
435                    $('#input-departure').select2("close");
436                }
437            }).on('select2:open', function () {
438                let a = $(this).data('select2');
439
440                if (!$('#input-departure-select-close').length) {
441                    a.$results.parents('.select2-results')
442                        .prepend('<div id="smg-departure-select-header"><div class="smg-departure-select-headline"">Abflughafen</div><span class="smg-departure-icon-close"></span></div>')
443                        .append('<div id="input-departure-select-close"><button type="button" class="smg-departure-select-button">Übernehmen</button></div>');
444
445                    $(".select2-results .smg-departure-select-button").click(function(){
446                        $('#input-departure').select2("close");
447                    });
448
449                    $(".select2-results .smg-departure-icon-close").click(function(){
450                        $('#input-departure').select2("close");
451                    });
452                }
453            });
454        }
455
456        /* EVENT LISTENER */
457        $('#package-btn').on('click', showPackage);
458        $('#hotel-only-btn').on('click', showHotel);
459        $('#fly-only-btn').on('click', showFly);
460        $('#fly-only-btn-ks').on('click', showFlies);
461        $('#input-destination').on('click', showAllInputFields);
462        $('#input-duration').on('click', showDurationList);
463        $('#input-duration').on('focusout', hideDurationList);
464        $('#duration-select > div').on('click', getChosenOption);
465        $('#input-travellers').on('click', showTravellersCounter);
466        $('#input-travellers').val('2 Erwachsene, 0 Kinder');
467        $('#travellers-counter').on('focusout', hideTravellersCounter);
468        $('#travellers-counter').on('mouseleave', hideTravellersCounter);
469        $('#input-period').on('change', getDates);
470        $('#input-duration').on('change', getDuration);
471        $('.button_children').click(function (e) {
472            var button_classes;
473
474            button_classes = $(e.currentTarget).prop('class');
475
476            if (button_classes.indexOf('up_count') !== -1) {
477                childrenCount = (childrenCount) + 1;
478            } else {
479                childrenCount = (childrenCount) - 1;
480            }
481
482            lastChildrenCount = childrenCount;
483            childrenCount = childrenCount < 0 ? 0 : childrenCount;
484            childrenCount = childrenCount > 8 ? 8 : childrenCount;
485
486            if (lastChildrenCount === childrenCount) {
487                if (button_classes.indexOf('up_count') !== -1) {
488                    addChildrenAgeInput(childrenCount);
489                } else {
490                    removeChildrenAgeInput();
491                }
492            }
493
494            if (childrenCount === 1) {
495                $('#line').css('display', 'block');
496            }
497
498            if (childrenCount === 0) {
499                $('#line').css('display', 'none');
500            }
501
502            $('.counter_children').val(childrenCount);
503            $('#input-travellers').val(adultCount + ' Erwachsene, ' + childrenCount + ' Kinder');
504            $('#input-travellers').css('color', 'black');
505        });
506
507        $('.button_children_age').click(function (e) {
508            const button_classes = $(e.currentTarget).prop('class');
509            const childrenAgeInput = $(this).parent().children('input');
510            let currentValue = +childrenAgeInput.val();
511
512            if (button_classes.indexOf('up_count') !== -1) {
513                currentValue = (currentValue) + 1;
514            } else {
515                currentValue = (currentValue) - 1;
516            }
517
518            if (currentValue >= 0 && currentValue < 18) {
519                childrenAgeInput.val(currentValue);
520            }
521        });
522
523        $('.counter_children').click(function () {
524            $(this).focus().select();
525        });
526
527        $('.button_adult').click(function (e) {
528            var button_classes;
529
530            button_classes = $(e.currentTarget).prop('class');
531
532            if (button_classes.indexOf('up_count') !== -1) {
533                adultCount = (adultCount) + 1;
534            } else {
535                adultCount = (adultCount) - 1;
536            }
537
538            adultCount = adultCount < 1 ? 1 : adultCount;
539            adultCount = adultCount > 8 ? 8 : adultCount;
540
541            $('.counter_adult').val(adultCount);
542            $('#input-travellers').val(adultCount + ' Erwachsene, ' + childrenCount + ' Kinder');
543            $('#input-travellers').css('color', 'black');
544        });
545
546        $('.counter_adult').click(function () {
547            $(this).focus().select();
548        });
549
550        $('body').on('click', '.select2-results__option', function (e) {
551            e.preventDefault();
552
553            var selected = $('#input-departure').select2("data");
554            var departure = "";
555
556            for (var i = 0; i <= selected.length - 1; i++) {
557                if (departure !== "") {
558                    departure += "|";
559                }
560
561                departure += selected[i].id;
562                document.getElementById('departure_value').value = departure;
563            }
564        });
565
566        $('body').on('click', '#duration-select', function (e) {
567            e.preventDefault();
568
569            var durationStr = document.getElementById('input-duration').value;
570
571            durationStr = durationStr.replace('–', '-')
572
573            if (durationMapping[durationStr]) {
574                document.getElementById('duration_value').value = durationMapping[durationStr];
575            }
576        });
577
578        function getFlatpickrCalenderCount() {
579            if ($(window).width() <= 1000) {
580                return 1;
581            }
582
583            return 3;
584        }
585
586        $("#input-period").flatpickr({
587            mode: 'range',
588            dateFormat: "d.m.Y",
589            minDate: new Date(),
590            showMonths: getFlatpickrCalenderCount(),
591            locale: 'de',
592            position: 'auto center',
593        });
594
595        var adultCount = +$('.counter_adult').val();
596        var childrenCount = +$('.counter_children').val();
597
598
599        function initDestination() {
600            settings = initDestinationField();
601            isInitialized = false;
602
603            $('#input-destination').typeahead('destroy');
604
605            $('#input-destination').typeahead({showHintOnFocus: true, minLength: 0}, settings)
606                .on('typeahead:select', function (ev, suggestion) {
607                    let destination = "";
608
609                    if (smg.type[travelType] === 'traffics') {
610                        if (suggestion.regionList && suggestion.regionList !== '') {
611                            let regionList = suggestion.regionList.toString().split(",");
612                            destination = "regionList_" + regionList.join("|regionList_");
613                        }
614
615                        if (suggestion.locationList && suggestion.locationList !== '') {
616                            let locationList = suggestion.locationList.toString().split(",");
617                            destination = "locationList_" + locationList.join("|locationList_") + '|regionList_' + suggestion.region.code;
618                        }
619
620                        if (suggestion.hotelChainList && suggestion.hotelChainList !== '') {
621                            let hotelChainList = suggestion.hotelChainList.toString().split(",");
622                            destination = "hotelChainList_" + hotelChainList.join("|hotelChainList_");
623                        }
624
625                        if (suggestion.giataHotelList && suggestion.giataHotelList !== '') {
626                            let giataHotelList = suggestion.giataHotelList.toString().split(",");
627                            destination = "giataHotelList_" + giataHotelList.join("|giataHotelList_") + '|locationList_' + suggestion.location.code;
628                        }
629
630                        if (suggestion.airportList && suggestion.airportList !== '') {
631                            let airportList = suggestion.airportList.toString().split(",");
632                            destination = "airportList_" + airportList.join("|airportList_");
633                        }
634
635                        if (suggestion.countryList && suggestion.countryList !== '') {
636                            let countryList = suggestion.countryList.toString().split(",");
637                            destination = "countryList_" + countryList.join("|countryList_");
638                        }
639                    } else if (smg.type[travelType] === 'tt') {
640                        if (suggestion.regionCode && suggestion.regionCode !== '') {
641                            let rgid = suggestion.regionCode.toString().split(",");
642
643                            destination = "rgid_" + rgid.join("|rgid_");
644                        }
645
646                        if (suggestion.iffRegionCode && suggestion.iffRegionCode !== '') {
647                            if (destination !== "") {
648                                destination += "|";
649                            }
650
651                            let rid = suggestion.iffRegionCode.toString().split(",");
652
653                            destination += "rid_" + rid.join("|rid_");
654                        }
655
656                        if (suggestion.iffVillageCode && suggestion.iffVillageCode !== '') {
657                            if (destination !== "") {
658                                destination += "|";
659                            }
660
661                            let cyid = suggestion.iffVillageCode.toString().split(",");
662
663                            destination += "cyid_" + cyid.join("|cyid_");
664                        }
665
666                        if (suggestion.iff && suggestion.iff !== '') {
667                            if (destination !== "") {
668                                destination += "|";
669                            }
670
671                            let aid = suggestion.iff.toString().split(",");
672
673                            destination += "aid_" + aid.join("|aid_");
674                        }
675
676                        if (suggestion.isoCode && suggestion.isoCode !== '') {
677                            if (destination !== "") {
678                                destination += "|";
679                            }
680
681                            let nid = suggestion.isoCode.toString().split(",");
682
683                            destination += "nid_" + nid.join("|nid_");
684                        }
685
686                        if (suggestion.countryISO3166 && suggestion.countryISO3166 !== '') {
687                            if (destination !== "") {
688                                destination += "|";
689                            }
690
691                            let nid = suggestion.countryISO3166.toString().split(",");
692
693                            destination += "nid_" + nid.join("|nid_");
694                        }
695                    } else {
696                        if (suggestion.region && suggestion.region !== '') {
697                            destination = suggestion.region;
698                        }
699
700                        if (suggestion.city && suggestion.city !== '') {
701                            if (destination !== "") {
702                                destination += "|";
703                            }
704
705                            destination += suggestion.city;
706                        }
707
708                        if (suggestion.hotel && suggestion.hotel !== '') {
709                            if (destination !== "") {
710                                destination += "|";
711                            }
712
713                            destination += suggestion.hotel;
714                        }
715                    }
716
717                    document.getElementById('destination_value').value = destination;
718                })
719        };
720
721        initDestination();
722
723        function showAllInputFields() {
724            $('#period').css("display", "flex");
725            $('#duration').css("display", "flex");
726
727            if (document.getElementById('hotel-only-btn') && !document.getElementById('hotel-only-btn').classList.contains("selected")) {
728                $('#departure').css("display", "flex");
729            }
730
731            $('#travellers').css("display", "flex");
732            $('#destination').css("border-bottom-left-radius", "0px");
733            $('#destination').css("border-bottom-right-radius", "0px");
734        }
735
736        function showPackage() {
737            active = 1;
738            ibePackage = 1;
739            ibeHotel = 0;
740            ibeFlight = 0;
741
742            initDestination();
743
744            document.getElementById('travel_type').value = "pa";
745            travelType = 'pa';
746            registerTypeAhead();
747
748            if ($('#travellers').css("display") === "none") {
749                $('#departure').css("display", "none");
750            } else {
751                $('#departure').css("display", "flex");
752            }
753
754            if (document.getElementById('package-btn') && !document.getElementById('package-btn').classList.contains("selected")) {
755                if (document.getElementById('hotel-only-btn')) {
756                    document.getElementById('hotel-only-btn').classList.remove("selected");
757                }
758
759                if (document.getElementById('fly-only-btn')) {
760                    document.getElementById('fly-only-btn').classList.remove("selected");
761                }
762
763                document.getElementById('package-btn').classList.add("selected");
764            }
765        }
766
767        function showFly() {
768            active = 1;
769            ibePackage = 0;
770            ibeHotel = 0;
771            ibeFlight = 1;
772
773            initDestination();
774
775            document.getElementById('travel_type').value = "nf";
776            travelType = 'nf';
777            registerTypeAhead();
778
779            $('#departure').css("display", "flex");
780
781            if (document.getElementById('fly-only-btn') && !document.getElementById('fly-only-btn').classList.contains("selected")) {
782                if (document.getElementById('hotel-only-btn')) {
783                    document.getElementById('hotel-only-btn').classList.remove("selected");
784                }
785
786                if (document.getElementById('package-btn')) {
787                    document.getElementById('package-btn').classList.remove("selected");
788                }
789
790                document.getElementById('fly-only-btn').classList.add("selected");
791            }
792        }
793
794        function showFlies() {
795            active = 1;
796            ibePackage = 0;
797            ibeHotel = 0;
798            ibeFlight = 1;
799
800            initDestination();
801
802            document.getElementById('travel_type').value = "nf";
803            travelType = 'nf';
804            registerTypeAhead();
805
806            if(smg.layout_id === "9f5fdec7-77a3-45f3-be4c-3fdaebfa3ef1") {
807                document.location.href = '/site//fluege';
808            } else {
809                document.location.href = '/site/linienflug';
810            }
811        }
812
813        function showHotel() {
814            active = 0;
815            ibePackage = 0;
816            ibeHotel = 1;
817            ibeFlight = 0;
818
819            initDestination();
820
821            document.getElementById('travel_type').value = "nh";
822            travelType = 'nh';
823            registerTypeAhead();
824
825            $('#departure').css("display", "none");
826
827            if (document.getElementById('hotel-only-btn') && !document.getElementById('hotel-only-btn').classList.contains("selected")) {
828                if (document.getElementById('package-btn')) {
829                    document.getElementById('package-btn').classList.remove("selected");
830                }
831
832                if (document.getElementById('fly-only-btn')) {
833                    document.getElementById('fly-only-btn').classList.remove("selected");
834                }
835
836                document.getElementById('hotel-only-btn').classList.add("selected");
837            }
838        }
839
840        function request(initRequest, id) {
841            if (smg.type[travelType] === 'traffics') {
842                return [
843                    {
844                        name: 'topRegions',
845                        source: function (query, callback) {
846                            if ($('#input-destination').val().length) {
847                                return callback();
848                            }
849                            callback([]);
850                        },
851                        limit: 20,
852                        templates: {
853                            suggestion: function (elem) {
854                                return '<div>&#9733; ' + elem.suggestion + ' <small class="destinationSuggestionType">' + elem.type + '</small></div>';
855                            }
856                        },
857                        display: function (data) {
858                            return data.suggestion
859                        },
860                    },
861                    {
862                        name: 'destinationSuggestions',
863                        source: new Bloodhound({
864                            datumTokenizer: Bloodhound.tokenizers.obj.whitespace('suggestion'),
865                            queryTokenizer: Bloodhound.tokenizers.whitespace,
866                            remote: {
867                                url: 'https://connector-ibe.traffics.de/v3/rest/completions?subTypeGiataHotel=true&subTypeRegion=true&subTypeLocation=true&subTypeDestinationAirport=false&searchLogic=nat&productType=pauschal&licence=' + smg.ibeTrafficsLicence + '&searchValue=',
868                                prepare: function (initRequest) {
869                                    return function (query, settings) {
870                                        settings.url = settings.url + query;
871
872                                        return settings;
873                                    }
874                                }(initRequest),
875                                transform: function (response) {
876                                    let suggestions = [];
877
878                                    response.regionList.forEach(function (item) {
879                                        let item_ = [];
880                                        item_.suggestion = item.name;
881                                        item_.type = 'Region';
882                                        item_.regionList = item.code;
883                                        suggestions.push(item_);
884                                    });
885
886                                    response.locationList.forEach(function (item) {
887                                        let item_ = [];
888                                        item_.suggestion = item.name;
889                                        item_.type = 'Stadt';
890                                        item_.locationList = item.code;
891                                        item_.region = item.region;
892                                        suggestions.push(item_);
893                                    });
894
895                                    response.hotelChainList.forEach(function (item) {
896                                        let item_ = [];
897                                        item_.suggestion = item.name;
898                                        item_.type = 'Hotelkette';
899                                        item_.hotelChainList = item.code;
900                                        suggestions.push(item_);
901                                    });
902
903                                    response.giataHotelList.forEach(function (item) {
904                                        let item_ = [];
905                                        item_.suggestion = item.name;
906                                        item_.type = 'Hotel';
907                                        item_.giataHotelList = item.code;
908                                        item_.location = item.location;
909                                        suggestions.push(item_);
910                                    });
911
912                                    response.airportList.forEach(function (item) {
913                                        let item_ = [];
914                                        item_.suggestion = item.name;
915                                        item_.type = 'Flughafen';
916                                        item_.airportList = item.code;
917                                        suggestions.push(item_);
918                                    });
919
920                                    response.countryList.forEach(function (item) {
921                                        let item_ = [];
922                                        item_.suggestion = item.name;
923                                        item_.type = 'Land';
924                                        item_.countryList = item.code;
925                                        suggestions.push(item_);
926                                    });
927
928                                    return suggestions;
929                                }
930                            }
931                        }),
932                        limit: 20,
933                        templates: {
934                            suggestion: function (elem) {
935                                return '<div>' + elem.suggestion + ' <small class="destinationSuggestionType">' + elem.type + '</small></div>';
936                            }
937                        },
938                        display: function (data) {
939                            return data.suggestion
940                        },
941                    }];
942            } else if (smg.type[travelType] === 'tt') {
943                return [
944                    {
945                        name: 'topRegions',
946                        source: function (query, callback) {
947                            if ($('#input-destination').val().length) {
948                                return callback();
949                            }
950                            callback([]);
951                        },
952                        limit: 20,
953                        templates: {
954                            suggestion: function (elem) {
955                                return '<div> ' + iconRegion + ' <span>' + elem.suggestion + '</span></div';
956                            },
957                            header: '<div class="dataset-header"> <span>Regionen</span> </div>'
958                        },
959                        display: function (data) {
960                            return data.suggestion
961                        },
962                    },
963                    {
964                        name: 'regionSuggestions',
965                        source: new Bloodhound({
966                            datumTokenizer: Bloodhound.tokenizers.obj.whitespace('suggestion'),
967                            queryTokenizer: Bloodhound.tokenizers.whitespace,
968                            remote: {
969                                url: 'https://suggestbox.traveltainment.eu/TravelTainmentNameSearchEE/Namesearch?',
970                                prepare: function (initRequest) {
971                                    return function (query, settings) {
972                                        var request = jQuery.extend(true, {async: true}, initRequest);
973                                        request.needle = query;
974                                        settings.url = settings.url + jQuery.param({search: JSON.stringify(request)});
975
976                                        return settings;
977                                    }
978                                }(initRequest),
979                                transform: function (response) {
980                                    return filterTTResponse(response).filter(function(val) {
981                                        return val.type === 'Region';
982                                    });
983                                }
984                            }
985                        }),
986                        limit: 20,
987                        templates: {
988                            suggestion: function (elem) {
989                                return '<div> ' + iconRegion + ' <span>' + elem.suggestion + '</span> </div>';
990                            },
991                            header: '<div class="dataset-header"> <span>Zielgebiete</span> </div>'
992                        },
993                        display: function (data) {
994                            return data.suggestion
995                        },
996                    },
997                    {
998                        name: 'countrySuggestions',
999                        source: new Bloodhound({
1000                            datumTokenizer: Bloodhound.tokenizers.obj.whitespace('suggestion'),
1001                            queryTokenizer: Bloodhound.tokenizers.whitespace,
1002                            remote: {
1003                                url: 'https://suggestbox.traveltainment.eu/TravelTainmentNameSearchEE/Namesearch?',
1004                                prepare: function (initRequest) {
1005                                    return function (query, settings) {
1006                                        var request = jQuery.extend(true, {async: true}, initRequest);
1007                                        request.needle = query;
1008                                        settings.url = settings.url + jQuery.param({search: JSON.stringify(request)});
1009
1010                                        return settings;
1011                                    }
1012                                }(initRequest),
1013                                transform: function (response) {
1014                                    return filterTTResponse(response).filter(function(val) {
1015                                        return val.type === 'Country';
1016                                    });
1017                                }
1018                            }
1019                        }),
1020                        limit: 20,
1021                        templates: {
1022                            suggestion: function (elem) {
1023                                return '<div> ' + iconRegion + ' <span>' + elem.suggestion + '</span> </div>';
1024                            },
1025                            header: '<div class="dataset-header"> <span>Zielgebiete</span> </div>'
1026                        },
1027                        display: function (data) {
1028                            return data.suggestion
1029                        },
1030                    },
1031                    {
1032                        name: 'destinationSuggestions',
1033                        source: new Bloodhound({
1034                            datumTokenizer: Bloodhound.tokenizers.obj.whitespace('suggestion'),
1035                            queryTokenizer: Bloodhound.tokenizers.whitespace,
1036                            remote: {
1037                                url: 'https://suggestbox.traveltainment.eu/TravelTainmentNameSearchEE/Namesearch?',
1038                                prepare: function (initRequest) {
1039                                    return function (query, settings) {
1040                                        var request = jQuery.extend(true, {async: true}, initRequest);
1041                                        request.needle = query;
1042                                        settings.url = settings.url + jQuery.param({search: JSON.stringify(request)});
1043
1044                                        return settings;
1045                                    }
1046                                }(initRequest),
1047                                transform: function (response) {
1048                                    return filterTTResponse(response).filter(function(val) {
1049                                        return val.type === 'Destination';
1050                                    });
1051                                }
1052                            }
1053                        }),
1054                        limit: 20,
1055                        templates: {
1056                            suggestion: function (elem) {
1057                                return '<div> ' + iconRegion + ' <span>' + elem.suggestion + '</span> </div>';
1058                            },
1059                            header: '<div class="dataset-header"> <span>Regionen</span> </div>'
1060                        },
1061                        display: function (data) {
1062                            return data.suggestion
1063                        },
1064                    },
1065                    {
1066                        name: 'citySuggestions',
1067                        source: new Bloodhound({
1068                            datumTokenizer: Bloodhound.tokenizers.obj.whitespace('suggestion'),
1069                            queryTokenizer: Bloodhound.tokenizers.whitespace,
1070                            remote: {
1071                                url: 'https://suggestbox.traveltainment.eu/TravelTainmentNameSearchEE/Namesearch?',
1072                                prepare: function (initRequest) {
1073                                    return function (query, settings) {
1074                                        var request = jQuery.extend(true, {async: true}, initRequest);
1075                                        request.needle = query;
1076                                        settings.url = settings.url + jQuery.param({search: JSON.stringify(request)});
1077
1078                                        return settings;
1079                                    }
1080                                }(initRequest),
1081                                transform: function (response) {
1082                                    return filterTTResponse(response).filter(function(val) {
1083                                        return val.type === 'Village';
1084                                    });
1085                                }
1086                            }
1087                        }),
1088                        limit: 20,
1089                        templates: {
1090                            suggestion: function (elem) {
1091                                return '<div> ' + iconCity + ' <span>' + elem.suggestion + '</span> </div>';
1092                            },
1093                            header: '<div class="dataset-header"> <span>Städte</span> </div>'
1094                        },
1095                        display: function (data) {
1096                            return data.suggestion
1097                        },
1098                    },
1099                    {
1100                        name: 'hotelSuggestions',
1101                        source: new Bloodhound({
1102                            datumTokenizer: Bloodhound.tokenizers.obj.whitespace('suggestion'),
1103                            queryTokenizer: Bloodhound.tokenizers.whitespace,
1104                            remote: {
1105                                url: 'https://suggestbox.traveltainment.eu/TravelTainmentNameSearchEE/Namesearch?',
1106                                prepare: function (initRequest) {
1107                                    return function (query, settings) {
1108                                        var request = jQuery.extend(true, {async: true}, initRequest);
1109                                        request.needle = query;
1110                                        settings.url = settings.url + jQuery.param({search: JSON.stringify(request)});
1111
1112                                        return settings;
1113                                    }
1114                                }(initRequest),
1115                                transform: function (response) {
1116                                    return filterTTResponse(response).filter(function(val) {
1117                                        return val.type === 'Accommodation';
1118                                    });
1119                                }
1120                            }
1121                        }),
1122                        limit: 20,
1123                        templates: {
1124                            suggestion: function (elem) {
1125                                return '<div> ' + iconHotel + ' <span>' + elem.suggestion + '</span> </div>';
1126                            },
1127                            header: '<div class="dataset-header"> <span>Hotels</span> </div>'
1128
1129                        },
1130                        display: function (data) {
1131                            return data.suggestion
1132                        },
1133                    }
1134                    ];
1135            } else {
1136                return [
1137                    {
1138                        name: 'topRegions',
1139                        source: function (query, callback) {
1140                            if ($('#input-destination').val().length) {
1141                                return callback();
1142                            }
1143
1144                            callback([]);
1145                        },
1146                        limit: 20,
1147                        templates: {
1148                            suggestion: function (elem) {
1149                                return '<div> ' + iconRegion + ' <span>' + elem.suggestion + '</span> </div>';
1150                            },
1151                            header: '<div class="dataset-header"> <span>Regionen</span> </div>'
1152                        },
1153                        display: function (data) {
1154                            return data.suggestion
1155                        },
1156                    },
1157                    {
1158                        name: 'regionSuggestions',
1159                        source: new Bloodhound({
1160                            datumTokenizer: Bloodhound.tokenizers.obj.whitespace('suggestion'),
1161                            queryTokenizer: Bloodhound.tokenizers.whitespace,
1162                            remote: {
1163                                url: 'https://api.go-suite.com/xena-autocomplete/v1/region-search?q=',
1164                                prepare: function (initRequest) {
1165                                    return function (query, settings) {
1166                                        settings.url = settings.url + query;
1167
1168                                        return settings;
1169                                    }
1170                                }(initRequest),
1171                                transform: function (response) {
1172                                    let suggestions = [];
1173
1174                                    if (!response.data) {
1175                                        return [];
1176                                    }
1177
1178                                    response.data.forEach(function (item) {
1179                                        let item_ = [];
1180                                        item_.suggestion = item.name;
1181                                        item_.name = item.name;
1182                                        item_.type = 'Region';
1183                                        item_.region = item.id;
1184                                        suggestions.push(item_);
1185                                    });
1186
1187                                    return suggestions;
1188                                }
1189                            }
1190                        }),
1191                        limit: 20,
1192                        templates: {
1193                            suggestion: function (elem) {
1194                                return '<div> ' + iconRegion + ' <span>' + elem.suggestion + '</span> </div>';
1195                            },
1196                            header: '<div class="dataset-header"> <span>Regionen</span> </div>'
1197                        },
1198                        display: function (data) {
1199                            return data.suggestion;
1200                        },
1201                    },
1202                    {
1203                        name: 'citySuggestions',
1204                        source: new Bloodhound({
1205                            datumTokenizer: Bloodhound.tokenizers.obj.whitespace('suggestion'),
1206                            queryTokenizer: Bloodhound.tokenizers.whitespace,
1207                            remote: {
1208                                url: 'https://api.go-suite.com/xena-autocomplete/v1/city-search?q=',
1209                                prepare: function (initRequest) {
1210                                    return function (query, settings) {
1211                                        settings.url = settings.url + query;
1212
1213                                        return settings;
1214                                    }
1215                                }(initRequest),
1216                                transform: function (response) {
1217                                    let suggestions = [];
1218
1219                                    if (!response.data) {
1220                                        return [];
1221                                    }
1222
1223                                    response.data.forEach(function (item) {
1224                                        let item_ = [];
1225                                        item_.suggestion = item.name;
1226                                        item_.name = item.name;
1227                                        item_.type = 'Stadt';
1228                                        item_.city = item.id;
1229                                        suggestions.push(item_);
1230                                    });
1231
1232                                    return suggestions;
1233                                }
1234                            }
1235                        }),
1236                        limit: 20,
1237                        templates: {
1238                            suggestion: function (elem) {
1239                                return '<div> ' + iconCity + ' <span>' + elem.suggestion + '</span> </div>';
1240                            },
1241                            header: '<div class="dataset-header"> <span>Städte</span> </div>'
1242                        },
1243                        display: function (data) {
1244                            return data.suggestion;
1245                        },
1246                    },
1247                    {
1248                        name: 'hotelSuggestions',
1249                        source: new Bloodhound({
1250                            datumTokenizer: Bloodhound.tokenizers.obj.whitespace('suggestion'),
1251                            queryTokenizer: Bloodhound.tokenizers.whitespace,
1252                            remote: {
1253                                url: 'https://api.go-suite.com/xena-autocomplete/v1/hotel-search?q=',
1254                                prepare: function (initRequest) {
1255                                    return function (query, settings) {
1256                                        settings.url = settings.url + query;
1257
1258                                        return settings;
1259                                    }
1260                                }(initRequest),
1261                                transform: function (response) {
1262                                    let suggestions = [];
1263
1264                                    if (!response.data) {
1265                                        return [];
1266                                    }
1267
1268                                    response.data.forEach(function (item) {
1269                                        let item_ = [];
1270                                        item_.suggestion = item.name;
1271                                        item_.name = item.name;
1272                                        item_.type = 'Hotel';
1273                                        item_.hotel = item.id;
1274                                        suggestions.push(item_);
1275                                    });
1276
1277                                    return suggestions;
1278                                }
1279                            }
1280                        }),
1281                        limit: 20,
1282                        templates: {
1283                            suggestion: function (elem) {
1284                                return '<div> ' + iconHotel + ' <span>' + elem.suggestion + '</span> </div>';
1285                            },
1286                            header: '<div class="dataset-header"> <span>Hotels</span> </div>'
1287                        },
1288                        display: function (data) {
1289                            return data.suggestion;
1290                        },
1291                    }
1292                ];
1293            }
1294        }
1295
1296        function initDestinationField(id) {
1297            var defaultRequest = {
1298                "selector": {
1299                    "locale": "de-DE",
1300                    "domain": "suggest4",
1301                },
1302                "options": {
1303                    "customer": "998000",
1304                    "source": "LamiPauschal",
1305                    "hits": "50",
1306                    "highlighting": "0",
1307                    "didYouMean": "1",
1308                    "suggestRegions": "1",
1309                    "suggestDestinations": "1",
1310                    "suggestVillages": "1",
1311                    "suggestPOIs": "0",
1312                    "suggestAccommodations": "1",
1313                    "suggestAirports": "0",
1314                    "poiTypes": [],
1315                    "contentType": "json",
1316                    "poiInsideRegion": "0",
1317                    "resultDetails": {
1318                        "includeMetaData": "1",
1319                        "includeType": "1",
1320                        "includeDLC": "0",
1321                        "includeIFF": "1",
1322                        "includeRegioncode": "1",
1323                        "includeIFFRegioncode": "1",
1324                        "includeIFFVillagecode": "1",
1325                        "includeVillageName": "1",
1326                        "includeRegionName": "1",
1327                        "includeDestinationName": "1",
1328                        "includeGeoLocation": "1",
1329                        "includeName": "1",
1330                        "includeCountryName": "1",
1331                        "includeProvinceName": "1",
1332                        "includeISO3166": "1"
1333                    },
1334                    "suggestCountries": "1",
1335                    "suggestProvinces": "0",
1336                    "preferredHierarchy": "Political"
1337                },
1338                "needle": "",
1339                "type": ""
1340            };
1341
1342            if (active === 0) {
1343                defaultRequest.options.source = 'HotelOnly';
1344            }
1345
1346            var initRequest = jQuery.extend(true, {}, defaultRequest);
1347
1348            return request(initRequest, id);
1349        }
1350
1351        function utf8_to_b64(str) {
1352            return window.btoa(unescape(encodeURIComponent(str)));
1353        }
1354
1355        function showDurationList() {
1356            document.getElementById('duration-list').style.display = "block";
1357            document.getElementById('input-duration').focus();
1358        }
1359
1360        function hideDurationList() {
1361            setTimeout(() => document.getElementById('duration-list').style.display = "none", 200);
1362        }
1363
1364        function getChosenOption(event) {
1365            var e = event.target
1366
1367            document.getElementById('input-duration').value = e.innerText;
1368
1369            hideDurationList();
1370        }
1371
1372        function showTravellersCounter() {
1373            document.getElementById('travellers-counter').style.display = "block";
1374        }
1375
1376        function hideTravellersCounter() {
1377            // Verzögert schließen und nur wenn weder Hover noch Fokus innerhalb bestehen
1378            const panel = document.getElementById('travellers-counter');
1379            setTimeout(function(){
1380                const isHovered = panel.matches(':hover');
1381                const isFocusedWithin = panel.matches(':focus-within');
1382                if (!isHovered && !isFocusedWithin) {
1383                    panel.style.display = "none";
1384                }
1385            }, 120);
1386        }
1387
1388        function getDates() {
1389            document.getElementById('start_date_value').value = getPeriodStart();
1390            document.getElementById('end_date_value').value = getPeriodEnd();
1391        }
1392
1393        function getPeriodStart() {
1394            var period = document.getElementById('input-period').value;
1395
1396            if (period !== '') {
1397                var regStart = / bis [0-9]{2}.[0-9]{2}.[0-9]{4}/;
1398                var start = period.replace(regStart, '');
1399                var startParts = start.split('.');
1400                return startParts[2] + '-' + startParts[1] + '-' + startParts[0];
1401            }
1402
1403            return '';
1404        }
1405
1406        function getPeriodEnd() {
1407            var period = document.getElementById('input-period').value;
1408
1409            if (period !== '') {
1410                var regEnd = /[0-9]{2}.[0-9]{2}.[0-9]{4} bis /;
1411                var end = period.replace(regEnd, '');
1412                var endParts = end.split('.');
1413                return endParts[2] + '-' + endParts[1] + '-' + endParts[0];
1414            }
1415
1416            return '';
1417        }
1418
1419        function getDuration() {
1420            var durationStr = document.getElementById('input-duration').value;
1421
1422            durationStr = durationStr.replace('–', '-')
1423
1424            if (!durationMapping[durationStr]) {
1425                return null;
1426            }
1427
1428            document.getElementById('duration_value').value = durationMapping[durationStr].days;
1429
1430            if (smg.type[travelType] === 'tt') {
1431                return durationMapping[durationStr].tt
1432            } else {
1433                return durationMapping[durationStr].urania
1434            }
1435        }
1436
1437        function addChildrenAgeInput(childrenCount) {
1438            const referenceChildrenAgeInput = $('.children_age_X');
1439            const clonedChildrenAgeInputContainer = referenceChildrenAgeInput.clone(true, true);
1440
1441            clonedChildrenAgeInputContainer.addClass(`children_age_${childrenCount}`).removeClass('children_age_X');
1442            clonedChildrenAgeInputContainer.children('.age-selector').children('input').attr('id', `children_age_${childrenCount}`);
1443            clonedChildrenAgeInputContainer.children('.age-selector').children('input').attr('placeholder', `Kind ${childrenCount}`);
1444            clonedChildrenAgeInputContainer.children('.age-selector').children('input').attr('name', 'children_age[]');
1445            clonedChildrenAgeInputContainer.children('label').attr('for', `children_age_${childrenCount}`);
1446            clonedChildrenAgeInputContainer.children('label').text(`Kind ${childrenCount}`);
1447            clonedChildrenAgeInputContainer.css('display', 'flex');
1448
1449            $('.travellers-children-wrapper').append(clonedChildrenAgeInputContainer);
1450        }
1451
1452        function removeChildrenAgeInput() {
1453            $('.children_age_'+ $('.counter_children').val()).remove();
1454        }
1455
1456        function filterTTResponse(response) {
1457            return response.matches.filter( function(val) { //callback function
1458                    return val;
1459            });
1460        }
1461
1462        function registerTypeAhead() {
1463            const settings = initDestinationField();
1464            $('#input-destination').typeahead('destroy');
1465
1466            $('#input-destination').typeahead({showHintOnFocus: true, minLength: 0}, settings)
1467                .on('typeahead:select', function (ev, suggestion) {
1468                    let destination = "";
1469
1470                    if (smg.type[travelType] === 'traffics') {
1471                        if (suggestion.regionList && suggestion.regionList !== '') {
1472                            let regionList = suggestion.regionList.toString().split(",");
1473                            destination = "regionList_" + regionList.join("|regionList_");
1474                        }
1475
1476                        if (suggestion.locationList && suggestion.locationList !== '') {
1477                            let locationList = suggestion.locationList.toString().split(",");
1478                            destination = "locationList_" + locationList.join("|locationList_") + '|regionList_' + suggestion.region.code;
1479                        }
1480
1481                        if (suggestion.hotelChainList && suggestion.hotelChainList !== '') {
1482                            let hotelChainList = suggestion.hotelChainList.toString().split(",");
1483                            destination = "hotelChainList_" + hotelChainList.join("|hotelChainList_");
1484                        }
1485
1486                        if (suggestion.giataHotelList && suggestion.giataHotelList !== '') {
1487                            let giataHotelList = suggestion.giataHotelList.toString().split(",");
1488                            destination = "giataHotelList_" + giataHotelList.join("|giataHotelList_") + '|locationList_' + suggestion.location.code;
1489                        }
1490
1491                        if (suggestion.airportList && suggestion.airportList !== '') {
1492                            let airportList = suggestion.airportList.toString().split(",");
1493                            destination = "airportList_" + airportList.join("|airportList_");
1494                        }
1495
1496                        if (suggestion.countryList && suggestion.countryList !== '') {
1497                            let countryList = suggestion.countryList.toString().split(",");
1498                            destination = "countryList_" + countryList.join("|countryList_");
1499                        }
1500                    } else if (smg.type[travelType] === 'tt') {
1501                        if (suggestion.regionCode && suggestion.regionCode !== '') {
1502                            let rgid = suggestion.regionCode.toString().split(",");
1503
1504                            destination = "rgid_" + rgid.join("|rgid_");
1505                        }
1506
1507                        if (suggestion.iffRegionCode && suggestion.iffRegionCode !== '') {
1508                            if (destination !== "") {
1509                                destination += "|";
1510                            }
1511
1512                            let rid = suggestion.iffRegionCode.toString().split(",");
1513
1514                            destination += "rid_" + rid.join("|rid_");
1515                        }
1516
1517                        if (suggestion.iffVillageCode && suggestion.iffVillageCode !== '') {
1518                            if (destination !== "") {
1519                                destination += "|";
1520                            }
1521
1522                            let cyid = suggestion.iffVillageCode.toString().split(",");
1523
1524                            destination += "cyid_" + cyid.join("|cyid_");
1525                        }
1526
1527                        if (suggestion.iff && suggestion.iff !== '') {
1528                            if (destination !== "") {
1529                                destination += "|";
1530                            }
1531
1532                            let aid = suggestion.iff.toString().split(",");
1533
1534                            destination += "aid_" + aid.join("|aid_");
1535                        }
1536
1537                        if (suggestion.isoCode && suggestion.isoCode !== '') {
1538                            if (destination !== "") {
1539                                destination += "|";
1540                            }
1541
1542                            let nid = suggestion.isoCode.toString().split(",");
1543
1544                            destination += "nid_" + nid.join("|nid_");
1545                        }
1546
1547                        if (suggestion.countryISO3166 && suggestion.countryISO3166 !== '') {
1548                            if (destination !== "") {
1549                                destination += "|";
1550                            }
1551
1552                            let nid = suggestion.countryISO3166.toString().split(",");
1553
1554                            destination += "nid_" + nid.join("|nid_");
1555                        }
1556                    } else {
1557                        if (suggestion.region && suggestion.region !== '') {
1558                            destination = suggestion.region;
1559                        }
1560
1561                        if (suggestion.city && suggestion.city !== '') {
1562                            if (destination !== "") {
1563                                destination += "|";
1564                            }
1565
1566                            destination += suggestion.city;
1567                        }
1568
1569                        if (suggestion.hotel && suggestion.hotel !== '') {
1570                            if (destination !== "") {
1571                                destination += "|";
1572                            }
1573
1574                            destination += suggestion.hotel;
1575                        }
1576                    }
1577
1578                    document.getElementById('destination_value').value = destination;
1579                })
1580        }
1581    }
1582)(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.