--- /dev/null
+function enableEdit(td) {
+ var oldComment = '';
+ if (td.firstChild) {
+ var oldComment = td.firstChild.nodeValue;
+ td.removeChild(td.firstChild);
+ }
+ var commentBox = document.createElement("input");
+ commentBox.value = oldComment;
+ // commentBox.setAttribute("size", oldComment.length + 10);
+ commentBox.onblur = function() { commitEdit(td); }
+ commentBox.onkeyup = function(evt) { if (evt.keyCode == 13) { commitEdit(td); } }
+ td.ondblclick = function() {}
+ td.appendChild(commentBox);
+ commentBox.focus();
+}
+
+function commitEdit(td) {
+ var newComment = td.firstChild.value;
+ $.ajax({
+ type: 'POST',
+ url: 'change-comment.pl',
+ data: {
+ 'entry': td.getAttributeNS('http://acl.samfundet.no/', 'entry'),
+ 'entity_type': td.getAttributeNS('http://acl.samfundet.no/', 'entity-type'),
+ 'entity': td.getAttributeNS('http://acl.samfundet.no/', 'entity'),
+ 'comment': newComment
+ }
+ }).fail(function() { alert("Klarte ikke å endre kommentaren"); });
+
+ td.firstChild.onblur = function() {};
+ td.removeChild(td.firstChild);
+
+ var commentLabel = document.createTextNode(newComment);
+ td.appendChild(commentLabel);
+ td.ondblclick = function() { enableEdit(td); }
+}