fe18c7cf5c
Signed-off-by: prescientmoon <git@moonythm.dev>
70 lines
1.3 KiB
JavaScript
70 lines
1.3 KiB
JavaScript
var count = 0;
|
|
var pins = [];
|
|
var sels = "yay";
|
|
var sele = "yay";
|
|
var num;
|
|
function pin(type){
|
|
this.state = true;
|
|
this.nei = "yay";
|
|
this.val = false;
|
|
if (type == 0){
|
|
this.type = true;
|
|
color = "black";
|
|
}
|
|
else{
|
|
this.type = false;
|
|
color = "red";
|
|
}
|
|
this.update = function(){
|
|
if (this.nei != "yay"){
|
|
if (!(this.type)){
|
|
this.val = this.nei.activation();
|
|
}
|
|
else{
|
|
this.val = this.nei.val;
|
|
}
|
|
}
|
|
if (this.val){
|
|
$((this.rep)).attr("fill","red");
|
|
}
|
|
else{
|
|
$((this.rep)).attr("fill","yellow");
|
|
}
|
|
}
|
|
this.id = count.toString();
|
|
this.name = "#"+this.id;
|
|
this.rep = add(20,20,"yellow","black",this.id,false);
|
|
clicked(this);
|
|
count++;
|
|
this.name = "#"+this.id;
|
|
this.set = function(x,y){
|
|
$(this.name).attr("x",x.toString());
|
|
$(this.name).attr("y",y.toString());
|
|
}
|
|
pins[pins.length] = this;
|
|
this.num = pins.length-1;
|
|
}
|
|
|
|
function clicked(ob){
|
|
$(ob.rep).click(function(e){
|
|
if (ob.type == true){
|
|
sels = ob;
|
|
}
|
|
else{
|
|
sele = ob;
|
|
}
|
|
console.log("click"+sels+sele+ob.type);
|
|
if ((sels!="yay")&&(sele!="yay")){
|
|
console.log("step 2");
|
|
if ((sels.state)){
|
|
sels.nei = sele;
|
|
sels.state = false;
|
|
sele.state = false;
|
|
a = new edge(sels,sele);
|
|
sels = "yay";
|
|
sele = "yay";
|
|
console.log("end");
|
|
}
|
|
}
|
|
});
|
|
} |