mirror of https://github.com/lgc-4/DataTools3.git
30 lines
672 B
JavaScript
30 lines
672 B
JavaScript
class NumberBox extends Box {
|
|
numberbox;
|
|
|
|
constructor() {
|
|
super("Number Box");
|
|
|
|
let input = new Connector(Connector.INPUT, "number");
|
|
input.addListener((d) => {
|
|
this.outputs[0].send(d);
|
|
this.numberbox.value = d;
|
|
});
|
|
|
|
this.inputs.push(input);
|
|
this.outputs.push(new Connector(Connector.OUTPUT, "number"));
|
|
}
|
|
|
|
buildElement() {
|
|
super.buildElement();
|
|
|
|
this.numberbox = document.createElement("input");
|
|
this.numberbox.type = "number";
|
|
this.numberbox.value = 0;
|
|
this.numberbox.addEventListener("input", () => {
|
|
this.outputs[0].send(parseFloat(this.numberbox.value));
|
|
})
|
|
this.content.appendChild(this.numberbox);
|
|
|
|
return this.element;
|
|
}
|
|
} |