File indexing completed on 2024-12-29 04:51:04
0001 /* 0002 SPDX-FileCopyrightText: 2022 Volker Krause <vkrause@kde.org> 0003 SPDX-License-Identifier: LGPL-2.0-or-later 0004 */ 0005 0006 function parseTicket(content, node, triggerNode) { 0007 const page = content.pages[triggerNode.location]; 0008 const text = page.textInRect(0.0, 0.0, 0.5, 0.5); 0009 let res = JsonLd.newBoatReservation(); 0010 res.reservedTicket.ticketToken = 'code39:' + triggerNode.content; 0011 res.reservationNumber = text.match(/TICKET ID\n\s+(\d+)/)[1]; 0012 0013 const dep = text.match(/Port of departure (.*)\n(?:.*\n)?\s*(\d{2}:\d{2} \d{2} \w+, \d{4})/); 0014 res.reservationFor.departureBoatTerminal.name = dep[1]; 0015 res.reservationFor.departureBoatTerminal.geo = JsonLd.toGeoCoordinates(page.links[0].url); 0016 res.reservationFor.departureTime = JsonLd.toDateTime(dep[2], 'hh:mm dd MMMM, yyyy', 'it'); 0017 0018 const arr = text.match(/Port of arrival (.*)\n(?:.*\n)?\s*(\d{2}:\d{2} \d{2} \w+, \d{4})/); 0019 res.reservationFor.arrivalBoatTerminal.name = arr[1]; 0020 res.reservationFor.arrivalTime = JsonLd.toDateTime(arr[2], 'hh:mm dd MMMM, yyyy', 'it'); 0021 0022 const rightTop = page.textInRect(0.5, 0.0, 1.0, 0.5); 0023 res.underName.name = rightTop.match(/(.*)\n/)[1]; 0024 0025 const price = rightTop.match(/TOTAL[\s\n]+(€ \d+,\d\d)/); 0026 if (price) 0027 ExtractorEngine.extractPrice(price[1], res); 0028 0029 return res; 0030 }