diff --git a/webui/src/main/js/trustLists.js b/webui/src/main/js/trustLists.js index d4b5f08f..51171909 100644 --- a/webui/src/main/js/trustLists.js +++ b/webui/src/main/js/trustLists.js @@ -20,12 +20,58 @@ class Persona { } this.status = xmlNode.getElementsByTagName("Status")[0].childNodes[0].nodeValue } + + getTrustLink() { + return "Mark Trusted" + } + + getNeutralLink() { + return "Mark Neutral" + } + + getDistrustLink() { + return "Mark Distrusted" + } + + getTrustActions() { + if (this.status == "TRUSTED") + return [this.getNeutralLink(), this.getDistrustLink()] + if (this.status == "NEUTRAL") + return [this.getTrustLink(), this.getDistrustLink()] + if (this.status == "DISTRUSTED") + return [this.getTrustLink(), this.getNeutralLink()] + return null + } } var lists = new Map() var revision = -1 var currentUser = null +function markTrusted(user) { + publishTrust(user, "", "trust") +} + +function markNeutral(user) { + publishTrust(user, "", "neutral") +} + +function markDistrusted(user) { + publishTrust(user, "", "distrust") +} + +function publishTrust(host, reason, trust) { + var xmlhttp = new XMLHttpRequest() + xmlhttp.onreadystatechange = function() { + if (this.readyState == 4 && this.status == 200) { + refreshLists() + } + } + xmlhttp.open("POST","/MuWire/Trust", true) + xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); + xmlhttp.send("action=" + trust + "&reason=" + reason + "&persona=" + host) +} + function unsubscribe(user) { var xmlhttp = new XMLHttpRequest() xmlhttp.onreadystatechange = function() { @@ -40,7 +86,7 @@ function unsubscribe(user) { function updateDiv(name, list) { - var html = "" + var html = "
UserReasonYour Trust
" var i for (i = 0; i < list.length; i++) { @@ -48,6 +94,7 @@ function updateDiv(name, list) { html += "" html += "" // maybe in
 		html += "
" + html += "" html += "" }
UserReasonYour TrustActions
" + list[i].user + "" + list[i].reason + "" + list[i].status + "" + list[i].getTrustActions().join(" ") + "