Last active
June 13, 2019 15:18
-
-
Save lvbeck/f5ecf7164b57f50dbed86cffb7898a6f to your computer and use it in GitHub Desktop.
get operations of materials
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getOperationsByMaterial(material) { | |
var operations_types = ["Prepare", "CutOpen", "CutOff", "Test", "CutOff", "Observe", "Summary"]; // 数组长度已知 | |
var operations = []; // 可变长度数组 | |
// 读入该条文本数据并得到操作集 | |
operations = ["Prepare", "CutOpen", "CutOff", "Test", "CutOff", "Observe", "CutOff", "Test", "Summary"]; | |
return operations; | |
} | |
function formatOperationsArray(operations) { | |
// 左对齐并插值 | |
operations.pop(); // 删除最后一项操作(Summary) | |
for(var i=operations.length; i<13; i++){ | |
operations.push("NA"); // 补齐空操作 | |
} | |
operations[12] = 'Summary'; // 添加最后一项操作(Summary) | |
return operations; | |
} | |
function getMaterialOperations(materials){ | |
var material_operations = []; | |
for(var i=0; i<materials.length; i++){ | |
var operations = getOperationsByMaterial(materials[i]); | |
material_operations[i] = formatOperationsArray(operations); | |
} | |
return material_operations; | |
} | |
var materials = []; // 文本数组长度 120 | |
var result = getMaterialOperations(materials); // 得到结果数组 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment