diff --git a/webui/src/main/js/browse.js b/webui/src/main/js/browse.js
index cc2977dc..7e420608 100644
--- a/webui/src/main/js/browse.js
+++ b/webui/src/main/js/browse.js
@@ -1,11 +1,23 @@
class Result {
- constructor(name, size, comment, infoHash, downloading, certificates) {
+ constructor(name, size, comment, infoHash, downloading, certificates, hostB64) {
this.name = name
this.size = size
this.infoHash = infoHash
this.comment = comment
this.downloading = downloading
this.certificates = certificates
+ this.hostB64 = hostB64
+ }
+
+ getCertificateBlock() {
+ if (this.certificates == "0")
+ return ""
+ var id = this.hostB64 + "_" + this.infoHash
+ var linkText = _t("View {0} Certificates", this.certificates)
+ var link = "" + linkText + ""
+ var linkBlock = "
" + link + "
"
+ linkBlock += ""
+ return linkBlock
}
}
@@ -29,6 +41,42 @@ var currentHost = null
var browsesByHost = new Map()
var resultsByInfoHash = new Map()
+function showCertificates(hostB64, infoHash) {
+ var fetch = new CertificateFetch(hostB64, infoHash)
+ certificateFetches.set(fetch.divId, fetch)
+
+ var xmlhttp = new XMLHttpRequest()
+ xmlhttp.onreadystatechange = function() {
+ if (this.readyState == 4 && this.status == 200) {
+ var hideLinkText = _t("Hide Certificates")
+ var hideLink = "" + hideLinkText + ""
+ var hideLinkSpan = document.getElementById("certificates-link-" + fetch.divId)
+ hideLinkSpan.innerHTML = hideLink
+
+ var certSpan = document.getElementById("certificates-" + fetch.divId)
+ certSpan.innerHTML = _t("Fetching Certificates")
+ }
+ }
+ xmlhttp.open("POST", "/MuWire/Certificate", true)
+ xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
+ xmlhttp.send("action=fetch&user=" + hostB64 + "&infoHash=" + infoHash)
+}
+
+function hideCertificates(hostB64, infoHash) {
+ var id = hostB64 + "_" + infoHash
+ certificateFetches.delete(id)
+
+ var certSpan = document.getElementById("certificates-" + id)
+ certSpan.innerHTML = ""
+
+ var result = resultsByInfoHash.get(infoHash)
+ var showLinkText = _t("View {0} Certificates", result.certificates)
+ var showLink = "" + showLinkText + ""
+
+ var linkSpan = document.getElementById("certificates-link-" + id)
+ linkSpan.innerHTML = showLink
+}
+
function refreshActive() {
var xmlhttp = new XMLHttpRequest()
xmlhttp.onreadystatechange = function() {
@@ -111,7 +159,7 @@ function showResults(host) {
comment = null
var certificates = results[i].getElementsByTagName("Certificates")[0].childNodes[0].nodeValue
- var result = new Result(name, size, comment, infoHash, downloading, certificates)
+ var result = new Result(name, size, comment, infoHash, downloading, certificates, browse.hostB64)
resultsByInfoHash.set(infoHash, result)
}
@@ -127,7 +175,7 @@ function showResults(host) {
showComments += ""
}
- tableHtml += "" + result.name + showComments + " | "
+ tableHtml += "" + result.name + showComments + result.getCertificateBlock() + " | "
tableHtml += "" + result.size + " | "
if (result.downloading == "true")
tableHtml += "" + _t("Downloading") + " | "
diff --git a/webui/src/main/webapp/BrowseHost.jsp b/webui/src/main/webapp/BrowseHost.jsp
index 4f635446..2fde71d0 100644
--- a/webui/src/main/webapp/BrowseHost.jsp
+++ b/webui/src/main/webapp/BrowseHost.jsp
@@ -12,10 +12,11 @@ String pagetitle="Browse Host";
<%@ include file="css.jsi"%>
+
-
+
<%@ include file="header.jsi"%>