summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ws/munia.css13
-rw-r--r--src/ws/node.js12
-rw-r--r--src/ws/proto.js4
-rw-r--r--src/ws/view.js12
4 files changed, 37 insertions, 4 deletions
diff --git a/src/ws/munia.css b/src/ws/munia.css
index 93e5ffe..3a94e85 100644
--- a/src/ws/munia.css
+++ b/src/ws/munia.css
@@ -60,6 +60,19 @@ body
*/
}
+.node .add_button
+{
+ float: right;
+ display: inline-box;
+ width: 1em;
+ height: 1em;
+ font-size: 0.5em;
+ vertical-align: text-center;
+ text-align: center;
+ border: solid green 2px;
+ cursor: pointer;
+}
+
.board
{
width: *;
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";
diff --git a/src/ws/proto.js b/src/ws/proto.js
index f597503..234410a 100644
--- a/src/ws/proto.js
+++ b/src/ws/proto.js
@@ -224,9 +224,9 @@ function unsubscribe(id)
transmit("unsubscribe "+id);
}
-function create(id, parent)
+function create(id, parent, before)
{
- transmit("create "+id+" "+parent);
+ transmit("create "+id+" "+parent+" "+before);
}
function remove(id)
diff --git a/src/ws/view.js b/src/ws/view.js
index b960170..78b23c1 100644
--- a/src/ws/view.js
+++ b/src/ws/view.js
@@ -94,7 +94,10 @@ function dragover(e)
{
last_after.style.borderColor = "black";
}
- after.style.borderColor = "red black black black";
+ if(after != null)
+ {
+ after.style.borderColor = "red black black black";
+ }
last_after = after;
}
@@ -239,3 +242,10 @@ function editTitle(e)
lineeditparent = e.target;
lineedit.focus();
}
+
+function addChild(e)
+{
+ e.stopPropagation();
+ id = idFromStr(e.target.parentElement.id);
+ create("x", id, -1);
+}