@@ -73,12 +73,16 @@ class View {
7373 }
7474
7575 stepForward ( ) {
76+ if ( control . getAlgoName ( ) === "MaxHeapFree" || control . getAlgoName ( ) === "MaxHeap" )
77+ this . setPause ( true ) ;
78+
7679 this . clickedPlay = false ;
7780 manager . next ( ) ;
7881 }
7982
8083 stepBack ( ) {
81- this . setPause ( true ) ;
84+ if ( control . getAlgoName ( ) === "MaxHeapFree" || control . getAlgoName ( ) === "MaxHeap" )
85+ this . setPause ( true ) ;
8286 if ( firstSelected != - 1 ) {
8387 selectIndex ( firstSelected , false ) ;
8488 firstSelected = - 1 ;
@@ -91,6 +95,7 @@ class View {
9195 this . started = false ;
9296 this . playing = false ;
9397 $ ( "#play" ) . text ( "Play" ) ;
98+ $ ( "#arrow" ) . addClass ( "hidden" ) . animate ( { left : ( $ ( "#arrayElem0" ) . position ( ) . left + 9 ) + "px" } , 0 ) ;
9499 manager . pause ( ) ;
95100 manager . nextEvents = new Array ;
96101 manager . previousEvents = new Array ;
@@ -110,7 +115,6 @@ class View {
110115 setValueAtIndex ( i , i ) ;
111116 }
112117
113-
114118 setSlow ( ) {
115119 manager . delayTime = 1500 ;
116120 this . restartManager ( ) ;
@@ -135,6 +139,7 @@ class View {
135139 $ ( "#sortArray" ) . hide ( ) ;
136140 $ ( "#sortArrayUL" ) . children ( "li" ) . remove ( ) ;
137141 lockPlay ( true ) ;
142+
138143 switch ( algo ) {
139144 case "MaxHeap" : {
140145 this . resetAll ( ) ;
@@ -151,6 +156,9 @@ class View {
151156 lockPlay ( false ) ;
152157 control . initController ( new BuildHeap ( 10 ) ) ;
153158 screenLock ( true ) ;
159+ control . getAlgorithm ( ) . build ( ) ;
160+ this . setPause ( true ) ;
161+ $ ( "#play" ) . text ( "Play" ) ;
154162 break ;
155163 }
156164 case "HeapSort" : {
@@ -159,6 +167,9 @@ class View {
159167 $ ( "#sortArray" ) . show ( ) ;
160168 control . initController ( new HeapSort ( 10 ) ) ;
161169 screenLock ( true ) ;
170+ ( < HeapSort > control . getAlgorithm ( ) ) . sort ( ) ;
171+ this . setPause ( true ) ;
172+ $ ( "#play" ) . text ( "Play" ) ;
162173 break ;
163174 }
164175 default : {
@@ -352,7 +363,6 @@ class View {
352363 this . started = true ;
353364 this . setPause ( false ) ;
354365 } else if ( algo === "HeapSort" && ! this . started && ! this . playing ) {
355- ( < HeapSort > control . getAlgorithm ( ) ) . sort ( ) ;
356366 this . started = true ;
357367 this . setPause ( false ) ;
358368 } else {
@@ -368,7 +378,8 @@ class View {
368378 if ( bool ) {
369379 this . playing = false ;
370380 manager . pause ( ) ;
371- $ ( "#play" ) . text ( "Resume" ) ;
381+ if ( ! ( control . getAlgoName ( ) === "MaxHeapFree" || control . getAlgoName ( ) === "MaxHeap" ) )
382+ $ ( "#play" ) . text ( "Resume" ) ;
372383 lockBackForward ( false ) ;
373384 } else {
374385 this . playing = true ;
0 commit comments