From f1f84c1c3873a89ad39cd6602023c2706d549ccf Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sun, 12 Jul 2020 18:24:43 +0200 Subject: Add child indicator. --- src/ws/node.js | 44 +++++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 17 deletions(-) (limited to 'src/ws/node.js') diff --git a/src/ws/node.js b/src/ws/node.js index 16eb9cc..67d9372 100644 --- a/src/ws/node.js +++ b/src/ws/node.js @@ -121,14 +121,14 @@ Node.prototype.addChild = function(node, insertBeforeId) this.children_element.appendChild(node.element); } -// if(this.childNodes.length == 0) -// { -// this.element.style.backgroundColor = "#aaa"; -// } -// else -// { -// this.element.style.backgroundColor = "#aaaa81"; -// } + if(this.childNodes.length > 0) + { + this.children_indicator_element.style.display = "inherit"; + } + else + { + this.children_indicator_element.style.display = "none"; + } }; Node.prototype.removeChild = function(node) @@ -140,14 +140,14 @@ Node.prototype.removeChild = function(node) node.parent = null; this.children_element.removeChild(node.element); -// if(this.childNodes.length == 0) -// { -// this.element.style.backgroundColor = "#aaa"; -// } -// else -// { -// this.element.style.backgroundColor = "#aaaa81"; -// } + if(this.childNodes.length > 0) + { + this.children_indicator_element.style.display = "inherit"; + } + else + { + this.children_indicator_element.style.display = "none"; + } }; Node.prototype.create = function() @@ -166,12 +166,22 @@ Node.prototype.create = function() this.children_element.className = "children"; this.element.appendChild(this.children_element); + var annotation = document.createElement("div"); + annotation.className = "annotation"; this.id_element = document.createElement("div"); this.id_element.className = "id"; var id_txt = document.createTextNode(this.id); this.id_element.appendChild(id_txt); - this.data_element.appendChild(this.id_element); + annotation.appendChild(this.id_element); + + this.children_indicator_element = document.createElement("div"); + this.children_indicator_element.className = "children_indicator"; + this.children_indicator_element.innerHTML = "⤷"; + this.children_indicator_element.style.display = "none"; + annotation.appendChild(this.children_indicator_element); + + this.data_element.appendChild(annotation); this.collapse_button = document.createElement("div"); this.collapse_button.name = "add_button"; -- cgit v1.2.3