@@ -29,10 +29,10 @@ canvas.addEventListener('mousemove', e => {
29
29
}
30
30
lastPositionX = e . offsetX ;
31
31
} ) ;
32
- window . addEventListener ( 'mousedown' , e => {
32
+ window . addEventListener ( 'mousedown' , ( ) => {
33
33
isDrawing = true ;
34
34
} ) ;
35
- window . addEventListener ( 'mouseup' , e => {
35
+ window . addEventListener ( 'mouseup' , ( ) => {
36
36
isDrawing = false ;
37
37
lastPositionX = null ;
38
38
} ) ;
@@ -67,7 +67,7 @@ function saveValue(x1, y1, x2) {
67
67
const cnt = canvas . getContext ( "2d" ) ;
68
68
cnt . font = "30px Arial" ;
69
69
70
- function generateArrayAndDraw ( event ) {
70
+ function generateArrayAndDraw ( ) {
71
71
arrayToSort = generateArray ( sizeSlider . value ) ;
72
72
if ( sortIndex ) {
73
73
updateSortMethod ( sortIndex ) ;
@@ -113,18 +113,15 @@ function switchSorting() {
113
113
// Stop
114
114
clearTimeout ( sortingTimeout ) ;
115
115
sortingTimeout = null ;
116
- osciallator . stop ( ) ;
116
+ oscillator . stop ( ) ;
117
117
startButton . innerText = "Start sorting" ;
118
118
startButton . className = "startButton" ;
119
119
generateButton . disabled = false ;
120
120
sizeSlider . disabled = false ;
121
121
} else {
122
- if ( osciallator === null ) {
123
- osciallator = new Oscillator ( ) ;
124
- }
125
122
isDoneSorting = false ;
126
- if ( sortIndex !== "7" ) {
127
- osciallator . resume ( ) ;
123
+ if ( sortMethod . constructor . sound ( ) ) {
124
+ oscillator . resume ( ) ;
128
125
}
129
126
startButton . innerText = "Stop sorting" ;
130
127
startButton . className = "stopButton" ;
@@ -163,17 +160,18 @@ function updateSortMethod(value) {
163
160
arrayToSortAccess = 0 ;
164
161
arrayToSortModifications = 0 ;
165
162
isDoneSorting = false ;
166
- if ( value === "7" ) {
167
- osciallator . stop ( ) ;
168
- } else if ( sortIndex === "7" && sortingTimeout ) {
169
- osciallator . resume ( ) ;
170
- }
171
163
let sortClass = sortsDictionary [ value ] ;
172
164
if ( sortClass === undefined ) {
173
165
alert ( "Something went wrong pls report this to admin@debianserver.cz error-1:" + value ) ;
174
166
return ;
175
167
}
176
168
sortMethod = new sortClass ( ) ;
169
+
170
+ if ( ! sortClass . sound ( ) ) {
171
+ oscillator . stop ( ) ;
172
+ } else if ( sortsDictionary [ sortIndex ] !== undefined && ! sortsDictionary [ sortIndex ] . sound ( ) && sortingTimeout ) {
173
+ oscillator . resume ( ) ;
174
+ }
177
175
sortIndex = value ;
178
176
}
179
177
0 commit comments