From 0598d697ee4657fd278fa9017888d7ca72024a0b Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Sat, 11 Feb 2012 17:10:49 +0000 Subject: [PATCH] Reordered dependencies within the WikiTextParseTree dump --- js/WikiTextParseTree.js | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/js/WikiTextParseTree.js b/js/WikiTextParseTree.js index 04164ce7f..8b362f160 100644 --- a/js/WikiTextParseTree.js +++ b/js/WikiTextParseTree.js @@ -296,6 +296,25 @@ WikiTextParseTree.prototype.toString = function(type) { ["treeNode"] )]; }, + renderDependencies = function(dependencies) { + var output = []; + for(var d in dependencies) { + if(d === "dependentAll") { + output.push(HTML.splitLabel("dependency",[HTML.text(d)],[HTML.text(dependencies[d])])); + } else { + var dependents = []; + for(var t in dependencies[d]) { + dependents.push(t); + } + output.push(HTML.splitLabel("dependency",[HTML.text(d)],[HTML.text(dependents.join(", "))])); + } + } + return HTML.splitLabel( + "dependencies", + [HTML.text("Dependencies")], + output + ); + }, renderMacroNode = function(node) { var params = [], ret = []; @@ -317,23 +336,7 @@ WikiTextParseTree.prototype.toString = function(type) { ["treeNode"] )); if(node.dependencies) { - var dependencies = []; - for(var d in node.dependencies) { - if(d === "dependentAll") { - dependencies.push(HTML.splitLabel("dependency",[HTML.text(d)],[HTML.text(node.dependencies[d])])); - } else { - var dependents = []; - for(var t in node.dependencies[d]) { - dependents.push(t); - } - dependencies.push(HTML.splitLabel("dependency",[HTML.text(d)],[HTML.text(dependents.join(","))])); - } - } - ret.push(HTML.splitLabel( - "dependencies", - [HTML.text("Dependencies")], - dependencies - )); + ret.push(renderDependencies(node.dependencies)); } if(node.children) { ret.push(renderArray(node.children)); @@ -382,7 +385,7 @@ WikiTextParseTree.prototype.toString = function(type) { return renderHtmlNode(node); } }; - return HTML(renderArray(this.tree),type); + return HTML(renderDependencies(this.dependencies),type) + HTML(renderArray(this.tree),type); }; exports.WikiTextParseTree = WikiTextParseTree;