From 697c41cf487c01b2970c0a13e12fe85f75bfba1d Mon Sep 17 00:00:00 2001 From: junwei Date: Wed, 26 Jun 2024 22:49:16 +0800 Subject: [PATCH] Fix bidirectional highlight when node identifier contains ":" symbol --- content/graphvizSvg/jquery.graphviz.svg.js | 24 +++++++++------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/content/graphvizSvg/jquery.graphviz.svg.js b/content/graphvizSvg/jquery.graphviz.svg.js index 28a8717..c6f2548 100644 --- a/content/graphvizSvg/jquery.graphviz.svg.js +++ b/content/graphvizSvg/jquery.graphviz.svg.js @@ -433,36 +433,33 @@ GraphvizSvg.prototype.clustersByName = function () { return this._clustersByName } - + GraphvizSvg.prototype.linkedTo = function (node, includeEdges) { var $retval = $() this.findLinked(node, includeEdges, function (nodeName, edgeName) { var other = null; - - const connection = edgeName.split("->"); - if(connection.length>1 && (connection[1] === nodeName || connection[1].startsWith(nodeName+":"))) { - return connection[0].split(":")[0]; + var match = '->' + nodeName + if (edgeName.endsWith(match)) { + other = edgeName.substring(0, edgeName.length - match.length); } - return other; }, $retval) return $retval } - + GraphvizSvg.prototype.linkedFrom = function (node, includeEdges) { var $retval = $() this.findLinked(node, includeEdges, function (nodeName, edgeName) { var other = null; - - const connection = edgeName.split("->"); - if(connection.length>1 && (connection[0] === nodeName || connection[0].startsWith(nodeName+":"))) { - return connection[1].split(":")[0]; + var match = nodeName + '->' + if (edgeName.startsWith(match)) { + other = edgeName.substring(match.length); } return other; }, $retval) return $retval } - + GraphvizSvg.prototype.linked = function (node, includeEdges) { var $retval = $() this.findLinked(node, includeEdges, function (nodeName, edgeName) { @@ -560,5 +557,4 @@ $.fn.graphviz = old return this } - - }(jQuery) \ No newline at end of file + }(jQuery)