36 lines
1.2 KiB
JavaScript
36 lines
1.2 KiB
JavaScript
// getValue(getContextData('2', 'cds.NULL_DATA', ''));
|
|
|
|
function getValue(json) {
|
|
let result;
|
|
if (json == undefined || json.length === 0)
|
|
result = 'A) Invalid input!';
|
|
else {
|
|
let parsed;
|
|
try {
|
|
parsed = JSON.parse(json);
|
|
} catch (error) {
|
|
parsed = null;
|
|
}
|
|
if (parsed == null)
|
|
result = 'B) Invalid input!';
|
|
else {
|
|
let reactorType = parsed.rds == undefined ? '' : parsed.rds.reactorType == undefined ? '' : parsed.rds.reactorType;
|
|
if (parsed.rds == undefined)
|
|
result = '-';
|
|
else if (parsed.rds.loadLockSide == undefined)
|
|
result = '_ - ' + reactorType;
|
|
else if (parsed.rds.loadLockSide === 'L')
|
|
result = 'Left - ' + reactorType;
|
|
else if (parsed.rds.loadLockSide === 'R')
|
|
result = 'Right - ' + reactorType;
|
|
else
|
|
result = parsed.rds.loadLockSide + ' - ' + reactorType;
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
const json = '{"rds":{"prodSpec":{"recipesAndPatterns":[{"recipe":"6IN25_ROTR","pattern":"","patternSize":0,"tool":"TENCOR"}]}}}';
|
|
const testA = getValue(json);
|
|
if (testA !== '1')
|
|
throw 'Test A failed: ' + testA; |