importing of certificates

pull/34/head
Zlatin Balevsky 2019-12-10 15:34:51 +00:00
parent c169a7613f
commit ec5c15ff64
1 changed files with 19 additions and 1 deletions

View File

@ -186,6 +186,12 @@ class Certificate {
this.imported = xmlNode.getElementsByTagName("Imported")[0].childNodes[0].nodeValue
}
getImportLink() {
var linkText = _t("Import")
var link = "<a href='#' onclick='window.importCertificate(\"" + this.base64 + "\"); return false;'>" + linkText + "</a>"
return link
}
renderRow() {
var commentPresent = "false"
if (this.comment != null)
@ -200,7 +206,7 @@ class Certificate {
if (this.imported == "true")
html += "<td>" + _t("Imported") + "</td>"
else
html += "<td>" + _t("Import") + "</td>"
html += "<td>" + this.getImportLink() + "</td>"
html += "</tr>"
return html
@ -681,6 +687,18 @@ function hideCertificatesBySender(fileInfoHash, count) {
linkSpan.innerHTML = showLink
}
function importCertificate(b64) {
var xmlhttp = new XMLHttpRequest()
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
refreshCertificates()
}
}
xmlhttp.open("POST", "/MuWire/Certificate", true)
xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
xmlhttp.send("action=import&base64=" + b64)
}
function refreshStatus() {
var xmlhttp = new XMLHttpRequest()
xmlhttp.onreadystatechange = function() {