in src/playground.ts [705:750]
function updateHoverCard(type: HoverType, nodeOrLink?: nn.Node | nn.Link,
coordinates?: [number, number]) {
let hovercard = d3.select("#hovercard");
if (type == null) {
hovercard.style("display", "none");
d3.select("#svg").on("click", null);
return;
}
d3.select("#svg").on("click", () => {
hovercard.select(".value").style("display", "none");
let input = hovercard.select("input");
input.style("display", null);
input.on("input", function() {
if (this.value != null && this.value !== "") {
if (type === HoverType.WEIGHT) {
(nodeOrLink as nn.Link).weight = +this.value;
} else {
(nodeOrLink as nn.Node).bias = +this.value;
}
updateUI();
}
});
input.on("keypress", () => {
if ((d3.event as any).keyCode === 13) {
updateHoverCard(type, nodeOrLink, coordinates);
}
});
(input.node() as HTMLInputElement).focus();
});
let value = (type === HoverType.WEIGHT) ?
(nodeOrLink as nn.Link).weight :
(nodeOrLink as nn.Node).bias;
let name = (type === HoverType.WEIGHT) ? "Weight" : "Bias";
hovercard.style({
"left": `${coordinates[0] + 20}px`,
"top": `${coordinates[1]}px`,
"display": "block"
});
hovercard.select(".type").text(name);
hovercard.select(".value")
.style("display", null)
.text(value.toPrecision(2));
hovercard.select("input")
.property("value", value.toPrecision(2))
.style("display", "none");
}