@@ -73,12 +73,16 @@ class View {
73
73
}
74
74
75
75
stepForward ( ) {
76
+ if ( control . getAlgoName ( ) === "MaxHeapFree" || control . getAlgoName ( ) === "MaxHeap" )
77
+ this . setPause ( true ) ;
78
+
76
79
this . clickedPlay = false ;
77
80
manager . next ( ) ;
78
81
}
79
82
80
83
stepBack ( ) {
81
- this . setPause ( true ) ;
84
+ if ( control . getAlgoName ( ) === "MaxHeapFree" || control . getAlgoName ( ) === "MaxHeap" )
85
+ this . setPause ( true ) ;
82
86
if ( firstSelected != - 1 ) {
83
87
selectIndex ( firstSelected , false ) ;
84
88
firstSelected = - 1 ;
@@ -91,6 +95,7 @@ class View {
91
95
this . started = false ;
92
96
this . playing = false ;
93
97
$ ( "#play" ) . text ( "Play" ) ;
98
+ $ ( "#arrow" ) . addClass ( "hidden" ) . animate ( { left : ( $ ( "#arrayElem0" ) . position ( ) . left + 9 ) + "px" } , 0 ) ;
94
99
manager . pause ( ) ;
95
100
manager . nextEvents = new Array ;
96
101
manager . previousEvents = new Array ;
@@ -110,7 +115,6 @@ class View {
110
115
setValueAtIndex ( i , i ) ;
111
116
}
112
117
113
-
114
118
setSlow ( ) {
115
119
manager . delayTime = 1500 ;
116
120
this . restartManager ( ) ;
@@ -135,6 +139,7 @@ class View {
135
139
$ ( "#sortArray" ) . hide ( ) ;
136
140
$ ( "#sortArrayUL" ) . children ( "li" ) . remove ( ) ;
137
141
lockPlay ( true ) ;
142
+
138
143
switch ( algo ) {
139
144
case "MaxHeap" : {
140
145
this . resetAll ( ) ;
@@ -151,6 +156,9 @@ class View {
151
156
lockPlay ( false ) ;
152
157
control . initController ( new BuildHeap ( 10 ) ) ;
153
158
screenLock ( true ) ;
159
+ control . getAlgorithm ( ) . build ( ) ;
160
+ this . setPause ( true ) ;
161
+ $ ( "#play" ) . text ( "Play" ) ;
154
162
break ;
155
163
}
156
164
case "HeapSort" : {
@@ -159,6 +167,9 @@ class View {
159
167
$ ( "#sortArray" ) . show ( ) ;
160
168
control . initController ( new HeapSort ( 10 ) ) ;
161
169
screenLock ( true ) ;
170
+ ( < HeapSort > control . getAlgorithm ( ) ) . sort ( ) ;
171
+ this . setPause ( true ) ;
172
+ $ ( "#play" ) . text ( "Play" ) ;
162
173
break ;
163
174
}
164
175
default : {
@@ -352,7 +363,6 @@ class View {
352
363
this . started = true ;
353
364
this . setPause ( false ) ;
354
365
} else if ( algo === "HeapSort" && ! this . started && ! this . playing ) {
355
- ( < HeapSort > control . getAlgorithm ( ) ) . sort ( ) ;
356
366
this . started = true ;
357
367
this . setPause ( false ) ;
358
368
} else {
@@ -368,7 +378,8 @@ class View {
368
378
if ( bool ) {
369
379
this . playing = false ;
370
380
manager . pause ( ) ;
371
- $ ( "#play" ) . text ( "Resume" ) ;
381
+ if ( ! ( control . getAlgoName ( ) === "MaxHeapFree" || control . getAlgoName ( ) === "MaxHeap" ) )
382
+ $ ( "#play" ) . text ( "Resume" ) ;
372
383
lockBackForward ( false ) ;
373
384
} else {
374
385
this . playing = true ;
0 commit comments