File indexing completed on 2024-12-29 04:51:02
0001 /* 0002 SPDX-FileCopyrightText: 2024 Volker Krause <vkrause@kde.org> 0003 SPDX-License-Identifier: LGPL-2.0-or-later 0004 */ 0005 0006 function extractPdfEticket(pdf, node, barcode) { 0007 const text = pdf.pages[barcode.location].text; 0008 const pnr = barcode.content.match(/(\d{13})\/([A-Z0-9]{6})/); 0009 const pas = text.match(/(?:PASSENGER :|NAME) *(\S.*\S)\/(\S.*\S)\n/); 0010 let reservations = []; 0011 let idx = 0; 0012 while (true) { 0013 const leg = text.substr(idx).match(/\] (\S.*?\S) (?: +(\S+) )? +([A-Z-0-9]{2})(\d{1,4}) +(\d{2}[A-Z]{3}\d{2}) +[A-Z]{3} +(\d{4}).*\n.*\n *(\S.*?\S) (?: +(\S+) )? +(\d{2}[A-K])? +(\d{2}[A-Z]{3}\d{2}) +[A-Z]{3} +(\d{4}) *(\S.*\S)/); 0014 if (!leg) 0015 break; 0016 idx += leg.index + leg[0].length; 0017 0018 let res = JsonLd.newFlightReservation(); 0019 res.reservedTicket.ticketNumber = pnr[1]; 0020 res.reservationNumber = pnr[2]; 0021 res.reservationFor.departureAirport.name = leg[1]; 0022 res.reservationFor.departureTerminal = leg[2]; 0023 res.reservationFor.airline.iataCode = leg[3]; 0024 res.reservationFor.flightNumber = leg[4]; 0025 res.reservationFor.departureTime = JsonLd.toDateTime(leg[5] + leg[6], "ddMMMyyhhmm", "en"); 0026 res.reservationFor.arrivalAirport.name = leg[7]; 0027 res.reservationFor.arrivalTerminal = leg[8]; 0028 res.airplaneSeat = leg[9] 0029 res.reservationFor.arrivalTime = JsonLd.toDateTime(leg[10] + leg[11], "ddMMMyyhhmm", "en"); 0030 res.reservationFor.airline.name = leg[12]; 0031 res.underName.familyName = pas[1]; 0032 res.underName.givenName = pas[2]; 0033 reservations.push(res); 0034 } 0035 0036 return reservations; 0037 }