File indexing completed on 2024-12-29 04:51:04
0001 /* 0002 SPDX-FileCopyrightText: 2019 Volker Krause <vkrause@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 function main(pdf, node, triggerNode) { 0008 var res = triggerNode.result[0]; 0009 var page = pdf.pages[triggerNode.location]; 0010 0011 // needs to be done manually as we don't have PDF ctime for this to work automatically 0012 var date = page.text.match(/Date +(\d\d \w{3} \d\d)/); 0013 var depTime = page.text.match(/Departure Time\s+(\d\d:\d\d)/); 0014 res.reservationFor.departureTime = JsonLd.toDateTime(date[1] + depTime[1], "dd MMM yyhh:mm", "en"); 0015 var boardingTime = page.text.match(/Boarding Time\s+(\d\d:\d\d)/); 0016 res.reservationFor.boardingTime = JsonLd.toDateTime(date[1] + boardingTime[1], "dd MMM yyhh:mm", "en"); 0017 return res; 0018 } 0019 0020 function parseHtml(doc) { 0021 var pnrElem = doc.eval('//td[@class="barcode1"]')[0]; 0022 var pnr = pnrElem.content.match(/: ([A-Z0-9]{6})/)[1]; 0023 0024 var reservations = new Array(); 0025 var row = doc.eval('//table//table//tr/th/..')[2].nextSibling; 0026 while (!row.isNull) { 0027 var res = JsonLd.newFlightReservation(); 0028 res.reservationNumber = pnr; 0029 0030 var f = row.recursiveContent.match(/(\d{2} \S{3} \d{2})[\n\s](.*)[\n\s]\s*(\d{2}:\d{2})[\n\s]\s*([A-Z0-9]{2}) *(\d{1,4})[\s\n]*(?:.*)*\s*(\d{2}:\d{2})\s*(.*)\s*(\d{2}:\d{2})/); 0031 0032 res.reservationFor.departureAirport.name = f[2]; 0033 res.reservationFor.arrivalAirport.name = f[7]; 0034 res.reservationFor.airline.iataCode = f[4]; 0035 res.reservationFor.flightNumber = f[5]; 0036 res.reservationFor.departureTime = JsonLd.toDateTime(f[1]+f[3], "dd MMM yyhh:mm", "en"); 0037 res.reservationFor.arrivalTime = JsonLd.toDateTime(f[1]+f[8], "dd MMM yyhh:mm", "en"); 0038 0039 reservations.push(res); 0040 row = row.nextSibling; 0041 } 0042 0043 return reservations; 0044 }