From 59d5ade418fdb0c6fe2d0c100f0a32b4c2dacd32 Mon Sep 17 00:00:00 2001 From: alyx Date: Fri, 4 Feb 2022 21:45:07 +0000 Subject: fix a bug where wiring and stopping on the grid would unwire everything --- grapher/script.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'grapher') diff --git a/grapher/script.js b/grapher/script.js index 9b0be9f..78b7efd 100644 --- a/grapher/script.js +++ b/grapher/script.js @@ -178,22 +178,22 @@ window.onload = async function() { rootel.addEventListener("mouseup", e => { if (e.button == 0) { + let newCon; switch (mode) { case 'wire_i-o': + connections.pop() + newCon = {i: wirestate.i, o: e.target} if (e.target.matches('.exec')) delConnections(e.target); - wirestate.o = e.target; - if (!e.target.parentElement.matches('.output')) - connections.pop(); - else if (wirestate.i.nextElementSibling.innerText != wirestate.o.nextElementSibling.innerText) - connections.pop(); + if (e.target.parentElement.matches('.output') && (newCon.i.nextElementSibling.innerText == newCon.o.nextElementSibling.innerText)) + connections.push(newCon); break; case 'wire_o-i': - if (!e.target.matches('.exec')) delConnections(e.target); - wirestate.i = e.target; - if (!e.target.parentElement.matches('.input')) - connections.pop(); - else if (wirestate.i.nextElementSibling.innerText != wirestate.o.nextElementSibling.innerText) - connections.pop(); + connections.pop() + newCon = {o: wirestate.o, i: e.target} + if (!e.target.matches('.exec') && !e.target.matches('#graph')) delConnections(e.target); + if (e.target.parentElement.matches('.input') && (newCon.i.nextElementSibling.innerText == newCon.o.nextElementSibling.innerText)) + connections.push(newCon); + break; break; case 'drag': if ((performance.now() - start) < 150 && !targ.children[0].matches('#selected')) { -- cgit v1.2.3-70-g09d2