Skip to content
Snippets Groups Projects
Commit 068de75d authored by baigner's avatar baigner
Browse files

New data structure try 4: Continued interpretation of new tree data in the...

New data structure try 4: Continued interpretation of new tree data in the html file (Not finished yet!!!)


Former-commit-id: cf5de0902eb57a55bc9a3190f08ba3faadcd91b9
parent ea31b364
No related branches found
No related tags found
No related merge requests found
...@@ -21483,36 +21483,74 @@ ...@@ -21483,36 +21483,74 @@
//2) objArray --> Array of current nodes //2) objArray --> Array of current nodes
//3) xPathList --> Array of actually used pipeLine data //3) xPathList --> Array of actually used pipeLine data
//aigner:HIER WEITER!!
function appendElement(anElement, xPath_list) //aigner: HIER WEITER!!!
//aigner:New implementation start
//######################################################################
function childExists(name, children){
var exists = false
children.forEach(function(child)
{
if (child.name == name)
{
exists = true;
}
})
return exists;
}
function appendChildren(aParent, xPath_list)
{ {
if (xPath_list.length > 1) if (xPath_list.length > 1)
{ {
anElement.children = []; //If element has no children yet, initialize children array
var numberOfChildren = anElement.children.length; if (!aParent.children){aParent.children = [];}
var newChild = {}; //remove the first element from the xPath list
anElement.children.append(newChild); let newXPath_list = JSON.parse(JSON.stringify(xPath_list));
anElement.children.forEach(function(aChild) newXPath_list.shift();
console.log(xPath_list)
console.log(newXPath_list)
//Create a new child element, if it does not exist yet
if (!childExists(xPath_list[0], aParent.children))
{
//Create a new child object
var newChild = {level: aParent.level+1, name: xPath_list[0], type: "variable"};
aParent.children.push(newChild);
}
aParent.children.forEach(function(aChild)
{
<!-- console.log("Children will be appended for: " + aChild.name) -->
<!-- console.log(newXPath_list) -->
appendChildren(aChild, newXPath_list)
})
} }
{
}
} }
function buildTree(elements) var newTree = {};
function buildTree(root, elements)
{ {
elements.forEach(function(element) elements.forEach(function(element)
{ {
var xPath_split = element.xpath.split("/"); var xPath_split = element.xpath.split("/");
var index = xPath_split.indexOf(""); var index = xPath_split.indexOf("");
if (index > -1) {xPath_split.splice(index, 1);} if (index > -1) {xPath_split.splice(index, 1);}
console.log(element) root.level = 0
console.log(xPath_split) root.name = xPath_split[0]
appendElement(element, xPath_split) console.log("####################")
console.log(element.xpath)
appendChildren(root, xPath_split)
}) })
} }
buildTree(treeData) buildTree(newTree, treeData)
console.log(newTree)
return
console.log("I passed the return!!!")
//######################################################################
//aigner:New implementation end
function getXPathForAllNodes(aNode, anxPath) function getXPathForAllNodes(aNode, anxPath)
{ {
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment