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.js44
1 files changed, 30 insertions, 14 deletions
diff --git a/src/ws/node.js b/src/ws/node.js
index e659730..047c1e3 100644
--- a/src/ws/node.js
+++ b/src/ws/node.js
@@ -43,7 +43,7 @@ function Node(id, subscribeid)
{
this.id = id;
this.subscribeid = subscribeid;
- this.children = new Array();
+ this.childNodes = new Array();
this.attributes = {};
this.parent = null;
}
@@ -53,6 +53,21 @@ Node.prototype.dump = function()
alert(this.id);
};
+Node.prototype.dumpChildren = function(msg)
+{
+ console.log("Node " + this.id +
+ " children (" + this.childNodes.length + "):");
+ if(msg)
+ {
+ console.log(msg);
+ }
+
+ for(var i = 0; i < this.childNodes.length; i++)
+ {
+ console.log("[" + i + "]: " + this.childNodes[i].id);
+ }
+}
+
Node.prototype.findNode = function(id, subscribeid)
{
if(this.subscribeid != subscribeid)
@@ -65,9 +80,9 @@ Node.prototype.findNode = function(id, subscribeid)
return this;
}
- for(var i = 0; i < this.children.length; i++)
+ for(var i = 0; i < this.childNodes.length; i++)
{
- var node = this.children[i];
+ var node = this.childNodes[i];
var child = node.findNode(id, subscribeid);
if(child != null)
{
@@ -88,12 +103,13 @@ Node.prototype.addChild = function(node, insertBeforeId)
node.parent = this;
var inserted = false;
- for(var i = 0; i < this.children.length; ++i)
+ for(var i = 0; i < this.childNodes.length; ++i)
{
- if(this.children[i].id == insertBeforeId)
+ if(this.childNodes[i].id == insertBeforeId)
{
- this.children.splice(i, 0, node);
- this.children_element.insertBefore(node.element, this.children_element.childNodes[i]);
+ this.childNodes.splice(i, 0, node);
+ this.children_element.insertBefore(node.element,
+ this.children_element.childNodes[i]);
inserted = true;
break;
}
@@ -101,11 +117,11 @@ Node.prototype.addChild = function(node, insertBeforeId)
if(inserted == false)
{
- this.children.push(node);
+ this.childNodes.push(node);
this.children_element.appendChild(node.element);
}
-// if(this.children.length == 0)
+// if(this.childNodes.length == 0)
// {
// this.element.style.backgroundColor = "#aaa";
// }
@@ -117,14 +133,14 @@ Node.prototype.addChild = function(node, insertBeforeId)
Node.prototype.removeChild = function(node)
{
- this.children = this.children.filter(function(e)
- {
- return e.id != node.id;
- });
+ this.childNodes = this.childNodes.filter(function(e)
+ {
+ return e.id != node.id;
+ });
node.parent = null;
this.children_element.removeChild(node.element);
-// if(this.children.length == 0)
+// if(this.childNodes.length == 0)
// {
// this.element.style.backgroundColor = "#aaa";
// }