1 function enableEdit(td) {
4 var oldComment = td.firstChild.nodeValue;
5 td.removeChild(td.firstChild);
7 var commentBox = document.createElement("input");
8 commentBox.value = oldComment;
9 // commentBox.setAttribute("size", oldComment.length + 10);
10 commentBox.onblur = function() { commitEdit(td); }
11 commentBox.onkeyup = function(evt) { if (evt.keyCode == 13) { commitEdit(td); } }
12 td.ondblclick = function() {}
13 td.appendChild(commentBox);
17 function commitEdit(td) {
18 var newComment = td.firstChild.value;
21 url: 'change-comment.pl',
23 'entry': td.getAttributeNS('http://acl.samfundet.no/', 'entry'),
24 'entity_type': td.getAttributeNS('http://acl.samfundet.no/', 'entity-type'),
25 'entity': td.getAttributeNS('http://acl.samfundet.no/', 'entity'),
28 }).fail(function() { alert("Klarte ikke å endre kommentaren"); });
30 td.firstChild.onblur = function() {};
31 td.removeChild(td.firstChild);
33 var commentLabel = document.createTextNode(newComment);
34 td.appendChild(commentLabel);
35 td.ondblclick = function() { enableEdit(td); }