mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-19 03:45:30 +08:00
Ref T658, improved matching script examples
This commit is contained in:
34
resources/share/matchingscript/changeAirline.reverse.js
Normal file
34
resources/share/matchingscript/changeAirline.reverse.js
Normal file
@@ -0,0 +1,34 @@
|
||||
// This is a demo file demonstrating some capabilities of the
|
||||
// matching script engine
|
||||
// This script runs after(!) the reverse lookup has been completed
|
||||
//
|
||||
// inObject values as from network
|
||||
// outObject to be returned back to matching engine
|
||||
// matchedObject the result so far, same as inObject for reverse lookup
|
||||
// modelSet user's current model set, not available in reverse lookup
|
||||
// webServices wraps access to swift web services
|
||||
//
|
||||
// outObject.rerun = true => rerun matching or reverse lookup after the value has been changed again, like a 2nd pass
|
||||
// outObject.modified = true => tell matching or reverse lookup that something has been changed
|
||||
//
|
||||
(function () {
|
||||
// avoid breaking matching/reverse lookup
|
||||
try {
|
||||
// EASYJET?
|
||||
if (inObject.airlineIcao === "EJU") {
|
||||
outObject.airlineIcao = "EZY";
|
||||
outObject.dbAirlineIcaoId = 2217;
|
||||
outObject.logMessage = "Changing EJU to EZY"; // display log
|
||||
outObject.modelString = ""; // invalidate any model
|
||||
outObject.dbModelId = -1; // invalidate
|
||||
outObject.modified = true;
|
||||
outObject.rerun = true; // treat the changed values as coming from network
|
||||
} else {
|
||||
outObject.logMessage = "No airline change, keeping " + inObject.airlineIcao;
|
||||
}
|
||||
} catch (err) {
|
||||
return err.toString();
|
||||
}
|
||||
|
||||
return outObject;
|
||||
})
|
||||
Reference in New Issue
Block a user