I would like to go through each of the Rows then each of the points and capture a value tied to ColNum equaling to each iteration of j then get the max of these values. In easier terms I want to get Width of all object that have attribute ColNum = 2 then get the max of that.
This code is a modified javascript/html for Schneider electric TGML editior.
function load(evt) {
var TGMLDocument;
var comp;
var Point;
var Row;
var Row_;
var colNum;
var testArr1 = {};
var testArr2;
TGMLDocument = evt.getCurrentTarget().getOwnerDocument().getDocumentElement();
comp = evt.getCurrentTarget();
Row = nodeFilter(TGMLDocument, "Id", "GlobalRowsX");
// Point = nodeFilter(comp, "Id", "Point");
for (var i = 0; i < Row.length; i++) {
// console.log("The Row is", i);
Point = nodeFilter(Row[i], "Id", "Point");
for (var j = 0; j < Point.length; j++) {
console.log("The Row is " + i + ", The Point is " + j);
Point[j].setAttribute("ColNum", j);
console.log("The Column Number is " + Point[j].getAttribute("ColNum"));
}
}
}
function nodeFilter(cComp, attrName, attrValue, searchType) {
try {
var returnArr = [];
switch (searchType) {
case 'children':
var children = cComp.getChildNodes();
break;
case 'nested':
var children = cComp.getElementsByTagName('*');
break;
default:
var children = cComp.getChildNodes();
}
for (var i = 0; i < children.length; i++) {
try {
if (children.item([i]).hasAttribute(attrName)) {
if (children.item([i]).getAttribute(attrName) == attrValue) {
returnArr.push(children.item([i]));
}
}
} catch (err) {}
}
if (returnArr.length > 1) {
return returnArr;
} else if (returnArr.length > 0) {
return returnArr[0];
} else {
return null;
}
} catch (err) {}
}
I have tried using arrays, obj {}, and eval to create dynamic variables declarations.
Row and Point are returned as arrays.


