summaryrefslogtreecommitdiff
path: root/src/ws/node.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/ws/node.js')
-rw-r--r--src/ws/node.js23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/ws/node.js b/src/ws/node.js
index e2af81e..e9d68b6 100644
--- a/src/ws/node.js
+++ b/src/ws/node.js
@@ -72,15 +72,32 @@ Node.prototype.findNode = function(id, subscribeid)
return null;
};
-Node.prototype.addChild = function(node)
+Node.prototype.addChild = function(node, insertBeforeId)
{
if(node.parent != null)
{
node.parent.removeChild(node);
}
- this.children.push(node);
+
node.parent = this;
- this.element.appendChild(node.element);
+
+ inserted = false;
+ for(i = 0; i < this.children.length; ++i)
+ {
+ if(this.children[i].id == insertBeforeId)
+ {
+ this.children.splice(i - 1, 0, node);
+ this.element.insertBefore(node.element, this.element.childNodes[i + 2]);
+ inserted = true;
+ break;
+ }
+ }
+
+ if(inserted == false)
+ {
+ this.children.push(node);
+ this.element.appendChild(node.element);
+ }
};
Node.prototype.removeChild = function(node)