File indexing completed on 2024-12-29 04:51:03
0001 /* 0002 SPDX-FileCopyrightText: 2019 Volker Krause <vkrause@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 function parsePdf(pdf, node, triggerNode) 0008 { 0009 if (!triggerNode.result) { 0010 return null; 0011 } 0012 0013 var ptTicket = triggerNode.content 0014 var res = JsonLd.newEventReservation(); 0015 res.reservationFor.name = ptTicket.ticketLayout.text(0, 52, 19, 1).trim(); 0016 res.reservationFor.location.name = "Congress Center Leipzig"; 0017 res.reservationFor.location.address.streetAddress = "Messeallee"; 0018 res.reservationFor.location.address.postalCode = "04356"; 0019 res.reservationFor.location.address.addressLocality = "Leipzig"; 0020 res.reservationFor.location.address.addressCountry = "DE"; 0021 res.reservationFor.location.geo.latitude = 51.39737; 0022 res.reservationFor.location.geo.longitude = 12.39528; 0023 var start = ptTicket.rct2Ticket.firstDayOfValidity; 0024 start.setHours(11); 0025 res.reservationFor.startDate = start; 0026 var end = ptTicket.rct2Ticket.firstDayOfValidity; 0027 end.setDate(30); 0028 end.setHours(18); 0029 res.reservationFor.endDate = end; 0030 0031 // search for the QR code with the actual event code 0032 const barcodes = node.findChildNodes({ scope: "Descendants", mimeType: "text/plain", match: "^[0-9a-z]{40}$" }); 0033 for (let i = 0; i < barcodes.length; ++i) { 0034 if (barcodes[i].location != triggerNode.location) { 0035 continue; 0036 } 0037 res.reservedTicket.ticketToken = "qrcode:" + barcodes[i].content; 0038 } 0039 0040 // generate the second ticket for public transport 0041 var pt = JsonLd.clone(res); 0042 pt.reservedTicket.ticketToken = 'aztecbin:' + ByteArray.toBase64(triggerNode.content.rawData); 0043 pt.reservedTicket.name = "Public Transport"; 0044 0045 var reservations = new Array(); 0046 reservations.push(res); 0047 reservations.push(pt); 0048 return reservations; 0049 }