]> git.sesse.net Git - itkacl/blob - itkacl-web-1.0/web/itkacl.js
Add some free icons, based on the Silk set, to draw the tree.
[itkacl] / itkacl-web-1.0 / web / itkacl.js
1 function enableEdit(td) {
2         var oldComment = '';
3         if (td.firstChild) {
4                 var oldComment = td.firstChild.nodeValue;
5                 td.removeChild(td.firstChild);
6         }
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);
14         commentBox.focus();
15 }
16
17 function commitEdit(td) {
18         var newComment = td.firstChild.value;
19         $.ajax({
20                 type: 'POST',
21                 url: 'change-comment.pl',
22                 data: {
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'),
26                         'comment': newComment
27                 }
28         }).fail(function() { alert("Klarte ikke å endre kommentaren"); });
29
30         td.firstChild.onblur = function() {};
31         td.removeChild(td.firstChild);
32
33         var commentLabel = document.createTextNode(newComment);
34         td.appendChild(commentLabel);
35         td.ondblclick = function() { enableEdit(td); }
36 }