diff --git a/webui/src/main/js/search.js b/webui/src/main/js/search.js index 30730705..ebe06eaa 100644 --- a/webui/src/main/js/search.js +++ b/webui/src/main/js/search.js @@ -51,6 +51,33 @@ class ResultsBySender { this.results.set(result.infoHash,result); } } + + getTrustLinks() { + if (this.trust == "NEUTRAL") + return this.getTrustLink() + this.getDistrustLink() + else if (this.trust == "TRUSTED") + return this.getNeutralLink() + this.getDistrustLink() + else + return this.getTrustLink() + this.getNeutralLink() + } + + getTrustLink() { + return "" + + "Mark Trusted" + } + + getNeutralLink() { + return "Mark Neutral" + } + + getDistrustLink() { + return "" + + "Mark Distrusted" + } } class ResultsByFile { @@ -94,6 +121,33 @@ class ResultByFile { if (comment.length == 1) this.comment = comment[0].childNodes[0].nodeValue; } + + getTrustLinks() { + if (this.trust == "NEUTRAL") + return this.getTrustLink() + this.getDistrustLink() + else if (this.trust == "TRUSTED") + return this.getNeutralLink() + this.getDistrustLink() + else + return this.getTrustLink() + this.getNeutralLink() + } + + getTrustLink() { + return "" + + "Mark Trusted" + } + + getNeutralLink() { + return "Mark Neutral" + } + + getDistrustLink() { + return "" + + "Mark Distrusted" + } } var statusByUUID = new Map() @@ -150,6 +204,72 @@ function download(resultInfoHash) { xmlhttp.send(encodeURI("action=start&infoHash="+resultInfoHash+"&uuid="+uuid)); } +function markTrusted(host) { + var linkSpan = document.getElementById("trusted-link-"+host) + linkSpan.innerHTML = "" + + var textAreaSpan = document.getElementById("trusted-"+host) + + var textbox = "" + var submitLink = "Submit" + var cancelLink = "Cancel" + + var html = "
" + textbox + "
" + submitLink + " " + cancelLink + "
" + + textAreaSpan.innerHTML = html +} + +function markNeutral(host) { + publishTrust(host, null, "NEUTRAL") +} + +function markDistrusted(host) { + var linkSpan = document.getElementById("distrusted-link-"+host) + linkSpan.innerHTML = "" + + var textAreaSpan = document.getElementById("distrusted-"+host) + + var textbox = "" + var submitLink = "Submit" + var cancelLink = "Cancel" + + var html = "
" + textbox + "
" + submitLink + " " + cancelLink + "
" + + textAreaSpan.innerHTML = html +} + +function submitTrust(host) { + var reason = document.getElementById("trust-reason-"+host).value + publishTrust(host, reason, "TRUSTED") +} + +function submitDistrust(host) { + var reason = document.getElementById("trust-reason-"+host).value + publishTrust(host, reason, "DISTRUSTED") +} + +function cancelTrust(host) { + var textAreaSpan = document.getElementById("trusted-" + host) + textAreaSpan.innerHTML = "" + + var linkSpan = document.getElementById("trusted-link-"+host) + var html = "Mark Trusted" + linkSpan.innerHTML = html +} + +function cancelDistrust(host) { + var textAreaSpan = document.getElementById("distrusted-" + host) + textAreaSpan.innerHTML = "" + + var linkSpan = document.getElementById("distrusted-link-"+host) + var html = "Mark Distrusted" + linkSpan.innerHTML = html +} + +function publishTrust(host, reason, trust) { + +} + function updateSender(senderName) { sender = senderName; @@ -237,7 +357,7 @@ function updateFile(fileInfoHash) { table += "" + getBrowseLink(result.senderB64) + "" } } - table += "" + result.trust + "" + table += "" + result.trust + " " + result.getTrustLinks() + "" table += ""; } table += ""; @@ -266,7 +386,7 @@ function updateUUIDBySender(resultUUID) { else table += "" + getBrowseLink(senderBatch.senderB64) + "" } - table += "" + senderBatch.trust + "" + table += "" + senderBatch.trust + " "+senderBatch.getTrustLinks() + "" table += ""; } table += "";