Commit c736c837 authored by Volker Krause's avatar Volker Krause
Browse files

Handle alternative MAV barcode format

parent 8dec9ce2
Pipeline #208176 passed with stage
in 3 minutes and 52 seconds
......@@ -9,9 +9,9 @@ function parseDateTime(value)
return new Date(value * 1000 + base.getTime());
}
// see https://community.kde.org/KDE_PIM/KItinerary/MAV_Barcode
function parseBarcode(data) {
var res = JsonLd.newTrainReservation();
// see https://community.kde.org/KDE_PIM/KItinerary/MAV_Barcode
const inner = ByteArray.inflate(data.slice(2));
const view = new DataView(inner);
res.reservationNumber = ByteArray.decodeUtf8(inner.slice(0, 17));
......@@ -40,6 +40,21 @@ function parseBarcode(data) {
return res;
}
function parseBarcodeAlternative(data)
{
var res = JsonLd.newTrainReservation();
res.reservationNumber = ByteArray.decodeUtf8(data.slice(2, 19));
res.reservationFor.provider.identifier = "uic:" + ByteArray.decodeUtf8(data.slice(20, 24));
const inner = ByteArray.inflate(data.slice(24));
const header2 = new DataView(inner.slice(0, 19));
if (header2.getUInt8(8) == 0x81) {
res.underName.name = ByteArray.decodeUtf8(inner.slice(19, 19 + 45));
}
res.reservedTicket.ticketToken = "pdf417bin:" + ByteArray.toBase64(data);
return res;
}
function parseTicket(pdf, node, triggerNode) {
var reservations = new Array();
const text = pdf.pages[triggerNode.location].text;
......
......@@ -11,12 +11,29 @@
"mimeType": "application/octet-stream",
"script": "mav.js"
},
{
"filter": [
{
"match": "^\\x05\\01[\\dA-Z]{17}\\x001155",
"mimeType": "application/octet-stream",
"scope": "Current"
}
],
"function": "parseBarcodeAlternative",
"mimeType": "application/octet-stream",
"script": "mav.js"
},
{
"filter": [
{
"match": "^\\x04\\x03\\x1f\\x8b",
"mimeType": "application/octet-stream",
"scope": "Descendants"
},
{
"match": "^\\x05\\01[\\dA-Z]{17}\\x001155",
"mimeType": "application/octet-stream",
"scope": "Descendants"
}
],
"function": "parseTicket",
......
Supports Markdown
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