credTable = {
let wrapper = {};
const generate = nodeA => {
let node = edgeMapAndUpgradedNodes.upgradedNodes.get(
nodeModule.fromParts(JSON.parse(nodeA))
);
console.log(nodeA);
let totalIn = 0;
let input = inEdges(node).map(e => {
totalIn += e.incomingCred;
return rowFromEdge(e);
});
let totalOut = 0;
let output = outEdges(node).map(e => {
totalOut += e.incomingCred;
return rowFromEdge(e);
});
let currentNode = html`<table><tr><td>${
nodeModule.toParts(node.address)[0]
}</td><td>${
nodeModule.toParts(node.address)[1]
}</td><td>${formatDescription(node.description)}</td></tr></table>`;
const headers =
"<tr><th>Focus</th><th>Cred</th><th>Type</th><th>Subtype</th><th>Description</th></tr>";
const form = html`<form>
<style>table, th, td {
border: 1px solid black;
padding: 0px 5px 0px 5px;
}
input[type='checkbox'] {
-webkit-appearance:none;
width:20px;
height:20px;
background:white;
border-radius:1px;
border:2px solid #555;
}
input[type='checkbox']:checked {
background: #abd;
}</style>
<h2>Current node</h2>
${currentNode}
<h2>Incoming Cred</h2>
Total: ${totalIn.toFixed(2)}
<table>
${headers}
${input}
</table>
<br/><br/><br/>
<h2>Outgoing Cred</h2>
Total: ${totalOut.toFixed(2)}
<table>
${headers}
${output}
</table>
<br/>
</form>`;
form.oninput = e => (form.innerHTML = generate(e.target.value).innerHTML);
return form;
};
if (!participantNode) return html``;
return generate(JSON.stringify(nodeModule.toParts(participantNode.address)));
}