diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2020-06-11 21:32:44 +0200 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2020-06-11 21:32:44 +0200 |
commit | 476d0319fad29ceccfc157aed1a49c88fa499959 (patch) | |
tree | 824a13afebf24a2216e66ae74ca491b0896170b7 /src/ws/node.js | |
parent | 4877c43451d30a0ae0e2d3eaae6b684304683581 (diff) |
Add crude add-child button to each node.
Diffstat (limited to 'src/ws/node.js')
-rw-r--r-- | src/ws/node.js | 12 |
1 files changed, 11 insertions, 1 deletions
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"; |