diff --git a/webui/src/main/js/filesTable.js b/webui/src/main/js/filesTable.js
index e5738a4d..8e4b1267 100644
--- a/webui/src/main/js/filesTable.js
+++ b/webui/src/main/js/filesTable.js
@@ -65,8 +65,10 @@ function refreshTable() {
var unshareLink = "Unshare"
+ var commentLink = ""
+
tableHtml += "
"
- tableHtml += ""+file.name+" "+unshareLink+" | "
+ tableHtml += ""+file.name+" " + unshareLink + commentLink + " | "
tableHtml += ""+file.size+" | "
tableHtml += ""+(file.comment != null)+" | "
tableHtml += "
"
@@ -102,3 +104,46 @@ function unshare(fileId) {
xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
xmlhttp.send("action=unshare&path="+fileId)
}
+
+function showCommentForm(nodeId) {
+ var linkSpan = document.getElementById("comment-link-"+nodeId)
+ linkSpan.innerHTML=""
+ var commentDiv = document.getElementById("comment-"+nodeId)
+
+ var node = filesByPath.get(nodeId)
+ var existingComment = node.comment == null ? "" : node.comment
+
+ var textArea = ""
+ var saveCommentLink = "Save"
+ var cancelCommentLink = "Cancel"
+
+ var html = textArea + "
" + saveCommentLink + " " + cancelCommentLink
+
+ commentDiv.innerHTML = html
+}
+
+function cancelComment(nodeId) {
+ var commentDiv = document.getElementById("comment-"+nodeId)
+ commentDiv.innerHTML = ""
+ var linkSpan = document.getElementById("comment-link-"+nodeId)
+ linkSpan.innerHTML = generateCommentLink(nodeId)
+}
+
+function saveComment(fileId) {
+ var comment = document.getElementById("comment-text-"+fileId).value
+ var file = filesByPath.get(fileId)
+ var xmlhttp = new XMLHttpRequest()
+ xmlhttp.onreadystatechange = function() {
+ if (this.readyState == 4 && this.status == 200) {
+ cancelComment(fileId)
+ refreshTable()
+ }
+ }
+ xmlhttp.open("POST", "/MuWire/Files", true)
+ xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
+ xmlhttp.send(encodeURI("action=comment&path="+fileId+ "&comment="+comment))
+}
+
+function generateCommentLink(nodeId) {
+ return "Comment"
+}