+
-
-
+
+
+
+
+
+
diff --git a/js/app.js b/js/app.js
index 7820f08..ddfad4f 100644
--- a/js/app.js
+++ b/js/app.js
@@ -88,6 +88,20 @@ $(function () {
var originalFlowNetwork = [];
var showOriginalCapacitiesAndCurrentFlow = false;
+ var defaults = {
+ handleColor: "grey",
+ handleSize: 15,
+ handleLineWidth: 10,
+ handleNodes: "node",
+ toggleOffOnLeave: true,
+ edgeType: function (source, target) {
+ return hasEdge(source, target) ? null : 'flat';
+ },
+ }
+
+ // edge handles, which is used for creating edge interactively
+ cy.edgehandles(defaults);
+
cy.panzoom({
// ... options ...
});
@@ -105,20 +119,6 @@ $(function () {
return hasEdge;
}
- var defaults = {
- handleColor: "grey",
- handleSize: 15,
- handleLineWidth: 10,
- handleNodes: "node",
- toggleOffOnLeave: true,
- edgeType: function (source, target) {
- return hasEdge(source, target) ? null : 'flat';
- },
- }
-
- // edge handles, which is used for creating edge interactively
- cy.edgehandles(defaults);
-
// Check which mode are we in: modifying or practicing
function allowModify() {
return $("#state").text().includes("State: Graph Creation");
@@ -401,7 +401,7 @@ function cancelHighlightedElements() {
allowModify() ||
(state === UPDATE_RESIDUAL_GRAPH && cy.$(":selected").isEdge() && !cy.$(":selected").css("label").includes("/"))
) {
- // Delete only if user is not updating capacity, I know this !"is not hidden" is really weird. However, jQuery (F*** it for wasting 1 hour of my time!)'s "is hidden"
+ // Delete only if user is not updating capacity, I know this !"is not hidden" is really weird. However, jQuery's "is hidden"
// only checks for css attributes display and visibility whereas jQuery's hide does not change those attributes but rather caches them...
if (e.key == "Delete" && !$("#mouse-update").is(":not(':hidden')")) {
const inputElement = document.getElementById("label");
@@ -454,6 +454,17 @@ function cancelHighlightedElements() {
source = source.substring(source.indexOf("=") + 1);
sink = $("#sink").text();
sink = sink.substring(sink.indexOf("=") + 1);
+
+ if (source === "")
+ {
+ alert("Please specify a source!");
+ return;
+ }
+ if (sink === "")
+ {
+ alert("Please specify a sink!");
+ return;
+ }
if (source === sink) {
alert("The source and the sink can not be the same node!");
return;
@@ -462,6 +473,7 @@ function cancelHighlightedElements() {
cy.edgehandles("disable");
+
hideElementAndItsChildren(".buttons");
state = states[index];
showElementAndItsChildren(".ending-actions");
@@ -1179,6 +1191,22 @@ function cancelHighlightedElements() {
document.getElementById("mark-as-source-or-sink").style.display = "none"
});
+ $("#delete-node").on("click", function(event) {
+ event.preventDefault();
+ lastRightClickedNode.remove();
+ document.getElementById("mark-as-source-or-sink").style.display = "none";
+ // source = $("#source").text()
+ if (lastRightClickedNode.id() == source)
+ {
+ $("#source").text("Source=");
+ }
+ sink = $("#sink").text()
+ if (lastRightClickedNode.id() == sink)
+ {
+ $("#sink").text("Sink=");
+ }
+ });
+
// Enter is the same as click
$("#floatingText").on("keydown", function (event) {
if (event.which === ENTER_KEY) {
diff --git a/js/file-layout-utils.js b/js/file-layout-utils.js
index d704c2d..7399a92 100644
--- a/js/file-layout-utils.js
+++ b/js/file-layout-utils.js
@@ -201,4 +201,5 @@ function resizeAndCenterAccordingToCurrentGraphBlock() {
// resize and center nodes/edges/etc.
cy.resize();
cy.center();
+ cy.edgehandles("resize");
}
\ No newline at end of file