Commit 37c9f28d authored by Volker Krause's avatar Volker Krause
Browse files

Further improve backward compatibility on the Context JS API

This fixes scripts checking for page numbers or previous result data being
set at all.
parent ef4a1771
......@@ -93,7 +93,7 @@
}
],
"objectName": "",
"pdfPageNumber": 0,
"pdfPageNumber": -1,
"senderDate": "Fri Feb 17 15:18:00 2012 GMT+0100"
}
]
......@@ -86,10 +86,8 @@
]
},
{
"data": [
],
"objectName": "",
"pdfPageNumber": 0,
"pdfPageNumber": -1,
"senderDate": "Invalid Date"
}
]
......@@ -94,7 +94,7 @@
}
],
"objectName": "",
"pdfPageNumber": 0,
"pdfPageNumber": -1,
"senderDate": "Invalid Date"
}
]
......@@ -66,10 +66,8 @@
]
},
{
"data": [
],
"objectName": "",
"pdfPageNumber": 0,
"pdfPageNumber": -1,
"senderDate": "Mon Aug 19 20:23:28 2019 GMT+0200"
}
]
......@@ -77,10 +77,8 @@
]
},
{
"data": [
],
"objectName": "",
"pdfPageNumber": 0,
"pdfPageNumber": -1,
"senderDate": "Mon Aug 19 20:23:28 2019 GMT+0200"
}
]
......@@ -14,10 +14,8 @@
},
{
"barcode": "Hello World!\n",
"data": [
],
"objectName": "",
"pdfPageNumber": 0,
"pdfPageNumber": -1,
"senderDate": "Invalid Date"
}
]
......@@ -463,10 +463,8 @@
]
},
{
"data": [
],
"objectName": "",
"pdfPageNumber": 0,
"pdfPageNumber": -1,
"senderDate": "Invalid Date"
}
]
......@@ -111,7 +111,12 @@ ExtractorResult ExtractorScriptEngine::execute(const ScriptExtractor *extractor,
const auto engineReset = qScopeGuard([&node]{ node.setScriptEngine(nullptr); });
// ### legacy context API, replace that by passing trigger node as a third argument eventually
d->m_context->m_data = d->m_engine.toScriptValue(triggerNode.result().jsonLdResult());
if (triggerNode.result().isEmpty()) {
d->m_context->m_data = {};
} else {
d->m_context->m_data = d->m_engine.toScriptValue(triggerNode.result().jsonLdResult());
}
if (triggerNode.isA<Uic9183Parser>()) {
d->m_context->m_barcode = triggerNode.content<Uic9183Parser>().rawData();
} else if (triggerNode.isA<VdvTicket>()) {
......@@ -123,7 +128,13 @@ ExtractorResult ExtractorScriptEngine::execute(const ScriptExtractor *extractor,
} else {
d->m_context->m_barcode.clear();
}
d->m_context->m_pdfPageNum = triggerNode.location().toInt();
if (triggerNode.location().isNull()) {
d->m_context->m_pdfPageNum = -1;
} else {
d->m_context->m_pdfPageNum = triggerNode.location().toInt();
}
d->m_context->m_senderDate = node.contextDateTime();
d->m_jsonLdApi->setContextDate(node.contextDateTime());
......
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