From c42e96d3607f62165330c5828e3807fa1a1e59a9 Mon Sep 17 00:00:00 2001 From: hppeng Date: Thu, 23 Jun 2022 07:53:55 -0700 Subject: [PATCH] Finally fixed bugs -- please test your code before pushing bad hpp --- js/display_atree.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/js/display_atree.js b/js/display_atree.js index 85c2872..8d2cf7a 100644 --- a/js/display_atree.js +++ b/js/display_atree.js @@ -68,17 +68,19 @@ function construct_AT(elem, tree) { // connect corners - let connector = connect_elem.cloneNode() - connector.style.backgroundImage = "url('../media/atree/connect_angle.png')"; - connector.id = "r" + parent_node.display.row + "-c" + node.display.col + "-angle" - document.getElementById("atree-row-" + parent_node.display.row).children[node.display.col].appendChild(connector); - if (parent_node.display.col > node.display.col && (parent_node.display.row != node.display.row)) { - connector.classList.add("rotate-180"); + if (parent_node.display.row != node.display.row && parent_node.display.col != node.display.col) { + let connector = connect_elem.cloneNode() + connector.style.backgroundImage = "url('../media/atree/connect_angle.png')"; + connector.id = "r" + parent_node.display.row + "-c" + node.display.col + "-angle" + document.getElementById("atree-row-" + parent_node.display.row).children[node.display.col].appendChild(connector); + if (parent_node.display.col > node.display.col) { + connector.classList.add("rotate-180"); + } + else {// if (parent_node.display.col < node.display.col && (parent_node.display.row != node.display.row)) { + connector.classList.add("rotate-270"); + } + resolve_connector(document.getElementById("atree-row-" + parent_node.display.row).children[node.display.col]); } - else if (parent_node.display.col < node.display.col && (parent_node.display.row != node.display.row)) { - connector.classList.add("rotate-270"); - } - resolve_connector(document.getElementById("atree-row-" + parent_node.display.row).children[node.display.col]); } // create node