summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2020-06-14 12:01:15 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2020-06-14 12:01:15 +0200
commitc678af3ae45e979c09f20defe7dbe33509c32707 (patch)
treec6040e685a73aaceaba0c2aa62e838d322656736 /src
parent30c9a26be53ce4e14edd7f0a2472da42d793bbee (diff)
Rename Node.children to Node.childNodes to avoid confusion with element children, which contains the DOM children.
Diffstat (limited to 'src')
-rw-r--r--src/ws/node.js44
-rw-r--r--src/ws/view.js2
2 files changed, 31 insertions, 15 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";
// }
diff --git a/src/ws/view.js b/src/ws/view.js
index 26b7c0d..e7c36fb 100644
--- a/src/ws/view.js
+++ b/src/ws/view.js
@@ -90,7 +90,7 @@ function getElementAfter(e)
var element_after = null;
var min_y_diff = 9999999999999;
- for(var i = 0; i < e.target.children.length; ++i)
+ for(var i = 0; i < e.target.childNodes.length; ++i)
{
if(e.target.children[i].className != "node") // Only look at node elements
{