Skip to content

Commit

Permalink
prevent type error on target selection when source is unselected: res…
Browse files Browse the repository at this point in the history
…olve #72
  • Loading branch information
KonradHoeffner committed Jun 21, 2024
1 parent 5569e6d commit 41b3b8d
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,14 +229,16 @@ function selectTarget(e, id) {
e.preventDefault();
document.getElementById("target-label").innerText = id;
if (targetElement) {
if (oldSourceId == sourceElement.id && id == targetElement.id) {
notyf.warning(`All non-empty paths between ${oldSourceId} and ${id} are already shown.`);
return;
} else if (oldSourceId == id && targetElement.id == sourceElement.id) {
notyf.success("Swapped source and target: paths remains the same in reverse.");
//return;
}
targetElement.classList.remove("target");
if (sourceElement) {
if (oldSourceId == sourceElement.id && id == targetElement.id) {
notyf.warning(`All non-empty paths between ${oldSourceId} and ${id} are already shown.`);
return;
} else if (oldSourceId == id && targetElement.id == sourceElement.id) {
notyf.success("Swapped source and target: paths remains the same in reverse.");
//return;
}
}
}
//console.log(id);
targetElement = document.getElementById(id);
Expand Down

0 comments on commit 41b3b8d

Please sign in to comment.