From 476d0319fad29ceccfc157aed1a49c88fa499959 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Thu, 11 Jun 2020 21:32:44 +0200 Subject: Add crude add-child button to each node. --- src/ws/node.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/ws/node.js') diff --git a/src/ws/node.js b/src/ws/node.js index 3baeb02..a8208fd 100644 --- a/src/ws/node.js +++ b/src/ws/node.js @@ -94,7 +94,8 @@ Node.prototype.addChild = function(node, insertBeforeId) if(this.children[i].id == insertBeforeId) { this.children.splice(i - 1, 0, node); - this.element.insertBefore(node.element, this.element.childNodes[i + 2]); + // Insert after id, title and add button (ie. + 3) + this.element.insertBefore(node.element, this.element.childNodes[i + 3]); inserted = true; break; } @@ -138,6 +139,15 @@ Node.prototype.create = function() // oberveid from the node id alone. node.id = createId(this.subscribeid, this.id); + var add_child_button = document.createElement("div"); + add_child_button.name = "add_button"; + add_child_button.setAttribute("onclick", "addChild(event)"); + add_child_button.setAttribute("nodeid", this.id); + add_child_button.setAttribute("class", "add_button"); + var txt_plus = document.createTextNode("+"); + add_child_button.appendChild(txt_plus); + node.appendChild(add_child_button); + /* var subscribe_button = document.createElement("div"); subscribe_button.name = "subscribe_button"; -- cgit v1.2.3