File indexing completed on 2024-12-29 04:51:02
0001 /* 0002 SPDX-FileCopyrightText: 2022 Volker Krause <vkrause@kde.org> 0003 SPDX-License-Identifier: LGPL-2.0-or-later 0004 */ 0005 0006 function parsePdf(pdf) { 0007 const text = pdf.text; 0008 let idx = 0; 0009 let reservations = []; 0010 while (true) { 0011 const trip = text.substr(idx).match(/Billet n° \d+ \/ \d+\n.*\n *(.*?) +(.*?) +(.*?) +(.*)\n *(\d{2}\/\d{2}\/\d{4}) +(\d{2}\/\d{2}\/\d{4})\n *(\d{2}:\d{2}) +(\d{2}:\d{2}) +(\d{2}:\d{2}) +(\d{2}:\d{2})\n +billet n° (\d+)\n/); 0012 if (!trip) { 0013 break; 0014 } 0015 let out = JsonLd.newBoatReservation(); 0016 out.reservationFor.departureBoatTerminal.name = trip[1]; 0017 out.reservationFor.arrivalBoatTerminal.name = trip[2]; 0018 out.reservationFor.departureTime = JsonLd.toDateTime(trip[5] + trip[7], 'dd/MM/yyyyhh:mm', 'fr'); 0019 out.reservationFor.arrivalTime = JsonLd.toDateTime(trip[5] + trip[8], 'dd/MM/yyyyhh:mm', 'fr'); 0020 out.reservationNumber = trip[11]; 0021 out.reservedTicket.ticketToken = 'barcode128:' + trip[11]; 0022 reservations.push(out); 0023 0024 let ret = JsonLd.newBoatReservation(); 0025 ret.reservationFor.departureBoatTerminal.name = trip[3]; 0026 ret.reservationFor.arrivalBoatTerminal.name = trip[4]; 0027 ret.reservationFor.departureTime = JsonLd.toDateTime(trip[6] + trip[9], 'dd/MM/yyyyhh:mm', 'fr'); 0028 ret.reservationFor.arrivalTime = JsonLd.toDateTime(trip[6] + trip[10], 'dd/MM/yyyyhh:mm', 'fr'); 0029 ret.reservationNumber = trip[11]; 0030 ret.reservedTicket.ticketToken = 'barcode128:' + trip[11]; 0031 reservations.push(ret); 0032 0033 idx += trip.index + trip[0].length; 0034 } 0035 return reservations; 0036 }