From 068de75db793734dea784be76db8d7a72e55b97e Mon Sep 17 00:00:00 2001 From: baigner <benedikt.aigner@rwth-aachen.de> Date: Tue, 17 Apr 2018 09:36:38 +0200 Subject: [PATCH] New data structure try 4: Continued interpretation of new tree data in the html file (Not finished yet!!!) Former-commit-id: cf5de0902eb57a55bc9a3190f08ba3faadcd91b9 --- kadmos/vistoms/templates/VISTOMS.html | 70 +++++++++++++++++++++------ 1 file changed, 54 insertions(+), 16 deletions(-) diff --git a/kadmos/vistoms/templates/VISTOMS.html b/kadmos/vistoms/templates/VISTOMS.html index 5a7f75ff9..ec5a91040 100644 --- a/kadmos/vistoms/templates/VISTOMS.html +++ b/kadmos/vistoms/templates/VISTOMS.html @@ -21483,36 +21483,74 @@ //2) objArray --> Array of current nodes //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) { - anElement.children = []; - var numberOfChildren = anElement.children.length; - var newChild = {}; - anElement.children.append(newChild); - anElement.children.forEach(function(aChild) + //If element has no children yet, initialize children array + if (!aParent.children){aParent.children = [];} + //remove the first element from the xPath list + let newXPath_list = JSON.parse(JSON.stringify(xPath_list)); + 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) { var xPath_split = element.xpath.split("/"); var index = xPath_split.indexOf(""); if (index > -1) {xPath_split.splice(index, 1);} - console.log(element) - console.log(xPath_split) - appendElement(element, xPath_split) + root.level = 0 + root.name = xPath_split[0] + 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) { -- GitLab