File indexing completed on 2024-12-29 04:51:02
0001 /* 0002 SPDX-FileCopyrightText: 2021 Volker Krause <vkrause@kde.org> 0003 SPDX-License-Identifier: LGPL-2.0-or-later 0004 */ 0005 0006 function parseConfirmation(text, node) { 0007 var flightRes = new Array(); 0008 var idx = 0; 0009 while (true) { 0010 const flight = text.substr(idx).match(/\[\d+\]\n(\d{1,2} \w+)\(.*\) ([A-Z0-9]+) (\d+)\n(.*) - (.*)\n.*?(\d{1,2}:\d{2})-(\d{1,2}:\d{2})/); 0011 if (!flight) { 0012 break; 0013 } 0014 idx += flight.index + flight[0].length; 0015 0016 var f = JsonLd.newFlightReservation(); 0017 f.reservationFor.departureAirport.name = flight[4]; 0018 f.reservationFor.arrivalAirport.name = flight[5]; 0019 f.reservationFor.departureTime = JsonLd.toDateTime(flight[1] + flight[6], "d MMMMhh:mm", "en"); 0020 f.reservationFor.arrivalTime = JsonLd.toDateTime(flight[1] + flight[7], "d MMMMhh:mm", "en"); 0021 f.reservationFor.airline.iataCode = flight[2]; 0022 f.reservationFor.flightNumber = flight[3]; 0023 flightRes.push(f); 0024 } 0025 0026 const seats = text.match(/\[Seat Number\]([\s\S]+?)\n\[/); 0027 if (!seats) { 0028 return flightRes; 0029 } 0030 var reservations = new Array(); 0031 for (seat of seats[1].split(/\n/)) { 0032 const passenger = seat.match(/(.*) (\d+[A-Z])[\n\[]/); 0033 if (!passenger) { 0034 continue; 0035 } 0036 for (flight of flightRes) { 0037 var res = JsonLd.clone(flight); 0038 res.underName.name = passenger[1]; 0039 res.airplaneSeat = passenger[2]; 0040 reservations.push(res); 0041 } 0042 } 0043 return reservations; 0044 }