diff --git a/webui/src/main/js/browse.js b/webui/src/main/js/browse.js index 9f87c374..0199e6c9 100644 --- a/webui/src/main/js/browse.js +++ b/webui/src/main/js/browse.js @@ -23,6 +23,7 @@ function initBrowse() { setInterval(refreshActive, 3000) } +var currentHost = null var browsesByHost = new Map() var resultsByInfoHash = new Map() @@ -81,6 +82,7 @@ function showResults(host) { var xmlhttp = new XMLHttpRequest() xmlhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { + currentHost = host var xmlDoc = this.responseXML resultsByInfoHash.clear() @@ -107,7 +109,14 @@ function showResults(host) { for (var [infoHash, result] of resultsByInfoHash) { tableHtml += "" - tableHtml += "" + result.name + "" + + var showComments = "" + if (result.comment != null) { + showComments = "
" + getShowCommentLink(infoHash) + "" + showComments += "
" + } + + tableHtml += "" + result.name + showComments + "" tableHtml += "" + result.size + "" if (result.downloading == "true") tableHtml += "Downloading" @@ -143,4 +152,26 @@ function download(host,infoHash) { xmlhttp.open("POST", "/MuWire/Browse", true) xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); xmlhttp.send("action=download&infoHash="+infoHash+"&host="+hostB64) +} + +function getShowCommentLink(infoHash) { + return "Show Comment" +} + +function showComment(infoHash) { + var linkSpan = document.getElementById("show-comment-"+infoHash) + var hideComment = "Hide Comment" + linkSpan.innerHTML = hideComment + + var commentSpan = document.getElementById("comment-"+infoHash) + var comment = resultsByInfoHash.get(infoHash).comment + commentSpan.innerHTML = "
" + comment + "
" +} + +function hideComment(infoHash) { + var linkSpan = document.getElementById("show-comment-"+infoHash) + linkSpan.innerHTML = getShowCommentLink(infoHash) + + var commentSpan = document.getElementById("comment-"+infoHash) + commentSpan.innerHTML = "" } \ No newline at end of file