File indexing completed on 2024-12-29 04:51:03
0001 /* 0002 SPDX-FileCopyrightText: 2017 Volker Krause <vkrause@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 function main(text) { 0008 var reservations = new Array(); 0009 var bookingRef = text.match(/(?:Individual reservation code|Individueller Buchungscode):?\s*(?:\(beim Check-In angeben\))?\s*\*\* ([A-Z0-9]{6})/); 0010 0011 var pos = 0; 0012 while (true) { 0013 var flightLine = text.substr(pos).match(/(?:Flight|Flug): ([0-9]{2}\.[0-9]{2}\.[0-9]{4})\s*\|\s*(?:Flugnummer\:)?\s*([A-Z0-9]{2}) ([0-9]{3,4}).*\n/); 0014 if (!flightLine) 0015 break; 0016 var idx = flightLine.index + flightLine[0].length; 0017 0018 var res = JsonLd.newFlightReservation(); 0019 res.reservationNumber = bookingRef[1]; 0020 res.reservationFor.flightNumber = flightLine[3]; 0021 0022 res.reservationFor.airline.iataCode = flightLine[2]; 0023 0024 var opByLine = text.substr(pos + idx).match(/^\s*\* (?:[Oo]perated by|durchgeführt von) (.*)\n/); 0025 if (opByLine) { 0026 idx += opByLine.index + opByLine[0].length; 0027 res.reservationFor.airline.name = opByLine[1]; 0028 } 0029 0030 var depLine = text.substr(pos + idx).match(/(?:Departure|Abflug):?\s*([0-9]{2}:[0-9]{2})\s+(.*)\n/); 0031 if (!depLine) 0032 break; 0033 idx += depLine.index + depLine[0].length; 0034 res.reservationFor.departureTime = JsonLd.toDateTime(flightLine[1] + ' ' + depLine[1], "dd.MM.yyyy hh:mm", "en"); 0035 res.reservationFor.departureAirport.name = depLine[2]; 0036 0037 var arrLine = text.substr(pos + idx).match(/(?:Arrival|Ankunft):?\s*([0-9]{2}:[0-9]{2})\s+(.*)\n/); 0038 if (!arrLine) 0039 break; 0040 idx += arrLine.index + arrLine[0].length; 0041 res.reservationFor.arrivalTime = JsonLd.toDateTime(flightLine[1] + ' ' + arrLine[1], "dd.MM.yyyy hh:mm", "en"); 0042 res.reservationFor.arrivalAirport.name = arrLine[2]; 0043 0044 reservations.push(res); 0045 if (idx == 0) 0046 break; 0047 pos += idx; 0048 } 0049 0050 return reservations; 0051 }