@@ -64,7 +64,23 @@ function hideArrayValues() {
6464// Selects an element. If method==find call method, else wait for second element before union or connected
6565function selectElement ( index ) {
6666 // Set new class for selected index
67- selectIndex ( index , true ) ;
67+ deselectNodeSelections ( ) ;
68+ deselectArrayElemSelections ( ) ;
69+ var $selected = $ ( "#arrayElem" + index ) ;
70+ if ( $selected . hasClass ( "selected" ) ) {
71+ $selected . removeClass ( "selected" ) ;
72+ }
73+ else {
74+ selectIndex ( index , true ) ;
75+ //Children to the highlighted node
76+ var highlightChildren = allNodes [ index ] . children ;
77+ console . log ( highlightChildren ) ;
78+ if ( highlightChildren . length > 0 ) {
79+ for ( var i = 0 ; i < highlightChildren . length ; i ++ ) {
80+ highlightNode ( highlightChildren [ i ] . id , "green" ) ;
81+ }
82+ }
83+ }
6884 var $method = $ ( 'input[name=method]:checked' , '#method' ) ;
6985 if ( $method . val ( ) == 'Find' ) {
7086 $method . next ( ) . text ( " find( " + index + " )" ) ;
@@ -238,6 +254,15 @@ function selectIndex(index, select) {
238254 }
239255 } ) ;
240256}
257+ function deselectNodeIndex ( index ) {
258+ $ ( "#node" + index ) . each ( function ( ) {
259+ $ ( this ) . removeClass ( "selected" ) ;
260+ $ ( this ) . removeClass ( "green" ) ;
261+ } ) ;
262+ }
263+ function deselectArrayElement ( index ) {
264+ $ ( "#arrayElem" + index ) . removeClass ( "selected" ) ;
265+ }
241266function highlightNode ( index , color ) {
242267 if ( color . toLowerCase ( ) == "green" || color . toLowerCase ( ) == "orange" ) {
243268 $ ( "#arrayElem" + index + ", #node" + index ) . each ( function ( ) {
@@ -273,6 +298,16 @@ function resetElementSelections() {
273298 selectIndex ( i , false ) ;
274299 }
275300}
301+ function deselectNodeSelections ( ) {
302+ for ( var i = 0 ; i < 10 ; i ++ ) {
303+ deselectNodeIndex ( i ) ;
304+ }
305+ }
306+ function deselectArrayElemSelections ( ) {
307+ for ( var i = 0 ; i < 10 ; i ++ ) {
308+ deselectArrayElement ( i ) ;
309+ }
310+ }
276311function saveState ( backendArray ) {
277312 viewer . saveState ( getGraphState ( ) , backendArray ) ;
278313}
0 commit comments