File tree Expand file tree Collapse file tree 6 files changed +15
-0
lines changed
Expand file tree Collapse file tree 6 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ const bubbleSort = async function () {
3333 barsEl . children [ sz - i - 1 ] . style . backgroundColor = "green" ;
3434 }
3535 document . getElementById ( "random-array" ) . classList . remove ( "disabled" ) ;
36+ document . getElementById ( "reversed-array" ) . classList . remove ( "disabled" ) ;
3637 document . getElementById ( "size" ) . classList . remove ( "disabled" ) ;
3738 document . getElementById ( "bubble" ) . classList . toggle ( "active-btn" ) ;
3839} ;
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ const insertionSort = async function () {
3737 barsEl . children [ i ] . style . removeProperty ( "border-color" ) ;
3838 }
3939 document . getElementById ( "random-array" ) . classList . remove ( "disabled" ) ;
40+ document . getElementById ( "reversed-array" ) . classList . remove ( "disabled" ) ;
4041 document . getElementById ( "size" ) . classList . remove ( "disabled" ) ;
4142 document . getElementById ( "insertion" ) . classList . toggle ( "active-btn" ) ;
4243} ;
Original file line number Diff line number Diff line change @@ -83,6 +83,7 @@ const mergeSort = async function () {
8383
8484 await mergeS ( 0 , Number ( sz - 1 ) ) . then ( ( ) => doGreen ( sz ) ) ;
8585 document . getElementById ( "random-array" ) . classList . remove ( "disabled" ) ;
86+ document . getElementById ( "reversed-array" ) . classList . remove ( "disabled" ) ;
8687 document . getElementById ( "size" ) . classList . remove ( "disabled" ) ;
8788 document . getElementById ( "merge" ) . classList . toggle ( "active-btn" ) ;
8889} ;
Original file line number Diff line number Diff line change @@ -91,6 +91,7 @@ const quickSort = async function () {
9191
9292 await quickS ( 0 , Number ( sz - 1 ) ) . then ( ( ) => doGreen ( sz ) ) ;
9393 document . getElementById ( "random-array" ) . classList . remove ( "disabled" ) ;
94+ document . getElementById ( "reversed-array" ) . classList . remove ( "disabled" ) ;
9495 document . getElementById ( "size" ) . classList . remove ( "disabled" ) ;
9596 document . getElementById ( "quick" ) . classList . toggle ( "active-btn" ) ;
9697} ;
Original file line number Diff line number Diff line change @@ -67,6 +67,7 @@ const selectionSort = async function () {
6767 barsEl . children [ mxInd ] . style . borderColor = barDefaultBorderColor ;
6868 }
6969 document . getElementById ( "random-array" ) . classList . remove ( "disabled" ) ;
70+ document . getElementById ( "reversed-array" ) . classList . remove ( "disabled" ) ;
7071 document . getElementById ( "size" ) . classList . remove ( "disabled" ) ;
7172 document . getElementById ( "selection" ) . classList . toggle ( "active-btn" ) ;
7273} ;
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ const barsEl = document.getElementById("bars");
44const sizeSlider = document . getElementById ( "size" ) ;
55// const barsRect = barsEl.getBoundingClientRect();
66const btnRandomArray = document . getElementById ( "random-array" ) ;
7+ const btnReversedArray = document . getElementById ( "reversed-array" ) ;
78const btnReload = document . getElementById ( "reload" ) ;
89// const barsWidth = barsRect.width;
910// const barsHeight = barsRect.height;
@@ -13,6 +14,14 @@ const barsHeight = barsEl.offsetHeight;
1314barsEl . innerHTML = "" ;
1415let bars = [ ] ;
1516
17+ const reversedArray = function ( ) {
18+ bars = [ ] ;
19+ for ( let i = sizeSlider . value ; i > 0 ; -- i ) {
20+ bars . push ( i ) ;
21+ }
22+ plantArray ( )
23+ }
24+
1625const randomArray = function ( ) {
1726 bars = [ ] ;
1827 for ( let i = 0 ; i < Number ( sizeSlider . value ) ; ++ i ) {
@@ -80,6 +89,7 @@ const tempDisable = function () {
8089
8190const tempEnable = function ( ) {
8291 document . getElementById ( "random-array" ) . classList . remove ( "disabled" ) ;
92+ document . getElementById ( "reversed-array" ) . classList . remove ( "disabled" ) ;
8393 document . getElementById ( "size" ) . classList . remove ( "disabled" ) ;
8494 document . getElementById ( "bubble" ) . classList . remove ( "disabled" ) ;
8595 document . getElementById ( "merge" ) . classList . remove ( "disabled" ) ;
You can’t perform that action at this time.
0 commit comments