summaryrefslogtreecommitdiff
path: root/src/ws/view.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/ws/view.js')
-rw-r--r--src/ws/view.js58
1 files changed, 24 insertions, 34 deletions
diff --git a/src/ws/view.js b/src/ws/view.js
index 4a10386..b960170 100644
--- a/src/ws/view.js
+++ b/src/ws/view.js
@@ -200,52 +200,42 @@ function node_submit_KeyUpHandler(target, e)
// Butt ugly.. but hey! it works...
//
var updateid;
-var divtxt;
-var oldtxt;
-var oldtitle;
-function onKeyUpHandler(target, e)
+var lineedit;
+var lineeditparent;
+function onKeyUpHandler(e)
{
if(e.which == 13)
{ // enter
- divtxt.removeChild(target);
- oldtxt.nodeValue = 'updating...';
- update(updateid, "title", target.value);
+ lineeditparent.removeChild(lineedit);
+ lineeditparent.nodeValue = 'updating...';
+ update(updateid, "title", lineedit.value);
}
if(e.which == 27)
{ // escape
- divtxt.removeChild(target);
- oldtxt.nodeValue = oldtitle;
+ lineeditparent.removeChild(lineedit);
}
}
-function onLostFocusHandler(target, e)
+function onLostFocusHandler(e)
{
- if(target.value == oldtitle)
- {
- divtxt.removeChild(target);
- oldtxt.nodeValue = oldtitle;
- }
+ lineeditparent.removeChild(lineedit);
}
-function editTitle(target, e)
+function editTitle(e)
{
e.stopPropagation();
- updateid = idFromStr(target.id);
- if(updateid < 10)
- {
- return;
- }
- var inp = document.createElement("input");
- var txtdiv = document.getElementById(target.id + "_txt");
- divtxt = txtdiv;
- oldtxt = txtdiv.firstChild;
- oldtitle = oldtxt.nodeValue;
- oldtxt.nodeValue = "";
- inp.setAttribute("onkeyup", "onKeyUpHandler(this, event)");
- inp.setAttribute("onblur", "onLostFocusHandler(this, event)");
- inp.setAttribute("style", "border: inherit; padding: inherit; margin: inherit; background: inherit;");
- inp.value = oldtitle;
- lineedit = inp;
- txtdiv.appendChild(inp);
- inp.focus();
+ updateid = idFromStr(e.target.id);
+ subscriptionId = subscriptionIdFromStr(e.target.id);
+
+ var node = findNode(updateid, subscriptionId);
+
+ lineedit = document.createElement("input");
+ lineedit.setAttribute("class", "edit");
+ lineedit.setAttribute("onkeyup", "onKeyUpHandler(event)");
+ lineedit.setAttribute("onblur", "onLostFocusHandler(event)");
+ lineedit.value = node.getTitle();
+ e.target.appendChild(lineedit);
+ //e.target.insertBefore(e.target.childNodes[2], lineedit);
+ lineeditparent = e.target;
+ lineedit.focus();
}