diff --git a/webui/src/main/js/search.js b/webui/src/main/js/search.js index a7a40d68..11094d6a 100644 --- a/webui/src/main/js/search.js +++ b/webui/src/main/js/search.js @@ -173,12 +173,85 @@ class ResultByFile { } } +class Certificate { + constructor(xmlNode) { + this.issuer = xmlNode.getElementsByTagName("Issuer")[0].childNodes[0].nodeVlue + this.name = xmlNode.getElementsByTagName("Name")[0].childNodes[0].nodeVlue + this.comment = null + try { + this.comment = xmlNode.getElementsByTagName("Comment")[0].childNodes[0].nodeVlue + } catch(ignore) {} + this.timestamp = xmlNode.getElementsByTagName("Timestamp")[0].childNodes[0].nodeVlue + this.base64 = xmlNode.getElementsByTagName("Base64")[0].childNodes[0].nodeVlue + } + + renderRow() { + var commentPresent = "false" + if (this.comment != null) + commentPresent = "true" + + var html = "" + html += "" + this.issuer + "" + html += "" + this.name + "" + html += "" + commentPresent + "" + html += "" + this.timestamp + "" + html += "" + return html + } +} + +class CertificateResponse { + constructor(xmlNode) { + this.status = xmlNode.getElementsByTagName("Status")[0].childNodes[0].nodeValue + this.total = xmlNode.getElementsByTagName("Total")[0].childNodes[0].nodeValue + + var certNodes = xmlNode.getElementsByTagName("Certificates")[0].getElementsByTagName("Certificate") + var i + this.certificates = [] + for (i = 0; i < certNodes.length; i++) { + certificates.push( new Certificate(certNodes[i])) + } + } + + renderTable() { + var html = _t("Status") + " " + this.status + if (this.certificates.length == 0) + return html + + html += " " + html += _t("Certificates") + " " + this.certificates.length + "/" + this.total + + var headers = [_t("Issuer"), _t("Name"), _t("Comment"), _t("Timestamp")] + html += "
" + html += "" + var i + for(i = 0; i < this.certificates.length; i++) { + html += this.certificates[i].renderRow() + } + html += "
" + headers.join("") + "
" + + return html + } +} + class CertificateFetch { constructor(senderB64, fileInfoHash) { this.senderB64 = senderB64 this.fileInfoHash = fileInfoHash this.divId = senderB64 + "_" + fileInfoHash } + + updateTable() { + var xmlhttp = new XMLHttpRequest() + xmlhttp.onreadystatechange = function() { + if (this.readyState == 4 && this.status == 200) { + + var block = document.getElementById("certificates-" + this.divId) + } + } + xmlhttp.open("GET", "/MuWire/Certificate", true) + xmlhttp.send() + } } var statusByUUID = new Map()