mirror of https://github.com/lgc-4/DataTools3.git
42 lines
841 B
JavaScript
42 lines
841 B
JavaScript
class Connector {
|
|
static INPUT = 0;
|
|
static OUTPUT = 1;
|
|
|
|
type;
|
|
|
|
element;
|
|
|
|
constructor(type, label = "") {
|
|
this.type = type;
|
|
this.element = "";
|
|
this.label = label;
|
|
if (this.label == "") {
|
|
switch (this.type) {
|
|
case Connector.INPUT:
|
|
this.label = "Input";
|
|
case Connector.OUTPUT:
|
|
this.label = "Output";
|
|
}
|
|
}
|
|
|
|
this.buildElement();
|
|
}
|
|
|
|
buildElement() {
|
|
this.element = document.createElement("div");
|
|
this.element.classList.add("connector");
|
|
|
|
if (this.type == Connector.INPUT) {
|
|
this.element.classList.add("connectorInput");
|
|
}
|
|
if (this.type == Connector.OUTPUT) {
|
|
this.element.classList.add("connectorOutput");
|
|
}
|
|
|
|
let circle = document.createElement("span");
|
|
circle.classList.add("connectorCircle");
|
|
|
|
let label = document.createElement("span");
|
|
label.classList.add("connectorLabel");
|
|
}
|
|
} |