File indexing completed on 2024-12-29 04:51:05

0001 /*
0002    SPDX-FileCopyrightText: 2019 Volker Krause <vkrause@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 function parseHtml(doc)
0008 {
0009     var text = doc.root.recursiveContent;
0010     var res = JsonLd.newLodgingReservation();
0011 
0012     res.reservationNumber = text.match(/Booking #:\s*(.*?)\n/)[1];
0013     res.reservationFor.name = doc.eval("//h1")[0].content;
0014 
0015     res.checkinTime = JsonLd.toDateTime(text.match(/Arrival:\s*(.*?)\n/)[1], "dd MMM yyyy", "en");
0016     res.checkoutTime = JsonLd.toDateTime(text.match(/Departure:\s*(.*?)\n/)[1], "dd MMM yyyy", "en");
0017 
0018     res.reservationFor.geo.latitude = text.match(/Latitude:\s(-?\d+.\d+)/)[1] * 1.0;
0019     res.reservationFor.geo.longitude = text.match(/Longitude:\s(-?\d+.\d+)/)[1] * 1.0;
0020 
0021     var addr = text.match(/Lodging information[\n\s]+(.*?)\n[\n\s]*(.*?)\n[\n\s]*(.*?)\n[\n\s]*(?:Telep|P)hone: (.*?)\n.*\n*\s*Email:\s+(.*?)\n\s*Internet:\s+(.*?)\n/);
0022     res.reservationFor.address.streetAddress = addr[2];
0023     res.reservationFor.address.addressLocality = addr[3];
0024     res.reservationFor.telephone = addr[4];
0025     res.reservationFor.email = addr[5];
0026     res.reservationFor.url = addr[6];
0027 
0028     const guest = text.match(/Guest data[\n\s]+Name: (.*)/);
0029     res.underName.name = guest[1];
0030 
0031     return res;
0032 }