Commit 68abdc37 authored by Volker Krause's avatar Volker Krause
Browse files

Port Norwegian extractor away from old Context API

parent f09b26d3
......@@ -4,9 +4,9 @@
SPDX-License-Identifier: LGPL-2.0-or-later
*/
function parsePage(page)
function parsePage(page, triggerNode)
{
var res = JsonLd.newFlightReservation();
var res = triggerNode ? triggerNode.result[0] : JsonLd.newFlightReservation();
var pnr = page.text.match(/\nBooking reference.*(.{6})\n/);
if (!pnr)
......@@ -47,21 +47,17 @@ function parsePage(page)
res.boardingGroup = group[1];
}
if (Context.barcode) {
res.reservedTicket.ticketToken = "azteccode:" + Context.barcode;
}
return res;
}
function extractPdf(pdf) {
if (Context.pdfPageNumber >= 0) {
return parsePage(pdf.pages[Context.pdfPageNumber]);
function extractPdf(pdf, node, triggerNode) {
if (triggerNode.location != undefined) {
return parsePage(pdf.pages[triggerNode.location], triggerNode);
}
var results = new Array();
var pages = pdf.pages;
for (var i = 0; i < pages.length; ++i) {
results.push(parsePage(pages[i]));
results.push(parsePage(pages[i], undefined));
}
return results;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment